How to declutter admin columns

Admin columns can be shown/hidden by using the Screen Options menu. Here, the custom column Headline news is being hidden using the UI: Alternatively, Admin Columns can be unset (and therefore hidden) programmatically: add_filter( ‘manage_post_posts_columns’, ‘wpse_hide_columns’, PHP_INT_MAX, 1 ); function wpse_hide_columns( $columns ) { // Check for the name of the column, and unset it … Read more

Using the default wordpress uploader inside plugin

have you search in other question? this is the jquery script to call media uploader if u click a element media button var $j = jQuery.noConflict(); function call_media_library() { var media_uploader; $j(document).on(‘click’, ‘.video_media_btn’, function(e){ e.preventDefault(); var btn_uploader = $j(this); if (media_uploader) { media_uploader.open(); return; } media_uploader = wp.media({ title: ‘Upload media’, //you can change type … Read more

Woocommerce: Add column to ORDERS admin page with items purchased

I have already manage to create a column thanks to this: // ADDING COLUMN TITLES add_filter( ‘manage_edit-shop_order_columns’, ‘custom_shop_order_column’,11); function custom_shop_order_column($columns) { //add columns $columns[‘my-column1’] = __( ‘Column Title’,’theme_slug’); return $columns; } // adding the data for each orders by column (example) add_action( ‘manage_shop_order_posts_custom_column’ , ‘custom_orders_list_column_content’, 10, 2 ); function custom_orders_list_column_content( $column ) { global $post, … Read more

admin_url in plugins

First rule of wordpress development is to always use a core API if one is available, there is usually a good reason for its existence. In this case, you are assuming something about how files are called and the URLs they are in. For an example were such an assumption will fail, is the (rarely … Read more

Wrong wp-admin URL

Eventually, I found the reason of this weird behaviour. It is caused by the JavaScript embedded in wp_admin_canonical_url() (https://developer.wordpress.org/reference/functions/wp_admin_canonical_url/) The URL is determined by this piece of code $_SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’] where the latter one returns wp-admin instead of hello/wp-admin. By manipulating the value in $_SERVER[‘REQUEST_URI’], I can successfully get the correct behaviour in admin … Read more

Reusable content block

if you’re using ACF, create an options page and then add a field there. Then present that data in a side widget by echoing out the field. once the field is created you can call it with this code: <?php the_field(‘page_content’, ‘option’); ?> I like to add it to a function function rt_show_field() { $field … Read more

Diplay comment date on WP_Post_Comments_List_Table

So, it doesn’t appear you can do much “properly” to solve this issue, however, you can take some advice from this answer and apply it to your problem: <?php add_filter( ‘get_comment_author_IP’, function( $comment_author_IP, $comment_ID, $comment ) { global $pagenow; if( is_admin() && ‘post.php’ === $pagenow && isset( $_GET[‘post’] ) ) { $comment_date = do_something_to_get_comment_date($comment_ID); $comment_author_IP … Read more