New answers tagged

0

Cleanest way is to add CSS to your own column. In this case wp_enqueue_style(...); with: .column-purchased-leads { width: 74px; text-align: center } You'll get neat column as "Posts".


-1

Before you can use, those two lines : wp_enqueue_style( 'wp-auth-check' ); wp_enqueue_script( 'wp-auth-check' ); you should register those assets, inside wp_enqueue_scripts or admin_enqueue_scripts, like the following : function my_assets() { wp_register_style( 'wp-auth-check', 'path/to/style', $deps = array, $ver = false, $media = 'all' ) ...


0

No, constructors should not define hooks. Constructors should be used to set the initial state of the object. Hooks have nothing to do with the object's initial state, so they don't belong in the constructor. Constructors should not have "side effects", so that using new ClassName() does not affect any other parts of the program, which is what registering ...


1

Answer by @Pieter Goosen : If you need to update the page before the main query fires and returns the page object, you will manually need to parse the URL (probably on init) and get the page ID from get_page_by_title() or get_page_by_path(). Otherwise, 'wp' would be earliest hook to get the page ID, for example: function my_early_id() { $...


-1

it depends on what you want to do. for example, suppose your plugin needs javascript for it to work. in this case, we can enqueue the javascript in the constructor of the Class : class My_Plugin{ function __construct (){ add_action( 'wp_enqueue_scripts', array( $this , 'my_script' ) ); } function my_script(){ // here ...


0

This is the solution: add_action('pre_post_update', function($post_id, $post_data) { global $original_post; $original_post = get_post($post_id); }, 10, 2); add_action( 'save_post_', function($post_id, $post, $update) { global $original_post; $original_post->post_title; // original post title $post->post_title; // new post title }...


1

Unfortunately there doesn't seem to be any action hooks available for adding custom checkboxes to the Menu Settings section (Github/wp-admin/nav-menus.php). For registering menu locations, you should use register_nav_menus().


0

Had a brainwave whilst typing up the question.. there are other actions that fire when a post is updated, such as post_updated which naturally update the post_modified timestamp. Instead I decided to save the activity's modified time as a meta value, and will sort on that instead and leave the post_modified functionality intact. The trimmed down function: ...


0

try out this plugin hop it's work for you https://wordpress.org/plugins/woo-bulk-price-update/


0

You can except to go to that logout page. Only you need to change your logout link in your frontend. <a href="<?php echo wp_logout_url()?>">logout</a> this code, make the logout without confirmation window. But also if you really need a confirmation, you can create a "new page" named "confirmation" now, in your frontend the logout can ...


0

There's no direct way of getting the post author's email from a post. You can get the email by using the author ID, which is present in standard WP_Post object. $post_author_id = intval( $post->post_author ); $post_author_email = get_the_author_meta('email', $post_author_id); Or if you just have the post ID $post_author_id = intval( get_post_field( '...


1

You can use this filter, function ar_lazyload_deactivate() { if ( is_singular( 'posttype name' ) ) { add_filter( 'do_rocket_lazyload', '__return_false' ); } } add_filter( 'wp', __NAMESPACE__ . '\ar_lazyload_deactivate' );


1

You can't just filter __FILE__. Or any arbitrary function or variable. You can only filter values that are passed to apply_filters(). In this case the wcpv_vendor_order_page_template filterable value is: dirname( __FILE__ ) . '/views/html-vendor-order-page.php' In other words, it's a path to a PHP file. If you want to change the PHP file that's loaded, you ...


1

save_post and new_to_publish is enough, with some checks, to update post metadata. And you don't need the redirection. <?php /** * Update Postmeta. * * @param integer $post_id Post ID. */ function wpse355298_job_publish_status( $post_id ) { // Check autosave. if ( wp_is_post_autosave( $post_id ) ) { return $post_id; } // ...


0

I find and use below code for when user in cart page and cart not empty: add_filter('woocommerce_get_checkout_url', 'dj_redirect_checkout'); function dj_redirect_checkout($url) { global $woocommerce; if(is_cart() && !is_user_logged_in() ){ $checkout_url = 'digits login url'; } else{ $checkout_url='https://...


1

Not really, but perhaps you using the wrong terms: A shortcode is a manually entered piece of text where code has been programmatically added so that when wp runs 'the_content' filter , it'll then call the function and replace the piece of text with the returned result of the function. It's a specialised form of a filter. It sounds like what you want is ...


0

I haven't verified this but you could try the upgrader_process_complete hook. More information on that hook. like follows function wp_answ_355114() { flush_rewrite_rules(); } do_action( 'upgrader_process_complete', 'wp_answ_355114' );


1

I realize you've already answered your issue. However, I think there is some additional explanation possible to give more clarity to the issue and the solution. The issue is your lqdnotes_add_div() function. This is hooked to a filter - the_content. In WordPress, any time you use a filter, your filter function must return a value for the item being ...


0

StackOverflow may be my rubber duck. Almost immediately after publishing the question the solution popped into my mind. The problem was in the function lqdnotes_add_div. This function took $content (the post content) as a parameter. If post was not of type lqdnotes then it didn't perform any operation on $content...or so I thought. PHP actually returns ...


Top 50 recent answers are included