Disable WordPress image compression

// Disable image compression add_filter( ‘jpeg_quality’, ‘smashing_jpeg_quality’ ); function smashing_jpeg_quality() { return 100; } // Disable image scaling add_filter( ‘big_image_size_threshold’, ‘__return_false’ );Continue reading

Remove BreadcrumbList Schema

add_filter(‘aioseo_schema_output’, ‘aioseo_schema_remove_breadcrumblist_schema’); function aioseo_schema_remove_breadcrumblist_schema($graphs) { foreach ($graphs as $index => $value) { if (isset($value[‘@type’]) && $value[‘@type’] === ‘BreadcrumbList’) { unset($graphs[$index]); } } return $graphs; }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

Masterstudy LMS – Woocomerce Create Account After Payment

add_action(‘woocommerce_order_status_completed’, ‘create_user_and_notify_on_order_completion_with_masterstudy’); function create_user_and_notify_on_order_completion_with_masterstudy($order_id) { $order = wc_get_order($order_id); $customer_email = $order->get_billing_email(); // Find user by email $user = get_user_by(’email’, $customer_email); if ($user) { // Existing user found, update ‘customer’ role if (!in_array(‘customer’, $user->roles)) { $user->add_role(‘customer’); } // Update order to…Continue reading

Tutor LMS – Woocommerce Create Account After Payment

add_action(‘woocommerce_order_status_completed’, ‘create_user_and_notify_on_order_completion’); function create_user_and_notify_on_order_completion($order_id) { $order = wc_get_order($order_id); $customer_email = $order->get_billing_email(); // Find user by email $user = get_user_by(’email’, $customer_email); if ($user) { // Existing user found, update ‘customer’ role if (!in_array(‘customer’, $user->roles)) { $user->add_role(‘customer’); } // Update order to…Continue reading

Add a single Order export field with all Shipping address details

function custom_woo_ce_extend_order_fields( $fields ) { $fields[] = array( ‘name’ => ‘shipping_address_full’, ‘label’ => ‘Shipping: All details’, ‘hover’ => ‘Custom Order field within functions.php’ ); return $fields; } add_filter( ‘woo_ce_order_fields’, ‘custom_woo_ce_extend_order_fields’ ); function custom_woo_ce_extend_order( $order, $order_id ) { $order->shipping_address_full = ”;…Continue reading