Check If a Script Has Been Loaded In WordPress

WordPress has a function which lets us detect if a specific script has been enqueued, registered, printed, or is in the queue to be printed.  It can be very useful for avoiding conflicts with libraries which have been already loaded by other themes or plugins. wp_script_is( $handle, $list ); It accepts two parameters: $handle –

2019-05-18T22:48:04+03:00By |Categories: WordPress|0 Comments

Add Scripts In WordPress

WordPress has an enqueuing system which allows developers to utilize the built-in JavaScript libraries rather than loading them multiple times. This helps avoid conflicts and reduces page load time. Example: function custom_scripts() { wp_register_script( 'my_script', plugins_url('my_script.js', __FILE__), array('jquery'), '1.0', true); wp_enqueue_script('my_script'); } add_action( 'wp_enqueue_scripts', 'custom_scripts' ); First, we need to register a script to be

2019-05-18T22:48:18+03:00By |Categories: WordPress|0 Comments

Adding an Options Page in WordPress Settings Menu

When you want to add an options page in WordPress, you need to use function add_options_page. This example will create one page containing a simple sting: add_action( 'admin_menu', 'my_menu' ); function my_menu() { add_options_page( 'Menu Title', 'Page Title', 'manage_options', 'page-slug', 'callback_fn' ); } function callback_fn() { echo "Some text"; } First part of the example adds

2019-05-18T23:04:54+03:00By |Categories: WordPress|0 Comments