Skip to content

Commit

Permalink
Load scripts only in plugin's settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
nima-rahbar committed Dec 17, 2021
1 parent 76a519d commit ff1cfe5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion wp-content/plugins/posts-by-date/includes/admin-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public function __construct()
{
add_action('admin_menu', array($this, 'posts_by_date_add_plugin_page'));
add_action('admin_init', array($this, 'posts_by_date_page_init'));
add_action('admin_init', array($this, 'posts_by_date_enqueue_scripts_admin'));
add_action('admin_enqueue_scripts', array($this, 'posts_by_date_enqueue_scripts_admin'));
}
public function posts_by_date_add_plugin_page()
{
Expand Down
12 changes: 7 additions & 5 deletions wp-content/plugins/posts-by-date/posts-by-date.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ public function __construct()
add_action('wp_ajax_nopriv_load_more', array($this, 'load_more'));
}

public function posts_by_date_enqueue_scripts_admin()
public function posts_by_date_enqueue_scripts_admin($hook_suffix)
{
wp_enqueue_style('bootstrap', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css', false, '5.1.3', 'all');
wp_enqueue_style('bootstrap-icons', 'https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css', false, '1.7.0', 'all');
wp_enqueue_script('bootstrap', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js', array('jquery'), '5.1.3', true);
wp_enqueue_script('posts-by-date', plugin_dir_url(__FILE__) . 'assets/js/posts-by-date-admin.js', array('jquery', 'jquery-ui-core', 'jquery-ui-slider', 'jquery-ui-spinner'), time(), true);
if ($hook_suffix == 'posts_page_posts-by-date') {
wp_enqueue_style('bootstrap', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css', false, '5.1.3', 'all');
wp_enqueue_style('bootstrap-icons', 'https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css', false, '1.7.0', 'all');
wp_enqueue_script('bootstrap', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js', array('jquery'), '5.1.3', true);
wp_enqueue_script('posts-by-date', plugin_dir_url(__FILE__) . 'assets/js/posts-by-date-admin.js', array('jquery', 'jquery-ui-core', 'jquery-ui-slider', 'jquery-ui-spinner'), time(), true);
}
}
public function posts_by_date_enqueue_scripts()
{
Expand Down

0 comments on commit ff1cfe5

Please sign in to comment.