front end editing using iFrames, best approach?

Using a custom template and wp_update_post you should be able to build your own edit/add post pages in your sites frontend. There are also various plugins available that attempt to do similar things. iFrames can be done, but it will need some checks in functions.php to check for a get variable and add conditional stylesheets … Read more

Three level taxonomy dropdown frontend

After spending many hours using google I managed to make 3-level hierarchical taxonomy dropdown with ajax. Here is my code: searchform.php <script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js” ></script> <script type=”text/javascript”> $(function(){ $(‘#apskritis’).change(function(){ var $apskritisSlug=$(‘#apskritis’).val(); // call ajax $(“#savivaldybe”).empty(); $(“#miestas_kaimas”).empty(); $.ajax({ url:”/wp-admin/admin-ajax.php”, type:’POST’, data:’action=get_savivaldybes&apskritis_slug=’ + $apskritisSlug, success:function(results) { //alert(results); $(“#savivaldybe”).removeAttr(“disabled”); $(“#savivaldybe”).append(results); } }); } ); $(‘#savivaldybe’).change(function(){ var $savivaldybeSlug=$(‘#savivaldybe’).val(); // … Read more

Using AJAX with Forms

Your add_action() calls for the AJAX handlers are too late. Add these hooks earlier, the best action is probably wp_loaded: add_action( ‘wp_loaded’, ‘register_ajax_handlers’ ); function register_ajax_handlers() { add_action( ‘wp_ajax_jp_ajax_request’, ‘jp_ajax_process’); add_action( ‘wp_ajax_nopriv_jp_ajax_request’, ‘jp_ajax_process’); } See also: Debug AJAX. This code should be placed in a plugin or in your theme’s functions.php.

Creating multiple enclosing shortcodes and fixing JS issues on click

Code:- function more_shortcode( $atts , $content = null ){ return ‘<div id=”more-outer-‘.$atts[‘id’].'”><a href=”#” id=”more-link-‘.$atts[‘id’].'”>More</a><div id=”more-inner”>’. $content .'</div></div>’; } add_shortcode( ‘more’, ‘more_shortcode’ ); Usage:- [more id=’1′]This is one.[/more] [more id=’2′]This is two.[/more] [more id=’3′]This is three.[/more] Output:- <div id=”more-outer-1″><a href=”#” id=”more-link-1″>More</a><div id=”more-inner”>This is one.</div></div> <div id=”more-outer-2″><a href=”#” id=”more-link-2″>More</a><div id=”more-inner”>This is two.</div></div> <div id=”more-outer-3″><a href=”#” id=”more-link-3″>More</a><div id=”more-inner”>This … Read more

RTL/LTR frontend switcher

Ok. I resolved it in this way. Let’s say that we have a CSS-file rtl.css, which contains rules for right-to-left content direction. Add menu items: Appearance->Menus->Select a menu to edit->Edit menus->Custom links. URL – ?language=rlt (or something like this), Link text – RTL (for example) URL – ?language=ltr, Link text – LTR Create a plugin: … Read more

limit file type and file size using media_handle_upload

Use PHP // Check that the nonce is valid, and the user can edit this post. if (isset( $_POST[‘my_image_upload_nonce’] ) && wp_verify_nonce( $_POST[‘my_image_upload_nonce’], ‘my_image_upload’ ) ){ // Input type file name $image_input_name=”my_image_upload”; // Allowed image types $allowed_image_types = array(‘image/jpeg’,’image/png’); // Maximum size in bytes $max_image_size = 1000 * 1000; // 1 MB (approx) // Check … Read more