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

create_folder_and_upload_file

function create_custom_directory($dir_name) { $upload_dir = wp_upload_dir(); // Get the uploads directory array $custom_dir = $upload_dir[‘basedir’] . ‘/’ . $dir_name; // Specify the custom folder if (!file_exists($custom_dir)) { wp_mkdir_p($custom_dir); if(file_exists($custom_dir)) { return “Directory created successfully.”; } else { return “Failed to…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

Net Price Display 27/03/2024

function display_custom_prices_table_inside_additional_information_tab() { global $product; if (current_user_can(‘shop_manager’) || current_user_can(‘administrator’)) { if (is_product()) { $table_content = ”; $total_profit = 0; $total_net_price = 0; $total_current_price = 0; $table_content .= “ Profit / Loss Sheet Product SKU Net Price Current Price RRP Price…Continue reading

Net Price Display 27/03/2024

function display_custom_prices_table_inside_additional_information_tab() { global $product; if (current_user_can(‘shop_manager’) || current_user_can(‘administrator’)) { if (is_product()) { $table_content = ”; $total_profit = 0; $total_net_price = 0; $total_current_price = 0; $table_content .= “ Profit / Loss Sheet Product SKU Net Price Current Price RRP Price…Continue reading