Tag Info

Hot answers tagged

7

You can try this: is_admin() && add_filter( 'gettext', function( $translated_text, $untranslated_text, $domain ) { $old = "Plugin <strong>activated</strong>."; $new = "Captain: The Core is stable and the Plugin is <strong>activated</strong> at full Warp speed"; if ( $untranslated_text === ...


2

You can check the $current_screen on the current_screen action, and redirect after checking some GET conditions: function wpd_current_screen( $current_screen ) { if ( 'toplevel_page_your_menu_item_id' == $current_screen->base ) { // check some condition and wp_redirect( admin_url() ); exit; } } add_action( ...


2

Some things non-WordPress specific regarding cookies: set cookie fails if some output has been done in the page you can't access to coockie value in the same request you set it (as @Milo pointed out in a comment to OP) Another general rule is better to use filter_input or filter_intput_array instead of direct accessing to super globals like $_GET or ...


2

I would use the registration_redirect filter. This allows you to set where the user is sent to, but leaves WordPress to perform the redirect (after everything has successfully processed). function wpse_139267_registration_redirect( $url ) { return site_url( 'thank-you' ); } add_filter( 'registration_redirect', 'wpse_139267_registration_redirect' );


2

You should first load your scripts with a hook on wp_enqueue_scripts like this for example : add_action( 'wp_enqueue_scripts', 'load_my_scripts' ); function load_my_scripts() { wp_enqueue_script( 'jquery' ); } What I like to do is, register my script with a hook on init and then enqueue them with a hook on wp_enqueue_scripts: // Register Scripts ...


2

Scripts and stylesheets should always be loaded in the head or in the footer via the wp_enqueue_scripts action hook. wp_enqueue_scripts is the proper hook to use when enqueuing items that are meant to appear on the front end The init hook executes before wp_head which is to early for script to load in the header. The wp_enqueue_scripts action hook is ...


1

The hooks you are looking for can be found in the WordPress Codex WP_Query - Filters: Filters posts_distinct - Alters SQL 'DISTINCTROW' clause to the query that returns the post array. posts_groupby - Alters SQL 'GROUP BY' clause of the query that returns the post array. posts_join - Alters SQL 'JOIN' clause of the query that returns the post ...


1

Even if is not very flexible filter you can use the gettex hook. Only be aware that this filter runs for every string being translated, so can affect performarce if over-used. To narrow the performance impact you can add it only of admin footer, and remove it just after had use it: add_action('admin_footer', function() { add_filter( 'gettext', ...


1

By default, the add_action function is only going to pass 1 parameter, but you can define how many do you have / need $accepted_args (int) (optional) The number of arguments the hooked function accepts. In WordPress 1.5.1+, hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run. So ...


1

Couple of things: 1: When you include the script after jquery, localise it using the wp_localize_script function: $nonce = wp_create_nonce("vote_nonce"); $yourscript_info = array( 'ajaxurl' => admin_url( 'admin-ajax.php'), 'nonce' => $nonce ); wp_localize_script( 'yourscript', 'yourscript', $yourscript_info ); $.ajax({ type: "POST", ...



Only top voted, non community-wiki answers of a minimum length are eligible