Use touch_time() on front-end form via plugin

You might try to include the the template.php file: <?php if( ! function_exists( ‘touch_time’ ) ) { require_once( ABSPATH . ‘/wp-admin/includes/template.php’ ); touch_time( 0, 0, 5 ); } ?> but I think it might be better to just copy the code from the touch_time() function into your own function and modify accordingly. Friday part of … Read more

Get subcategories with JSON API plugin

Retrieving terms With the current version of the “WP API” (JSON API plugin), there’s a simple way to retrieve terms: GET /taxonomies/<taxonomy>/terms The method responsible is get_taxonomy_terms( $taxonomy ) in the plugins core. You will have to check is_wp_error() on the return value to check if the taxonomy exists at the point where you invoke … Read more

Remove Widgets in Dashboard

I think the best way to go about this is to create a new plugin (or put in the theme function.php but a plugin will always work independent of theme) that disables the widgets you don’t need. Something like this. function wpse_47707_disable_admin_meta() { remove_meta_box( ‘dashboard_browser_nag’, ‘dashboard’, ‘normal’ ); remove_meta_box( ‘dashboard_right_now’, ‘dashboard’, ‘normal’ ); remove_meta_box( ‘dashboard_recent_comments’, … Read more

update_meta_user difference in i:1 and b:1, how to write b:1

Your first serialized string is broken. I can’t spot why but you should not be trying to manipulate capabilities manually. You already have a user object. Use it. if( $new_roles === ‘administrator’ ) { $capabilities = array (“administrator”,’activate_plugins’,’delete_others_pages’,’delete_others_posts’,’delete_pages’,’delete_plugins’,’delete_posts’,’delete_private_pages’,’delete_private_posts’,’delete_published_pages’,’delete_published_posts’,’edit_dashboard’,’edit_files’,’edit_others_pages’,’edit_others_posts’,’edit_pages’,’edit_posts’,’edit_private_pages’,’edit_private_posts’,’edit_published_pages’,’edit_published_posts’,’edit_theme_options’,’export’,’import’,’list_users’,’manage_categories’,’manage_links’,’manage_options’,’moderate_comments’,’promote_users’,’publish_pages’,’publish_posts’,’read_private_pages’,’read_private_posts’,’read’,’remove_users’,’switch_themes’,’upload_files’,’create_product’); $user->set_role(‘administrator’); foreach ($capabilities as $cap) { $user->add_cap($cap); } } Untested but that should work. However, you should … Read more

WP-PageNavi plugin doesn’t work with multiple pages of search results

I discovered that the problem was in my theme’s searchform.php file. I changed the form method from “post” to “get.” Now search queries show up in the url address. Before: <form action=”<?php echo $_SERVER[‘PHP_SELF’]; ?>” method=”post”> After: <form action=”<?php echo $_SERVER[‘PHP_SELF’]; ?>” method=”get”> Problem solved.

How to set value/term of a Woocommerce attribute text field in admin panel?

I am assuming the ID of that text filed, is url-field here is the JS code $(“#url-field”).keyup(function(event) { var url_val=$(“#url-field”).val(); $.ajax({ type:”POST”, url: ajaxurl, data: { action:’use_someprefix_update_url’, search_string:url_val, namefiled : namehere, postid : postidhereYouCangetItIHope }, success:function(data){ alert(“Success, you can remove me 🙂 “); } }); }); Here comes PHP, put this in functions.php function use_someprefix_update_url(){ … Read more