New answers tagged

0

So I figured it out. I added the $arg that was provided through plugin $identify and copied the rest of the information from the plugin to overwrite everything.. and finally after 2 weeks asking, searching and trying it does what i want. Here's the filter I used without altering the plugin: add_filter( 'segment_get_current_user_identify', ...


0

This is how I bootstrapped youtube embeds in one of my projects. /** * Responsive Youtube embeds. */ add_filter( 'embed_oembed_html', function( $html, $url, $attr, $post_ID ) { if ( false !== stripos( $html, '<iframe ' ) && false !== stripos( $html, '.youtube.com/embed' ) ) { $html = sprintf('<div class="embed-responsive ...


1

The delete_attachment action is fired when wp_delete_attachment() function is called to delete an item in the media library.


0

WC()->cart->get_cart() will return an array of current cart items. array( $cart_item_key => $cart_item, $cart_item_key => $cart_item, ... ) Keys $cart_item_key are unique and you need to use one in order to remove item from cart like that: WC()->cart->remove_cart_item( $cart_item_key );


0

I'm not sure what you're trying, but this code should do the job. add_action( 'template_redirect', 'remove_product_from_cart' ); function remove_product_from_cart() { // Run only in the Cart or Checkout Page if( is_cart() || is_checkout() ) { // Set the product ID to remove $prod_to_remove = 58; // Cycle through each ...


2

The add_attachment action is fired when the wp_insert_attachment() function is called to add an item to the media library. Images are added to posts after going into the media library first. Even when adding via the post editor, items are added to the library with wp_insert_attachment() then to the post. add_action( 'add_attachment', xyz_my_function() { ...


1

The comments_array filter as part of the comments_template() function, the purpose of which is to load a comment template. It filters comments being prepared to be rendered in the comment section of singular type pages. The preprocess_comment and comment_post actions (in that order) both fire as part of the wp_new_comment() function, the purpose of which is ...


0

I am not sure what is exactly do you need but you can re declare same function and definition in your plugin file or theme function.php as your requirement. I think do you not need to change core functions bcz wordpress also provide developer can override function as own requirement. In pluggable.php file have wp_set_auth_cookie function if ( ...


1

The use of header() function produce output in the middle of the request and crash it. To modify uploaded image you should use wp_handle_upload filter instead of save_post action. Also, ideally, you should use WP_Image_Editor class, which will use the best image manipulation library available in the server (GD, Imagemagick) and triggers several filters and ...


0

Run this once, it will be saved in database. You can run it once by adding it to functions.php and reloading the site once. $user = new WP_User( $user_id ); // the user id you want to have that capability $user->add_cap( 'edit_others_posts' ); // or any other capability that you want


1

What your function says: On FRONT END do this before template display:      if user is logged in:           check if you are NOT on admin page (back end), if you are not on admin page:               , ...


0

This shows a more readable list of filters function print_filters_for( $hook = '' ) { global $wp_filter; if( empty( $hook ) || !isset( $wp_filter[$hook] ) ) return; $ret=''; foreach($wp_filter[$hook] as $priority => $realhook){ foreach($realhook as $hook_k => $hook_v){ ...


0

My customer wanted "free shipping" over orders 100 < so I used a custom woocommerce/cart/cart-shipping.php Take a look at the contents of it, might help you: https://gist.github.com/eminozlem/ab93b3d91413e59eb86e8601c418656d


1

Plugins are loaded in the order of their file names. e.g. plugin with name abc.php loaded first then xyz.php so if you are trying to remove an action from plugin abc.php and that was added in plugin xyz.php then it is not possible without any tweak. Because action was never added at time you are trying to remove it. You can simply place a die(__FILE__); in ...


1

@AlexanderFarber, there are many way to attach attribute class under wp_nav_menu link. I agree with @Sumit, adding page links in Appearance > Menu WordPress take care of current-menu-item class or current_page_item class. Also, this way is best practice to handle your nav menu in the future. Create dynamic link in wp_nav_menu Since your question related ...


0

Here is my own solution - in the /wp-content/themes/twentythirteen-child/functions.php file add the current-menu-item CSS style if the page slug is player: function my_nav_menu_items( $items ) { $profile = sprintf('<li class="menu-item menu-item-type-custom menu-item-object-custom %s"><a ...


0

The other pages show a 'current menu item' css state: .nav-menu .current_page_item > a, .nav-menu .current_page_ancestor > a, .nav-menu .current-menu-item > a, .nav-menu .current-menu-ancestor > a { color: #bc360a; font-style: italic; This page is showing as 'page-id-32'. If that corresponds to the page in the menu it should show the ...


0

I think it was pagination causing the problem. Not sure whether this is a WooCommerce bug or is intentional, but by default on the single product page a relational link is added to a next product. (I can't see why that is there because I would have thought only one product should ever be displayed, but I'm probably missing something.) So that meant some ...


1

I see two things. You're missing an action call - you need add_action( 'wp_ajax_render_admin_charts_page', 'render_admin_charts_page' ); add_action('wp_ajax_nopriv_render_admin_charts_page', 'render_admin_charts_page'); Plus, from looking at your render_admin_charts_page() you need to change your json dataType to html. Your charts function is outputting ...


0

You need to limit yourself to the main loop and this can be done by checking if is_main_query returns true. This might not be enough as that hook/filter was probably designed with the intention of augmenting the summery and therefor might be called more then once even during execution of the main loop itself. You have two option here Use a much better ...


0

More importantly you should notice what link is produced by get_delete_post_link(). It's an admin link is_admin() check will be always true. Instead you need something else that helps match the request. Try adding and query arg to your delete link. add_query_arg( 'origin', 'fe', get_delete_post_link( get_the_ID() ) ); then in the action ...


1

while googling about the same issue I came upon your question and a similar question from the Wordpress forums. You can control the output of the generated code via the image_send_to_editor filter like this: function filter_image_send_to_editor($html, $id, $caption, $title, $align, $url, $size, $alt) { $html = sprintf('<a href="#" ...


2

You're adding the action on comment_form_before_fields in comment_form_logged_in_after. The latter is called only when the user is logged in, and the former is only called when the user is not logged in. You can add WordPress actions and filters at any time after WordPress is initialized. If you're adding the action in a plugin, add it on init or even when ...



Top 50 recent answers are included