Tag Info

Hot answers tagged

5

You can hook onto pre_insert_term, check the taxonomy and whether or not the user has the specified role as follows: function disallow_insert_term($term, $taxonomy) { $user = wp_get_current_user(); if ( $taxonomy === 'post_tag' && in_array('somerole', $user->roles) ) { return new WP_Error( 'disallow_insert_term', ...


3

You need to enqueue the scripts as well, not only register them. You can, however, just simply enqueue a script without registering it if you are not going to enqueue it conditionally. I would try something like this: (Untested and requires PHP5.4+) add_action( 'wp_enqueue_scripts', enqueue_scripts, 11 ); function enqueue_scripts() { /** * Build ...


2

This should work: add_action( 'woocommerce_init', 'remove_wcpgsk_email_order_table' ); function remove_wcpgsk_email_order_table() { global $wcpgsk; remove_action( 'woocommerce_email_after_order_table', array( $wcpgsk, 'wcpgsk_email_after_order_table' ) ); }


2

using wp_die(); at the end of AJAX function fixed the issue for me. e.g add_action( 'wp_ajax_my_ajax_function', 'my_ajax_function' ); function my_ajax_function(){ echo json_encode($myvar); wp_die(); }


2

The short answer to your question is yes; however, the methods to do this are a little bit hacky and generally I would recommend against all of them unless absolutely necessary. Since pluggable functions actually replace the stock function by way of function_exists() whichever plugin that "plugs" the function first will win. What you want to do is ensure ...


1

I don't suspect that your tax_query is failing you, but actually your tag parameter is. single_tag_title() returns the name of the tag, not the slug. All tag and category queries are converted to a tax_query in the WP_Query class before being passed to the WP_Tax_Query class to build the relative string for the SQL query. Term names and slugs gets ...


1

You need to wrap the first three || conditions in additional parentheses so they are evaluated first BEFORE the last && condition: Psuedocode example: here here ↓ ↓ if ( (condition || condtion || condition) && ! condition ) { //do business logic... } This now ...


1

You can simply use require, require_once, include or include_once functions to include custom PHP files in your theme. require( 'folder/custom.php' ); Usually you should keep your custom PHP files in a folder. Developers vote against using require_once because it is a little slower than require since it requires the system to keep a log of what's already ...


1

You are almost there. You just need to use wp_mail to send emails containing in your array. Here is how you can achieve that using save_post action hook. /** * To send email on updating your event post * * @param int $post_id The post ID. * @param post $post The post object. * @param bool $update Whether this is an existing post being updated or not. ...


1

You have two options here In a child theme, dequeue and deregister the scripts and style you are not going to need. Just remember to hook your function to wp_enqueue_scripts with a lower priority (higher number) Use the twentyfifteen as a base to a new theme. I have successfully used bundled themes in the past to create new, selfstanding themes. That is ...


1

You can use the following functions: time (); return The time by seconds date(); y- Year m- Month d- Day h- Hours i- Minute s- Second for ex: date("Y-m-d H:i:s");


1

If your plugin is registered like this: class Test_Class_Parent { function __construct() { add_action('wp_head',array($this,'test_method')); } function test_method() { echo 'Echoed from the parent'; } } $p = new Test_Class_Parent(); Then you should be able to remove the filter by accessing the global: class Test_Class_Child extends ...


1

Yes, there is a filter for this. The correct filter is wp_mail and is defined in /wp-includes/pluggable.php Line 135 So the code (maybe in your functions.php) should look something like this: function mail_template($args){ ob_start(); require_once (get_template_directory() . '/mail-templates/contacemail.php'); $args['message'] = ...



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