Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS をフッターから強制的に読み込む機能を廃止 #1096

Merged
merged 6 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading