Screen Options JavaScript Code

This is in wp-admin/js/common.js or wp-admin/js/common.min.js: // Scroll into view when focused $(‘#contextual-help-link, #show-settings-link’).on( ‘focus.scroll-into-view’, function(e){ if ( e.target.scrollIntoView ) e.target.scrollIntoView(false); }); Found with a search for show-settings-link in the complete source. 🙂

Covert WordPress Blogname into JQuery

Use wp_localize_script function set_js_var() { $translation_array = array( ‘blog_name’ => get_bloginfo(‘name’) ); wp_localize_script( ‘jquery’, ‘my_data’, $translation_array ); } add_action(‘wp_enqueue_scripts’,’set_js_var’); If you look at the source of the page you will see something like: <script type=”text/javascript”> /* <![CDATA[ */ var my_data = {“blog_name”:”WordPress 3.5.1 Release”}; /* ]]> */ </script> That is your Javascript variable. You have … Read more

Replacing WordPress Icons (menu,icons32, etc)?

The CSS is in wp-admin/css/colors-classic.css and wp-admin/css/colors-fresh.css and the min versions of those, including the icons32-2x.png ones. I can see them when I grep the directory. For example, wp-admin/css/colors-classic.css:2162. The images themselves are in wp-admin/images, as you can see from the style rules, but you should not be hacking/replacing those. They will be overwritten when … Read more

Assigning tags to a post from front end using tag-it jquery UI plugin

I added the fieldName parameter to tagit function like this: <script type=”text/javascript”> $(document).ready(function() { $(“#myTags”).tagit( { fieldName: “tages[]” } ); }); </script> Now I can echo $_POST[‘tages’]; since the HTML after execution became: <input type=”hidden” style=”display:none;” value=”d” name=”tages”> In addition, $_POST[‘tages’]; is a PHP array which I can directly put in second parameter of wp_set_object_terms. … Read more

Separate jQuery for Individual Comments?

Replace your jquery with this <script type=”text/javascript”> (function($){ $(document).ready(function() { var $option = $(‘.option’); var $fruit = $(‘.fruit-name’); var $last; var parent $option.click(function() { parent=$(this).parents(‘.comment-form-rating’); $(‘.fruit-name’,parent).val(this.innerHTML) }) }); })(jQuery); </script> your script not working because .fruit-name not contain correct reference variable. Updated for debugging put code and check. <script type=”text/javascript”> (function($){ $(document).ready(function() { var $option … Read more

Slider’s missing navigation

WordPress loads jQuery in “No Conflict” mode. The $ alias does not work. This is the cause of most of the “jQuery doesn’t work” questions on this site. Your code is using that $ alias, despite the Codex warnings against doing so. Use jQuery.(document) or wrap your code like… (function($) { $(function() { // more … Read more

sanitizing/escaping plugin options

sanitize_text_field( $str ) Sanitize a string from user input or from the db. Checks for invalid UTF-8, Convert single < characters to entity, strip all tags, remove line breaks, tabs and extra white space, strip octets http://codex.wordpress.org/Function_Reference/sanitize_text_field

“switchEditors is not defined” with wp_editor() in jQuery UI tabs

I have tackled this by putting TinyMCE on the first tab, and making it a static tab, all others are still ajax, would still like it to be ajax, if anyone has any solutions. <div id=”tabs”> <ul id=”wpsca_ul”> <li><a href=”#wpsca_addedit” title=”add page”><?php echo __(‘Add Page’,’wpsca_lang’);?></a></li> <li><a href=”https://wordpress.stackexchange.com/questions/106799/<?php echo get_option(“siteurl’ ).’/?wpsca=wpscalist’;?>” title=”manage addedit”><?php echo __(‘Manage Pages’,’wpsca_lang’);?></a></li> … Read more

Showing Meta Box via Jquery Checkbox

Found a solution to it though, pretty simple <script type=”text/javascript”> jQuery(document).ready(function($) { var dw_match_display = $(‘#dw_match_display’); dw_match_display.hide(); if ($(‘#dw_complete’).prop(‘checked’) ) { dw_match_display.show(); } $( ‘#dw_match_details’ ).on( ‘change’, ‘#dw_complete’, function() { dw_match_display.hide(); if ( $(this).prop(‘checked’) ) { dw_match_display.show(); } }); }); jQuery(document).ready(function($) { $( ‘#dw_match_display’ ).change(); }); </script>

How do I implement jPanelMenu?

You can “initialize” the script any time after it has been loaded on the page. I usually do that in wp_footer (Especially if you enqueue the script in the footer) but you can add it to wp_head too. add_action( ‘wp_footer’, ‘wpa_107420_footer_script’ ); function wpa_107420_footer_script(){ ?> <script type=”text/javascript”> jQuery(document).ready(function($) { // Stuff to do as soon … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)