How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?

The way to do this is to use the ‘admin_enqueue_scripts’ hook to en-queue the files you need. This hook will get passed a $hook_suffix that relates to the current page that is loaded: function my_admin_enqueue($hook_suffix) { if($hook_suffix == ‘appearance_page_theme-options’) { wp_enqueue_script(‘my-theme-settings’, get_template_directory_uri() . ‘/js/theme-settings.js’, array(‘jquery’)); wp_enqueue_style(‘my-theme-settings’, get_template_directory_uri() . ‘/styles/theme-settings.css’); ?> <script type=”text/javascript”> //<![CDATA[ var template_directory … Read more

What is the preferred way to add custom javascript files to the site?

Use wp_enqueue_script() in your theme The basic answer is to use wp_enqueue_script() in an wp_enqueue_scripts hook for front end admin_enqueue_scripts for admin. It might look something like this (which assumes you are calling from your theme’s functions.php file; note how I reference the stylesheet directory): <?php add_action( ‘wp_enqueue_scripts’, ‘mysite_enqueue’ ); function mysite_enqueue() { $ss_url = … Read more

show hide image script after 4 seconds [closed]

If you had for example, <img src=”https://wordpress.stackexchange.com/questions/228932/rdp_banner.jpg” id=”logoimage”> You could just do… add_action(‘init’,’checkvisitcookie’); function checkvisitcookie() { if (isset($_COOKIE[‘firsttimevisit’])) {return;} setCookie(‘firsttimevisit’,’1′,100*365*24*60*60); add_action(‘wp_footer’,’fadelogoout’); } function fadelogoout() { echo “<script> jQuery(document).ready(function() { setTimeout(function() { jQuery(‘#logoimage’).fadeOut(); }, 5000); }); </script>”; } Just to make it almost relevant to WordPress 😉

Uncaught type error after WordPress update to 5.5.3 and visual composer to 6.4.1

I got some uncaught error after updating WP to 5.5.3 version and visual coomposer to 6.4.1. Visual composer page builder stopped working, it only shows shortcode in the backend. Luckily nothing breaks on the front-end. When logged in backend in chrome see this error in console. “Uncaught TypeError: Cannot read property ‘Constructor’ of undefined” at … Read more