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

random reason on refresh

You say that you are… … wanting to add a random reason (quote) as to why they should join which will change after every reload of the page And you seem to trying to do this by placing Javascript in a text widget. I assume that is what you mean by the ‘”text” in the … Read more

Newest version of javascript

As the Codex tells us you can add another parameter to the function that holds the version number. wp_register_script( $handle, $src, $deps, $ver, $in_footer ); $ver String specifying the script version number, if it has one, which is concatenated to the end of the path as a query string. If no version is specified or … Read more

How to add 3 weeks to the_time() function

You should use get_the_time() and not the_time(). First one returns time and second one echoes it. I don’t think you should do this in JS though (there is no need to, and users can always block JS and see this image anyway). Your code could look something like this (it’s in PHP): if ( strtotime( … Read more

Creating a custom wordpress widget and stopping js from running twice(once in active widget once in widget selector)?

Use wp_enqueue_script. You assign a name to your js file when enqueued, and it will stop a file from being enqueued multiple times. Right now your JS is simple enough, but as it gets more complex, it’s better to have it outside in it’s on .js file. add_action( ‘wp_enqueue_scripts’, ‘add_my_js’ ); function add_my_js() { wp_enqueue_script( … Read more

Showing Different Code on Pages With Different Layouts

function add_js_one_col_wpse_107240() { if (is_page()) { $pobj = get_queried_object(); if(!empty(get_post_meta($pobj->ID,’one-col’,true)) { wp_enqueue_script(/* … */); } else { wp_enqueue_script(/* … a different script … */); } } } add_action(‘wp_enqueue_scripts’,’add_js_one_col_wpse_107240′); get_queried_object will get you the page information. It will be a WP_Post object on a “Page”. global $post should probably work too, but this is cleaner. Use … Read more

creating a static HTML/JS/PHP page

i need to create a static page that allows me to code HTML/JS/PHP… Create a custom page template and integrate your structure in it. .. that connects to a separate MYSQL backend. I don’t know why you want a separate MySQL backend. In your comment, you tell that you’re making a contact form. I guess … Read more