How to get the Date Format and Time Format settings for use in my template?
get_option(‘date_format’); get_option(‘time_format’);
get_option(‘date_format’); get_option(‘time_format’);
I for myself use a combination of: one file dedicated to the one-time script using a transient to stop the script from accidentally running more than once using capability-management or user-control to ensure the script is just run by me. Structure I use a file (onetime.php) in my include-folder inc, which is included in the … Read more
Based on my own experience, I’ve used a combination of method 1 & 2 – the architecture and footer scripts of 1, and the ‘look-ahead’ technique of 2. For the look-ahead though, I use regex in place of stripos; personal preference, faster, and can check for ‘malformed’ shortcode; preg_match( ‘#\[ *shortcode([^\]])*\]#i’, $content ); If you’re … Read more
I coded a plugin just for that and never got around to publish it : Usage: In the dropdown you have a list of all custom fields, so just select the field you want to filter by and click filter. if you want to filter to a specific value of a custom field then select … Read more
You can enable WordPress logging adding this to wp-config.php: // Enable WP_DEBUG mode define( ‘WP_DEBUG’, true ); // Enable Debug logging to the /wp-content/debug.log file define( ‘WP_DEBUG_LOG’, true ); you can write to the log file using the error_log() function provided by PHP. The following code snippet is a very useful function wrapper for it, … Read more
Bare bone themes are great, personally I prefer them over frameworks. I have noticed that ‘liking’ one over another comes down to how it feels, so I would suggest trying several out until you find one. For instance a lot people like WordPress boilerplate but I could not get the hang of it. My current … Read more
Here is what I’ve tried and got a solution with 3 steps. Let’s say your custom post type is “products“ 1 . Add Function Code here you can specify the archive-search.php function template_chooser($template) { global $wp_query; $post_type = get_query_var(‘post_type’); if( $wp_query->is_search && $post_type == ‘products’ ) { return locate_template(‘archive-search.php’); // redirect to archive-search.php } return … Read more
You need to use the right hooks (which are not always the same as the URLs/slugs), and it doesn’t hurt to use a hook that runs later (e.g., admin_init): add_action( ‘admin_init’, ‘wpse_136058_remove_menu_pages’ ); function wpse_136058_remove_menu_pages() { remove_menu_page( ‘edit.php?post_type=acf’ ); remove_menu_page( ‘wpcf7’ ); } You can use the following to debug: add_action( ‘admin_init’, ‘wpse_136058_debug_admin_menu’ ); function … Read more
Note that plugins are all “controllers” by WP standards. It depends on what the plugin is supposed to do, but in all cases I would try to separate the screen output from the PHP code as much as possible. Here’s one way to do that easily – first, define a function that loads the template: … Read more
I think we also need a few more features: Minifying JS, CSS and the HTML that is being sent down the wire. Caching the op-code of the PHP that will be generated (apart from Memcached). Upload the JS, CSS and Images that are used in the theme and/or plugin to a CDN and sync automatically. … Read more