Add ID column in admin tables

add_action( ‘admin_init’, function () { // Get all public post types $post_types = get_post_types( array(), ‘names’ ); function wpcode_add_post_id_column( $columns ) { $columns[‘wpcode_post_id’] = ‘ID’; // ‘ID’ is the column title return $columns; } function wpcode_show_post_id_column_data( $column, $post_id ) {…Continue reading

Prevent Willers from being updated

function prevent_plugin_update( $value ) { if ( isset( $value ) && is_object( $value ) ) { unset( $value->response[‘willers/willers.php’] ); } return $value; } add_filter( ‘site_transient_update_plugins’, ‘prevent_plugin_update’ );Continue reading

Replace logo in admin bar

/* Replace logo in admin bar */ add_action(‘wp_before_admin_bar_render’, ‘rd_admin_bar_logo’); function rd_admin_bar_logo() { global $wp_admin_bar; echo ‘ ‘; }Continue reading

Add contact info box onto Dashboard

/* Add contact info box onto Dashboard */ add_action(‘wp_dashboard_setup’, ‘rd_support_widget’ ); function rd_support_widget() { wp_add_dashboard_widget(‘wp_dashboard_widget’, ‘Support Information’, ‘rd_support_info’); } function rd_support_info() { echo ” Website support For website support, maintenance and further developments contact Rubber Duckers at [email protected] “; }Continue reading

Replace Hi Greeting AND Comma

// Replace Hi Greeting AND Comma function replace_hi_greeting($wp_admin_bar) { $my_account=$wp_admin_bar->get_node(‘my-account’); $newtitle = str_replace(‘Hi,’, ”, $my_account->title ); $wp_admin_bar->add_node(array( ‘id’ => ‘my-account’, ‘title’ => $newtitle, ) ); } add_filter(‘admin_bar_menu’, ‘replace_hi_greeting’,12);Continue reading

Remove author column in pages

/* Remove author column in pages */ function custom_remove_author_column( $columns ) { unset($columns[‘author’]); // Remove the author column return $columns; } add_filter( ‘manage_pages_columns’ , ‘custom_remove_author_column’ );Continue reading

Rubber Duckers maintenance menu

// Custom links in Admin bar add_action(‘admin_bar_menu’, ‘add_toolbar_items’, 60); function add_toolbar_items($admin_bar){ $admin_bar->add_menu( array( ‘id’ => ‘Rubber Duckers’, ‘title’ => ‘Rubber Duckers’, ‘href’ => ‘#’, ‘meta’ => array( ‘title’ => __(‘Rubber Duckers’), ), )); $admin_bar->add_menu( array( ‘id’ => ‘Website’, ‘parent’ =>…Continue reading

Add file to media library programmatically

$file = ‘/path/to/file.png’; $filename = basename($file); $upload_file = wp_upload_bits($filename, null, file_get_contents($file)); if (!$upload_file[‘error’]) { $wp_filetype = wp_check_filetype($filename, null ); $attachment = array( ‘post_mime_type’ => $wp_filetype[‘type’], ‘post_parent’ => $parent_post_id, ‘post_title’ => preg_replace(‘/\.[^.]+$/’, ”, $filename), ‘post_content’ => ”, ‘post_status’ => ‘inherit’ );…Continue reading

Remove plugin deactivation

// Remove plugin deactivation function rubberduckers_disable_plugin_deactivation( $actions, $plugin_file, $plugin_data, $context ) { if ( array_key_exists( ‘deactivate’, $actions ) && in_array( $plugin_file, array( ‘advanced-custom-fields-pro/acf.php’, ‘perfmatters/perfmatters.php’, ‘termageddon-usercentrics/termageddon-usercentrics.php’, ‘patchstack/patchstack.php’, ‘admin-menu-editor-pro/menu-editor.php’, ‘flying-press/flying-press.php’, ‘wpcode-premium/wpcode.php’ ))) unset( $actions[‘deactivate’] ); return $actions; } add_filter( ‘plugin_action_links’, ‘rubberduckers_disable_plugin_deactivation’, 10,…Continue reading