How use %like% in sql statement wordpress

$wpdb->prepare() doesn’t actually fully support sprintf() placeholders. From the Codex: The query parameter for prepare accepts sprintf()-like placeholders. The %s (string), %d (integer) and %f (float) formats are supported. It’s not entirely obvious from that but the argument swapping formats (e.g. %1$d) are not supported (in any case you have the incorrect syntax: it should … Read more

How to trigger an action with a URL

As @toscho says you need an endpoint. Note code is untested. /** * Flush rewrite rules */ function install_my_plugin() { my_plugin_endpoint(); flush_rewrite_rules(); } register_activation_hook( __FILE__, ‘install_my_plugin’ ); /** * Flush rewrite rules */ function unistall_my_plugin() { flush_rewrite_rules(); } register_deactivation_hook( __FILE__, ‘unistall_my_plugin’ ); /** * Add the endpoint */ function my_plugin_endpoint() { add_rewrite_endpoint( ‘action’, EP_ROOT ); … Read more

WooCommerce – results per page not working after page reload

Let’s imagine you got a dropdown like the following // The template tag that you place in your … template function WPSE116198PerPageSelect() { $selected = <?php <select name=”woo_per_page” id=”woo_per_page” size=”3″> <?php foreach ( array( 24, 36, 48 ) as $val ) { ?><option <?php value=”<?php echo $val; ?> selected( get_query_var( ‘woo_per_page’ ), $val ); ?>> … Read more

Hook to generate a dynamic sitemap with “All in One SEO Pack” Plugin

This is the solution from Peter Baylies (Plugin Author) add_filter( ‘option_aioseop_options’, ‘itdge_sitemap_addl_pages’ ); function itdge_sitemap_addl_pages( $option ) { if ( !empty( $option ) && !empty( $option[‘modules’] ) && !empty( $option[‘modules’][‘aiosp_sitemap_options’]) ) { $my_sitemap_entries = Array( ‘/test1’ => Array( ‘prio’ => ‘0.1’, ‘freq’ => ‘daily’, ‘mod’ => ‘2014-04-01’ ), ‘/test2’ => Array( ‘prio’ => ‘0.3’, ‘freq’ … Read more

get_plugins() doesn’t work after plugins_loaded

Possibly you’re trying to use that code in a non-admin page. The functon get_plugins is only available on admin side and if you ant to use it somewhere else you have to load the file “plugin.php” manually. To solve this error add that check at the beginning of your function: if ( ! function_exists( ‘get_plugins’ … Read more

How can I create a plugin installation link?

Well, looks like I have found the answer. The action should be changed like so: $action = ‘install-plugin’; $slug = ‘akismet’; wp_nonce_url( add_query_arg( array( ‘action’ => $action, ‘plugin’ => $slug ), admin_url( ‘update.php’ ) ), $action.’_’.$slug ); The answer was found in line 275 in the source code: https://core.trac.wordpress.org/browser/tags/3.9.1/src/wp-admin/includes/plugin-install.php

How to include plugin without activation?

WP_PLUGIN_DIR.’/pluginName/’ will give you the absolute path to the directory of the plugin. EDIT After comment Plugins are plugins, theme files are theme files. Lets not confuse the two. You cannot copy a plugin in the theme directory – because stuff does not work like that. After careful editing you can include the plugin as … Read more

Have plugin require two other plugins

check if the plugins are active and display a warning at the top of the page if there not: http://codex.wordpress.org/Function_Reference/is_plugin_active add_action( ‘admin_init’, ‘spp_plugin_has_parents’ ); function spp_plugin_has_parents() { if ( is_admin() && current_user_can( ‘activate_plugins’) && !is_plugin_active( ‘advanced-custom-fields/acf.php’) || !is_plugin_active( ‘paid-memberships-pro/paid-memberships-pro.php’ ) ) { add_action( ‘admin_notices’, ‘spp_plugin_notice’ ); deactivate_plugins( plugin_basename( __FILE__) ); if ( isset( $_GET[‘activate’] ) … Read more