$wpdb in php 5.5

There is no difference in this respect between PHP 5.3 and 5.5. The code doesn’t need to change. However, you should still use prepare properly. Like so: $query = $wpdb->prepare( ‘UPDATE wp_building_plan SET sale_price = %s, available = %s, broker_name = %s, broker_email = %s, broker_phone = %s WHERE id = %s’, $sale_price, $available, $broker_name, … Read more

Including template in shortcodes

I’m not quite sure this is what you are trying to do, however, this is one way to use an external template file for your shortcode output. This is your shortcode function (e.g., in functions.php): function qt_shortcodez() { return include ‘template/shortcode.php’; } // function qt_shortcodez And that is the very output (i.e., shortcode.php): <?php ob_start(); … Read more

How to replace settings in WordPress plugin from a theme

You are already pretty close. Extending your example: In your plugin put this: $default_settings = array( ‘key_one’ => 0, ‘key_two’ => 1 ); $settings = apply_filters( ‘example_filter’, $default_settings); Then a theme can change it like this: add_filter(‘example_filter’,’my_function’); function my_function($settings){ $settings[‘key_one’] = 1; return $settings; }

If $var is empty, return 404.

I have run into the same issue that using $wp_query->set_404(); would properly adjust the global object but not return the 404 template. So in the plugin I was writing I used the tried and tested method: add_filter( ‘template_include’, ‘wp_139917_force_404’ ); function wp_139917_force_404(){ global $wp_query; $wp_query->set_404(); status_header(404); include get_404_template(); exit; } ~ modified from source: https://github.com/codearachnid/woocommerce-product-permalink/blob/master/inc/product-permalinks.php#L56 … Read more