Skip to content

Commit

Permalink
Merge pull request #1096 from vektor-inc/abolish/js-footer
Browse files Browse the repository at this point in the history
JS をフッターから強制的に読み込む機能を廃止
  • Loading branch information
kurudrive authored Jul 1, 2024
2 parents 7959d0f + 8da2d48 commit 0ef4af2
Show file tree
Hide file tree
Showing 9 changed files with 3,680 additions and 4,065 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Setup Node 14.x
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 20.x
- name: install npm scripts
run: npm install
- name: install Composer Package
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Setup Node 14.x
- name: Setup Node 20.x
uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 20.x
- name: install npm scripts
run: npm install
- name: install Composer Package
Expand Down
39 changes: 0 additions & 39 deletions admin/customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,42 +98,3 @@ public function render_content() {
}

} // function veu_customize_register_add_control(){


add_action( 'customize_register', 'veu_customize_register_pagespeed' );
function veu_customize_register_pagespeed( $wp_customize ) {

/*
Page speedind setting
/*-------------------------------------------*/
$wp_customize->add_section(
'veu_speeding_setting',
array(
'title' => __( 'Page Speedind Setting', 'vk-all-in-one-expansion-unit' ),
'priority' => 1,
'panel' => 'veu_setting',
)
);

// JS Footer Setting.
$wp_customize->add_setting(
'vkExUnit_pagespeeding[js_footer]',
array(
'default' => false,
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'veu_sanitize_boolean',
)
);
$wp_customize->add_control(
'vkExUnit_pagespeeding[js_footer]',
array(
'label' => __( 'Load JS from footer', 'vk-all-in-one-expansion-unit' ),
'section' => 'veu_speeding_setting',
'settings' => 'vkExUnit_pagespeeding[js_footer]',
'type' => 'checkbox',
'description' => __( 'If you enable this setting that JavaScript of ExUnit, WordPress, and more will be loaded from footer.', 'vk-all-in-one-expansion-unit' ),
)
);

}
32 changes: 6 additions & 26 deletions initialize.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,34 +106,14 @@ function change_old_options() {
unset( $option['css_exunit'] );
}

}
add_action( 'after_setup_theme', 'change_old_options', 4 );

/**
* Move JavaScripts To Footer
* https://nelog.jp/header-js-to-footer
*/
function veu_move_scripts_to_footer() {
$default = array(
'css_exunit' => false,
'js_footer' => false,
);
$option = get_option( 'vkExUnit_pagespeeding', $default );
$option = wp_parse_args( $option, $default );
if ( $option['js_footer'] ) {
// Remove Header Scripts.
remove_action( 'wp_head', 'wp_print_scripts' );
remove_action( 'wp_head', 'wp_print_head_scripts', 9 );
remove_action( 'wp_head', 'wp_enqueue_scripts', 1 );

// Remove Footer Scripts.
add_action( 'wp_footer', 'wp_print_scripts', 5 );
add_action( 'wp_footer', 'wp_print_head_scripts', 5 );
add_action( 'wp_footer', 'wp_enqueue_scripts', 5 );
if ( isset( $option['js_footer'] ) ) {
unset( $option['js_footer'] );
}
}
add_action( 'wp_enqueue_scripts', 'veu_move_scripts_to_footer' );

update_option( 'vkExUnit_pagespeeding', $option );

}
add_action( 'after_setup_theme', 'change_old_options', 4 );

function veu_change_enqueue_point_to_footer( $enqueue_point ) {
$enqueue_point = 'wp_footer';
Expand Down
Loading

0 comments on commit 0ef4af2

Please sign in to comment.