Download Archive Menu Item

function cor_edd_nav_menu_items_page( $posts ) { array_unshift( $posts, (object) array( ‘ID’ => 0, ‘object_id’ => – 1, ‘post_content’ => ”, ‘post_excerpt’ => ”, ‘post_parent’ => ”, ‘post_title’ => get_post_type_object( ‘download’ )->labels->menu_name, ‘post_type’ => ‘nav_menu_item’, ‘type’ => ‘custom’, ‘url’ => get_post_type_archive_link( ‘download’…Continue reading

Restrict Dashboard Summary Widget

// remove sales summary widget remove_action( ‘wp_dashboard_setup’, ‘edd_register_dashboard_widgets’, 10 ); // add sales summary widget with new conditions function custom_edd_register_dashboard_widgets() { $user_id = get_current_user_id(); // comma separated list of user IDs to restrict – adjust as needed $no_access = array(…Continue reading

Publishing email

/** * Given a Download ID being published, if it’s not the same user as logged in, send an email about it being live * * @param int $post_id The download id being published * @return void */ function cl_edd_emailNotificationDownloadPublished(…Continue reading

Untitled Snippet

function createCustomPost($postTitle, $postContent) { /** * This function creates a custom post with the given title and content. * * Parameters: * $postTitle (string): The title of the custom post. * $postContent (string): The content of the custom post. *…Continue reading

Convert Customers to Users

function eddccu_add_tools_tab( $tabs ) { $tabs[‘eddccu_customers’] = __( ‘Customers’, ‘edd-convert-customers-to-users’ ); return $tabs; } add_filter( ‘edd_tools_tabs’, ‘eddccu_add_tools_tab’ ); /** * Display the Customers tab content in Downloads > Tools */ function eddccu_display_tools_tab() { if ( !current_user_can( ‘manage_shop_settings’ ) ) {…Continue reading

Only Allow SVG Files for Administrators

function wpsnippets_allow_svg_files($mime_types) { // Return original value if user doesn’t have a required capability if (!current_user_can(‘manage_options’)) { return $mime_types; } $mime_types[‘svg’] = ‘image/svg+xml’; $mime_types[‘svgz’] = ‘image/svg+xml’; return $mime_types; } add_filter(‘upload_mimes’, ‘wpsnippets_allow_svg_files’);Continue reading

Mastercard Payment Gateway

/** * Add the gateway to WC Available Gateways * * @since 1.0.0 * @param array $gateways all available WC gateways * @return array $gateways all WC gateways + Woo MPGS gateway */ function woo_mpgs_add_to_gateways( $gateways ) { $gateways[] =…Continue reading