WordPress

/WordPress

Remove Scripts And Styles In WordPress

WordPress provides dequeuing and deregistering functions for both scripts and styles. This is very useful for reducing the potential of conflicts with plugins and load time. wp_deregister_script()wp_deregister_style()wp_dequeue_script()wp_dequeue_style() Each of these four functions accepts only one parameter: $handle – the unique name of the script or stylesheet you want to deregister or dequeue. They allow us [...]

By |2019-05-18T22:47:32+03:00April 22nd, 2019|Categories: WordPress|0 Comments

Add Styles In WordPress

Wordpress has enqueuing system which provides programmable way of loading styles. It has a built-in support for dependency management. Example: function custom_styles() { wp_register_style( 'my_stylesheet', plugins_url('my-stylesheet.css', __FILE__), array('bootstrap-main'), '1.0', 'screen'); wp_enqueue_style('my_stylesheet'); } add_action( 'wp_enqueue_scripts', 'custom_styles' ); We need to register a stylesheet to be enqueued by using a wp_register_style function. This function accepts 5 parameters: [...]

By |2019-05-18T22:47:46+03:00April 15th, 2019|Categories: WordPress|0 Comments

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 – [...]

By |2019-05-18T22:48:04+03:00April 8th, 2019|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 [...]

By |2019-05-18T22:48:18+03:00April 1st, 2019|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 [...]

By |2019-05-18T23:04:54+03:00July 7th, 2017|Categories: WordPress|0 Comments
We use cookies on this site to improve our service, perform analytics and remember website preference. By using the site, you consent to these cookies (Privacy policy). I consent to cookies