From 5091162468996bfc530499198a7c1031e94e85c5 Mon Sep 17 00:00:00 2001 From: Nick Temple Date: Mon, 21 Feb 2022 18:58:40 -0700 Subject: [PATCH 01/17] Change Post Type --- commercestore.php | 4 +- includes/admin/admin-actions.php | 14 +-- includes/admin/admin-footer.php | 2 +- includes/admin/admin-pages.php | 96 +++++++++---------- includes/admin/class-cs-notices.php | 4 +- includes/admin/dashboard-widgets.php | 2 +- includes/admin/downloads/contextual-help.php | 2 +- .../admin/downloads/dashboard-columns.php | 16 ++-- includes/admin/downloads/metabox.php | 8 +- .../admin/extensions/abstract-extension.php | 6 +- .../extensions/class-extension-manager.php | 2 +- .../product-education/class-reviews.php | 2 +- .../import/class-batch-import-downloads.php | 2 +- .../import/class-batch-import-payments.php | 8 +- .../reporting/class-base-logs-list-table.php | 4 +- .../class-categories-reports-table.php | 4 +- .../class-download-reports-table.php | 4 +- .../class-export-download-history.php | 4 +- .../class-file-downloads-logs-list-table.php | 8 +- .../reporting/class-sales-logs-list-table.php | 8 +- .../export/class-batch-export-customers.php | 4 +- .../export/class-batch-export-downloads.php | 4 +- .../class-batch-export-file-downloads.php | 4 +- .../export/class-batch-export-sales.php | 4 +- includes/admin/reporting/reports.php | 8 +- includes/admin/settings/display-settings.php | 4 +- includes/admin/tools.php | 2 +- .../class-cs-tools-recount-all-stats.php | 4 +- includes/admin/tracking.php | 2 +- includes/admin/upgrades/upgrade-functions.php | 2 +- .../admin/upgrades/v3/class-data-migrator.php | 6 +- includes/admin/upload-functions.php | 2 +- .../views/tmpl-order-form-add-order-item.php | 2 +- includes/ajax-functions.php | 12 +-- includes/api/class-cs-api-v2.php | 4 +- includes/api/class-cs-api.php | 12 +-- includes/cart/functions.php | 2 +- includes/class-cs-cli.php | 6 +- includes/class-cs-download.php | 4 +- includes/class-cs-html-elements.php | 4 +- includes/class-cs-register-meta.php | 16 ++-- includes/class-structured-data.php | 2 +- .../database/schemas/class-order-items.php | 2 +- .../database/tables/class-order-items.php | 2 +- includes/deprecated-functions.php | 8 +- includes/download-functions.php | 14 +-- includes/gateways/paypal/admin/notices.php | 2 +- includes/misc-functions.php | 2 +- includes/orders/functions/actions.php | 2 +- includes/orders/functions/orders.php | 4 +- includes/payments/class-cs-payment.php | 4 +- includes/payments/class-payment-stats.php | 2 +- includes/payments/class-payments-query.php | 12 +-- includes/payments/functions.php | 6 +- includes/post-types.php | 18 ++-- includes/process-download.php | 24 ++--- includes/query-filters.php | 2 +- .../class-earnings-by-taxonomy-list-table.php | 2 +- includes/reports/reports-functions.php | 2 +- includes/scripts.php | 4 +- includes/shortcodes.php | 2 +- .../subscriptions/includes/admin/metabox.php | 4 +- .../subscriptions/includes/admin/scripts.php | 2 +- .../subscriptions/includes/admin/settings.php | 2 +- .../includes/cs-subscriptions-db.php | 4 +- .../includes/gateways/cs-recurring-paypal.php | 2 +- .../includes/gateways/cs-recurring-stripe.php | 2 +- .../includes/plugin-content-restriction.php | 22 ++--- includes/subscriptions/subscriptions.php | 6 +- includes/template-functions.php | 18 ++-- includes/theme-compatibility.php | 8 +- includes/user-functions.php | 2 +- includes/widgets.php | 10 +- 73 files changed, 253 insertions(+), 253 deletions(-) diff --git a/commercestore.php b/commercestore.php index e5f44d42c3..877b7c3718 100644 --- a/commercestore.php +++ b/commercestore.php @@ -38,10 +38,10 @@ const CS_FEATURE_VARIABLE_PRICE = true; const CS_FEATURE_MARKETING = false; -const CS_DEFAULT_SLUG = 'products'; // Override with the CS_SLUG constant +const CS_DEFAULT_SLUG = 'store'; // Override with the CS_SLUG constant // @todo replace hardcoding of post_type and taxonomies with the following constants all throughout the codebase -const CS_POST_TYPE = 'download'; +const CS_POST_TYPE = 'csproduct'; const CS_TAG_TYPE = CS_POST_TYPE . '_tag'; const CS_CAT_TYPE = CS_POST_TYPE . '_category'; diff --git a/includes/admin/admin-actions.php b/includes/admin/admin-actions.php index ba543b6dd5..15b4fcbb72 100644 --- a/includes/admin/admin-actions.php +++ b/includes/admin/admin-actions.php @@ -63,7 +63,7 @@ function cs_taxonomies_tabs() { // Get taxonomies $taxonomy = sanitize_key( $_GET['taxonomy'] ); - $taxonomies = get_object_taxonomies( 'download' ); + $taxonomies = get_object_taxonomies( CS_POST_TYPE ); // Bail if current taxonomy is not a download taxonomy if ( ! in_array( $taxonomy, $taxonomies, true ) ) { @@ -85,7 +85,7 @@ function cs_taxonomies_tabs() { function cs_admin_adjust_submenus() { // Get taxonomies - $taxonomies = get_object_taxonomies( 'download' ); + $taxonomies = get_object_taxonomies( CS_POST_TYPE ); // Bail if no taxonomies if ( empty( $taxonomies ) ) { @@ -123,7 +123,7 @@ function cs_taxonomies_modify_menu_highlight() { // Get taxonomies $taxonomy = sanitize_key( $_GET['taxonomy'] ); - $taxonomies = get_object_taxonomies( 'download' ); + $taxonomies = get_object_taxonomies( CS_POST_TYPE ); // Bail if current taxonomy is not a download taxonomy if ( ! in_array( $taxonomy, $taxonomies, true ) ) { @@ -154,8 +154,8 @@ function cs_add_new_modify_menu_highlight() { // Get post_type $post_type = sanitize_key( $_GET['post_type'] ); - // Bail if current post type is not download - if ( 'download' !== $post_type ) { + // Bail if current post type is not ours + if ( CS_POST_TYPE !== $post_type ) { return; } @@ -180,13 +180,13 @@ function cs_display_product_tabs() { ); // Get taxonomies - $taxonomies = get_object_taxonomies( 'download', 'objects' ); + $taxonomies = get_object_taxonomies( CS_POST_TYPE, 'objects' ); foreach ( $taxonomies as $tax => $details ) { $tabs[ $tax ] = array( 'name' => $details->labels->menu_name, 'url' => add_query_arg( array( 'taxonomy' => $tax, - 'post_type' => 'download' + 'post_type' => CS_POST_TYPE ), admin_url( 'edit-tags.php' ) ) ); } diff --git a/includes/admin/admin-footer.php b/includes/admin/admin-footer.php index 57a5feae24..6d44c5ccba 100644 --- a/includes/admin/admin-footer.php +++ b/includes/admin/admin-footer.php @@ -23,7 +23,7 @@ function cs_admin_rate_us( $footer_text ) { global $typenow; - if ( $typenow == 'download' ) { + if ( $typenow == CS_POST_TYPE ) { // VERIFY $rate_text = sprintf( __( 'Thank you for using CommerceStore! Please rate us on WordPress.org', 'commercestore' ), 'https://commercestore.com', 'https://wordpress.org/support/plugin/commercestore/reviews/?rate=5#new-post' diff --git a/includes/admin/admin-pages.php b/includes/admin/admin-pages.php index 319f9b949e..20c60ca484 100644 --- a/includes/admin/admin-pages.php +++ b/includes/admin/admin-pages.php @@ -174,25 +174,25 @@ function cs_is_admin_page( $passed_page = '', $passed_view = '', $include_non_ex $tab = isset( $_GET['tab'] ) ? strtolower( $_GET['tab'] ) : false; switch ( $passed_page ) { - case 'download': + case CS_POST_TYPE: switch ( $passed_view ) { case 'list-table': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' ) { $found = true; } break; case 'edit': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'post.php' ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'post.php' ) { $found = true; } break; case 'new': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'post-new.php' ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'post-new.php' ) { $found = true; } break; default: - if ( ( 'download' === $typenow || 'download' === $post_type ) || 'download' === $post_type || ( 'post-new.php' === $pagenow && 'download' === $post_type ) ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) || CS_POST_TYPE === $post_type || ( 'post-new.php' === $pagenow && CS_POST_TYPE === $post_type ) ) { $found = true; } break; @@ -202,17 +202,17 @@ function cs_is_admin_page( $passed_page = '', $passed_view = '', $include_non_ex switch ( $passed_view ) { case 'list-table': case 'new': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' !== $action && 'download_category' === $taxonomy ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' !== $action && 'download_category' === $taxonomy ) { $found = true; } break; case 'edit': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' === $action && 'download_category' === $taxonomy ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' === $action && 'download_category' === $taxonomy ) { $found = true; } break; default: - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit-tags.php' && 'download_category' === $taxonomy ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit-tags.php' && 'download_category' === $taxonomy ) { $found = true; } break; @@ -222,17 +222,17 @@ function cs_is_admin_page( $passed_page = '', $passed_view = '', $include_non_ex switch ( $passed_view ) { case 'list-table': case 'new': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' !== $action && 'download_tax' === $taxonomy ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' !== $action && 'download_tax' === $taxonomy ) { $found = true; } break; case 'edit': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' === $action && 'download_tax' === $taxonomy ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' === $action && 'download_tax' === $taxonomy ) { $found = true; } break; default: - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit-tags.php' && 'download_tax' === $taxonomy ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit-tags.php' && 'download_tax' === $taxonomy ) { $found = true; } break; @@ -241,17 +241,17 @@ function cs_is_admin_page( $passed_page = '', $passed_view = '', $include_non_ex case 'payments': switch ( $passed_view ) { case 'list-table': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-payment-history' === $page && false === $view ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-payment-history' === $page && false === $view ) { $found = true; } break; case 'edit': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-payment-history' === $page && 'view-order-details' === $view ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-payment-history' === $page && 'view-order-details' === $view ) { $found = true; } break; default: - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-payment-history' === $page ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-payment-history' === $page ) { $found = true; } break; @@ -260,22 +260,22 @@ function cs_is_admin_page( $passed_page = '', $passed_view = '', $include_non_ex case 'discounts': switch ( $passed_view ) { case 'list-table': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-discounts' === $page && false === $cs_action ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-discounts' === $page && false === $cs_action ) { $found = true; } break; case 'edit': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-discounts' === $page && 'edit_discount' === $cs_action ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-discounts' === $page && 'edit_discount' === $cs_action ) { $found = true; } break; case 'new': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-discounts' === $page && 'add_discount' === $cs_action ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-discounts' === $page && 'add_discount' === $cs_action ) { $found = true; } break; default: - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-discounts' === $page ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-discounts' === $page ) { $found = true; } break; @@ -285,37 +285,37 @@ function cs_is_admin_page( $passed_page = '', $passed_view = '', $include_non_ex switch ( $passed_view ) { // If you want to do something like enqueue a script on a particular report's duration, look at $_GET[ 'range' ] case 'earnings': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && ( 'earnings' === $view || '-1' === $view || false === $view ) ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && ( 'earnings' === $view || '-1' === $view || false === $view ) ) { $found = true; } break; case 'downloads': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && 'downloads' === $view ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && 'downloads' === $view ) { $found = true; } break; case 'customers': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && 'customers' === $view ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && 'customers' === $view ) { $found = true; } break; case 'gateways': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && 'gateways' === $view ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && 'gateways' === $view ) { $found = true; } break; case 'taxes': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && 'taxes' === $view ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && 'taxes' === $view ) { $found = true; } break; case 'export': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && 'export' === $view ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && 'export' === $view ) { $found = true; } break; default: - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page ) { $found = true; } break; @@ -324,52 +324,52 @@ function cs_is_admin_page( $passed_page = '', $passed_view = '', $include_non_ex case 'settings': switch ( $passed_view ) { case 'general': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && ( 'general' === $tab || false === $tab ) ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && ( 'general' === $tab || false === $tab ) ) { $found = true; } break; case 'gateways': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'gateways' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'gateways' === $tab ) { $found = true; } break; case 'emails': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'emails' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'emails' === $tab ) { $found = true; } break; case 'styles': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'styles' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'styles' === $tab ) { $found = true; } break; case 'taxes': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'taxes' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'taxes' === $tab ) { $found = true; } break; case 'extensions': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'extensions' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'extensions' === $tab ) { $found = true; } break; case 'licenses': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'licenses' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'licenses' === $tab ) { $found = true; } break; case 'misc': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'misc' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'misc' === $tab ) { $found = true; } break; case 'marketing': - if ( ( 'download' == $typenow || 'download' === $post_type ) && $pagenow == 'edit.php' && 'cs-settings' === $page && 'marketing' === $tab ) { + if ( ( CS_POST_TYPE == $typenow || CS_POST_TYPE === $post_type ) && $pagenow == 'edit.php' && 'cs-settings' === $page && 'marketing' === $tab ) { $found = true; } break; default: - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page ) { $found = true; } break; @@ -378,68 +378,68 @@ function cs_is_admin_page( $passed_page = '', $passed_view = '', $include_non_ex case 'tools': switch ( $passed_view ) { case 'general': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page && ( 'general' === $tab || false === $tab ) ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page && ( 'general' === $tab || false === $tab ) ) { $found = true; } break; case 'api_keys': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page && 'api_keys' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page && 'api_keys' === $tab ) { $found = true; } break; case 'system_info': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page && 'system_info' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page && 'system_info' === $tab ) { $found = true; } break; case 'logs': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page && 'logs' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page && 'logs' === $tab ) { $found = true; } break; case 'import_export': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page && 'import_export' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page && 'import_export' === $tab ) { $found = true; } break; default: - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page ) { $found = true; } break; } break; case 'addons': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-addons' === $page ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-addons' === $page ) { $found = true; } break; case 'customers': switch ( $passed_view ) { case 'list-table': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-customers' === $page && false === $view ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-customers' === $page && false === $view ) { $found = true; } break; case 'overview': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-customers' === $page && 'overview' === $view ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-customers' === $page && 'overview' === $view ) { $found = true; } break; case 'notes': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-customers' === $page && 'notes' === $view ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-customers' === $page && 'notes' === $view ) { $found = true; } break; default: - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-customers' === $page ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-customers' === $page ) { $found = true; } break; } break; case 'reports': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page ) { $found = true; } break; @@ -453,7 +453,7 @@ function cs_is_admin_page( $passed_page = '', $passed_view = '', $include_non_ex $admin_pages = cs_get_admin_pages(); // Downloads sub-page or Dashboard page - if ( ( 'download' === $typenow ) || ( $include_non_exclusive && 'index.php' === $pagenow ) ) { + if ( ( CS_POST_TYPE === $typenow ) || ( $include_non_exclusive && 'index.php' === $pagenow ) ) { $found = true; // Registered global pages diff --git a/includes/admin/class-cs-notices.php b/includes/admin/class-cs-notices.php index 901278a751..e4cfd894c5 100644 --- a/includes/admin/class-cs-notices.php +++ b/includes/admin/class-cs-notices.php @@ -381,7 +381,7 @@ private function add_settings_notices() { // URL to fix this $url = add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-settings', 'tab' => 'gateways' ) ); @@ -730,7 +730,7 @@ private function show_debugging_notice() { wp_enqueue_script( 'cs-admin-notices', CS_PLUGIN_URL . 'assets/js/cs-admin-notices.js', array( 'jquery' ), CS_VERSION, true ); $view_url = add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-tools', 'tab' => 'debug_log', ), diff --git a/includes/admin/dashboard-widgets.php b/includes/admin/dashboard-widgets.php index d1d09b0764..1b849e64c3 100644 --- a/includes/admin/dashboard-widgets.php +++ b/includes/admin/dashboard-widgets.php @@ -265,7 +265,7 @@ function cs_load_dashboard_sales_widget( ) { * @return void */ function cs_dashboard_at_a_glance_widget( $items ) { - $num_posts = wp_count_posts( 'download' ); + $num_posts = wp_count_posts( CS_POST_TYPE ); if ( $num_posts && $num_posts->publish ) { $text = _n( '%s ' . cs_get_label_singular(), '%s ' . cs_get_label_plural(), $num_posts->publish, 'commercestore' ); diff --git a/includes/admin/downloads/contextual-help.php b/includes/admin/downloads/contextual-help.php index d897e13f10..6ace6aa06a 100644 --- a/includes/admin/downloads/contextual-help.php +++ b/includes/admin/downloads/contextual-help.php @@ -21,7 +21,7 @@ function cs_downloads_contextual_help() { $screen = get_current_screen(); - if ( $screen->id != 'download' ) + if ( $screen->id != CS_POST_TYPE ) return; $screen->set_help_sidebar( diff --git a/includes/admin/downloads/dashboard-columns.php b/includes/admin/downloads/dashboard-columns.php index cc4884e371..fb7d72a553 100644 --- a/includes/admin/downloads/dashboard-columns.php +++ b/includes/admin/downloads/dashboard-columns.php @@ -50,7 +50,7 @@ function cs_download_columns( $download_columns ) { function cs_render_download_columns( $column_name, $post_id ) { // Bail if not a download - if ( get_post_type( $post_id ) !== 'download' ) { + if ( get_post_type( $post_id ) !== CS_POST_TYPE ) { return; } @@ -127,7 +127,7 @@ function cs_sortable_download_columns( $columns ) { */ function cs_sort_downloads( $vars ) { // Check if we're viewing the "download" post type - if ( isset( $vars['post_type'] ) && 'download' == $vars['post_type'] ) { + if ( isset( $vars['post_type'] ) && CS_POST_TYPE == $vars['post_type'] ) { // Check if 'orderby' is set to "sales" if ( isset( $vars['orderby'] ) && 'sales' == $vars['orderby'] ) { $vars = array_merge( @@ -173,7 +173,7 @@ function cs_sort_downloads( $vars ) { * @return array Array of all sort variables */ function cs_filter_downloads( $vars ) { - if ( isset( $vars['post_type'] ) && 'download' == $vars['post_type'] ) { + if ( isset( $vars['post_type'] ) && CS_POST_TYPE == $vars['post_type'] ) { // If an author ID was passed, use it if ( isset( $_REQUEST['author'] ) && ! current_user_can( 'view_shop_reports' ) ) { @@ -220,8 +220,8 @@ function cs_download_load() { function cs_add_download_filters() { global $typenow; - // Checks if the current post type is 'download' - if ( $typenow !== 'download') { + // Checks if the current post type is CS_POST_TYPE + if ( $typenow !== CS_POST_TYPE) { return; } @@ -272,7 +272,7 @@ function cs_add_download_filters() { function cs_remove_month_filter( $dates ) { global $typenow; - if ( 'download' === $typenow ) { + if ( CS_POST_TYPE === $typenow ) { $dates = array(); } @@ -291,7 +291,7 @@ function cs_remove_month_filter( $dates ) { function cs_price_field_quick_edit( $column_name, $post_type ) { // Bail if not price or download - if ( $column_name !== 'price' || $post_type !== 'download' ) { + if ( $column_name !== 'price' || $post_type !== CS_POST_TYPE ) { return; } ?> @@ -321,7 +321,7 @@ function cs_price_field_quick_edit( $column_name, $post_type ) { * @return void */ function cs_price_save_quick_edit( $post_id ) { - if ( ! isset( $_POST['post_type']) || 'download' !== $_POST['post_type'] ) { + if ( ! isset( $_POST['post_type']) || CS_POST_TYPE !== $_POST['post_type'] ) { return; } diff --git a/includes/admin/downloads/metabox.php b/includes/admin/downloads/metabox.php index 31645653f8..5bd90b315d 100644 --- a/includes/admin/downloads/metabox.php +++ b/includes/admin/downloads/metabox.php @@ -21,7 +21,7 @@ * @return void */ function cs_add_download_meta_box() { - $post_types = apply_filters( 'cs_download_metabox_post_types', array( 'download' ) ); + $post_types = apply_filters( 'cs_download_metabox_post_types', array( CS_POST_TYPE ) ); foreach ( $post_types as $post_type ) { @@ -923,11 +923,11 @@ function cs_render_file_row( $key, $args, $post_id, $index ) { function cs_download_media_strings( $strings ) { global $post; - if ( empty( $post ) || ( $post->post_type !== 'download' ) ) { + if ( empty( $post ) || ( $post->post_type !== CS_POST_TYPE ) ) { return $strings; } - $downloads_object = get_post_type_object( 'download' ); + $downloads_object = get_post_type_object( CS_POST_TYPE ); $labels = $downloads_object->labels; $strings['insertIntoPost'] = sprintf( __( 'Insert into %s', 'commercestore' ), strtolower( $labels->singular_name ) ); @@ -1139,7 +1139,7 @@ function cs_render_download_quantity_option( $post_id = 0 ) { */ function cs_render_meta_box_shortcode() { - if ( get_post_type() !== 'download' ) { + if ( get_post_type() !== CS_POST_TYPE ) { return; } diff --git a/includes/admin/extensions/abstract-extension.php b/includes/admin/extensions/abstract-extension.php index 002f2c9298..39505173b1 100644 --- a/includes/admin/extensions/abstract-extension.php +++ b/includes/admin/extensions/abstract-extension.php @@ -156,7 +156,7 @@ protected function is_cs_settings_screen() { * @return bool */ protected function is_download_edit_screen() { - return cs_is_admin_page( 'download', 'edit' ) || cs_is_admin_page( 'download', 'new' ); + return cs_is_admin_page( CS_POST_TYPE, 'edit' ) || cs_is_admin_page( CS_POST_TYPE, 'new' ); } /** @@ -315,7 +315,7 @@ protected function get_link_parameters( ProductData $product_data ) { 'button_text' => sprintf( __( 'View %s', 'commercestore' ), cs_get_label_plural() ), 'href' => add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, ), admin_url( 'edit.php' ) ), @@ -327,7 +327,7 @@ protected function get_link_parameters( ProductData $product_data ) { 'button_text' => sprintf( __( 'Configure %s', 'commercestore' ), $product_data->title ), 'href' => add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-settings', 'tab' => urlencode( $tab ), 'section' => urlencode( $section ), diff --git a/includes/admin/extensions/class-extension-manager.php b/includes/admin/extensions/class-extension-manager.php index 88ec0e7db7..0612510782 100644 --- a/includes/admin/extensions/class-extension-manager.php +++ b/includes/admin/extensions/class-extension-manager.php @@ -282,7 +282,7 @@ public function install() { $url = esc_url_raw( add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-addons', ), admin_url( 'edit.php' ) diff --git a/includes/admin/extensions/product-education/class-reviews.php b/includes/admin/extensions/product-education/class-reviews.php index e7cc0c7ea2..8e582c781d 100644 --- a/includes/admin/extensions/product-education/class-reviews.php +++ b/includes/admin/extensions/product-education/class-reviews.php @@ -127,7 +127,7 @@ public function maybe_do_metabox() { 'cs-reviews-status', __( 'Product Reviews', 'commercestore' ), array( $this, 'settings_field' ), - 'download', + CS_POST_TYPE, 'side', 'low' ); diff --git a/includes/admin/import/class-batch-import-downloads.php b/includes/admin/import/class-batch-import-downloads.php index bca8df522f..58805aa808 100644 --- a/includes/admin/import/class-batch-import-downloads.php +++ b/includes/admin/import/class-batch-import-downloads.php @@ -93,7 +93,7 @@ public function process_step() { // Import Download $args = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_title' => '', 'post_name' => '', 'post_status' => '', diff --git a/includes/admin/import/class-batch-import-payments.php b/includes/admin/import/class-batch-import-payments.php index ce08a87212..9f98f8f7cf 100644 --- a/includes/admin/import/class-batch-import-payments.php +++ b/includes/admin/import/class-batch-import-payments.php @@ -310,7 +310,7 @@ public function create_payment( $row = array() ) { foreach( $downloads as $download ) { if( is_array( $download ) ) { - $download_name = $download['download']; + $download_name = $download[CS_POST_TYPE]; $price = $download['price']; $tax = $download['tax']; $price_id = $download['price_id']; @@ -521,7 +521,7 @@ private function maybe_create_download( $title = '' ) { return false; } - $download = get_page_by_title( $title, OBJECT, 'download' ); + $download = get_page_by_title( $title, OBJECT, CS_POST_TYPE ); if( $download ) { @@ -530,7 +530,7 @@ private function maybe_create_download( $title = '' ) { } else { $args = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_title' => $title, 'post_author' => get_current_user_id() ); @@ -579,7 +579,7 @@ public function get_downloads_from_cs( $data_str ) { $price_id = isset( $matches[1][1] ) ? trim( $matches[1][1] ) : false; $d_array[] = array( - 'download' => trim( $d[0] ), + CS_POST_TYPE => trim( $d[0] ), 'price' => $price - $tax, 'tax' => $tax, 'price_id' => $price_id, diff --git a/includes/admin/reporting/class-base-logs-list-table.php b/includes/admin/reporting/class-base-logs-list-table.php index ceb773e74c..e68056d283 100644 --- a/includes/admin/reporting/class-base-logs-list-table.php +++ b/includes/admin/reporting/class-base-logs-list-table.php @@ -162,7 +162,7 @@ public function get_filtered_end_date() { * @return int Download ID. */ public function get_filtered_download() { - return absint( $this->get_request_var( 'download', false ) ); + return absint( $this->get_request_var( CS_POST_TYPE, false ) ); } /** @@ -238,7 +238,7 @@ public function log_views() { */ public function downloads_filter() { $downloads = get_posts( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_status' => 'any', 'posts_per_page' => -1, 'orderby' => 'title', diff --git a/includes/admin/reporting/class-categories-reports-table.php b/includes/admin/reporting/class-categories-reports-table.php index dc06b5023f..03d2172dd7 100644 --- a/includes/admin/reporting/class-categories-reports-table.php +++ b/includes/admin/reporting/class-categories-reports-table.php @@ -173,7 +173,7 @@ public function get_data() { } $downloads = get_posts( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => -1, 'fields' => 'ids', 'tax_query' => array( @@ -223,7 +223,7 @@ public function get_data() { if ( ! empty( $child_terms ) ) { foreach ( $child_terms as $child_term ) { $child_downloads = get_posts( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => -1, 'fields' => 'ids', 'tax_query' => array( diff --git a/includes/admin/reporting/class-download-reports-table.php b/includes/admin/reporting/class-download-reports-table.php index 6d0e57bf25..ee77e7bdfa 100644 --- a/includes/admin/reporting/class-download-reports-table.php +++ b/includes/admin/reporting/class-download-reports-table.php @@ -133,7 +133,7 @@ public function get_category() { */ public function get_total_downloads() { $total = 0; - $counts = wp_count_posts( 'download', 'readable' ); + $counts = wp_count_posts( CS_POST_TYPE, 'readable' ); foreach( $counts as $count ) { $total += $count; @@ -180,7 +180,7 @@ public function query() { $category = $this->get_category(); $args = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_status' => 'publish', 'order' => $order, 'fields' => 'ids', diff --git a/includes/admin/reporting/class-export-download-history.php b/includes/admin/reporting/class-export-download-history.php index ddf32cff76..9626409aa7 100644 --- a/includes/admin/reporting/class-export-download-history.php +++ b/includes/admin/reporting/class-export-download-history.php @@ -59,7 +59,7 @@ public function csv_cols() { 'date' => __( 'Date', 'commercestore' ), 'user' => __( 'Downloaded by', 'commercestore' ), 'ip' => __( 'IP Address', 'commercestore' ), - 'download' => __( 'Product', 'commercestore' ), + CS_POST_TYPE => __( 'Product', 'commercestore' ), 'file' => __( 'File', 'commercestore' ) ); return $cols; @@ -99,7 +99,7 @@ public function get_data() { 'date' => $log->post_date, 'user' => $user, 'ip' => get_post_meta( $log->ID, '_cs_log_ip', true ), - 'download' => get_the_title( $log->post_parent ), + CS_POST_TYPE => get_the_title( $log->post_parent ), 'file' => $file_name ); } diff --git a/includes/admin/reporting/class-file-downloads-logs-list-table.php b/includes/admin/reporting/class-file-downloads-logs-list-table.php index fb57b6f557..8a38294b76 100644 --- a/includes/admin/reporting/class-file-downloads-logs-list-table.php +++ b/includes/admin/reporting/class-file-downloads-logs-list-table.php @@ -69,13 +69,13 @@ public function __construct() { public function column_default( $item, $column_name ) { $base_url = remove_query_arg( 'paged' ); switch ( $column_name ) { - case 'download' : + case CS_POST_TYPE : $download = new CS_Download( $item[ $column_name ] ); $column_value = ! empty( $item['price_id'] ) ? cs_get_download_name( $download->ID, $item['price_id'] ) : cs_get_download_name( $download->ID ); - return '' . $column_value . ''; + return '' . $column_value . ''; case 'customer' : return ! empty( $item[ 'customer' ]->id ) ? '' . $item['customer']->name . '' @@ -103,7 +103,7 @@ public function column_default( $item, $column_name ) { public function get_columns() { return array( 'ID' => __( 'Log ID', 'commercestore' ), - 'download' => cs_get_label_singular(), + CS_POST_TYPE => cs_get_label_singular(), 'customer' => __( 'Customer', 'commercestore' ), 'payment_id' => __( 'Order Number', 'commercestore' ), 'file' => __( 'File', 'commercestore' ), @@ -152,7 +152,7 @@ function get_logs( $log_query = array() ) { if ( empty( $this->file_search ) || ( ! empty( $this->file_search ) && strpos( strtolower( $file_name ), strtolower( $this->get_search() ) ) !== false ) ) { $logs_data[] = array( 'ID' => $log->id, - 'download' => $log->product_id, + CS_POST_TYPE => $log->product_id, 'customer' => new CS_Customer( $customer_id ), 'payment_id' => $log->order_id, 'price_id' => $log->price_id, diff --git a/includes/admin/reporting/class-sales-logs-list-table.php b/includes/admin/reporting/class-sales-logs-list-table.php index fe725bb6b5..ec8aacf26f 100644 --- a/includes/admin/reporting/class-sales-logs-list-table.php +++ b/includes/admin/reporting/class-sales-logs-list-table.php @@ -47,7 +47,7 @@ public function column_default( $item, $column_name ) { $currency = $item['currency']; switch ( $column_name ) { - case 'download': + case CS_POST_TYPE: $download_id = $item[ $column_name ]; $download = cs_get_download( $download_id ); $price_id = ! empty( $item['price_id'] ) @@ -55,7 +55,7 @@ public function column_default( $item, $column_name ) { : 0; $title = $download->get_name( $price_id ); - $return = '' . $title . ''; + $return = '' . $title . ''; break; case 'customer': @@ -96,7 +96,7 @@ public function get_columns() { return array( 'ID' => __( 'Order Number', 'commercestore' ), 'customer' => __( 'Customer', 'commercestore' ), - 'download' => cs_get_label_singular(), + CS_POST_TYPE => cs_get_label_singular(), 'amount' => __( 'Item Amount', 'commercestore' ), 'date' => __( 'Date', 'commercestore' ), ); @@ -235,7 +235,7 @@ public function get_logs( $log_query = array() ) { 'ID' => $order->get_number(), 'order_id' => $order->id, 'customer' => cs_get_customer( $order->customer_id ), - 'download' => $order_item->product_id, + CS_POST_TYPE => $order_item->product_id, 'price_id' => $order_item->price_id, 'item_price' => $order_item->amount, 'amount' => $order_item->total, diff --git a/includes/admin/reporting/export/class-batch-export-customers.php b/includes/admin/reporting/export/class-batch-export-customers.php index 54b88ae42b..9ebc47158b 100644 --- a/includes/admin/reporting/export/class-batch-export-customers.php +++ b/includes/admin/reporting/export/class-batch-export-customers.php @@ -207,8 +207,8 @@ public function set_properties( $request ) { ? absint( $request['taxonomy'] ) : null; - $this->download = isset( $request['download'] ) - ? absint( $request['download'] ) + $this->download = isset( $request[CS_POST_TYPE] ) + ? absint( $request[CS_POST_TYPE] ) : null; $this->price_id = ! empty( $request['cs_price_option'] ) && 0 !== $request['cs_price_option'] diff --git a/includes/admin/reporting/export/class-batch-export-downloads.php b/includes/admin/reporting/export/class-batch-export-downloads.php index db954e441e..5110cf39b4 100644 --- a/includes/admin/reporting/export/class-batch-export-downloads.php +++ b/includes/admin/reporting/export/class-batch-export-downloads.php @@ -83,7 +83,7 @@ public function get_data() { ); $args = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => 30, 'paged' => $this->step, 'orderby' => 'ID', @@ -196,7 +196,7 @@ public function get_data() { */ public function get_percentage_complete() { $args = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => - 1, 'post_status' => 'any', 'fields' => 'ids', diff --git a/includes/admin/reporting/export/class-batch-export-file-downloads.php b/includes/admin/reporting/export/class-batch-export-file-downloads.php index 93e136e812..3078e1cfb2 100644 --- a/includes/admin/reporting/export/class-batch-export-file-downloads.php +++ b/includes/admin/reporting/export/class-batch-export-file-downloads.php @@ -44,7 +44,7 @@ public function csv_cols() { 'user' => __( 'Downloaded by', 'commercestore' ), 'ip' => __( 'IP Address', 'commercestore' ), 'user_agent' => __( 'User Agent', 'commercestore' ), - 'download' => __( 'Product', 'commercestore' ), + CS_POST_TYPE => __( 'Product', 'commercestore' ), 'file' => __( 'File', 'commercestore' ), ); @@ -102,7 +102,7 @@ public function get_data() { 'user' => $customer, 'ip' => $log->ip, 'user_agent' => $log->user_agent, - 'download' => get_the_title( $log->product_id ), + CS_POST_TYPE => get_the_title( $log->product_id ), 'file' => $file_name, ); } diff --git a/includes/admin/reporting/export/class-batch-export-sales.php b/includes/admin/reporting/export/class-batch-export-sales.php index 7689649b87..aeabc2e176 100644 --- a/includes/admin/reporting/export/class-batch-export-sales.php +++ b/includes/admin/reporting/export/class-batch-export-sales.php @@ -42,7 +42,7 @@ public function csv_cols() { 'email' => __( 'Email', 'commercestore' ), 'first_name' => __( 'First Name', 'commercestore' ), 'last_name' => __( 'Last Name', 'commercestore' ), - 'download' => cs_get_label_singular(), + CS_POST_TYPE => cs_get_label_singular(), 'quantity' => __( 'Quantity', 'commercestore' ), 'amount' => __( 'Item Amount', 'commercestore' ), 'payment_id' => __( 'Payment ID', 'commercestore' ), @@ -104,7 +104,7 @@ public function get_data() { 'email' => $order->email, 'first_name' => isset( $user_info['first_name'] ) ? $user_info['first_name'] : '', 'last_name' => isset( $user_info['last_name'] ) ? $user_info['last_name'] : '', - 'download' => $download_title, + CS_POST_TYPE => $download_title, 'quantity' => $item->quantity, 'amount' => $order->total, 'payment_id' => $order->id, diff --git a/includes/admin/reporting/reports.php b/includes/admin/reporting/reports.php index 6d1dd6a222..6c686cef00 100644 --- a/includes/admin/reporting/reports.php +++ b/includes/admin/reporting/reports.php @@ -562,7 +562,7 @@ function cs_register_downloads_report( $reports ) { $reports->add_report( 'downloads', array( 'label' => cs_get_label_plural(), 'priority' => 10, - 'icon' => 'download', + 'icon' => CS_POST_TYPE, 'endpoints' => array( 'tiles' => $tiles, 'charts' => $charts, @@ -1798,7 +1798,7 @@ function cs_register_file_downloads_report( $reports ) { $reports->add_report( 'file_downloads', array( 'label' => __( 'File Downloads', 'commercestore' ), - 'icon' => 'download', + 'icon' => CS_POST_TYPE, 'priority' => 30, 'endpoints' => array( 'tiles' => $tiles, @@ -2843,7 +2843,7 @@ function display_export_report() {

html->product_dropdown( array( - 'name' => 'download', + 'name' => CS_POST_TYPE, 'id' => 'cs_customer_export_download', 'chosen' => true, /* translators: the plural post type label */ diff --git a/includes/admin/settings/display-settings.php b/includes/admin/settings/display-settings.php index 4139d9921f..b50ab69242 100644 --- a/includes/admin/settings/display-settings.php +++ b/includes/admin/settings/display-settings.php @@ -78,7 +78,7 @@ function cs_options_page_primary_nav( $tabs, $active_tab = '' ) { $tab_url = add_query_arg( array( 'settings-updated' => false, - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-settings', 'tab' => $tab_id, ), @@ -129,7 +129,7 @@ function cs_options_page_secondary_nav( $active_tab = '', $section = '', $sectio // Tab & Section $tab_url = add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-settings', 'tab' => $active_tab, 'section' => $section_id, diff --git a/includes/admin/tools.php b/includes/admin/tools.php index d44ca5b0e9..7ffbaca904 100644 --- a/includes/admin/tools.php +++ b/includes/admin/tools.php @@ -1659,7 +1659,7 @@ function cs_redirect_sales_log() { ); $args_to_remap = array( - 'download' => 'product-id', + CS_POST_TYPE => 'product-id', 'start-date' => 'start-date', 'end-date' => 'end-date' ); diff --git a/includes/admin/tools/class-cs-tools-recount-all-stats.php b/includes/admin/tools/class-cs-tools-recount-all-stats.php index cbb5e8543d..3d11177059 100644 --- a/includes/admin/tools/class-cs-tools-recount-all-stats.php +++ b/includes/admin/tools/class-cs-tools-recount-all-stats.php @@ -37,7 +37,7 @@ class CS_Tools_Recount_All_Stats extends CS_Tools_Recount_Download_Stats { */ public function get_percentage_complete() { $percentage = 100; - $total = array_sum( (array) wp_count_posts( 'download' ) ); + $total = array_sum( (array) wp_count_posts( CS_POST_TYPE ) ); if ( $total > 0 ) { $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; @@ -96,7 +96,7 @@ private function get_download_ids() { if ( null === $this->download_ids ) { $this->download_ids = get_posts( array( 'post_status' => 'any', - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => $this->per_step, 'offset' => ( $this->step - 1 ) * $this->per_step, 'fields' => 'ids', diff --git a/includes/admin/tracking.php b/includes/admin/tracking.php index ce6a688790..d26d7c5a7d 100644 --- a/includes/admin/tracking.php +++ b/includes/admin/tracking.php @@ -107,7 +107,7 @@ private function setup_data() { $data['active_plugins'] = $active_plugins; $data['inactive_plugins'] = $plugins; $data['active_gateways'] = array_keys( cs_get_enabled_payment_gateways() ); - $data['products'] = wp_count_posts( 'download' )->publish; + $data['products'] = wp_count_posts( CS_POST_TYPE )->publish; $data['download_label'] = cs_get_label_singular( true ); $data['locale'] = get_locale(); diff --git a/includes/admin/upgrades/upgrade-functions.php b/includes/admin/upgrades/upgrade-functions.php index 27d38f66fe..410e12f9af 100644 --- a/includes/admin/upgrades/upgrade-functions.php +++ b/includes/admin/upgrades/upgrade-functions.php @@ -422,7 +422,7 @@ function cs_v131_upgrades() { cs_set_time_limit(); $query = new WP_Query( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => -1, 'post_status' => 'publish' ) ); diff --git a/includes/admin/upgrades/v3/class-data-migrator.php b/includes/admin/upgrades/v3/class-data-migrator.php index 97bc1a6584..05dce6bafe 100644 --- a/includes/admin/upgrades/v3/class-data-migrator.php +++ b/includes/admin/upgrades/v3/class-data-migrator.php @@ -331,7 +331,7 @@ public static function logs( $data = null ) { $log_data = array( 'object_id' => $data->post_parent, - 'object_type' => 'download', + 'object_type' => CS_POST_TYPE, 'user_id' => ! empty( $meta_to_migrate['_cs_log_user'] ) ? $meta_to_migrate['_cs_log_user'] : $data->post_author, 'type' => $data->slug, 'title' => $data->post_title, @@ -899,7 +899,7 @@ public static function orders( $data = null ) { 'product_name' => $product_name, 'price_id' => $price_id, 'cart_index' => $key, - 'type' => 'download', + 'type' => CS_POST_TYPE, 'status' => $order_status, 'quantity' => $cart_item['quantity'], 'amount' => (float) $cart_item['item_price'], @@ -1046,7 +1046,7 @@ public static function orders( $data = null ) { 'product_name' => $download->post_name, 'price_id' => null, 'cart_index' => $cart_index, - 'type' => 'download', + 'type' => CS_POST_TYPE, 'quantity' => 1, 'amount' => (float) $payment_meta['amount'], 'subtotal' => (float) $payment_meta['amount'], diff --git a/includes/admin/upload-functions.php b/includes/admin/upload-functions.php index 8494e97d64..c8a0dbbfe7 100644 --- a/includes/admin/upload-functions.php +++ b/includes/admin/upload-functions.php @@ -29,7 +29,7 @@ function cs_change_downloads_upload_dir() { global $pagenow; if ( ! empty( $_REQUEST['post_id'] ) && ( 'async-upload.php' == $pagenow || 'media-upload.php' == $pagenow ) ) { - if ( 'download' == get_post_type( $_REQUEST['post_id'] ) ) { + if ( CS_POST_TYPE == get_post_type( $_REQUEST['post_id'] ) ) { cs_create_protection_files( true ); add_filter( 'upload_dir', 'cs_set_upload_dir' ); } diff --git a/includes/admin/views/tmpl-order-form-add-order-item.php b/includes/admin/views/tmpl-order-form-add-order-item.php index 4ea7a770b6..345740404f 100644 --- a/includes/admin/views/tmpl-order-form-add-order-item.php +++ b/includes/admin/views/tmpl-order-form-add-order-item.php @@ -22,7 +22,7 @@ 'fields' => 'ids', 'orderby' => 'date', 'order' => 'ASC', - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => 25, 'post_status' => array( 'publish', diff --git a/includes/ajax-functions.php b/includes/ajax-functions.php index 03243680e6..6eab049d3b 100644 --- a/includes/ajax-functions.php +++ b/includes/ajax-functions.php @@ -386,7 +386,7 @@ function cs_ajax_remove_discount() { /** * Allow for custom remove discount code handling. - * + * * @since 2.11.4 */ $return = apply_filters( 'cs_ajax_remove_discount_response', $return ); @@ -451,7 +451,7 @@ function cs_ajax_get_download_title() { $post_type = get_post_type( $post_id ); $title = 'fail'; - if ( 'download' === $post_type ) { + if ( CS_POST_TYPE === $post_type ) { $post_title = get_the_title( $_POST['download_id'] ); if ( $post_title ) { echo $title = $post_title; @@ -643,7 +643,7 @@ function cs_ajax_download_search() { $args = array( 'orderby' => 'title', 'order' => 'ASC', - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => 50, 'post_status' => implode( ',', $status ), // String 'post__not_in' => $excludes, // Array @@ -844,7 +844,7 @@ function cs_check_for_download_price_variations() { $download_id = intval( $_POST['download_id'] ); $download = get_post( $download_id ); - if ( 'download' != $download->post_type ) { + if ( CS_POST_TYPE != $download->post_type ) { die( '-2' ); } @@ -953,8 +953,8 @@ function cs_ajax_add_order_item() { ? sanitize_text_field( $_POST['nonce'] ) : ''; - $download = isset( $_POST['download'] ) - ? cs_parse_product_dropdown_value( sanitize_text_field( $_POST['download'] ) ) + $download = isset( $_POST[CS_POST_TYPE] ) + ? cs_parse_product_dropdown_value( sanitize_text_field( $_POST[CS_POST_TYPE] ) ) : array(); $country = isset( $_POST['country'] ) diff --git a/includes/api/class-cs-api-v2.php b/includes/api/class-cs-api-v2.php index 316e3b55d7..7b5cf94698 100644 --- a/includes/api/class-cs-api-v2.php +++ b/includes/api/class-cs-api-v2.php @@ -38,7 +38,7 @@ public function get_products( $args = array() ) { $products['products'] = array(); $query_args = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => $this->per_page(), 'suppress_filters' => true, 'paged' => $this->get_paged(), @@ -157,7 +157,7 @@ public function get_products( $args = array() ) { } else { - if ( get_post_type( $args['product'] ) == 'download' ) { + if ( get_post_type( $args['product'] ) == CS_POST_TYPE ) { $product_info = get_post( $args['product'] ); $products['products'][0] = $this->get_product_data( $product_info ); diff --git a/includes/api/class-cs-api.php b/includes/api/class-cs-api.php index d4a925611f..97ee27c8c7 100644 --- a/includes/api/class-cs-api.php +++ b/includes/api/class-cs-api.php @@ -1100,7 +1100,7 @@ public function get_products( $args = array() ) { $products['products'] = array(); $parameters = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => $this->per_page(), 'suppress_filters' => true, 'paged' => $this->get_paged(), @@ -1120,7 +1120,7 @@ public function get_products( $args = array() ) { } } } else { - if ( get_post_type( $args['product'] ) == 'download' ) { + if ( get_post_type( $args['product'] ) == CS_POST_TYPE ) { $product_info = get_post( $args['product'] ); $products['products'][0] = $this->get_product_data( $product_info ); @@ -1301,14 +1301,14 @@ public function get_stats( $args = array() ) { } } } elseif ( $args['product'] == 'all' ) { - $products = get_posts( array( 'post_type' => 'download', 'nopaging' => true ) ); + $products = get_posts( array( 'post_type' => CS_POST_TYPE, 'nopaging' => true ) ); $i = 0; foreach ( $products as $product_info ) { $sales['sales'][ $i ] = array( $product_info->post_name => cs_get_download_sales_stats( $product_info->ID ) ); $i ++; } } else { - if ( get_post_type( $args['product'] ) == 'download' ) { + if ( get_post_type( $args['product'] ) == CS_POST_TYPE ) { $product_info = get_post( $args['product'] ); $sales['sales'][0] = array( $product_info->post_name => cs_get_download_sales_stats( $args['product'] ) ); } else { @@ -1417,7 +1417,7 @@ public function get_stats( $args = array() ) { } } } elseif ( $args['product'] == 'all' ) { - $products = get_posts( array( 'post_type' => 'download', 'nopaging' => true ) ); + $products = get_posts( array( 'post_type' => CS_POST_TYPE, 'nopaging' => true ) ); $i = 0; foreach ( $products as $product_info ) { @@ -1425,7 +1425,7 @@ public function get_stats( $args = array() ) { $i ++; } } else { - if ( get_post_type( $args['product'] ) == 'download' ) { + if ( get_post_type( $args['product'] ) == CS_POST_TYPE ) { $product_info = get_post( $args['product'] ); $earnings['earnings'][0] = array( $product_info->post_name => cs_get_download_earnings_stats( $args['product'] ) ); } else { diff --git a/includes/cart/functions.php b/includes/cart/functions.php index a6022ee11f..fad556db18 100644 --- a/includes/cart/functions.php +++ b/includes/cart/functions.php @@ -479,7 +479,7 @@ function cs_add_collection_to_cart( $taxonomy, $terms ) { $cart_item_ids = array(); $items = get_posts( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => -1, $taxonomy => $terms ) ); diff --git a/includes/class-cs-cli.php b/includes/class-cs-cli.php index 547ffc3cf8..452d88494b 100644 --- a/includes/class-cs-cli.php +++ b/includes/class-cs-cli.php @@ -564,7 +564,7 @@ public function payments( $args, $assoc_args ) { // No specified product if ( ! $id ) { $products = get_posts( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'orderby' => 'rand', 'order' => 'ASC', 'posts_per_page' => rand( 1, 3 ), @@ -572,7 +572,7 @@ public function payments( $args, $assoc_args ) { } else { $product = get_post( $id ); - if ( 'download' !== $product->post_type ) { + if ( CS_POST_TYPE !== $product->post_type ) { WP_CLI::error( __( 'Specified ID is not a product', 'commercestore' ) ); return; @@ -741,7 +741,7 @@ public function create_discounts( $args, $assoc_args ) { ) ); $download_ids = get_posts( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => 2, 'fields' => 'ids', 'orderby' => 'rand', diff --git a/includes/class-cs-download.php b/includes/class-cs-download.php index 5dac1e03ff..ed6c153e60 100644 --- a/includes/class-cs-download.php +++ b/includes/class-cs-download.php @@ -165,7 +165,7 @@ private function setup_download( $download ) { return false; } - if ( 'download' !== $download->post_type ) { + if ( CS_POST_TYPE !== $download->post_type ) { return false; } @@ -203,7 +203,7 @@ public function create( $data = array() ) { } $defaults = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_status' => 'draft', 'post_title' => __( 'New Download Product', 'commercestore' ) ); diff --git a/includes/class-cs-html-elements.php b/includes/class-cs-html-elements.php index 02f26e7d17..19a47c063d 100644 --- a/includes/class-cs-html-elements.php +++ b/includes/class-cs-html-elements.php @@ -44,7 +44,7 @@ public function product_dropdown( $args = array() ) { 'show_variations_only' => false, 'placeholder' => sprintf( __( 'Choose a %s', 'commercestore' ), cs_get_label_singular() ), 'data' => array( - 'search-type' => 'download', + 'search-type' => CS_POST_TYPE, 'search-placeholder' => sprintf( __( 'Search %s', 'commercestore' ), cs_get_label_plural() ), ), 'required' => false, @@ -53,7 +53,7 @@ public function product_dropdown( $args = array() ) { $args = wp_parse_args( $args, $defaults ); $product_args = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page' => $args['number'], diff --git a/includes/class-cs-register-meta.php b/includes/class-cs-register-meta.php index a2b679fead..36fa3b0440 100644 --- a/includes/class-cs-register-meta.php +++ b/includes/class-cs-register-meta.php @@ -69,7 +69,7 @@ public function register_download_meta() { 'post', '_cs_download_earnings', array( - 'object_subtype' => 'download', + 'object_subtype' => CS_POST_TYPE, 'sanitize_callback' => 'cs_sanitize_amount', 'type' => 'float', 'description' => __( 'The total earnings for the specified product', 'commercestore' ), @@ -80,7 +80,7 @@ public function register_download_meta() { 'post', '_cs_download_sales', array( - 'object_subtype' => 'download', + 'object_subtype' => CS_POST_TYPE, 'sanitize_callback' => array( $this, 'intval_wrapper' ), 'type' => 'float', 'description' => __( 'The number of sales for the specified product.', 'commercestore' ), @@ -91,7 +91,7 @@ public function register_download_meta() { 'post', 'cs_price', array( - 'object_subtype' => 'download', + 'object_subtype' => CS_POST_TYPE, 'sanitize_callback' => array( $this, 'sanitize_price' ), 'type' => 'float', 'description' => __( 'The price of the product.', 'commercestore' ), @@ -107,7 +107,7 @@ public function register_download_meta() { 'post', 'cs_variable_prices', array( - 'object_subtype' => 'download', + 'object_subtype' => CS_POST_TYPE, 'sanitize_callback' => array( $this, 'sanitize_variable_prices' ), 'single' => true, 'type' => 'object', @@ -140,7 +140,7 @@ public function register_download_meta() { 'post', 'cs_download_files', array( - 'object_subtype' => 'download', + 'object_subtype' => CS_POST_TYPE, 'sanitize_callback' => array( $this, 'sanitize_files' ), 'type' => 'array', 'description' => __( 'The files associated with the product, available for download.', 'commercestore' ), @@ -151,7 +151,7 @@ public function register_download_meta() { 'post', '_cs_bundled_products', array( - 'object_subtype' => 'download', + 'object_subtype' => CS_POST_TYPE, 'sanitize_callback' => array( $this, 'sanitize_array' ), 'single' => true, 'type' => 'array', @@ -171,7 +171,7 @@ public function register_download_meta() { 'post', '_cs_button_behavior', array( - 'object_subtype' => 'download', + 'object_subtype' => CS_POST_TYPE, 'sanitize_callback' => 'sanitize_text_field', 'type' => 'string', 'description' => __( "Defines how this product's 'Purchase' button should behave, either add to cart or buy now", 'commercestore' ), @@ -183,7 +183,7 @@ public function register_download_meta() { 'post', '_cs_default_price_id', array( - 'object_subtype' => 'download', + 'object_subtype' => CS_POST_TYPE, 'sanitize_callback' => array( $this, 'intval_wrapper' ), 'type' => 'int', 'description' => __( 'When variable pricing is enabled, this value defines which option should be chosen by default.', 'commercestore' ), diff --git a/includes/class-structured-data.php b/includes/class-structured-data.php index 36de4b3c87..03ac6d8939 100644 --- a/includes/class-structured-data.php +++ b/includes/class-structured-data.php @@ -94,7 +94,7 @@ private function set_data( $data = null ) { * @return string */ public function generate_structured_data( $context = false, $args = null ) { - if ( is_singular( 'download' ) || 'download' === $context ) { + if ( is_singular( CS_POST_TYPE ) || CS_POST_TYPE === $context ) { $this->generate_download_data( $args ); } diff --git a/includes/database/schemas/class-order-items.php b/includes/database/schemas/class-order-items.php index 36ce6dd171..5379e16d6c 100644 --- a/includes/database/schemas/class-order-items.php +++ b/includes/database/schemas/class-order-items.php @@ -108,7 +108,7 @@ class Order_Items extends Schema { 'name' => 'type', 'type' => 'varchar', 'length' => '20', - 'default' => 'download', + 'default' => CS_POST_TYPE, // VERIFY 'sortable' => true, 'transition' => true ), diff --git a/includes/database/tables/class-order-items.php b/includes/database/tables/class-order-items.php index b85b1b1e8e..5be927b5ee 100644 --- a/includes/database/tables/class-order-items.php +++ b/includes/database/tables/class-order-items.php @@ -71,7 +71,7 @@ protected function set_schema() { product_name text NOT NULL default '', price_id bigint(20) unsigned default null, cart_index bigint(20) unsigned NOT NULL default '0', - type varchar(20) NOT NULL default 'download', + type varchar(20) NOT NULL default CS_POST_TYPE, status varchar(20) NOT NULL default 'pending', quantity int signed NOT NULL default '0', amount decimal(18,9) NOT NULL default '0', diff --git a/includes/deprecated-functions.php b/includes/deprecated-functions.php index 57b5fd9823..862a78e460 100644 --- a/includes/deprecated-functions.php +++ b/includes/deprecated-functions.php @@ -747,7 +747,7 @@ function cs_microdata_title( $title, $id = 0 ) { return $title; } - if ( $post->ID == $id && is_singular( 'download' ) && 'download' == get_post_type( intval( $id ) ) ) { + if ( $post->ID == $id && is_singular( CS_POST_TYPE ) && CS_POST_TYPE == get_post_type( intval( $id ) ) ) { $title = '' . $title . ''; } @@ -774,7 +774,7 @@ function cs_microdata_wrapper_open( $query ) { return; } - if ( $query && ! empty( $query->query['post_type'] ) && $query->query['post_type'] == 'download' && is_singular( 'download' ) && $query->is_main_query() ) { + if ( $query && ! empty( $query->query['post_type'] ) && $query->query['post_type'] == CS_POST_TYPE && is_singular( CS_POST_TYPE ) && $query->is_main_query() ) { $microdata_open = true; echo '
'; } @@ -802,7 +802,7 @@ function cs_microdata_wrapper_close() { return; } - if ( $post && $post->post_type == 'download' && is_singular( 'download' ) && is_main_query() ) { + if ( $post && $post->post_type == CS_POST_TYPE && is_singular( CS_POST_TYPE ) && is_main_query() ) { $microdata_close = true; echo '
'; } @@ -831,7 +831,7 @@ function cs_microdata_description( $content ) { return $content; } - if ( $post && $post->post_type == 'download' && is_singular( 'download' ) && is_main_query() ) { + if ( $post && $post->post_type == CS_POST_TYPE && is_singular( CS_POST_TYPE ) && is_main_query() ) { $microdata_description = true; $content = apply_filters( 'cs_microdata_wrapper', '
' . $content . '
' ); } diff --git a/includes/download-functions.php b/includes/download-functions.php index d208ee9ae7..229d66320d 100644 --- a/includes/download-functions.php +++ b/includes/download-functions.php @@ -33,7 +33,7 @@ function cs_get_download_by( $field = '', $value = '' ) { case 'id': $download = get_post( $value ); - if ( 'download' !== get_post_type( $download ) ) { + if ( CS_POST_TYPE !== get_post_type( $download ) ) { return false; } @@ -42,7 +42,7 @@ function cs_get_download_by( $field = '', $value = '' ) { case 'slug': case 'name': $download = get_posts( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'name' => $value, 'posts_per_page' => 1, 'post_status' => 'any', @@ -56,7 +56,7 @@ function cs_get_download_by( $field = '', $value = '' ) { case 'sku': $download = get_posts( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'meta_key' => 'cs_sku', 'meta_value' => $value, 'posts_per_page' => 1, @@ -98,7 +98,7 @@ function cs_get_download( $download_id = 0 ) { // Fetch download by name. } else { $args = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'name' => $download_id, 'post_per_page' => 1, 'fields' => 'ids', @@ -823,7 +823,7 @@ function cs_remove_download_logs_on_delete( $download_id = 0 ) { $download_id = absint( $download_id ); // Bail if the post type is not `download`. - if ( 'download' !== get_post_type( $download_id ) ) { + if ( CS_POST_TYPE !== get_post_type( $download_id ) ) { return; } @@ -835,7 +835,7 @@ function cs_remove_download_logs_on_delete( $download_id = 0 ) { // Delete logs. $wpdb->delete( $wpdb->cs_logs, array( 'object_id' => $download_id, - 'object_type' => 'download', + 'object_type' => CS_POST_TYPE, ), array( '%d', '%s' ) ); } add_action( 'delete_post', 'cs_remove_download_logs_on_delete' ); @@ -1528,7 +1528,7 @@ function cs_get_random_download( $post_ids = true ) { */ function cs_get_random_downloads( $num = 3, $post_ids = true ) { $args = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'orderby' => 'rand', 'numberposts' => $num, ); diff --git a/includes/gateways/paypal/admin/notices.php b/includes/gateways/paypal/admin/notices.php index 5d6105d9e3..cf73eb09a9 100644 --- a/includes/gateways/paypal/admin/notices.php +++ b/includes/gateways/paypal/admin/notices.php @@ -38,7 +38,7 @@ ) ), 'cs_notice_nonce' ); $setup_url = add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-settings', 'tab' => 'gateways', 'section' => 'paypal_commerce' diff --git a/includes/misc-functions.php b/includes/misc-functions.php index 2e94fbbe55..461922acf7 100644 --- a/includes/misc-functions.php +++ b/includes/misc-functions.php @@ -25,7 +25,7 @@ function cs_get_admin_base_url() { // Default args $args = array( - 'post_type' => 'download' + 'post_type' => CS_POST_TYPE ); // Default URL diff --git a/includes/orders/functions/actions.php b/includes/orders/functions/actions.php index 2cc5e9605e..984108c512 100644 --- a/includes/orders/functions/actions.php +++ b/includes/orders/functions/actions.php @@ -308,7 +308,7 @@ function cs_add_manual_order( $args = array() ) { 'product_name' => cs_get_download_name( $download['id'], absint( $price_id ) ), 'price_id' => $price_id, 'cart_index' => $cart_key, - 'type' => 'download', + 'type' => CS_POST_TYPE, 'status' => 'complete', 'quantity' => $quantity, 'amount' => $amount, diff --git a/includes/orders/functions/orders.php b/includes/orders/functions/orders.php index 99403f90c4..8c44570598 100644 --- a/includes/orders/functions/orders.php +++ b/includes/orders/functions/orders.php @@ -834,7 +834,7 @@ function cs_build_order( $order_data = array() ) { $download = cs_get_download( $item['id'] ); // Skip if download is missing or not actually a download. - if ( empty( $download ) || ( 'download' !== $download->post_type ) ) { + if ( empty( $download ) || ( CS_POST_TYPE !== $download->post_type ) ) { continue; } @@ -864,7 +864,7 @@ function cs_build_order( $order_data = array() ) { 'product_name' => $item_name, 'price_id' => $price_id, 'cart_index' => $key, - 'type' => 'download', + 'type' => CS_POST_TYPE, 'status' => ! empty( $order_data['status'] ) ? $order_data['status'] : 'pending', 'quantity' => $item['quantity'], 'amount' => $item['item_price'], diff --git a/includes/payments/class-cs-payment.php b/includes/payments/class-cs-payment.php index 7527a657c5..b3138168c4 100644 --- a/includes/payments/class-cs-payment.php +++ b/includes/payments/class-cs-payment.php @@ -1134,7 +1134,7 @@ public function add_download( $download_id = 0, $args = array(), $options = arra $download = new CS_Download( $download_id ); // Bail if this post isn't a download. - if ( ! $download || 'download' !== $download->post_type ) { + if ( ! $download || CS_POST_TYPE !== $download->post_type ) { return false; } @@ -1282,7 +1282,7 @@ public function remove_download( $download_id, $args = array() ) { * * We need to allow this to process though for a missing post ID, in case it's a download that was deleted. */ - if ( ! empty( $download->ID ) && 'download' !== $download->post_type ) { + if ( ! empty( $download->ID ) && CS_POST_TYPE !== $download->post_type ) { return false; } diff --git a/includes/payments/class-payment-stats.php b/includes/payments/class-payment-stats.php index aba0b47529..fb0c6802bd 100644 --- a/includes/payments/class-payment-stats.php +++ b/includes/payments/class-payment-stats.php @@ -228,7 +228,7 @@ public function get_earnings( $download_id = 0, $start_date = false, $end_date = } else { $args = array( 'object_id' => $download_id, - 'object_type' => 'download', + 'object_type' => CS_POST_TYPE, 'type' => 'sale', 'log_type' => false, 'date_created_query' => array( diff --git a/includes/payments/class-payments-query.php b/includes/payments/class-payments-query.php index 16a2eaa966..3686134dc1 100644 --- a/includes/payments/class-payments-query.php +++ b/includes/payments/class-payments-query.php @@ -91,7 +91,7 @@ public function __construct( $args = array() ) { 'search_in_notes' => false, 'children' => false, 'fields' => null, - 'download' => null, + CS_POST_TYPE => null, 'gateway' => null, 'post__in' => null, 'post__not_in' => null, @@ -520,15 +520,15 @@ public function children() { * @since 1.8 */ public function download() { - if ( empty( $this->args['download'] ) ) { + if ( empty( $this->args[CS_POST_TYPE] ) ) { return; } $order_ids = array(); - if ( is_array( $this->args['download'] ) ) { + if ( is_array( $this->args[CS_POST_TYPE] ) ) { $orders = cs_get_order_items( array( - 'product_id__in' => (array) $this->args['download'], + 'product_id__in' => (array) $this->args[CS_POST_TYPE], ) ); foreach ( $orders as $order ) { @@ -537,7 +537,7 @@ public function download() { } } else { $orders = cs_get_order_items( array( - 'product_id' => $this->args['download'], + 'product_id' => $this->args[CS_POST_TYPE], ) ); foreach ( $orders as $order ) { @@ -548,7 +548,7 @@ public function download() { $this->args['id__in'] = $order_ids; - $this->__unset( 'download' ); + $this->__unset( CS_POST_TYPE ); } /** diff --git a/includes/payments/functions.php b/includes/payments/functions.php index 4718762c55..d1aa2f5077 100644 --- a/includes/payments/functions.php +++ b/includes/payments/functions.php @@ -343,7 +343,7 @@ function cs_count_payments( $args = array() ) { 's' => null, 'start-date' => null, 'end-date' => null, - 'download' => null, + CS_POST_TYPE => null, 'gateway' => null, 'type' => 'sale', ) ); @@ -403,9 +403,9 @@ function cs_count_payments( $args = array() ) { } } - if ( ! empty( $args['download'] ) && is_numeric( $args['download'] ) ) { + if ( ! empty( $args[CS_POST_TYPE] ) && is_numeric( $args[CS_POST_TYPE] ) ) { $join = "INNER JOIN {$wpdb->cs_order_items} cs_oi ON cs_o.id = cs_oi.order_id"; - $where .= $wpdb->prepare( ' AND cs_oi.product_id = %d', absint( $args['download'] ) ); + $where .= $wpdb->prepare( ' AND cs_oi.product_id = %d', absint( $args[CS_POST_TYPE] ) ); } if ( ! empty( $args['gateway'] ) ) { diff --git a/includes/post-types.php b/includes/post-types.php index 82dd3b3740..51bd9951ea 100644 --- a/includes/post-types.php +++ b/includes/post-types.php @@ -75,7 +75,7 @@ function cs_setup_cs_post_types() { 'hierarchical' => false, 'supports' => apply_filters( 'cs_download_supports', array( 'title', 'editor', 'thumbnail', 'excerpt', 'revisions', 'author' ) ), ); - register_post_type( 'download', apply_filters( 'cs_download_post_type_args', $download_args ) ); + register_post_type( CS_POST_TYPE, apply_filters( 'cs_download_post_type_args', $download_args ) ); /** Payment Post Type */ @@ -222,7 +222,7 @@ function cs_change_default_title( $title ) { $screen = get_current_screen(); - if ( 'download' === $screen->post_type ) { + if ( CS_POST_TYPE === $screen->post_type ) { $label = cs_get_label_singular(); $title = sprintf( __( 'Enter %s name here', 'commercestore' ), $label ); } @@ -269,8 +269,8 @@ function cs_setup_download_taxonomies() { ), ) ); - register_taxonomy( 'download_category', array( 'download' ), $category_args ); - register_taxonomy_for_object_type( 'download_category', 'download' ); + register_taxonomy( 'download_category', array( CS_POST_TYPE ), $category_args ); + register_taxonomy_for_object_type( 'download_category', CS_POST_TYPE ); /** Tags */ $tag_labels = array( @@ -303,8 +303,8 @@ function cs_setup_download_taxonomies() { ) ); - register_taxonomy( 'download_tag', array( 'download' ), $tag_args ); - register_taxonomy_for_object_type( 'download_tag', 'download' ); + register_taxonomy( 'download_tag', array( CS_POST_TYPE ), $tag_args ); + register_taxonomy_for_object_type( 'download_tag', CS_POST_TYPE ); } add_action( 'init', 'cs_setup_download_taxonomies', 0 ); @@ -428,7 +428,7 @@ function cs_updated_messages( $messages ) { $url2 = cs_get_label_singular(); $url3 = ''; - $messages['download'] = array( + $messages[CS_POST_TYPE] = array( 1 => sprintf( __( '%2$s updated. %1$sView %2$s%3$s.', 'commercestore' ), $url1, $url2, $url3 ), 4 => sprintf( __( '%2$s updated. %1$sView %2$s%3$s.', 'commercestore' ), $url1, $url2, $url3 ), 6 => sprintf( __( '%2$s published. %1$sView %2$s%3$s.', 'commercestore' ), $url1, $url2, $url3 ), @@ -455,7 +455,7 @@ function cs_bulk_updated_messages( $bulk_messages, $bulk_counts ) { $singular = cs_get_label_singular(); $plural = cs_get_label_plural(); - $bulk_messages['download'] = array( + $bulk_messages[CS_POST_TYPE] = array( 'updated' => sprintf( _n( '%1$s %2$s updated.', '%1$s %3$s updated.', $bulk_counts['updated'], 'commercestore' ), $bulk_counts['updated'], $singular, $plural ), 'locked' => sprintf( _n( '%1$s %2$s not updated, somebody is editing it.', '%1$s %3$s not updated, somebody is editing them.', $bulk_counts['locked'], 'commercestore' ), $bulk_counts['locked'], $singular, $plural ), 'deleted' => sprintf( _n( '%1$s %2$s permanently deleted.', '%1$s %3$s permanently deleted.', $bulk_counts['deleted'], 'commercestore' ), $bulk_counts['deleted'], $singular, $plural ), @@ -480,7 +480,7 @@ function cs_bulk_updated_messages( $bulk_messages, $bulk_counts ) { * @return array */ function cs_download_row_actions( $actions, $post ) { - if ( 'download' === $post->post_type ) { + if ( CS_POST_TYPE === $post->post_type ) { return array_merge( array( 'id' => '#' . $post->ID ), $actions ); } diff --git a/includes/process-download.php b/includes/process-download.php index 19265bbbfc..b76fa7e40a 100644 --- a/includes/process-download.php +++ b/includes/process-download.php @@ -22,12 +22,12 @@ * @return void */ function cs_process_download() { - if ( ! isset( $_GET['download_id'] ) && isset( $_GET['download'] ) ) { - $_GET['download_id'] = $_GET['download']; + if ( ! isset( $_GET['download_id'] ) && isset( $_GET[CS_POST_TYPE] ) ) { + $_GET['download_id'] = $_GET[CS_POST_TYPE]; } $args = apply_filters( 'cs_process_download_args', array( - 'download' => ( isset( $_GET['download_id'] ) ) ? (int) $_GET['download_id'] : '', + CS_POST_TYPE => ( isset( $_GET['download_id'] ) ) ? (int) $_GET['download_id'] : '', 'email' => ( isset( $_GET['email'] ) ) ? rawurldecode( $_GET['email'] ) : '', 'expire' => ( isset( $_GET['expire'] ) ) ? rawurldecode( $_GET['expire'] ) : '', 'file_key' => ( isset( $_GET['file'] ) ) ? (int) $_GET['file'] : '', @@ -44,12 +44,12 @@ function cs_process_download() { $args = cs_process_signed_download_url( $args ); // Backfill some legacy super globals for backwards compatibility - $_GET['download_id'] = $args['download']; + $_GET['download_id'] = $args[CS_POST_TYPE]; $_GET['email'] = $args['email']; $_GET['expire'] = $args['expire']; $_GET['download_key'] = $args['key']; $_GET['price_id'] = $args['price_id']; - } elseif ( ! empty( $args['download'] ) && ! empty( $args['key'] ) && ! empty( $args['email'] ) && ! empty( $args['expire'] ) && isset( $args['file_key'] ) ) { + } elseif ( ! empty( $args[CS_POST_TYPE] ) && ! empty( $args['key'] ) && ! empty( $args['email'] ) && ! empty( $args['expire'] ) && isset( $args['file_key'] ) ) { // Validate a legacy URL without a token $args = cs_process_legacy_download_url( $args ); @@ -60,13 +60,13 @@ function cs_process_download() { $args['has_access'] = apply_filters( 'cs_file_download_has_access', $args['has_access'], $args['payment'], $args ); if ( $args['payment'] && $args['has_access'] ) { - do_action( 'cs_process_verified_download', $args['download'], $args['email'], $args['payment'], $args ); + do_action( 'cs_process_verified_download', $args[CS_POST_TYPE], $args['email'], $args['payment'], $args ); // Determine the download method set in settings $method = cs_get_file_download_method(); // Payment has been verified, setup the download - $download_files = cs_get_download_files( $args['download'] ); + $download_files = cs_get_download_files( $args[CS_POST_TYPE] ); $attachment_id = ! empty( $download_files[ $args['file_key'] ]['attachment_id'] ) ? absint( $download_files[ $args['file_key'] ]['attachment_id'] ) : false; $thumbnail_size = ! empty( $download_files[ $args['file_key'] ]['thumbnail_size'] ) ? sanitize_text_field( $download_files[ $args['file_key'] ]['thumbnail_size'] ) : false; $requested_file = isset( $download_files[ $args['file_key'] ]['file'] ) ? $download_files[ $args['file_key'] ]['file'] : ''; @@ -157,7 +157,7 @@ function cs_process_download() { $user_info['name'] = $user_data->display_name; } - cs_record_download_in_log( $args['download'], $args['file_key'], $user_info, cs_get_ip(), $args['payment'], $args['price_id'] ); + cs_record_download_in_log( $args[CS_POST_TYPE], $args['file_key'], $user_info, cs_get_ip(), $args['payment'], $args['price_id'] ); $file_extension = cs_get_file_extension( $requested_file ); $ctype = cs_get_file_ctype( $file_extension ); @@ -182,7 +182,7 @@ function cs_process_download() { } @ini_set( 'zlib.output_compression', 'Off' ); - do_action( 'cs_process_download_headers', $requested_file, $args['download'], $args['email'], $args['payment'] ); + do_action( 'cs_process_download_headers', $requested_file, $args[CS_POST_TYPE], $args['email'], $args['payment'] ); nocache_headers(); header( 'Robots: none' ); @@ -831,7 +831,7 @@ function cs_readfile_chunked( $file, $retbytes = true ) { function cs_process_legacy_download_url( $args ) { // Verify the payment - $args['payment'] = cs_verify_download_link( $args['download'], $args['key'], $args['email'], $args['expire'], $args['file_key'] ); + $args['payment'] = cs_verify_download_link( $args[CS_POST_TYPE], $args['key'], $args['email'], $args['expire'], $args['file_key'] ); // Defaulting this to true for now because the method below doesn't work well $args['has_access'] = true; @@ -874,7 +874,7 @@ function cs_process_signed_download_url( $args ) { } $args['expire'] = $_GET['ttl']; - $args['download'] = $order_parts[1]; + $args[CS_POST_TYPE] = $order_parts[1]; $args['payment'] = $order_parts[0]; $args['file_key'] = $order_parts[2]; $args['price_id'] = $order_parts[3]; @@ -884,7 +884,7 @@ function cs_process_signed_download_url( $args ) { // Access is granted if there's at least one `complete` order item that matches the order + download + price ID. $args['has_access'] = cs_order_grants_access_to_download_files( array( 'order_id' => $args['payment'], - 'product_id' => $args['download'], + 'product_id' => $args[CS_POST_TYPE], 'price_id' => ! empty( $args['price_id'] ) ? $args['price_id'] : '' ) ); diff --git a/includes/query-filters.php b/includes/query-filters.php index 4bff6db111..1ab16b2d81 100644 --- a/includes/query-filters.php +++ b/includes/query-filters.php @@ -37,7 +37,7 @@ function cs_block_attachments() { return; } - if ( 'download' !== get_post_type( $parent ) && false === $cs_file ) { + if ( CS_POST_TYPE !== get_post_type( $parent ) && false === $cs_file ) { return; } diff --git a/includes/reports/data/downloads/class-earnings-by-taxonomy-list-table.php b/includes/reports/data/downloads/class-earnings-by-taxonomy-list-table.php index 7de8d2a3ae..c90799c12b 100644 --- a/includes/reports/data/downloads/class-earnings-by-taxonomy-list-table.php +++ b/includes/reports/data/downloads/class-earnings-by-taxonomy-list-table.php @@ -55,7 +55,7 @@ public function get_data() { } } - $taxonomies = get_object_taxonomies( 'download', 'names' ); + $taxonomies = get_object_taxonomies( CS_POST_TYPE, 'names' ); $taxonomies = array_map( 'sanitize_text_field', $taxonomies ); $placeholders = implode( ', ', array_fill( 0, count( $taxonomies ), '%s' ) ); diff --git a/includes/reports/reports-functions.php b/includes/reports/reports-functions.php index d4efa0c581..a55ee1dc31 100644 --- a/includes/reports/reports-functions.php +++ b/includes/reports/reports-functions.php @@ -1290,7 +1290,7 @@ function filter_items( $report = false ) { // Get form actions $action = admin_url( add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-reports', 'view' => get_current_report(), ), 'edit.php' ) ); diff --git a/includes/scripts.php b/includes/scripts.php index 08596de0d2..0b81ed1e70 100644 --- a/includes/scripts.php +++ b/includes/scripts.php @@ -181,7 +181,7 @@ function cs_localize_scripts() { ? cs_get_item_position_in_cart( $post->ID ) : -1; - if ( ( ! empty( $post->post_content ) && ( has_shortcode( $post->post_content, 'purchase_link' ) || has_shortcode( $post->post_content, 'downloads' ) ) ) || is_post_type_archive( 'download' ) ) { + if ( ( ! empty( $post->post_content ) && ( has_shortcode( $post->post_content, 'purchase_link' ) || has_shortcode( $post->post_content, 'downloads' ) ) ) || is_post_type_archive( CS_POST_TYPE ) ) { $has_purchase_links = true; } else { $has_purchase_links = false; @@ -398,7 +398,7 @@ function cs_enqueue_admin_scripts( $hook = '' ) { } // Downloads page. - if ( cs_is_admin_page( 'download' ) ) { + if ( cs_is_admin_page( CS_POST_TYPE ) ) { wp_enqueue_script( 'cs-admin-downloads' ); } diff --git a/includes/shortcodes.php b/includes/shortcodes.php index e8533a5d40..49390f59ce 100644 --- a/includes/shortcodes.php +++ b/includes/shortcodes.php @@ -334,7 +334,7 @@ function cs_downloads_query( $atts, $content = null ) { ), $atts, 'downloads' ); $query = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'orderby' => $atts['orderby'], 'order' => $atts['order'] ); diff --git a/includes/subscriptions/includes/admin/metabox.php b/includes/subscriptions/includes/admin/metabox.php index 86abd5af7b..7fad48da04 100644 --- a/includes/subscriptions/includes/admin/metabox.php +++ b/includes/subscriptions/includes/admin/metabox.php @@ -651,7 +651,7 @@ function cs_recurring_display_parent_payment( $payment_id = 0 ) { } $parent_url = add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-payment-history', 'view' => 'view-order-details', 'id' => urlencode( $payment->parent_payment ), @@ -660,7 +660,7 @@ function cs_recurring_display_parent_payment( $payment_id = 0 ) { ); $sub_url = add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-subscriptions', 'id' => urlencode( $sub->id ), ), diff --git a/includes/subscriptions/includes/admin/scripts.php b/includes/subscriptions/includes/admin/scripts.php index 2ec0aeb006..d6ee15f653 100644 --- a/includes/subscriptions/includes/admin/scripts.php +++ b/includes/subscriptions/includes/admin/scripts.php @@ -14,7 +14,7 @@ function cs_recurring_admin_scripts( $hook ) { return; } - if ( is_object( $post ) && 'download' != $post->post_type ) { + if ( is_object( $post ) && CS_POST_TYPE != $post->post_type ) { return; } diff --git a/includes/subscriptions/includes/admin/settings.php b/includes/subscriptions/includes/admin/settings.php index 4a68ee4d32..eb651a2115 100644 --- a/includes/subscriptions/includes/admin/settings.php +++ b/includes/subscriptions/includes/admin/settings.php @@ -579,7 +579,7 @@ function cs_recurring_guest_checkout_description( $settings ) { function cs_recurring_get_email_settings_url() { return add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-settings', 'tab' => 'emails', 'section' => 'recurring', diff --git a/includes/subscriptions/includes/cs-subscriptions-db.php b/includes/subscriptions/includes/cs-subscriptions-db.php index 6bc18c9731..d0d5b44198 100644 --- a/includes/subscriptions/includes/cs-subscriptions-db.php +++ b/includes/subscriptions/includes/cs-subscriptions-db.php @@ -333,7 +333,7 @@ public function get_subscriptions( $args = array() ) { } else { // See if search matches a product name - $download = get_page_by_title( trim( $args['search'] ), OBJECT, 'download' ); + $download = get_page_by_title( trim( $args['search'] ), OBJECT, CS_POST_TYPE ); if( $download ) { @@ -653,7 +653,7 @@ public function count( $args = array() ) { } else { // See if search matches a product name - $download = get_page_by_title( trim( $args['search'] ), OBJECT, 'download' ); + $download = get_page_by_title( trim( $args['search'] ), OBJECT, CS_POST_TYPE ); if( $download ) { diff --git a/includes/subscriptions/includes/gateways/cs-recurring-paypal.php b/includes/subscriptions/includes/gateways/cs-recurring-paypal.php index 9a0c570995..0a13b94070 100644 --- a/includes/subscriptions/includes/gateways/cs-recurring-paypal.php +++ b/includes/subscriptions/includes/gateways/cs-recurring-paypal.php @@ -677,7 +677,7 @@ public function validate_paypal_recurring_download( $post_id = 0 ) { if ( isset( $post->post_type ) && $post->post_type == 'revision' ) { return $post_id; } - if ( ! isset( $post->post_type ) || $post->post_type != 'download' ) { + if ( ! isset( $post->post_type ) || $post->post_type != CS_POST_TYPE ) { return $post_id; } if ( ! current_user_can( 'edit_products', $post_id ) ) { diff --git a/includes/subscriptions/includes/gateways/cs-recurring-stripe.php b/includes/subscriptions/includes/gateways/cs-recurring-stripe.php index c32c399bda..aa9ab9ce43 100644 --- a/includes/subscriptions/includes/gateways/cs-recurring-stripe.php +++ b/includes/subscriptions/includes/gateways/cs-recurring-stripe.php @@ -697,7 +697,7 @@ public function create_stripe_subscriptions( $intent ) { ), 'metadata' => array( 'payment_key' => $this->purchase_data['purchase_key'], - 'download' => $subscription['name'], + CS_POST_TYPE => $subscription['name'], 'download_id' => $subscription['id'], 'price_id' => $subscription['price_id'], 'caller' => __CLASS__ . '|' . __METHOD__ . '|' . __LINE__ . '|' . CS_RECURRING_VERSION, diff --git a/includes/subscriptions/includes/plugin-content-restriction.php b/includes/subscriptions/includes/plugin-content-restriction.php index 12b66f93bd..bbbe088d4f 100644 --- a/includes/subscriptions/includes/plugin-content-restriction.php +++ b/includes/subscriptions/includes/plugin-content-restriction.php @@ -193,20 +193,20 @@ public function can_access_content( $return, $user_id, $restricted_to, $post_id foreach ( $restricted_to as $item ) { - if ( 'any' === $item['download'] ) { + if ( 'any' === $item[CS_POST_TYPE] ) { $return['status'] = $subscriber->has_active_subscription() ? true : false; return $return; } // Get the Download object so we can use it in variable price checks. - $download = new CS_Download( $item['download'] ); + $download = new CS_Download( $item[CS_POST_TYPE] ); if ( isset( $item['price_id'] ) && $download->has_variable_prices() ) { if ( is_numeric( $item['price_id'] ) ) { // Check if the variably-riced product is Recurring-enabled or not. - $recurring_enabled = CS_Recurring()->is_price_recurring( $item['download'], $item['price_id'] ); + $recurring_enabled = CS_Recurring()->is_price_recurring( $item[CS_POST_TYPE], $item['price_id'] ); } elseif ( 'all' === $item['price_id'] ) { @@ -224,14 +224,14 @@ public function can_access_content( $return, $user_id, $restricted_to, $post_id } else { // Check if the product is Recurring-enabled or not. - $recurring_enabled = CS_Recurring()->is_recurring( $item['download'] ); + $recurring_enabled = CS_Recurring()->is_recurring( $item[CS_POST_TYPE] ); } if ( $recurring_enabled ) { // If this subscriber has an active subscription to the variably-product in question. - if ( $subscriber->has_active_product_subscription( $item['download'] ) ) { + if ( $subscriber->has_active_product_subscription( $item[CS_POST_TYPE] ) ) { $has_access = true; break; } @@ -317,19 +317,19 @@ public function restrict_shortcode_content( $content, $restricted_to, $atts ) { $custom_message = isset( $atts['message'] ) ? $atts['message'] : false; $products = array(); foreach ( $restricted_to as $item ) { - if ( cs_recurring()->is_recurring( $item['download'] ) ) { - $has_access = $subscriber->has_active_product_subscription( $item['download'] ); + if ( cs_recurring()->is_recurring( $item[CS_POST_TYPE] ) ) { + $has_access = $subscriber->has_active_product_subscription( $item[CS_POST_TYPE] ); } else { - if ( ! empty( $item['download']['price_id'] ) && is_numeric( $item['download']['price_id'] ) && cs_has_variable_prices( $item['download'] ) ) { - $has_access = cs_has_user_purchased( $user_id, $item['download'], $item['download']['price_id'] ); + if ( ! empty( $item[CS_POST_TYPE]['price_id'] ) && is_numeric( $item[CS_POST_TYPE]['price_id'] ) && cs_has_variable_prices( $item[CS_POST_TYPE] ) ) { + $has_access = cs_has_user_purchased( $user_id, $item[CS_POST_TYPE], $item[CS_POST_TYPE]['price_id'] ); } else { - $has_access = cs_has_user_purchased( $user_id, $item['download'] ); + $has_access = cs_has_user_purchased( $user_id, $item[CS_POST_TYPE] ); } } if ( $has_access ) { return $content; } - $products[] = get_the_title( $item['download'] ); + $products[] = get_the_title( $item[CS_POST_TYPE] ); } // At this point, $has_access is false and we just need to get the correct message. diff --git a/includes/subscriptions/subscriptions.php b/includes/subscriptions/subscriptions.php index 6ecb08d737..a9445892f5 100644 --- a/includes/subscriptions/subscriptions.php +++ b/includes/subscriptions/subscriptions.php @@ -1556,9 +1556,9 @@ public function enable_child_payments( $query ) { $query_has_recurring = true; - if( ! empty( $query->initial_args['download'] ) ) { + if( ! empty( $query->initial_args[CS_POST_TYPE] ) ) { $query_has_recurring = false; - $download = $query->initial_args['download']; + $download = $query->initial_args[CS_POST_TYPE]; if ( ! is_array( $download ) && strpos( $download, ',' ) ) { $download = explode( ',', $download ); @@ -1623,7 +1623,7 @@ public function enqueue_scripts() { ( 'page' === $post->post_type && has_shortcode( $post->post_content, 'cs_downloads' ) ) || ( 'page' === $post->post_type && has_shortcode( $post->post_content, 'downloads' ) ) || ( 'page' === $post->post_type && has_shortcode( $post->post_content, 'cs_subscriptions' ) ) || - 'download' === $post->post_type ) + CS_POST_TYPE === $post->post_type ) ) ) { $load_js = true; } diff --git a/includes/template-functions.php b/includes/template-functions.php index afa74a7619..4dc99b713e 100644 --- a/includes/template-functions.php +++ b/includes/template-functions.php @@ -414,7 +414,7 @@ function cs_variable_price_quantity_field( $key, $price, $download_id ) { function cs_before_download_content( $content ) { global $post; - if ( $post && $post instanceof WP_Post && 'download' === $post->post_type && is_singular( 'download' ) && is_main_query() && ! post_password_required() ) { + if ( $post && $post instanceof WP_Post && CS_POST_TYPE === $post->post_type && is_singular( CS_POST_TYPE ) && is_main_query() && ! post_password_required() ) { ob_start(); do_action( 'cs_before_download_content', $post->ID ); $content = ob_get_clean() . $content; @@ -439,7 +439,7 @@ function cs_before_download_content( $content ) { function cs_after_download_content( $content ) { global $post; - if ( $post && $post->post_type == 'download' && is_singular( 'download' ) && is_main_query() && !post_password_required() ) { + if ( $post && $post->post_type == CS_POST_TYPE && is_singular( CS_POST_TYPE ) && is_main_query() && !post_password_required() ) { ob_start(); do_action( 'cs_after_download_content', $post->ID ); $content .= ob_get_clean(); @@ -840,7 +840,7 @@ function cs_add_body_classes( $class ) { * @return array Modified array of classes */ function cs_add_download_post_classes( $classes, $class = '', $post_id = false ) { - if( ! $post_id || get_post_type( $post_id ) !== 'download' || is_admin() ) { + if( ! $post_id || get_post_type( $post_id ) !== CS_POST_TYPE || is_admin() ) { return $classes; } @@ -866,7 +866,7 @@ function cs_add_download_post_classes( $classes, $class = '', $post_id = false ) } // Add cs-download - if( is_singular( 'download' ) ) { + if( is_singular( CS_POST_TYPE ) ) { $classes[] = 'cs-download'; } } @@ -883,7 +883,7 @@ function cs_add_download_post_classes( $classes, $class = '', $post_id = false ) */ function cs_add_oembed_price() { - if( 'download' !== get_post_type( get_the_ID() ) ) { + if( CS_POST_TYPE !== get_post_type( get_the_ID() ) ) { return; } @@ -914,7 +914,7 @@ function cs_remove_embed_comments_button() { $hide_comments = apply_filters( 'cs_embed_hide_comments', true, $post ); - if ( ! empty( $post ) && $post->post_type == 'download' && true === $hide_comments ) { + if ( ! empty( $post ) && $post->post_type == CS_POST_TYPE && true === $hide_comments ) { remove_action( 'embed_content_meta', 'print_embed_comments_button' ); } } @@ -994,7 +994,7 @@ function cs_download_shortcode_item( $atts, $i ) { $cs_download_shortcode_item_atts = $atts; $cs_download_shortcode_item_i = $i; - cs_get_template_part( 'shortcode', 'download' ); + cs_get_template_part( 'shortcode', CS_POST_TYPE ); } add_action( 'cs_download_shortcode_item', 'cs_download_shortcode_item', 10, 2 ); @@ -1086,7 +1086,7 @@ function cs_download_shortcode_excerpt_length() { function cs_downloads_pagination( $atts, $downloads, $query ) { if ( filter_var( $atts['pagination'], FILTER_VALIDATE_BOOLEAN ) ) { $args = array( - 'type' => 'download', + 'type' => CS_POST_TYPE, 'format' => '?paged=%#%', 'current' => max( 1, $query['paged'] ), 'total' => $downloads->max_num_pages @@ -1128,7 +1128,7 @@ function cs_pagination( $args = array() ) { ); $args = wp_parse_args( $args, $defaults ); - + /** * Filter pagination args. * diff --git a/includes/theme-compatibility.php b/includes/theme-compatibility.php index d15f0c528e..c5acc86170 100644 --- a/includes/theme-compatibility.php +++ b/includes/theme-compatibility.php @@ -27,16 +27,16 @@ */ function cs_responsive_download_post_class( $classes = array(), $class = '', $post_id = 0 ) { if ( - ! is_singular( 'download' ) && - ! is_post_type_archive( 'download' ) && + ! is_singular( CS_POST_TYPE ) && + ! is_post_type_archive( CS_POST_TYPE ) && ! is_tax( 'download_category' ) && ! is_tax( 'download_tag' ) ) return $classes; - if ( ( $key = array_search( 'download', $classes ) ) ) + if ( ( $key = array_search( CS_POST_TYPE, $classes ) ) ) unset( $classes[ $key ] ); return $classes; } -add_filter( 'post_class', 'cs_responsive_download_post_class', 999, 3 ); \ No newline at end of file +add_filter( 'post_class', 'cs_responsive_download_post_class', 999, 3 ); diff --git a/includes/user-functions.php b/includes/user-functions.php index 267f7341d0..b1349103ef 100644 --- a/includes/user-functions.php +++ b/includes/user-functions.php @@ -154,7 +154,7 @@ function cs_get_users_purchased_products( $user = 0, $status = 'complete' ) { $args = apply_filters( 'cs_get_users_purchased_products_args', array( 'include' => $product_ids, - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => -1, ) ); diff --git a/includes/widgets.php b/includes/widgets.php index c7ec4fae6c..dfe1a9b63f 100644 --- a/includes/widgets.php +++ b/includes/widgets.php @@ -260,12 +260,12 @@ public function widget( $args, $instance ) { } } - if ( ! isset( $instance['display_type'] ) || ( 'specific' === $instance['display_type'] && ! isset( $instance['download_id'] ) ) || ( 'current' == $instance['display_type'] && ! is_singular( 'download' ) ) ) { + if ( ! isset( $instance['display_type'] ) || ( 'specific' === $instance['display_type'] && ! isset( $instance['download_id'] ) ) || ( 'current' == $instance['display_type'] && ! is_singular( CS_POST_TYPE ) ) ) { return; } // set correct download ID. - if ( 'current' == $instance['display_type'] && is_singular( 'download' ) ) { + if ( 'current' == $instance['display_type'] && is_singular( CS_POST_TYPE ) ) { $download_id = get_the_ID(); } else { $download_id = absint( $instance['download_id'] ); @@ -273,7 +273,7 @@ public function widget( $args, $instance ) { // Since we can take a typed in value, make sure it's a download we're looking for $download = get_post( $download_id ); - if ( ! is_object( $download ) || 'download' !== $download->post_type ) { + if ( ! is_object( $download ) || CS_POST_TYPE !== $download->post_type ) { return; } @@ -398,11 +398,11 @@ public function form( $instance ) {

> - + publish < 1000 ) : ?> 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => -1, 'post_status' => 'publish', ); From 59df2a0fdce42d9bdee5a622d71af75745c0cced Mon Sep 17 00:00:00 2001 From: Nick Temple Date: Mon, 21 Feb 2022 18:58:40 -0700 Subject: [PATCH 02/17] Change Post Type --- commercestore.php | 4 +- includes/admin/admin-actions.php | 14 +-- includes/admin/admin-footer.php | 2 +- includes/admin/admin-pages.php | 96 +++++++++---------- includes/admin/class-cs-notices.php | 4 +- includes/admin/dashboard-widgets.php | 2 +- includes/admin/downloads/contextual-help.php | 2 +- .../admin/downloads/dashboard-columns.php | 16 ++-- includes/admin/downloads/metabox.php | 8 +- .../admin/extensions/abstract-extension.php | 6 +- .../extensions/class-extension-manager.php | 2 +- .../product-education/class-reviews.php | 2 +- .../import/class-batch-import-downloads.php | 2 +- .../import/class-batch-import-payments.php | 8 +- .../reporting/class-base-logs-list-table.php | 4 +- .../class-categories-reports-table.php | 4 +- .../class-download-reports-table.php | 4 +- .../class-export-download-history.php | 4 +- .../class-file-downloads-logs-list-table.php | 8 +- .../reporting/class-sales-logs-list-table.php | 8 +- .../export/class-batch-export-customers.php | 4 +- .../export/class-batch-export-downloads.php | 4 +- .../class-batch-export-file-downloads.php | 4 +- .../export/class-batch-export-sales.php | 4 +- includes/admin/reporting/reports.php | 8 +- includes/admin/settings/display-settings.php | 4 +- includes/admin/tools.php | 2 +- .../class-cs-tools-recount-all-stats.php | 4 +- includes/admin/tracking.php | 2 +- includes/admin/upgrades/upgrade-functions.php | 2 +- .../admin/upgrades/v3/class-data-migrator.php | 6 +- includes/admin/upload-functions.php | 2 +- .../views/tmpl-order-form-add-order-item.php | 2 +- includes/ajax-functions.php | 12 +-- includes/api/class-cs-api-v2.php | 4 +- includes/api/class-cs-api.php | 12 +-- includes/cart/functions.php | 2 +- includes/class-cs-cli.php | 6 +- includes/class-cs-download.php | 4 +- includes/class-cs-html-elements.php | 4 +- includes/class-cs-register-meta.php | 16 ++-- includes/class-structured-data.php | 2 +- .../database/schemas/class-order-items.php | 2 +- .../database/tables/class-order-items.php | 2 +- includes/deprecated-functions.php | 8 +- includes/download-functions.php | 14 +-- includes/gateways/paypal/admin/notices.php | 2 +- includes/misc-functions.php | 2 +- includes/orders/functions/actions.php | 2 +- includes/orders/functions/orders.php | 4 +- includes/payments/class-cs-payment.php | 4 +- includes/payments/class-payment-stats.php | 2 +- includes/payments/class-payments-query.php | 12 +-- includes/payments/functions.php | 6 +- includes/post-types.php | 18 ++-- includes/process-download.php | 24 ++--- includes/query-filters.php | 2 +- .../class-earnings-by-taxonomy-list-table.php | 2 +- includes/reports/reports-functions.php | 2 +- includes/scripts.php | 4 +- includes/shortcodes.php | 2 +- .../subscriptions/includes/admin/metabox.php | 4 +- .../subscriptions/includes/admin/scripts.php | 2 +- .../subscriptions/includes/admin/settings.php | 2 +- .../includes/cs-subscriptions-db.php | 4 +- .../includes/gateways/cs-recurring-paypal.php | 2 +- .../includes/gateways/cs-recurring-stripe.php | 2 +- .../includes/plugin-content-restriction.php | 22 ++--- includes/subscriptions/subscriptions.php | 6 +- includes/template-functions.php | 18 ++-- includes/theme-compatibility.php | 8 +- includes/user-functions.php | 2 +- includes/widgets.php | 10 +- 73 files changed, 253 insertions(+), 253 deletions(-) diff --git a/commercestore.php b/commercestore.php index e5f44d42c3..877b7c3718 100644 --- a/commercestore.php +++ b/commercestore.php @@ -38,10 +38,10 @@ const CS_FEATURE_VARIABLE_PRICE = true; const CS_FEATURE_MARKETING = false; -const CS_DEFAULT_SLUG = 'products'; // Override with the CS_SLUG constant +const CS_DEFAULT_SLUG = 'store'; // Override with the CS_SLUG constant // @todo replace hardcoding of post_type and taxonomies with the following constants all throughout the codebase -const CS_POST_TYPE = 'download'; +const CS_POST_TYPE = 'csproduct'; const CS_TAG_TYPE = CS_POST_TYPE . '_tag'; const CS_CAT_TYPE = CS_POST_TYPE . '_category'; diff --git a/includes/admin/admin-actions.php b/includes/admin/admin-actions.php index ba543b6dd5..15b4fcbb72 100644 --- a/includes/admin/admin-actions.php +++ b/includes/admin/admin-actions.php @@ -63,7 +63,7 @@ function cs_taxonomies_tabs() { // Get taxonomies $taxonomy = sanitize_key( $_GET['taxonomy'] ); - $taxonomies = get_object_taxonomies( 'download' ); + $taxonomies = get_object_taxonomies( CS_POST_TYPE ); // Bail if current taxonomy is not a download taxonomy if ( ! in_array( $taxonomy, $taxonomies, true ) ) { @@ -85,7 +85,7 @@ function cs_taxonomies_tabs() { function cs_admin_adjust_submenus() { // Get taxonomies - $taxonomies = get_object_taxonomies( 'download' ); + $taxonomies = get_object_taxonomies( CS_POST_TYPE ); // Bail if no taxonomies if ( empty( $taxonomies ) ) { @@ -123,7 +123,7 @@ function cs_taxonomies_modify_menu_highlight() { // Get taxonomies $taxonomy = sanitize_key( $_GET['taxonomy'] ); - $taxonomies = get_object_taxonomies( 'download' ); + $taxonomies = get_object_taxonomies( CS_POST_TYPE ); // Bail if current taxonomy is not a download taxonomy if ( ! in_array( $taxonomy, $taxonomies, true ) ) { @@ -154,8 +154,8 @@ function cs_add_new_modify_menu_highlight() { // Get post_type $post_type = sanitize_key( $_GET['post_type'] ); - // Bail if current post type is not download - if ( 'download' !== $post_type ) { + // Bail if current post type is not ours + if ( CS_POST_TYPE !== $post_type ) { return; } @@ -180,13 +180,13 @@ function cs_display_product_tabs() { ); // Get taxonomies - $taxonomies = get_object_taxonomies( 'download', 'objects' ); + $taxonomies = get_object_taxonomies( CS_POST_TYPE, 'objects' ); foreach ( $taxonomies as $tax => $details ) { $tabs[ $tax ] = array( 'name' => $details->labels->menu_name, 'url' => add_query_arg( array( 'taxonomy' => $tax, - 'post_type' => 'download' + 'post_type' => CS_POST_TYPE ), admin_url( 'edit-tags.php' ) ) ); } diff --git a/includes/admin/admin-footer.php b/includes/admin/admin-footer.php index 57a5feae24..6d44c5ccba 100644 --- a/includes/admin/admin-footer.php +++ b/includes/admin/admin-footer.php @@ -23,7 +23,7 @@ function cs_admin_rate_us( $footer_text ) { global $typenow; - if ( $typenow == 'download' ) { + if ( $typenow == CS_POST_TYPE ) { // VERIFY $rate_text = sprintf( __( 'Thank you for using CommerceStore! Please rate us on WordPress.org', 'commercestore' ), 'https://commercestore.com', 'https://wordpress.org/support/plugin/commercestore/reviews/?rate=5#new-post' diff --git a/includes/admin/admin-pages.php b/includes/admin/admin-pages.php index 319f9b949e..20c60ca484 100644 --- a/includes/admin/admin-pages.php +++ b/includes/admin/admin-pages.php @@ -174,25 +174,25 @@ function cs_is_admin_page( $passed_page = '', $passed_view = '', $include_non_ex $tab = isset( $_GET['tab'] ) ? strtolower( $_GET['tab'] ) : false; switch ( $passed_page ) { - case 'download': + case CS_POST_TYPE: switch ( $passed_view ) { case 'list-table': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' ) { $found = true; } break; case 'edit': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'post.php' ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'post.php' ) { $found = true; } break; case 'new': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'post-new.php' ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'post-new.php' ) { $found = true; } break; default: - if ( ( 'download' === $typenow || 'download' === $post_type ) || 'download' === $post_type || ( 'post-new.php' === $pagenow && 'download' === $post_type ) ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) || CS_POST_TYPE === $post_type || ( 'post-new.php' === $pagenow && CS_POST_TYPE === $post_type ) ) { $found = true; } break; @@ -202,17 +202,17 @@ function cs_is_admin_page( $passed_page = '', $passed_view = '', $include_non_ex switch ( $passed_view ) { case 'list-table': case 'new': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' !== $action && 'download_category' === $taxonomy ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' !== $action && 'download_category' === $taxonomy ) { $found = true; } break; case 'edit': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' === $action && 'download_category' === $taxonomy ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' === $action && 'download_category' === $taxonomy ) { $found = true; } break; default: - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit-tags.php' && 'download_category' === $taxonomy ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit-tags.php' && 'download_category' === $taxonomy ) { $found = true; } break; @@ -222,17 +222,17 @@ function cs_is_admin_page( $passed_page = '', $passed_view = '', $include_non_ex switch ( $passed_view ) { case 'list-table': case 'new': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' !== $action && 'download_tax' === $taxonomy ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' !== $action && 'download_tax' === $taxonomy ) { $found = true; } break; case 'edit': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' === $action && 'download_tax' === $taxonomy ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' === $action && 'download_tax' === $taxonomy ) { $found = true; } break; default: - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit-tags.php' && 'download_tax' === $taxonomy ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit-tags.php' && 'download_tax' === $taxonomy ) { $found = true; } break; @@ -241,17 +241,17 @@ function cs_is_admin_page( $passed_page = '', $passed_view = '', $include_non_ex case 'payments': switch ( $passed_view ) { case 'list-table': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-payment-history' === $page && false === $view ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-payment-history' === $page && false === $view ) { $found = true; } break; case 'edit': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-payment-history' === $page && 'view-order-details' === $view ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-payment-history' === $page && 'view-order-details' === $view ) { $found = true; } break; default: - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-payment-history' === $page ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-payment-history' === $page ) { $found = true; } break; @@ -260,22 +260,22 @@ function cs_is_admin_page( $passed_page = '', $passed_view = '', $include_non_ex case 'discounts': switch ( $passed_view ) { case 'list-table': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-discounts' === $page && false === $cs_action ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-discounts' === $page && false === $cs_action ) { $found = true; } break; case 'edit': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-discounts' === $page && 'edit_discount' === $cs_action ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-discounts' === $page && 'edit_discount' === $cs_action ) { $found = true; } break; case 'new': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-discounts' === $page && 'add_discount' === $cs_action ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-discounts' === $page && 'add_discount' === $cs_action ) { $found = true; } break; default: - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-discounts' === $page ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-discounts' === $page ) { $found = true; } break; @@ -285,37 +285,37 @@ function cs_is_admin_page( $passed_page = '', $passed_view = '', $include_non_ex switch ( $passed_view ) { // If you want to do something like enqueue a script on a particular report's duration, look at $_GET[ 'range' ] case 'earnings': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && ( 'earnings' === $view || '-1' === $view || false === $view ) ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && ( 'earnings' === $view || '-1' === $view || false === $view ) ) { $found = true; } break; case 'downloads': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && 'downloads' === $view ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && 'downloads' === $view ) { $found = true; } break; case 'customers': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && 'customers' === $view ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && 'customers' === $view ) { $found = true; } break; case 'gateways': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && 'gateways' === $view ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && 'gateways' === $view ) { $found = true; } break; case 'taxes': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && 'taxes' === $view ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && 'taxes' === $view ) { $found = true; } break; case 'export': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && 'export' === $view ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page && 'export' === $view ) { $found = true; } break; default: - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page ) { $found = true; } break; @@ -324,52 +324,52 @@ function cs_is_admin_page( $passed_page = '', $passed_view = '', $include_non_ex case 'settings': switch ( $passed_view ) { case 'general': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && ( 'general' === $tab || false === $tab ) ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && ( 'general' === $tab || false === $tab ) ) { $found = true; } break; case 'gateways': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'gateways' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'gateways' === $tab ) { $found = true; } break; case 'emails': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'emails' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'emails' === $tab ) { $found = true; } break; case 'styles': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'styles' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'styles' === $tab ) { $found = true; } break; case 'taxes': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'taxes' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'taxes' === $tab ) { $found = true; } break; case 'extensions': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'extensions' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'extensions' === $tab ) { $found = true; } break; case 'licenses': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'licenses' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'licenses' === $tab ) { $found = true; } break; case 'misc': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'misc' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page && 'misc' === $tab ) { $found = true; } break; case 'marketing': - if ( ( 'download' == $typenow || 'download' === $post_type ) && $pagenow == 'edit.php' && 'cs-settings' === $page && 'marketing' === $tab ) { + if ( ( CS_POST_TYPE == $typenow || CS_POST_TYPE === $post_type ) && $pagenow == 'edit.php' && 'cs-settings' === $page && 'marketing' === $tab ) { $found = true; } break; default: - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-settings' === $page ) { $found = true; } break; @@ -378,68 +378,68 @@ function cs_is_admin_page( $passed_page = '', $passed_view = '', $include_non_ex case 'tools': switch ( $passed_view ) { case 'general': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page && ( 'general' === $tab || false === $tab ) ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page && ( 'general' === $tab || false === $tab ) ) { $found = true; } break; case 'api_keys': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page && 'api_keys' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page && 'api_keys' === $tab ) { $found = true; } break; case 'system_info': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page && 'system_info' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page && 'system_info' === $tab ) { $found = true; } break; case 'logs': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page && 'logs' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page && 'logs' === $tab ) { $found = true; } break; case 'import_export': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page && 'import_export' === $tab ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page && 'import_export' === $tab ) { $found = true; } break; default: - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-tools' === $page ) { $found = true; } break; } break; case 'addons': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-addons' === $page ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-addons' === $page ) { $found = true; } break; case 'customers': switch ( $passed_view ) { case 'list-table': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-customers' === $page && false === $view ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-customers' === $page && false === $view ) { $found = true; } break; case 'overview': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-customers' === $page && 'overview' === $view ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-customers' === $page && 'overview' === $view ) { $found = true; } break; case 'notes': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-customers' === $page && 'notes' === $view ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-customers' === $page && 'notes' === $view ) { $found = true; } break; default: - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-customers' === $page ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-customers' === $page ) { $found = true; } break; } break; case 'reports': - if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' && 'cs-reports' === $page ) { $found = true; } break; @@ -453,7 +453,7 @@ function cs_is_admin_page( $passed_page = '', $passed_view = '', $include_non_ex $admin_pages = cs_get_admin_pages(); // Downloads sub-page or Dashboard page - if ( ( 'download' === $typenow ) || ( $include_non_exclusive && 'index.php' === $pagenow ) ) { + if ( ( CS_POST_TYPE === $typenow ) || ( $include_non_exclusive && 'index.php' === $pagenow ) ) { $found = true; // Registered global pages diff --git a/includes/admin/class-cs-notices.php b/includes/admin/class-cs-notices.php index 901278a751..e4cfd894c5 100644 --- a/includes/admin/class-cs-notices.php +++ b/includes/admin/class-cs-notices.php @@ -381,7 +381,7 @@ private function add_settings_notices() { // URL to fix this $url = add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-settings', 'tab' => 'gateways' ) ); @@ -730,7 +730,7 @@ private function show_debugging_notice() { wp_enqueue_script( 'cs-admin-notices', CS_PLUGIN_URL . 'assets/js/cs-admin-notices.js', array( 'jquery' ), CS_VERSION, true ); $view_url = add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-tools', 'tab' => 'debug_log', ), diff --git a/includes/admin/dashboard-widgets.php b/includes/admin/dashboard-widgets.php index d1d09b0764..1b849e64c3 100644 --- a/includes/admin/dashboard-widgets.php +++ b/includes/admin/dashboard-widgets.php @@ -265,7 +265,7 @@ function cs_load_dashboard_sales_widget( ) { * @return void */ function cs_dashboard_at_a_glance_widget( $items ) { - $num_posts = wp_count_posts( 'download' ); + $num_posts = wp_count_posts( CS_POST_TYPE ); if ( $num_posts && $num_posts->publish ) { $text = _n( '%s ' . cs_get_label_singular(), '%s ' . cs_get_label_plural(), $num_posts->publish, 'commercestore' ); diff --git a/includes/admin/downloads/contextual-help.php b/includes/admin/downloads/contextual-help.php index d897e13f10..6ace6aa06a 100644 --- a/includes/admin/downloads/contextual-help.php +++ b/includes/admin/downloads/contextual-help.php @@ -21,7 +21,7 @@ function cs_downloads_contextual_help() { $screen = get_current_screen(); - if ( $screen->id != 'download' ) + if ( $screen->id != CS_POST_TYPE ) return; $screen->set_help_sidebar( diff --git a/includes/admin/downloads/dashboard-columns.php b/includes/admin/downloads/dashboard-columns.php index cc4884e371..fb7d72a553 100644 --- a/includes/admin/downloads/dashboard-columns.php +++ b/includes/admin/downloads/dashboard-columns.php @@ -50,7 +50,7 @@ function cs_download_columns( $download_columns ) { function cs_render_download_columns( $column_name, $post_id ) { // Bail if not a download - if ( get_post_type( $post_id ) !== 'download' ) { + if ( get_post_type( $post_id ) !== CS_POST_TYPE ) { return; } @@ -127,7 +127,7 @@ function cs_sortable_download_columns( $columns ) { */ function cs_sort_downloads( $vars ) { // Check if we're viewing the "download" post type - if ( isset( $vars['post_type'] ) && 'download' == $vars['post_type'] ) { + if ( isset( $vars['post_type'] ) && CS_POST_TYPE == $vars['post_type'] ) { // Check if 'orderby' is set to "sales" if ( isset( $vars['orderby'] ) && 'sales' == $vars['orderby'] ) { $vars = array_merge( @@ -173,7 +173,7 @@ function cs_sort_downloads( $vars ) { * @return array Array of all sort variables */ function cs_filter_downloads( $vars ) { - if ( isset( $vars['post_type'] ) && 'download' == $vars['post_type'] ) { + if ( isset( $vars['post_type'] ) && CS_POST_TYPE == $vars['post_type'] ) { // If an author ID was passed, use it if ( isset( $_REQUEST['author'] ) && ! current_user_can( 'view_shop_reports' ) ) { @@ -220,8 +220,8 @@ function cs_download_load() { function cs_add_download_filters() { global $typenow; - // Checks if the current post type is 'download' - if ( $typenow !== 'download') { + // Checks if the current post type is CS_POST_TYPE + if ( $typenow !== CS_POST_TYPE) { return; } @@ -272,7 +272,7 @@ function cs_add_download_filters() { function cs_remove_month_filter( $dates ) { global $typenow; - if ( 'download' === $typenow ) { + if ( CS_POST_TYPE === $typenow ) { $dates = array(); } @@ -291,7 +291,7 @@ function cs_remove_month_filter( $dates ) { function cs_price_field_quick_edit( $column_name, $post_type ) { // Bail if not price or download - if ( $column_name !== 'price' || $post_type !== 'download' ) { + if ( $column_name !== 'price' || $post_type !== CS_POST_TYPE ) { return; } ?> @@ -321,7 +321,7 @@ function cs_price_field_quick_edit( $column_name, $post_type ) { * @return void */ function cs_price_save_quick_edit( $post_id ) { - if ( ! isset( $_POST['post_type']) || 'download' !== $_POST['post_type'] ) { + if ( ! isset( $_POST['post_type']) || CS_POST_TYPE !== $_POST['post_type'] ) { return; } diff --git a/includes/admin/downloads/metabox.php b/includes/admin/downloads/metabox.php index 31645653f8..5bd90b315d 100644 --- a/includes/admin/downloads/metabox.php +++ b/includes/admin/downloads/metabox.php @@ -21,7 +21,7 @@ * @return void */ function cs_add_download_meta_box() { - $post_types = apply_filters( 'cs_download_metabox_post_types', array( 'download' ) ); + $post_types = apply_filters( 'cs_download_metabox_post_types', array( CS_POST_TYPE ) ); foreach ( $post_types as $post_type ) { @@ -923,11 +923,11 @@ function cs_render_file_row( $key, $args, $post_id, $index ) { function cs_download_media_strings( $strings ) { global $post; - if ( empty( $post ) || ( $post->post_type !== 'download' ) ) { + if ( empty( $post ) || ( $post->post_type !== CS_POST_TYPE ) ) { return $strings; } - $downloads_object = get_post_type_object( 'download' ); + $downloads_object = get_post_type_object( CS_POST_TYPE ); $labels = $downloads_object->labels; $strings['insertIntoPost'] = sprintf( __( 'Insert into %s', 'commercestore' ), strtolower( $labels->singular_name ) ); @@ -1139,7 +1139,7 @@ function cs_render_download_quantity_option( $post_id = 0 ) { */ function cs_render_meta_box_shortcode() { - if ( get_post_type() !== 'download' ) { + if ( get_post_type() !== CS_POST_TYPE ) { return; } diff --git a/includes/admin/extensions/abstract-extension.php b/includes/admin/extensions/abstract-extension.php index 002f2c9298..39505173b1 100644 --- a/includes/admin/extensions/abstract-extension.php +++ b/includes/admin/extensions/abstract-extension.php @@ -156,7 +156,7 @@ protected function is_cs_settings_screen() { * @return bool */ protected function is_download_edit_screen() { - return cs_is_admin_page( 'download', 'edit' ) || cs_is_admin_page( 'download', 'new' ); + return cs_is_admin_page( CS_POST_TYPE, 'edit' ) || cs_is_admin_page( CS_POST_TYPE, 'new' ); } /** @@ -315,7 +315,7 @@ protected function get_link_parameters( ProductData $product_data ) { 'button_text' => sprintf( __( 'View %s', 'commercestore' ), cs_get_label_plural() ), 'href' => add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, ), admin_url( 'edit.php' ) ), @@ -327,7 +327,7 @@ protected function get_link_parameters( ProductData $product_data ) { 'button_text' => sprintf( __( 'Configure %s', 'commercestore' ), $product_data->title ), 'href' => add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-settings', 'tab' => urlencode( $tab ), 'section' => urlencode( $section ), diff --git a/includes/admin/extensions/class-extension-manager.php b/includes/admin/extensions/class-extension-manager.php index 88ec0e7db7..0612510782 100644 --- a/includes/admin/extensions/class-extension-manager.php +++ b/includes/admin/extensions/class-extension-manager.php @@ -282,7 +282,7 @@ public function install() { $url = esc_url_raw( add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-addons', ), admin_url( 'edit.php' ) diff --git a/includes/admin/extensions/product-education/class-reviews.php b/includes/admin/extensions/product-education/class-reviews.php index e7cc0c7ea2..8e582c781d 100644 --- a/includes/admin/extensions/product-education/class-reviews.php +++ b/includes/admin/extensions/product-education/class-reviews.php @@ -127,7 +127,7 @@ public function maybe_do_metabox() { 'cs-reviews-status', __( 'Product Reviews', 'commercestore' ), array( $this, 'settings_field' ), - 'download', + CS_POST_TYPE, 'side', 'low' ); diff --git a/includes/admin/import/class-batch-import-downloads.php b/includes/admin/import/class-batch-import-downloads.php index bca8df522f..58805aa808 100644 --- a/includes/admin/import/class-batch-import-downloads.php +++ b/includes/admin/import/class-batch-import-downloads.php @@ -93,7 +93,7 @@ public function process_step() { // Import Download $args = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_title' => '', 'post_name' => '', 'post_status' => '', diff --git a/includes/admin/import/class-batch-import-payments.php b/includes/admin/import/class-batch-import-payments.php index ce08a87212..9f98f8f7cf 100644 --- a/includes/admin/import/class-batch-import-payments.php +++ b/includes/admin/import/class-batch-import-payments.php @@ -310,7 +310,7 @@ public function create_payment( $row = array() ) { foreach( $downloads as $download ) { if( is_array( $download ) ) { - $download_name = $download['download']; + $download_name = $download[CS_POST_TYPE]; $price = $download['price']; $tax = $download['tax']; $price_id = $download['price_id']; @@ -521,7 +521,7 @@ private function maybe_create_download( $title = '' ) { return false; } - $download = get_page_by_title( $title, OBJECT, 'download' ); + $download = get_page_by_title( $title, OBJECT, CS_POST_TYPE ); if( $download ) { @@ -530,7 +530,7 @@ private function maybe_create_download( $title = '' ) { } else { $args = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_title' => $title, 'post_author' => get_current_user_id() ); @@ -579,7 +579,7 @@ public function get_downloads_from_cs( $data_str ) { $price_id = isset( $matches[1][1] ) ? trim( $matches[1][1] ) : false; $d_array[] = array( - 'download' => trim( $d[0] ), + CS_POST_TYPE => trim( $d[0] ), 'price' => $price - $tax, 'tax' => $tax, 'price_id' => $price_id, diff --git a/includes/admin/reporting/class-base-logs-list-table.php b/includes/admin/reporting/class-base-logs-list-table.php index ceb773e74c..e68056d283 100644 --- a/includes/admin/reporting/class-base-logs-list-table.php +++ b/includes/admin/reporting/class-base-logs-list-table.php @@ -162,7 +162,7 @@ public function get_filtered_end_date() { * @return int Download ID. */ public function get_filtered_download() { - return absint( $this->get_request_var( 'download', false ) ); + return absint( $this->get_request_var( CS_POST_TYPE, false ) ); } /** @@ -238,7 +238,7 @@ public function log_views() { */ public function downloads_filter() { $downloads = get_posts( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_status' => 'any', 'posts_per_page' => -1, 'orderby' => 'title', diff --git a/includes/admin/reporting/class-categories-reports-table.php b/includes/admin/reporting/class-categories-reports-table.php index dc06b5023f..03d2172dd7 100644 --- a/includes/admin/reporting/class-categories-reports-table.php +++ b/includes/admin/reporting/class-categories-reports-table.php @@ -173,7 +173,7 @@ public function get_data() { } $downloads = get_posts( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => -1, 'fields' => 'ids', 'tax_query' => array( @@ -223,7 +223,7 @@ public function get_data() { if ( ! empty( $child_terms ) ) { foreach ( $child_terms as $child_term ) { $child_downloads = get_posts( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => -1, 'fields' => 'ids', 'tax_query' => array( diff --git a/includes/admin/reporting/class-download-reports-table.php b/includes/admin/reporting/class-download-reports-table.php index 6d0e57bf25..ee77e7bdfa 100644 --- a/includes/admin/reporting/class-download-reports-table.php +++ b/includes/admin/reporting/class-download-reports-table.php @@ -133,7 +133,7 @@ public function get_category() { */ public function get_total_downloads() { $total = 0; - $counts = wp_count_posts( 'download', 'readable' ); + $counts = wp_count_posts( CS_POST_TYPE, 'readable' ); foreach( $counts as $count ) { $total += $count; @@ -180,7 +180,7 @@ public function query() { $category = $this->get_category(); $args = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_status' => 'publish', 'order' => $order, 'fields' => 'ids', diff --git a/includes/admin/reporting/class-export-download-history.php b/includes/admin/reporting/class-export-download-history.php index ddf32cff76..9626409aa7 100644 --- a/includes/admin/reporting/class-export-download-history.php +++ b/includes/admin/reporting/class-export-download-history.php @@ -59,7 +59,7 @@ public function csv_cols() { 'date' => __( 'Date', 'commercestore' ), 'user' => __( 'Downloaded by', 'commercestore' ), 'ip' => __( 'IP Address', 'commercestore' ), - 'download' => __( 'Product', 'commercestore' ), + CS_POST_TYPE => __( 'Product', 'commercestore' ), 'file' => __( 'File', 'commercestore' ) ); return $cols; @@ -99,7 +99,7 @@ public function get_data() { 'date' => $log->post_date, 'user' => $user, 'ip' => get_post_meta( $log->ID, '_cs_log_ip', true ), - 'download' => get_the_title( $log->post_parent ), + CS_POST_TYPE => get_the_title( $log->post_parent ), 'file' => $file_name ); } diff --git a/includes/admin/reporting/class-file-downloads-logs-list-table.php b/includes/admin/reporting/class-file-downloads-logs-list-table.php index fb57b6f557..8a38294b76 100644 --- a/includes/admin/reporting/class-file-downloads-logs-list-table.php +++ b/includes/admin/reporting/class-file-downloads-logs-list-table.php @@ -69,13 +69,13 @@ public function __construct() { public function column_default( $item, $column_name ) { $base_url = remove_query_arg( 'paged' ); switch ( $column_name ) { - case 'download' : + case CS_POST_TYPE : $download = new CS_Download( $item[ $column_name ] ); $column_value = ! empty( $item['price_id'] ) ? cs_get_download_name( $download->ID, $item['price_id'] ) : cs_get_download_name( $download->ID ); - return '' . $column_value . ''; + return '' . $column_value . ''; case 'customer' : return ! empty( $item[ 'customer' ]->id ) ? '' . $item['customer']->name . '' @@ -103,7 +103,7 @@ public function column_default( $item, $column_name ) { public function get_columns() { return array( 'ID' => __( 'Log ID', 'commercestore' ), - 'download' => cs_get_label_singular(), + CS_POST_TYPE => cs_get_label_singular(), 'customer' => __( 'Customer', 'commercestore' ), 'payment_id' => __( 'Order Number', 'commercestore' ), 'file' => __( 'File', 'commercestore' ), @@ -152,7 +152,7 @@ function get_logs( $log_query = array() ) { if ( empty( $this->file_search ) || ( ! empty( $this->file_search ) && strpos( strtolower( $file_name ), strtolower( $this->get_search() ) ) !== false ) ) { $logs_data[] = array( 'ID' => $log->id, - 'download' => $log->product_id, + CS_POST_TYPE => $log->product_id, 'customer' => new CS_Customer( $customer_id ), 'payment_id' => $log->order_id, 'price_id' => $log->price_id, diff --git a/includes/admin/reporting/class-sales-logs-list-table.php b/includes/admin/reporting/class-sales-logs-list-table.php index fe725bb6b5..ec8aacf26f 100644 --- a/includes/admin/reporting/class-sales-logs-list-table.php +++ b/includes/admin/reporting/class-sales-logs-list-table.php @@ -47,7 +47,7 @@ public function column_default( $item, $column_name ) { $currency = $item['currency']; switch ( $column_name ) { - case 'download': + case CS_POST_TYPE: $download_id = $item[ $column_name ]; $download = cs_get_download( $download_id ); $price_id = ! empty( $item['price_id'] ) @@ -55,7 +55,7 @@ public function column_default( $item, $column_name ) { : 0; $title = $download->get_name( $price_id ); - $return = '' . $title . ''; + $return = '' . $title . ''; break; case 'customer': @@ -96,7 +96,7 @@ public function get_columns() { return array( 'ID' => __( 'Order Number', 'commercestore' ), 'customer' => __( 'Customer', 'commercestore' ), - 'download' => cs_get_label_singular(), + CS_POST_TYPE => cs_get_label_singular(), 'amount' => __( 'Item Amount', 'commercestore' ), 'date' => __( 'Date', 'commercestore' ), ); @@ -235,7 +235,7 @@ public function get_logs( $log_query = array() ) { 'ID' => $order->get_number(), 'order_id' => $order->id, 'customer' => cs_get_customer( $order->customer_id ), - 'download' => $order_item->product_id, + CS_POST_TYPE => $order_item->product_id, 'price_id' => $order_item->price_id, 'item_price' => $order_item->amount, 'amount' => $order_item->total, diff --git a/includes/admin/reporting/export/class-batch-export-customers.php b/includes/admin/reporting/export/class-batch-export-customers.php index 54b88ae42b..9ebc47158b 100644 --- a/includes/admin/reporting/export/class-batch-export-customers.php +++ b/includes/admin/reporting/export/class-batch-export-customers.php @@ -207,8 +207,8 @@ public function set_properties( $request ) { ? absint( $request['taxonomy'] ) : null; - $this->download = isset( $request['download'] ) - ? absint( $request['download'] ) + $this->download = isset( $request[CS_POST_TYPE] ) + ? absint( $request[CS_POST_TYPE] ) : null; $this->price_id = ! empty( $request['cs_price_option'] ) && 0 !== $request['cs_price_option'] diff --git a/includes/admin/reporting/export/class-batch-export-downloads.php b/includes/admin/reporting/export/class-batch-export-downloads.php index db954e441e..5110cf39b4 100644 --- a/includes/admin/reporting/export/class-batch-export-downloads.php +++ b/includes/admin/reporting/export/class-batch-export-downloads.php @@ -83,7 +83,7 @@ public function get_data() { ); $args = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => 30, 'paged' => $this->step, 'orderby' => 'ID', @@ -196,7 +196,7 @@ public function get_data() { */ public function get_percentage_complete() { $args = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => - 1, 'post_status' => 'any', 'fields' => 'ids', diff --git a/includes/admin/reporting/export/class-batch-export-file-downloads.php b/includes/admin/reporting/export/class-batch-export-file-downloads.php index 93e136e812..3078e1cfb2 100644 --- a/includes/admin/reporting/export/class-batch-export-file-downloads.php +++ b/includes/admin/reporting/export/class-batch-export-file-downloads.php @@ -44,7 +44,7 @@ public function csv_cols() { 'user' => __( 'Downloaded by', 'commercestore' ), 'ip' => __( 'IP Address', 'commercestore' ), 'user_agent' => __( 'User Agent', 'commercestore' ), - 'download' => __( 'Product', 'commercestore' ), + CS_POST_TYPE => __( 'Product', 'commercestore' ), 'file' => __( 'File', 'commercestore' ), ); @@ -102,7 +102,7 @@ public function get_data() { 'user' => $customer, 'ip' => $log->ip, 'user_agent' => $log->user_agent, - 'download' => get_the_title( $log->product_id ), + CS_POST_TYPE => get_the_title( $log->product_id ), 'file' => $file_name, ); } diff --git a/includes/admin/reporting/export/class-batch-export-sales.php b/includes/admin/reporting/export/class-batch-export-sales.php index 7689649b87..aeabc2e176 100644 --- a/includes/admin/reporting/export/class-batch-export-sales.php +++ b/includes/admin/reporting/export/class-batch-export-sales.php @@ -42,7 +42,7 @@ public function csv_cols() { 'email' => __( 'Email', 'commercestore' ), 'first_name' => __( 'First Name', 'commercestore' ), 'last_name' => __( 'Last Name', 'commercestore' ), - 'download' => cs_get_label_singular(), + CS_POST_TYPE => cs_get_label_singular(), 'quantity' => __( 'Quantity', 'commercestore' ), 'amount' => __( 'Item Amount', 'commercestore' ), 'payment_id' => __( 'Payment ID', 'commercestore' ), @@ -104,7 +104,7 @@ public function get_data() { 'email' => $order->email, 'first_name' => isset( $user_info['first_name'] ) ? $user_info['first_name'] : '', 'last_name' => isset( $user_info['last_name'] ) ? $user_info['last_name'] : '', - 'download' => $download_title, + CS_POST_TYPE => $download_title, 'quantity' => $item->quantity, 'amount' => $order->total, 'payment_id' => $order->id, diff --git a/includes/admin/reporting/reports.php b/includes/admin/reporting/reports.php index 6d1dd6a222..6c686cef00 100644 --- a/includes/admin/reporting/reports.php +++ b/includes/admin/reporting/reports.php @@ -562,7 +562,7 @@ function cs_register_downloads_report( $reports ) { $reports->add_report( 'downloads', array( 'label' => cs_get_label_plural(), 'priority' => 10, - 'icon' => 'download', + 'icon' => CS_POST_TYPE, 'endpoints' => array( 'tiles' => $tiles, 'charts' => $charts, @@ -1798,7 +1798,7 @@ function cs_register_file_downloads_report( $reports ) { $reports->add_report( 'file_downloads', array( 'label' => __( 'File Downloads', 'commercestore' ), - 'icon' => 'download', + 'icon' => CS_POST_TYPE, 'priority' => 30, 'endpoints' => array( 'tiles' => $tiles, @@ -2843,7 +2843,7 @@ function display_export_report() {

html->product_dropdown( array( - 'name' => 'download', + 'name' => CS_POST_TYPE, 'id' => 'cs_customer_export_download', 'chosen' => true, /* translators: the plural post type label */ diff --git a/includes/admin/settings/display-settings.php b/includes/admin/settings/display-settings.php index 4139d9921f..b50ab69242 100644 --- a/includes/admin/settings/display-settings.php +++ b/includes/admin/settings/display-settings.php @@ -78,7 +78,7 @@ function cs_options_page_primary_nav( $tabs, $active_tab = '' ) { $tab_url = add_query_arg( array( 'settings-updated' => false, - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-settings', 'tab' => $tab_id, ), @@ -129,7 +129,7 @@ function cs_options_page_secondary_nav( $active_tab = '', $section = '', $sectio // Tab & Section $tab_url = add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-settings', 'tab' => $active_tab, 'section' => $section_id, diff --git a/includes/admin/tools.php b/includes/admin/tools.php index d44ca5b0e9..7ffbaca904 100644 --- a/includes/admin/tools.php +++ b/includes/admin/tools.php @@ -1659,7 +1659,7 @@ function cs_redirect_sales_log() { ); $args_to_remap = array( - 'download' => 'product-id', + CS_POST_TYPE => 'product-id', 'start-date' => 'start-date', 'end-date' => 'end-date' ); diff --git a/includes/admin/tools/class-cs-tools-recount-all-stats.php b/includes/admin/tools/class-cs-tools-recount-all-stats.php index cbb5e8543d..3d11177059 100644 --- a/includes/admin/tools/class-cs-tools-recount-all-stats.php +++ b/includes/admin/tools/class-cs-tools-recount-all-stats.php @@ -37,7 +37,7 @@ class CS_Tools_Recount_All_Stats extends CS_Tools_Recount_Download_Stats { */ public function get_percentage_complete() { $percentage = 100; - $total = array_sum( (array) wp_count_posts( 'download' ) ); + $total = array_sum( (array) wp_count_posts( CS_POST_TYPE ) ); if ( $total > 0 ) { $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; @@ -96,7 +96,7 @@ private function get_download_ids() { if ( null === $this->download_ids ) { $this->download_ids = get_posts( array( 'post_status' => 'any', - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => $this->per_step, 'offset' => ( $this->step - 1 ) * $this->per_step, 'fields' => 'ids', diff --git a/includes/admin/tracking.php b/includes/admin/tracking.php index ce6a688790..d26d7c5a7d 100644 --- a/includes/admin/tracking.php +++ b/includes/admin/tracking.php @@ -107,7 +107,7 @@ private function setup_data() { $data['active_plugins'] = $active_plugins; $data['inactive_plugins'] = $plugins; $data['active_gateways'] = array_keys( cs_get_enabled_payment_gateways() ); - $data['products'] = wp_count_posts( 'download' )->publish; + $data['products'] = wp_count_posts( CS_POST_TYPE )->publish; $data['download_label'] = cs_get_label_singular( true ); $data['locale'] = get_locale(); diff --git a/includes/admin/upgrades/upgrade-functions.php b/includes/admin/upgrades/upgrade-functions.php index 27d38f66fe..410e12f9af 100644 --- a/includes/admin/upgrades/upgrade-functions.php +++ b/includes/admin/upgrades/upgrade-functions.php @@ -422,7 +422,7 @@ function cs_v131_upgrades() { cs_set_time_limit(); $query = new WP_Query( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => -1, 'post_status' => 'publish' ) ); diff --git a/includes/admin/upgrades/v3/class-data-migrator.php b/includes/admin/upgrades/v3/class-data-migrator.php index 97bc1a6584..05dce6bafe 100644 --- a/includes/admin/upgrades/v3/class-data-migrator.php +++ b/includes/admin/upgrades/v3/class-data-migrator.php @@ -331,7 +331,7 @@ public static function logs( $data = null ) { $log_data = array( 'object_id' => $data->post_parent, - 'object_type' => 'download', + 'object_type' => CS_POST_TYPE, 'user_id' => ! empty( $meta_to_migrate['_cs_log_user'] ) ? $meta_to_migrate['_cs_log_user'] : $data->post_author, 'type' => $data->slug, 'title' => $data->post_title, @@ -899,7 +899,7 @@ public static function orders( $data = null ) { 'product_name' => $product_name, 'price_id' => $price_id, 'cart_index' => $key, - 'type' => 'download', + 'type' => CS_POST_TYPE, 'status' => $order_status, 'quantity' => $cart_item['quantity'], 'amount' => (float) $cart_item['item_price'], @@ -1046,7 +1046,7 @@ public static function orders( $data = null ) { 'product_name' => $download->post_name, 'price_id' => null, 'cart_index' => $cart_index, - 'type' => 'download', + 'type' => CS_POST_TYPE, 'quantity' => 1, 'amount' => (float) $payment_meta['amount'], 'subtotal' => (float) $payment_meta['amount'], diff --git a/includes/admin/upload-functions.php b/includes/admin/upload-functions.php index 8494e97d64..c8a0dbbfe7 100644 --- a/includes/admin/upload-functions.php +++ b/includes/admin/upload-functions.php @@ -29,7 +29,7 @@ function cs_change_downloads_upload_dir() { global $pagenow; if ( ! empty( $_REQUEST['post_id'] ) && ( 'async-upload.php' == $pagenow || 'media-upload.php' == $pagenow ) ) { - if ( 'download' == get_post_type( $_REQUEST['post_id'] ) ) { + if ( CS_POST_TYPE == get_post_type( $_REQUEST['post_id'] ) ) { cs_create_protection_files( true ); add_filter( 'upload_dir', 'cs_set_upload_dir' ); } diff --git a/includes/admin/views/tmpl-order-form-add-order-item.php b/includes/admin/views/tmpl-order-form-add-order-item.php index 4ea7a770b6..345740404f 100644 --- a/includes/admin/views/tmpl-order-form-add-order-item.php +++ b/includes/admin/views/tmpl-order-form-add-order-item.php @@ -22,7 +22,7 @@ 'fields' => 'ids', 'orderby' => 'date', 'order' => 'ASC', - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => 25, 'post_status' => array( 'publish', diff --git a/includes/ajax-functions.php b/includes/ajax-functions.php index 03243680e6..6eab049d3b 100644 --- a/includes/ajax-functions.php +++ b/includes/ajax-functions.php @@ -386,7 +386,7 @@ function cs_ajax_remove_discount() { /** * Allow for custom remove discount code handling. - * + * * @since 2.11.4 */ $return = apply_filters( 'cs_ajax_remove_discount_response', $return ); @@ -451,7 +451,7 @@ function cs_ajax_get_download_title() { $post_type = get_post_type( $post_id ); $title = 'fail'; - if ( 'download' === $post_type ) { + if ( CS_POST_TYPE === $post_type ) { $post_title = get_the_title( $_POST['download_id'] ); if ( $post_title ) { echo $title = $post_title; @@ -643,7 +643,7 @@ function cs_ajax_download_search() { $args = array( 'orderby' => 'title', 'order' => 'ASC', - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => 50, 'post_status' => implode( ',', $status ), // String 'post__not_in' => $excludes, // Array @@ -844,7 +844,7 @@ function cs_check_for_download_price_variations() { $download_id = intval( $_POST['download_id'] ); $download = get_post( $download_id ); - if ( 'download' != $download->post_type ) { + if ( CS_POST_TYPE != $download->post_type ) { die( '-2' ); } @@ -953,8 +953,8 @@ function cs_ajax_add_order_item() { ? sanitize_text_field( $_POST['nonce'] ) : ''; - $download = isset( $_POST['download'] ) - ? cs_parse_product_dropdown_value( sanitize_text_field( $_POST['download'] ) ) + $download = isset( $_POST[CS_POST_TYPE] ) + ? cs_parse_product_dropdown_value( sanitize_text_field( $_POST[CS_POST_TYPE] ) ) : array(); $country = isset( $_POST['country'] ) diff --git a/includes/api/class-cs-api-v2.php b/includes/api/class-cs-api-v2.php index 316e3b55d7..7b5cf94698 100644 --- a/includes/api/class-cs-api-v2.php +++ b/includes/api/class-cs-api-v2.php @@ -38,7 +38,7 @@ public function get_products( $args = array() ) { $products['products'] = array(); $query_args = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => $this->per_page(), 'suppress_filters' => true, 'paged' => $this->get_paged(), @@ -157,7 +157,7 @@ public function get_products( $args = array() ) { } else { - if ( get_post_type( $args['product'] ) == 'download' ) { + if ( get_post_type( $args['product'] ) == CS_POST_TYPE ) { $product_info = get_post( $args['product'] ); $products['products'][0] = $this->get_product_data( $product_info ); diff --git a/includes/api/class-cs-api.php b/includes/api/class-cs-api.php index d4a925611f..97ee27c8c7 100644 --- a/includes/api/class-cs-api.php +++ b/includes/api/class-cs-api.php @@ -1100,7 +1100,7 @@ public function get_products( $args = array() ) { $products['products'] = array(); $parameters = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => $this->per_page(), 'suppress_filters' => true, 'paged' => $this->get_paged(), @@ -1120,7 +1120,7 @@ public function get_products( $args = array() ) { } } } else { - if ( get_post_type( $args['product'] ) == 'download' ) { + if ( get_post_type( $args['product'] ) == CS_POST_TYPE ) { $product_info = get_post( $args['product'] ); $products['products'][0] = $this->get_product_data( $product_info ); @@ -1301,14 +1301,14 @@ public function get_stats( $args = array() ) { } } } elseif ( $args['product'] == 'all' ) { - $products = get_posts( array( 'post_type' => 'download', 'nopaging' => true ) ); + $products = get_posts( array( 'post_type' => CS_POST_TYPE, 'nopaging' => true ) ); $i = 0; foreach ( $products as $product_info ) { $sales['sales'][ $i ] = array( $product_info->post_name => cs_get_download_sales_stats( $product_info->ID ) ); $i ++; } } else { - if ( get_post_type( $args['product'] ) == 'download' ) { + if ( get_post_type( $args['product'] ) == CS_POST_TYPE ) { $product_info = get_post( $args['product'] ); $sales['sales'][0] = array( $product_info->post_name => cs_get_download_sales_stats( $args['product'] ) ); } else { @@ -1417,7 +1417,7 @@ public function get_stats( $args = array() ) { } } } elseif ( $args['product'] == 'all' ) { - $products = get_posts( array( 'post_type' => 'download', 'nopaging' => true ) ); + $products = get_posts( array( 'post_type' => CS_POST_TYPE, 'nopaging' => true ) ); $i = 0; foreach ( $products as $product_info ) { @@ -1425,7 +1425,7 @@ public function get_stats( $args = array() ) { $i ++; } } else { - if ( get_post_type( $args['product'] ) == 'download' ) { + if ( get_post_type( $args['product'] ) == CS_POST_TYPE ) { $product_info = get_post( $args['product'] ); $earnings['earnings'][0] = array( $product_info->post_name => cs_get_download_earnings_stats( $args['product'] ) ); } else { diff --git a/includes/cart/functions.php b/includes/cart/functions.php index a6022ee11f..fad556db18 100644 --- a/includes/cart/functions.php +++ b/includes/cart/functions.php @@ -479,7 +479,7 @@ function cs_add_collection_to_cart( $taxonomy, $terms ) { $cart_item_ids = array(); $items = get_posts( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => -1, $taxonomy => $terms ) ); diff --git a/includes/class-cs-cli.php b/includes/class-cs-cli.php index 547ffc3cf8..452d88494b 100644 --- a/includes/class-cs-cli.php +++ b/includes/class-cs-cli.php @@ -564,7 +564,7 @@ public function payments( $args, $assoc_args ) { // No specified product if ( ! $id ) { $products = get_posts( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'orderby' => 'rand', 'order' => 'ASC', 'posts_per_page' => rand( 1, 3 ), @@ -572,7 +572,7 @@ public function payments( $args, $assoc_args ) { } else { $product = get_post( $id ); - if ( 'download' !== $product->post_type ) { + if ( CS_POST_TYPE !== $product->post_type ) { WP_CLI::error( __( 'Specified ID is not a product', 'commercestore' ) ); return; @@ -741,7 +741,7 @@ public function create_discounts( $args, $assoc_args ) { ) ); $download_ids = get_posts( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => 2, 'fields' => 'ids', 'orderby' => 'rand', diff --git a/includes/class-cs-download.php b/includes/class-cs-download.php index 5dac1e03ff..ed6c153e60 100644 --- a/includes/class-cs-download.php +++ b/includes/class-cs-download.php @@ -165,7 +165,7 @@ private function setup_download( $download ) { return false; } - if ( 'download' !== $download->post_type ) { + if ( CS_POST_TYPE !== $download->post_type ) { return false; } @@ -203,7 +203,7 @@ public function create( $data = array() ) { } $defaults = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_status' => 'draft', 'post_title' => __( 'New Download Product', 'commercestore' ) ); diff --git a/includes/class-cs-html-elements.php b/includes/class-cs-html-elements.php index 02f26e7d17..19a47c063d 100644 --- a/includes/class-cs-html-elements.php +++ b/includes/class-cs-html-elements.php @@ -44,7 +44,7 @@ public function product_dropdown( $args = array() ) { 'show_variations_only' => false, 'placeholder' => sprintf( __( 'Choose a %s', 'commercestore' ), cs_get_label_singular() ), 'data' => array( - 'search-type' => 'download', + 'search-type' => CS_POST_TYPE, 'search-placeholder' => sprintf( __( 'Search %s', 'commercestore' ), cs_get_label_plural() ), ), 'required' => false, @@ -53,7 +53,7 @@ public function product_dropdown( $args = array() ) { $args = wp_parse_args( $args, $defaults ); $product_args = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page' => $args['number'], diff --git a/includes/class-cs-register-meta.php b/includes/class-cs-register-meta.php index a2b679fead..36fa3b0440 100644 --- a/includes/class-cs-register-meta.php +++ b/includes/class-cs-register-meta.php @@ -69,7 +69,7 @@ public function register_download_meta() { 'post', '_cs_download_earnings', array( - 'object_subtype' => 'download', + 'object_subtype' => CS_POST_TYPE, 'sanitize_callback' => 'cs_sanitize_amount', 'type' => 'float', 'description' => __( 'The total earnings for the specified product', 'commercestore' ), @@ -80,7 +80,7 @@ public function register_download_meta() { 'post', '_cs_download_sales', array( - 'object_subtype' => 'download', + 'object_subtype' => CS_POST_TYPE, 'sanitize_callback' => array( $this, 'intval_wrapper' ), 'type' => 'float', 'description' => __( 'The number of sales for the specified product.', 'commercestore' ), @@ -91,7 +91,7 @@ public function register_download_meta() { 'post', 'cs_price', array( - 'object_subtype' => 'download', + 'object_subtype' => CS_POST_TYPE, 'sanitize_callback' => array( $this, 'sanitize_price' ), 'type' => 'float', 'description' => __( 'The price of the product.', 'commercestore' ), @@ -107,7 +107,7 @@ public function register_download_meta() { 'post', 'cs_variable_prices', array( - 'object_subtype' => 'download', + 'object_subtype' => CS_POST_TYPE, 'sanitize_callback' => array( $this, 'sanitize_variable_prices' ), 'single' => true, 'type' => 'object', @@ -140,7 +140,7 @@ public function register_download_meta() { 'post', 'cs_download_files', array( - 'object_subtype' => 'download', + 'object_subtype' => CS_POST_TYPE, 'sanitize_callback' => array( $this, 'sanitize_files' ), 'type' => 'array', 'description' => __( 'The files associated with the product, available for download.', 'commercestore' ), @@ -151,7 +151,7 @@ public function register_download_meta() { 'post', '_cs_bundled_products', array( - 'object_subtype' => 'download', + 'object_subtype' => CS_POST_TYPE, 'sanitize_callback' => array( $this, 'sanitize_array' ), 'single' => true, 'type' => 'array', @@ -171,7 +171,7 @@ public function register_download_meta() { 'post', '_cs_button_behavior', array( - 'object_subtype' => 'download', + 'object_subtype' => CS_POST_TYPE, 'sanitize_callback' => 'sanitize_text_field', 'type' => 'string', 'description' => __( "Defines how this product's 'Purchase' button should behave, either add to cart or buy now", 'commercestore' ), @@ -183,7 +183,7 @@ public function register_download_meta() { 'post', '_cs_default_price_id', array( - 'object_subtype' => 'download', + 'object_subtype' => CS_POST_TYPE, 'sanitize_callback' => array( $this, 'intval_wrapper' ), 'type' => 'int', 'description' => __( 'When variable pricing is enabled, this value defines which option should be chosen by default.', 'commercestore' ), diff --git a/includes/class-structured-data.php b/includes/class-structured-data.php index 36de4b3c87..03ac6d8939 100644 --- a/includes/class-structured-data.php +++ b/includes/class-structured-data.php @@ -94,7 +94,7 @@ private function set_data( $data = null ) { * @return string */ public function generate_structured_data( $context = false, $args = null ) { - if ( is_singular( 'download' ) || 'download' === $context ) { + if ( is_singular( CS_POST_TYPE ) || CS_POST_TYPE === $context ) { $this->generate_download_data( $args ); } diff --git a/includes/database/schemas/class-order-items.php b/includes/database/schemas/class-order-items.php index 36ce6dd171..5379e16d6c 100644 --- a/includes/database/schemas/class-order-items.php +++ b/includes/database/schemas/class-order-items.php @@ -108,7 +108,7 @@ class Order_Items extends Schema { 'name' => 'type', 'type' => 'varchar', 'length' => '20', - 'default' => 'download', + 'default' => CS_POST_TYPE, // VERIFY 'sortable' => true, 'transition' => true ), diff --git a/includes/database/tables/class-order-items.php b/includes/database/tables/class-order-items.php index b85b1b1e8e..5be927b5ee 100644 --- a/includes/database/tables/class-order-items.php +++ b/includes/database/tables/class-order-items.php @@ -71,7 +71,7 @@ protected function set_schema() { product_name text NOT NULL default '', price_id bigint(20) unsigned default null, cart_index bigint(20) unsigned NOT NULL default '0', - type varchar(20) NOT NULL default 'download', + type varchar(20) NOT NULL default CS_POST_TYPE, status varchar(20) NOT NULL default 'pending', quantity int signed NOT NULL default '0', amount decimal(18,9) NOT NULL default '0', diff --git a/includes/deprecated-functions.php b/includes/deprecated-functions.php index 57b5fd9823..862a78e460 100644 --- a/includes/deprecated-functions.php +++ b/includes/deprecated-functions.php @@ -747,7 +747,7 @@ function cs_microdata_title( $title, $id = 0 ) { return $title; } - if ( $post->ID == $id && is_singular( 'download' ) && 'download' == get_post_type( intval( $id ) ) ) { + if ( $post->ID == $id && is_singular( CS_POST_TYPE ) && CS_POST_TYPE == get_post_type( intval( $id ) ) ) { $title = '' . $title . ''; } @@ -774,7 +774,7 @@ function cs_microdata_wrapper_open( $query ) { return; } - if ( $query && ! empty( $query->query['post_type'] ) && $query->query['post_type'] == 'download' && is_singular( 'download' ) && $query->is_main_query() ) { + if ( $query && ! empty( $query->query['post_type'] ) && $query->query['post_type'] == CS_POST_TYPE && is_singular( CS_POST_TYPE ) && $query->is_main_query() ) { $microdata_open = true; echo '
'; } @@ -802,7 +802,7 @@ function cs_microdata_wrapper_close() { return; } - if ( $post && $post->post_type == 'download' && is_singular( 'download' ) && is_main_query() ) { + if ( $post && $post->post_type == CS_POST_TYPE && is_singular( CS_POST_TYPE ) && is_main_query() ) { $microdata_close = true; echo '
'; } @@ -831,7 +831,7 @@ function cs_microdata_description( $content ) { return $content; } - if ( $post && $post->post_type == 'download' && is_singular( 'download' ) && is_main_query() ) { + if ( $post && $post->post_type == CS_POST_TYPE && is_singular( CS_POST_TYPE ) && is_main_query() ) { $microdata_description = true; $content = apply_filters( 'cs_microdata_wrapper', '
' . $content . '
' ); } diff --git a/includes/download-functions.php b/includes/download-functions.php index d208ee9ae7..229d66320d 100644 --- a/includes/download-functions.php +++ b/includes/download-functions.php @@ -33,7 +33,7 @@ function cs_get_download_by( $field = '', $value = '' ) { case 'id': $download = get_post( $value ); - if ( 'download' !== get_post_type( $download ) ) { + if ( CS_POST_TYPE !== get_post_type( $download ) ) { return false; } @@ -42,7 +42,7 @@ function cs_get_download_by( $field = '', $value = '' ) { case 'slug': case 'name': $download = get_posts( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'name' => $value, 'posts_per_page' => 1, 'post_status' => 'any', @@ -56,7 +56,7 @@ function cs_get_download_by( $field = '', $value = '' ) { case 'sku': $download = get_posts( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'meta_key' => 'cs_sku', 'meta_value' => $value, 'posts_per_page' => 1, @@ -98,7 +98,7 @@ function cs_get_download( $download_id = 0 ) { // Fetch download by name. } else { $args = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'name' => $download_id, 'post_per_page' => 1, 'fields' => 'ids', @@ -823,7 +823,7 @@ function cs_remove_download_logs_on_delete( $download_id = 0 ) { $download_id = absint( $download_id ); // Bail if the post type is not `download`. - if ( 'download' !== get_post_type( $download_id ) ) { + if ( CS_POST_TYPE !== get_post_type( $download_id ) ) { return; } @@ -835,7 +835,7 @@ function cs_remove_download_logs_on_delete( $download_id = 0 ) { // Delete logs. $wpdb->delete( $wpdb->cs_logs, array( 'object_id' => $download_id, - 'object_type' => 'download', + 'object_type' => CS_POST_TYPE, ), array( '%d', '%s' ) ); } add_action( 'delete_post', 'cs_remove_download_logs_on_delete' ); @@ -1528,7 +1528,7 @@ function cs_get_random_download( $post_ids = true ) { */ function cs_get_random_downloads( $num = 3, $post_ids = true ) { $args = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'orderby' => 'rand', 'numberposts' => $num, ); diff --git a/includes/gateways/paypal/admin/notices.php b/includes/gateways/paypal/admin/notices.php index 5d6105d9e3..cf73eb09a9 100644 --- a/includes/gateways/paypal/admin/notices.php +++ b/includes/gateways/paypal/admin/notices.php @@ -38,7 +38,7 @@ ) ), 'cs_notice_nonce' ); $setup_url = add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-settings', 'tab' => 'gateways', 'section' => 'paypal_commerce' diff --git a/includes/misc-functions.php b/includes/misc-functions.php index 2e94fbbe55..461922acf7 100644 --- a/includes/misc-functions.php +++ b/includes/misc-functions.php @@ -25,7 +25,7 @@ function cs_get_admin_base_url() { // Default args $args = array( - 'post_type' => 'download' + 'post_type' => CS_POST_TYPE ); // Default URL diff --git a/includes/orders/functions/actions.php b/includes/orders/functions/actions.php index 2cc5e9605e..984108c512 100644 --- a/includes/orders/functions/actions.php +++ b/includes/orders/functions/actions.php @@ -308,7 +308,7 @@ function cs_add_manual_order( $args = array() ) { 'product_name' => cs_get_download_name( $download['id'], absint( $price_id ) ), 'price_id' => $price_id, 'cart_index' => $cart_key, - 'type' => 'download', + 'type' => CS_POST_TYPE, 'status' => 'complete', 'quantity' => $quantity, 'amount' => $amount, diff --git a/includes/orders/functions/orders.php b/includes/orders/functions/orders.php index 99403f90c4..8c44570598 100644 --- a/includes/orders/functions/orders.php +++ b/includes/orders/functions/orders.php @@ -834,7 +834,7 @@ function cs_build_order( $order_data = array() ) { $download = cs_get_download( $item['id'] ); // Skip if download is missing or not actually a download. - if ( empty( $download ) || ( 'download' !== $download->post_type ) ) { + if ( empty( $download ) || ( CS_POST_TYPE !== $download->post_type ) ) { continue; } @@ -864,7 +864,7 @@ function cs_build_order( $order_data = array() ) { 'product_name' => $item_name, 'price_id' => $price_id, 'cart_index' => $key, - 'type' => 'download', + 'type' => CS_POST_TYPE, 'status' => ! empty( $order_data['status'] ) ? $order_data['status'] : 'pending', 'quantity' => $item['quantity'], 'amount' => $item['item_price'], diff --git a/includes/payments/class-cs-payment.php b/includes/payments/class-cs-payment.php index 7527a657c5..b3138168c4 100644 --- a/includes/payments/class-cs-payment.php +++ b/includes/payments/class-cs-payment.php @@ -1134,7 +1134,7 @@ public function add_download( $download_id = 0, $args = array(), $options = arra $download = new CS_Download( $download_id ); // Bail if this post isn't a download. - if ( ! $download || 'download' !== $download->post_type ) { + if ( ! $download || CS_POST_TYPE !== $download->post_type ) { return false; } @@ -1282,7 +1282,7 @@ public function remove_download( $download_id, $args = array() ) { * * We need to allow this to process though for a missing post ID, in case it's a download that was deleted. */ - if ( ! empty( $download->ID ) && 'download' !== $download->post_type ) { + if ( ! empty( $download->ID ) && CS_POST_TYPE !== $download->post_type ) { return false; } diff --git a/includes/payments/class-payment-stats.php b/includes/payments/class-payment-stats.php index aba0b47529..fb0c6802bd 100644 --- a/includes/payments/class-payment-stats.php +++ b/includes/payments/class-payment-stats.php @@ -228,7 +228,7 @@ public function get_earnings( $download_id = 0, $start_date = false, $end_date = } else { $args = array( 'object_id' => $download_id, - 'object_type' => 'download', + 'object_type' => CS_POST_TYPE, 'type' => 'sale', 'log_type' => false, 'date_created_query' => array( diff --git a/includes/payments/class-payments-query.php b/includes/payments/class-payments-query.php index 16a2eaa966..3686134dc1 100644 --- a/includes/payments/class-payments-query.php +++ b/includes/payments/class-payments-query.php @@ -91,7 +91,7 @@ public function __construct( $args = array() ) { 'search_in_notes' => false, 'children' => false, 'fields' => null, - 'download' => null, + CS_POST_TYPE => null, 'gateway' => null, 'post__in' => null, 'post__not_in' => null, @@ -520,15 +520,15 @@ public function children() { * @since 1.8 */ public function download() { - if ( empty( $this->args['download'] ) ) { + if ( empty( $this->args[CS_POST_TYPE] ) ) { return; } $order_ids = array(); - if ( is_array( $this->args['download'] ) ) { + if ( is_array( $this->args[CS_POST_TYPE] ) ) { $orders = cs_get_order_items( array( - 'product_id__in' => (array) $this->args['download'], + 'product_id__in' => (array) $this->args[CS_POST_TYPE], ) ); foreach ( $orders as $order ) { @@ -537,7 +537,7 @@ public function download() { } } else { $orders = cs_get_order_items( array( - 'product_id' => $this->args['download'], + 'product_id' => $this->args[CS_POST_TYPE], ) ); foreach ( $orders as $order ) { @@ -548,7 +548,7 @@ public function download() { $this->args['id__in'] = $order_ids; - $this->__unset( 'download' ); + $this->__unset( CS_POST_TYPE ); } /** diff --git a/includes/payments/functions.php b/includes/payments/functions.php index 4718762c55..d1aa2f5077 100644 --- a/includes/payments/functions.php +++ b/includes/payments/functions.php @@ -343,7 +343,7 @@ function cs_count_payments( $args = array() ) { 's' => null, 'start-date' => null, 'end-date' => null, - 'download' => null, + CS_POST_TYPE => null, 'gateway' => null, 'type' => 'sale', ) ); @@ -403,9 +403,9 @@ function cs_count_payments( $args = array() ) { } } - if ( ! empty( $args['download'] ) && is_numeric( $args['download'] ) ) { + if ( ! empty( $args[CS_POST_TYPE] ) && is_numeric( $args[CS_POST_TYPE] ) ) { $join = "INNER JOIN {$wpdb->cs_order_items} cs_oi ON cs_o.id = cs_oi.order_id"; - $where .= $wpdb->prepare( ' AND cs_oi.product_id = %d', absint( $args['download'] ) ); + $where .= $wpdb->prepare( ' AND cs_oi.product_id = %d', absint( $args[CS_POST_TYPE] ) ); } if ( ! empty( $args['gateway'] ) ) { diff --git a/includes/post-types.php b/includes/post-types.php index 82dd3b3740..51bd9951ea 100644 --- a/includes/post-types.php +++ b/includes/post-types.php @@ -75,7 +75,7 @@ function cs_setup_cs_post_types() { 'hierarchical' => false, 'supports' => apply_filters( 'cs_download_supports', array( 'title', 'editor', 'thumbnail', 'excerpt', 'revisions', 'author' ) ), ); - register_post_type( 'download', apply_filters( 'cs_download_post_type_args', $download_args ) ); + register_post_type( CS_POST_TYPE, apply_filters( 'cs_download_post_type_args', $download_args ) ); /** Payment Post Type */ @@ -222,7 +222,7 @@ function cs_change_default_title( $title ) { $screen = get_current_screen(); - if ( 'download' === $screen->post_type ) { + if ( CS_POST_TYPE === $screen->post_type ) { $label = cs_get_label_singular(); $title = sprintf( __( 'Enter %s name here', 'commercestore' ), $label ); } @@ -269,8 +269,8 @@ function cs_setup_download_taxonomies() { ), ) ); - register_taxonomy( 'download_category', array( 'download' ), $category_args ); - register_taxonomy_for_object_type( 'download_category', 'download' ); + register_taxonomy( 'download_category', array( CS_POST_TYPE ), $category_args ); + register_taxonomy_for_object_type( 'download_category', CS_POST_TYPE ); /** Tags */ $tag_labels = array( @@ -303,8 +303,8 @@ function cs_setup_download_taxonomies() { ) ); - register_taxonomy( 'download_tag', array( 'download' ), $tag_args ); - register_taxonomy_for_object_type( 'download_tag', 'download' ); + register_taxonomy( 'download_tag', array( CS_POST_TYPE ), $tag_args ); + register_taxonomy_for_object_type( 'download_tag', CS_POST_TYPE ); } add_action( 'init', 'cs_setup_download_taxonomies', 0 ); @@ -428,7 +428,7 @@ function cs_updated_messages( $messages ) { $url2 = cs_get_label_singular(); $url3 = ''; - $messages['download'] = array( + $messages[CS_POST_TYPE] = array( 1 => sprintf( __( '%2$s updated. %1$sView %2$s%3$s.', 'commercestore' ), $url1, $url2, $url3 ), 4 => sprintf( __( '%2$s updated. %1$sView %2$s%3$s.', 'commercestore' ), $url1, $url2, $url3 ), 6 => sprintf( __( '%2$s published. %1$sView %2$s%3$s.', 'commercestore' ), $url1, $url2, $url3 ), @@ -455,7 +455,7 @@ function cs_bulk_updated_messages( $bulk_messages, $bulk_counts ) { $singular = cs_get_label_singular(); $plural = cs_get_label_plural(); - $bulk_messages['download'] = array( + $bulk_messages[CS_POST_TYPE] = array( 'updated' => sprintf( _n( '%1$s %2$s updated.', '%1$s %3$s updated.', $bulk_counts['updated'], 'commercestore' ), $bulk_counts['updated'], $singular, $plural ), 'locked' => sprintf( _n( '%1$s %2$s not updated, somebody is editing it.', '%1$s %3$s not updated, somebody is editing them.', $bulk_counts['locked'], 'commercestore' ), $bulk_counts['locked'], $singular, $plural ), 'deleted' => sprintf( _n( '%1$s %2$s permanently deleted.', '%1$s %3$s permanently deleted.', $bulk_counts['deleted'], 'commercestore' ), $bulk_counts['deleted'], $singular, $plural ), @@ -480,7 +480,7 @@ function cs_bulk_updated_messages( $bulk_messages, $bulk_counts ) { * @return array */ function cs_download_row_actions( $actions, $post ) { - if ( 'download' === $post->post_type ) { + if ( CS_POST_TYPE === $post->post_type ) { return array_merge( array( 'id' => '#' . $post->ID ), $actions ); } diff --git a/includes/process-download.php b/includes/process-download.php index 19265bbbfc..b76fa7e40a 100644 --- a/includes/process-download.php +++ b/includes/process-download.php @@ -22,12 +22,12 @@ * @return void */ function cs_process_download() { - if ( ! isset( $_GET['download_id'] ) && isset( $_GET['download'] ) ) { - $_GET['download_id'] = $_GET['download']; + if ( ! isset( $_GET['download_id'] ) && isset( $_GET[CS_POST_TYPE] ) ) { + $_GET['download_id'] = $_GET[CS_POST_TYPE]; } $args = apply_filters( 'cs_process_download_args', array( - 'download' => ( isset( $_GET['download_id'] ) ) ? (int) $_GET['download_id'] : '', + CS_POST_TYPE => ( isset( $_GET['download_id'] ) ) ? (int) $_GET['download_id'] : '', 'email' => ( isset( $_GET['email'] ) ) ? rawurldecode( $_GET['email'] ) : '', 'expire' => ( isset( $_GET['expire'] ) ) ? rawurldecode( $_GET['expire'] ) : '', 'file_key' => ( isset( $_GET['file'] ) ) ? (int) $_GET['file'] : '', @@ -44,12 +44,12 @@ function cs_process_download() { $args = cs_process_signed_download_url( $args ); // Backfill some legacy super globals for backwards compatibility - $_GET['download_id'] = $args['download']; + $_GET['download_id'] = $args[CS_POST_TYPE]; $_GET['email'] = $args['email']; $_GET['expire'] = $args['expire']; $_GET['download_key'] = $args['key']; $_GET['price_id'] = $args['price_id']; - } elseif ( ! empty( $args['download'] ) && ! empty( $args['key'] ) && ! empty( $args['email'] ) && ! empty( $args['expire'] ) && isset( $args['file_key'] ) ) { + } elseif ( ! empty( $args[CS_POST_TYPE] ) && ! empty( $args['key'] ) && ! empty( $args['email'] ) && ! empty( $args['expire'] ) && isset( $args['file_key'] ) ) { // Validate a legacy URL without a token $args = cs_process_legacy_download_url( $args ); @@ -60,13 +60,13 @@ function cs_process_download() { $args['has_access'] = apply_filters( 'cs_file_download_has_access', $args['has_access'], $args['payment'], $args ); if ( $args['payment'] && $args['has_access'] ) { - do_action( 'cs_process_verified_download', $args['download'], $args['email'], $args['payment'], $args ); + do_action( 'cs_process_verified_download', $args[CS_POST_TYPE], $args['email'], $args['payment'], $args ); // Determine the download method set in settings $method = cs_get_file_download_method(); // Payment has been verified, setup the download - $download_files = cs_get_download_files( $args['download'] ); + $download_files = cs_get_download_files( $args[CS_POST_TYPE] ); $attachment_id = ! empty( $download_files[ $args['file_key'] ]['attachment_id'] ) ? absint( $download_files[ $args['file_key'] ]['attachment_id'] ) : false; $thumbnail_size = ! empty( $download_files[ $args['file_key'] ]['thumbnail_size'] ) ? sanitize_text_field( $download_files[ $args['file_key'] ]['thumbnail_size'] ) : false; $requested_file = isset( $download_files[ $args['file_key'] ]['file'] ) ? $download_files[ $args['file_key'] ]['file'] : ''; @@ -157,7 +157,7 @@ function cs_process_download() { $user_info['name'] = $user_data->display_name; } - cs_record_download_in_log( $args['download'], $args['file_key'], $user_info, cs_get_ip(), $args['payment'], $args['price_id'] ); + cs_record_download_in_log( $args[CS_POST_TYPE], $args['file_key'], $user_info, cs_get_ip(), $args['payment'], $args['price_id'] ); $file_extension = cs_get_file_extension( $requested_file ); $ctype = cs_get_file_ctype( $file_extension ); @@ -182,7 +182,7 @@ function cs_process_download() { } @ini_set( 'zlib.output_compression', 'Off' ); - do_action( 'cs_process_download_headers', $requested_file, $args['download'], $args['email'], $args['payment'] ); + do_action( 'cs_process_download_headers', $requested_file, $args[CS_POST_TYPE], $args['email'], $args['payment'] ); nocache_headers(); header( 'Robots: none' ); @@ -831,7 +831,7 @@ function cs_readfile_chunked( $file, $retbytes = true ) { function cs_process_legacy_download_url( $args ) { // Verify the payment - $args['payment'] = cs_verify_download_link( $args['download'], $args['key'], $args['email'], $args['expire'], $args['file_key'] ); + $args['payment'] = cs_verify_download_link( $args[CS_POST_TYPE], $args['key'], $args['email'], $args['expire'], $args['file_key'] ); // Defaulting this to true for now because the method below doesn't work well $args['has_access'] = true; @@ -874,7 +874,7 @@ function cs_process_signed_download_url( $args ) { } $args['expire'] = $_GET['ttl']; - $args['download'] = $order_parts[1]; + $args[CS_POST_TYPE] = $order_parts[1]; $args['payment'] = $order_parts[0]; $args['file_key'] = $order_parts[2]; $args['price_id'] = $order_parts[3]; @@ -884,7 +884,7 @@ function cs_process_signed_download_url( $args ) { // Access is granted if there's at least one `complete` order item that matches the order + download + price ID. $args['has_access'] = cs_order_grants_access_to_download_files( array( 'order_id' => $args['payment'], - 'product_id' => $args['download'], + 'product_id' => $args[CS_POST_TYPE], 'price_id' => ! empty( $args['price_id'] ) ? $args['price_id'] : '' ) ); diff --git a/includes/query-filters.php b/includes/query-filters.php index 4bff6db111..1ab16b2d81 100644 --- a/includes/query-filters.php +++ b/includes/query-filters.php @@ -37,7 +37,7 @@ function cs_block_attachments() { return; } - if ( 'download' !== get_post_type( $parent ) && false === $cs_file ) { + if ( CS_POST_TYPE !== get_post_type( $parent ) && false === $cs_file ) { return; } diff --git a/includes/reports/data/downloads/class-earnings-by-taxonomy-list-table.php b/includes/reports/data/downloads/class-earnings-by-taxonomy-list-table.php index 7de8d2a3ae..c90799c12b 100644 --- a/includes/reports/data/downloads/class-earnings-by-taxonomy-list-table.php +++ b/includes/reports/data/downloads/class-earnings-by-taxonomy-list-table.php @@ -55,7 +55,7 @@ public function get_data() { } } - $taxonomies = get_object_taxonomies( 'download', 'names' ); + $taxonomies = get_object_taxonomies( CS_POST_TYPE, 'names' ); $taxonomies = array_map( 'sanitize_text_field', $taxonomies ); $placeholders = implode( ', ', array_fill( 0, count( $taxonomies ), '%s' ) ); diff --git a/includes/reports/reports-functions.php b/includes/reports/reports-functions.php index d4efa0c581..a55ee1dc31 100644 --- a/includes/reports/reports-functions.php +++ b/includes/reports/reports-functions.php @@ -1290,7 +1290,7 @@ function filter_items( $report = false ) { // Get form actions $action = admin_url( add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-reports', 'view' => get_current_report(), ), 'edit.php' ) ); diff --git a/includes/scripts.php b/includes/scripts.php index 08596de0d2..0b81ed1e70 100644 --- a/includes/scripts.php +++ b/includes/scripts.php @@ -181,7 +181,7 @@ function cs_localize_scripts() { ? cs_get_item_position_in_cart( $post->ID ) : -1; - if ( ( ! empty( $post->post_content ) && ( has_shortcode( $post->post_content, 'purchase_link' ) || has_shortcode( $post->post_content, 'downloads' ) ) ) || is_post_type_archive( 'download' ) ) { + if ( ( ! empty( $post->post_content ) && ( has_shortcode( $post->post_content, 'purchase_link' ) || has_shortcode( $post->post_content, 'downloads' ) ) ) || is_post_type_archive( CS_POST_TYPE ) ) { $has_purchase_links = true; } else { $has_purchase_links = false; @@ -398,7 +398,7 @@ function cs_enqueue_admin_scripts( $hook = '' ) { } // Downloads page. - if ( cs_is_admin_page( 'download' ) ) { + if ( cs_is_admin_page( CS_POST_TYPE ) ) { wp_enqueue_script( 'cs-admin-downloads' ); } diff --git a/includes/shortcodes.php b/includes/shortcodes.php index e8533a5d40..49390f59ce 100644 --- a/includes/shortcodes.php +++ b/includes/shortcodes.php @@ -334,7 +334,7 @@ function cs_downloads_query( $atts, $content = null ) { ), $atts, 'downloads' ); $query = array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'orderby' => $atts['orderby'], 'order' => $atts['order'] ); diff --git a/includes/subscriptions/includes/admin/metabox.php b/includes/subscriptions/includes/admin/metabox.php index 86abd5af7b..7fad48da04 100644 --- a/includes/subscriptions/includes/admin/metabox.php +++ b/includes/subscriptions/includes/admin/metabox.php @@ -651,7 +651,7 @@ function cs_recurring_display_parent_payment( $payment_id = 0 ) { } $parent_url = add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-payment-history', 'view' => 'view-order-details', 'id' => urlencode( $payment->parent_payment ), @@ -660,7 +660,7 @@ function cs_recurring_display_parent_payment( $payment_id = 0 ) { ); $sub_url = add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-subscriptions', 'id' => urlencode( $sub->id ), ), diff --git a/includes/subscriptions/includes/admin/scripts.php b/includes/subscriptions/includes/admin/scripts.php index 2ec0aeb006..d6ee15f653 100644 --- a/includes/subscriptions/includes/admin/scripts.php +++ b/includes/subscriptions/includes/admin/scripts.php @@ -14,7 +14,7 @@ function cs_recurring_admin_scripts( $hook ) { return; } - if ( is_object( $post ) && 'download' != $post->post_type ) { + if ( is_object( $post ) && CS_POST_TYPE != $post->post_type ) { return; } diff --git a/includes/subscriptions/includes/admin/settings.php b/includes/subscriptions/includes/admin/settings.php index 4a68ee4d32..eb651a2115 100644 --- a/includes/subscriptions/includes/admin/settings.php +++ b/includes/subscriptions/includes/admin/settings.php @@ -579,7 +579,7 @@ function cs_recurring_guest_checkout_description( $settings ) { function cs_recurring_get_email_settings_url() { return add_query_arg( array( - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-settings', 'tab' => 'emails', 'section' => 'recurring', diff --git a/includes/subscriptions/includes/cs-subscriptions-db.php b/includes/subscriptions/includes/cs-subscriptions-db.php index 6bc18c9731..d0d5b44198 100644 --- a/includes/subscriptions/includes/cs-subscriptions-db.php +++ b/includes/subscriptions/includes/cs-subscriptions-db.php @@ -333,7 +333,7 @@ public function get_subscriptions( $args = array() ) { } else { // See if search matches a product name - $download = get_page_by_title( trim( $args['search'] ), OBJECT, 'download' ); + $download = get_page_by_title( trim( $args['search'] ), OBJECT, CS_POST_TYPE ); if( $download ) { @@ -653,7 +653,7 @@ public function count( $args = array() ) { } else { // See if search matches a product name - $download = get_page_by_title( trim( $args['search'] ), OBJECT, 'download' ); + $download = get_page_by_title( trim( $args['search'] ), OBJECT, CS_POST_TYPE ); if( $download ) { diff --git a/includes/subscriptions/includes/gateways/cs-recurring-paypal.php b/includes/subscriptions/includes/gateways/cs-recurring-paypal.php index 9a0c570995..0a13b94070 100644 --- a/includes/subscriptions/includes/gateways/cs-recurring-paypal.php +++ b/includes/subscriptions/includes/gateways/cs-recurring-paypal.php @@ -677,7 +677,7 @@ public function validate_paypal_recurring_download( $post_id = 0 ) { if ( isset( $post->post_type ) && $post->post_type == 'revision' ) { return $post_id; } - if ( ! isset( $post->post_type ) || $post->post_type != 'download' ) { + if ( ! isset( $post->post_type ) || $post->post_type != CS_POST_TYPE ) { return $post_id; } if ( ! current_user_can( 'edit_products', $post_id ) ) { diff --git a/includes/subscriptions/includes/gateways/cs-recurring-stripe.php b/includes/subscriptions/includes/gateways/cs-recurring-stripe.php index c32c399bda..aa9ab9ce43 100644 --- a/includes/subscriptions/includes/gateways/cs-recurring-stripe.php +++ b/includes/subscriptions/includes/gateways/cs-recurring-stripe.php @@ -697,7 +697,7 @@ public function create_stripe_subscriptions( $intent ) { ), 'metadata' => array( 'payment_key' => $this->purchase_data['purchase_key'], - 'download' => $subscription['name'], + CS_POST_TYPE => $subscription['name'], 'download_id' => $subscription['id'], 'price_id' => $subscription['price_id'], 'caller' => __CLASS__ . '|' . __METHOD__ . '|' . __LINE__ . '|' . CS_RECURRING_VERSION, diff --git a/includes/subscriptions/includes/plugin-content-restriction.php b/includes/subscriptions/includes/plugin-content-restriction.php index 12b66f93bd..bbbe088d4f 100644 --- a/includes/subscriptions/includes/plugin-content-restriction.php +++ b/includes/subscriptions/includes/plugin-content-restriction.php @@ -193,20 +193,20 @@ public function can_access_content( $return, $user_id, $restricted_to, $post_id foreach ( $restricted_to as $item ) { - if ( 'any' === $item['download'] ) { + if ( 'any' === $item[CS_POST_TYPE] ) { $return['status'] = $subscriber->has_active_subscription() ? true : false; return $return; } // Get the Download object so we can use it in variable price checks. - $download = new CS_Download( $item['download'] ); + $download = new CS_Download( $item[CS_POST_TYPE] ); if ( isset( $item['price_id'] ) && $download->has_variable_prices() ) { if ( is_numeric( $item['price_id'] ) ) { // Check if the variably-riced product is Recurring-enabled or not. - $recurring_enabled = CS_Recurring()->is_price_recurring( $item['download'], $item['price_id'] ); + $recurring_enabled = CS_Recurring()->is_price_recurring( $item[CS_POST_TYPE], $item['price_id'] ); } elseif ( 'all' === $item['price_id'] ) { @@ -224,14 +224,14 @@ public function can_access_content( $return, $user_id, $restricted_to, $post_id } else { // Check if the product is Recurring-enabled or not. - $recurring_enabled = CS_Recurring()->is_recurring( $item['download'] ); + $recurring_enabled = CS_Recurring()->is_recurring( $item[CS_POST_TYPE] ); } if ( $recurring_enabled ) { // If this subscriber has an active subscription to the variably-product in question. - if ( $subscriber->has_active_product_subscription( $item['download'] ) ) { + if ( $subscriber->has_active_product_subscription( $item[CS_POST_TYPE] ) ) { $has_access = true; break; } @@ -317,19 +317,19 @@ public function restrict_shortcode_content( $content, $restricted_to, $atts ) { $custom_message = isset( $atts['message'] ) ? $atts['message'] : false; $products = array(); foreach ( $restricted_to as $item ) { - if ( cs_recurring()->is_recurring( $item['download'] ) ) { - $has_access = $subscriber->has_active_product_subscription( $item['download'] ); + if ( cs_recurring()->is_recurring( $item[CS_POST_TYPE] ) ) { + $has_access = $subscriber->has_active_product_subscription( $item[CS_POST_TYPE] ); } else { - if ( ! empty( $item['download']['price_id'] ) && is_numeric( $item['download']['price_id'] ) && cs_has_variable_prices( $item['download'] ) ) { - $has_access = cs_has_user_purchased( $user_id, $item['download'], $item['download']['price_id'] ); + if ( ! empty( $item[CS_POST_TYPE]['price_id'] ) && is_numeric( $item[CS_POST_TYPE]['price_id'] ) && cs_has_variable_prices( $item[CS_POST_TYPE] ) ) { + $has_access = cs_has_user_purchased( $user_id, $item[CS_POST_TYPE], $item[CS_POST_TYPE]['price_id'] ); } else { - $has_access = cs_has_user_purchased( $user_id, $item['download'] ); + $has_access = cs_has_user_purchased( $user_id, $item[CS_POST_TYPE] ); } } if ( $has_access ) { return $content; } - $products[] = get_the_title( $item['download'] ); + $products[] = get_the_title( $item[CS_POST_TYPE] ); } // At this point, $has_access is false and we just need to get the correct message. diff --git a/includes/subscriptions/subscriptions.php b/includes/subscriptions/subscriptions.php index 6ecb08d737..a9445892f5 100644 --- a/includes/subscriptions/subscriptions.php +++ b/includes/subscriptions/subscriptions.php @@ -1556,9 +1556,9 @@ public function enable_child_payments( $query ) { $query_has_recurring = true; - if( ! empty( $query->initial_args['download'] ) ) { + if( ! empty( $query->initial_args[CS_POST_TYPE] ) ) { $query_has_recurring = false; - $download = $query->initial_args['download']; + $download = $query->initial_args[CS_POST_TYPE]; if ( ! is_array( $download ) && strpos( $download, ',' ) ) { $download = explode( ',', $download ); @@ -1623,7 +1623,7 @@ public function enqueue_scripts() { ( 'page' === $post->post_type && has_shortcode( $post->post_content, 'cs_downloads' ) ) || ( 'page' === $post->post_type && has_shortcode( $post->post_content, 'downloads' ) ) || ( 'page' === $post->post_type && has_shortcode( $post->post_content, 'cs_subscriptions' ) ) || - 'download' === $post->post_type ) + CS_POST_TYPE === $post->post_type ) ) ) { $load_js = true; } diff --git a/includes/template-functions.php b/includes/template-functions.php index afa74a7619..4dc99b713e 100644 --- a/includes/template-functions.php +++ b/includes/template-functions.php @@ -414,7 +414,7 @@ function cs_variable_price_quantity_field( $key, $price, $download_id ) { function cs_before_download_content( $content ) { global $post; - if ( $post && $post instanceof WP_Post && 'download' === $post->post_type && is_singular( 'download' ) && is_main_query() && ! post_password_required() ) { + if ( $post && $post instanceof WP_Post && CS_POST_TYPE === $post->post_type && is_singular( CS_POST_TYPE ) && is_main_query() && ! post_password_required() ) { ob_start(); do_action( 'cs_before_download_content', $post->ID ); $content = ob_get_clean() . $content; @@ -439,7 +439,7 @@ function cs_before_download_content( $content ) { function cs_after_download_content( $content ) { global $post; - if ( $post && $post->post_type == 'download' && is_singular( 'download' ) && is_main_query() && !post_password_required() ) { + if ( $post && $post->post_type == CS_POST_TYPE && is_singular( CS_POST_TYPE ) && is_main_query() && !post_password_required() ) { ob_start(); do_action( 'cs_after_download_content', $post->ID ); $content .= ob_get_clean(); @@ -840,7 +840,7 @@ function cs_add_body_classes( $class ) { * @return array Modified array of classes */ function cs_add_download_post_classes( $classes, $class = '', $post_id = false ) { - if( ! $post_id || get_post_type( $post_id ) !== 'download' || is_admin() ) { + if( ! $post_id || get_post_type( $post_id ) !== CS_POST_TYPE || is_admin() ) { return $classes; } @@ -866,7 +866,7 @@ function cs_add_download_post_classes( $classes, $class = '', $post_id = false ) } // Add cs-download - if( is_singular( 'download' ) ) { + if( is_singular( CS_POST_TYPE ) ) { $classes[] = 'cs-download'; } } @@ -883,7 +883,7 @@ function cs_add_download_post_classes( $classes, $class = '', $post_id = false ) */ function cs_add_oembed_price() { - if( 'download' !== get_post_type( get_the_ID() ) ) { + if( CS_POST_TYPE !== get_post_type( get_the_ID() ) ) { return; } @@ -914,7 +914,7 @@ function cs_remove_embed_comments_button() { $hide_comments = apply_filters( 'cs_embed_hide_comments', true, $post ); - if ( ! empty( $post ) && $post->post_type == 'download' && true === $hide_comments ) { + if ( ! empty( $post ) && $post->post_type == CS_POST_TYPE && true === $hide_comments ) { remove_action( 'embed_content_meta', 'print_embed_comments_button' ); } } @@ -994,7 +994,7 @@ function cs_download_shortcode_item( $atts, $i ) { $cs_download_shortcode_item_atts = $atts; $cs_download_shortcode_item_i = $i; - cs_get_template_part( 'shortcode', 'download' ); + cs_get_template_part( 'shortcode', CS_POST_TYPE ); } add_action( 'cs_download_shortcode_item', 'cs_download_shortcode_item', 10, 2 ); @@ -1086,7 +1086,7 @@ function cs_download_shortcode_excerpt_length() { function cs_downloads_pagination( $atts, $downloads, $query ) { if ( filter_var( $atts['pagination'], FILTER_VALIDATE_BOOLEAN ) ) { $args = array( - 'type' => 'download', + 'type' => CS_POST_TYPE, 'format' => '?paged=%#%', 'current' => max( 1, $query['paged'] ), 'total' => $downloads->max_num_pages @@ -1128,7 +1128,7 @@ function cs_pagination( $args = array() ) { ); $args = wp_parse_args( $args, $defaults ); - + /** * Filter pagination args. * diff --git a/includes/theme-compatibility.php b/includes/theme-compatibility.php index d15f0c528e..c5acc86170 100644 --- a/includes/theme-compatibility.php +++ b/includes/theme-compatibility.php @@ -27,16 +27,16 @@ */ function cs_responsive_download_post_class( $classes = array(), $class = '', $post_id = 0 ) { if ( - ! is_singular( 'download' ) && - ! is_post_type_archive( 'download' ) && + ! is_singular( CS_POST_TYPE ) && + ! is_post_type_archive( CS_POST_TYPE ) && ! is_tax( 'download_category' ) && ! is_tax( 'download_tag' ) ) return $classes; - if ( ( $key = array_search( 'download', $classes ) ) ) + if ( ( $key = array_search( CS_POST_TYPE, $classes ) ) ) unset( $classes[ $key ] ); return $classes; } -add_filter( 'post_class', 'cs_responsive_download_post_class', 999, 3 ); \ No newline at end of file +add_filter( 'post_class', 'cs_responsive_download_post_class', 999, 3 ); diff --git a/includes/user-functions.php b/includes/user-functions.php index 267f7341d0..b1349103ef 100644 --- a/includes/user-functions.php +++ b/includes/user-functions.php @@ -154,7 +154,7 @@ function cs_get_users_purchased_products( $user = 0, $status = 'complete' ) { $args = apply_filters( 'cs_get_users_purchased_products_args', array( 'include' => $product_ids, - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => -1, ) ); diff --git a/includes/widgets.php b/includes/widgets.php index c7ec4fae6c..dfe1a9b63f 100644 --- a/includes/widgets.php +++ b/includes/widgets.php @@ -260,12 +260,12 @@ public function widget( $args, $instance ) { } } - if ( ! isset( $instance['display_type'] ) || ( 'specific' === $instance['display_type'] && ! isset( $instance['download_id'] ) ) || ( 'current' == $instance['display_type'] && ! is_singular( 'download' ) ) ) { + if ( ! isset( $instance['display_type'] ) || ( 'specific' === $instance['display_type'] && ! isset( $instance['download_id'] ) ) || ( 'current' == $instance['display_type'] && ! is_singular( CS_POST_TYPE ) ) ) { return; } // set correct download ID. - if ( 'current' == $instance['display_type'] && is_singular( 'download' ) ) { + if ( 'current' == $instance['display_type'] && is_singular( CS_POST_TYPE ) ) { $download_id = get_the_ID(); } else { $download_id = absint( $instance['download_id'] ); @@ -273,7 +273,7 @@ public function widget( $args, $instance ) { // Since we can take a typed in value, make sure it's a download we're looking for $download = get_post( $download_id ); - if ( ! is_object( $download ) || 'download' !== $download->post_type ) { + if ( ! is_object( $download ) || CS_POST_TYPE !== $download->post_type ) { return; } @@ -398,11 +398,11 @@ public function form( $instance ) {

> - + publish < 1000 ) : ?> 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => -1, 'post_status' => 'publish', ); From 83dc72f29da189319a3cb7b7ba5920af7f6f6cf5 Mon Sep 17 00:00:00 2001 From: Nick Temple Date: Wed, 23 Feb 2022 19:20:47 -0700 Subject: [PATCH 03/17] restore the word 'download' where necessary, teasing out what it means --- commercestore.php | 14 ++++++++++++ includes/admin/admin-pages.php | 2 +- includes/admin/downloads/contextual-help.php | 2 +- .../product-education/class-reviews.php | 2 +- .../import/class-batch-import-payments.php | 4 ++-- .../reporting/class-base-logs-list-table.php | 2 +- .../class-export-download-history.php | 4 ++-- .../class-file-downloads-logs-list-table.php | 8 +++---- .../reporting/class-sales-logs-list-table.php | 8 +++---- .../export/class-batch-export-customers.php | 4 ++-- .../class-batch-export-file-downloads.php | 4 ++-- .../export/class-batch-export-sales.php | 4 ++-- includes/admin/reporting/reports.php | 6 ++--- includes/admin/tools.php | 2 +- includes/ajax-functions.php | 4 ++-- .../database/schemas/class-order-items.php | 2 +- includes/payments/class-payments-query.php | 4 ++-- includes/payments/functions.php | 6 ++--- includes/post-types.php | 4 ++-- includes/process-download.php | 22 +++++++++---------- .../includes/gateways/cs-recurring-stripe.php | 2 +- .../includes/plugin-content-restriction.php | 22 +++++++++---------- includes/template-functions.php | 2 +- includes/theme-compatibility.php | 2 +- 24 files changed, 75 insertions(+), 61 deletions(-) diff --git a/commercestore.php b/commercestore.php index 877b7c3718..fe4996d4be 100644 --- a/commercestore.php +++ b/commercestore.php @@ -41,10 +41,24 @@ const CS_DEFAULT_SLUG = 'store'; // Override with the CS_SLUG constant // @todo replace hardcoding of post_type and taxonomies with the following constants all throughout the codebase + +const CS_ICON = 'download'; // Change the icon here + const CS_POST_TYPE = 'csproduct'; const CS_TAG_TYPE = CS_POST_TYPE . '_tag'; const CS_CAT_TYPE = CS_POST_TYPE . '_category'; +// Tease out the word 'download' that is used in different contexts. +// search and replace back during build? +const CS_EX_DOWNLOAD_CSS_CLASS = 'download'; +const CS_EX_DOWNLOAD_SHORTCODE = 'download'; +const CS_EX_DOWNLOAD_ITEM = 'download'; +const CS_EX_DOWNLOAD_ARGS = 'download'; +const CS_EX_DOWNLOAD_MESSAGES = 'download'; + + + + const CS_BASE_PLUGIN = __FILE__; require_once( __DIR__ . '/vendor/autoload.php' ); diff --git a/includes/admin/admin-pages.php b/includes/admin/admin-pages.php index 20c60ca484..522f8ffa4b 100644 --- a/includes/admin/admin-pages.php +++ b/includes/admin/admin-pages.php @@ -174,7 +174,7 @@ function cs_is_admin_page( $passed_page = '', $passed_view = '', $include_non_ex $tab = isset( $_GET['tab'] ) ? strtolower( $_GET['tab'] ) : false; switch ( $passed_page ) { - case CS_POST_TYPE: + case 'download': switch ( $passed_view ) { case 'list-table': if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit.php' ) { diff --git a/includes/admin/downloads/contextual-help.php b/includes/admin/downloads/contextual-help.php index 6ace6aa06a..d897e13f10 100644 --- a/includes/admin/downloads/contextual-help.php +++ b/includes/admin/downloads/contextual-help.php @@ -21,7 +21,7 @@ function cs_downloads_contextual_help() { $screen = get_current_screen(); - if ( $screen->id != CS_POST_TYPE ) + if ( $screen->id != 'download' ) return; $screen->set_help_sidebar( diff --git a/includes/admin/extensions/product-education/class-reviews.php b/includes/admin/extensions/product-education/class-reviews.php index 8e582c781d..e7cc0c7ea2 100644 --- a/includes/admin/extensions/product-education/class-reviews.php +++ b/includes/admin/extensions/product-education/class-reviews.php @@ -127,7 +127,7 @@ public function maybe_do_metabox() { 'cs-reviews-status', __( 'Product Reviews', 'commercestore' ), array( $this, 'settings_field' ), - CS_POST_TYPE, + 'download', 'side', 'low' ); diff --git a/includes/admin/import/class-batch-import-payments.php b/includes/admin/import/class-batch-import-payments.php index 9f98f8f7cf..b7311a6abc 100644 --- a/includes/admin/import/class-batch-import-payments.php +++ b/includes/admin/import/class-batch-import-payments.php @@ -310,7 +310,7 @@ public function create_payment( $row = array() ) { foreach( $downloads as $download ) { if( is_array( $download ) ) { - $download_name = $download[CS_POST_TYPE]; + $download_name = $download['download']; $price = $download['price']; $tax = $download['tax']; $price_id = $download['price_id']; @@ -579,7 +579,7 @@ public function get_downloads_from_cs( $data_str ) { $price_id = isset( $matches[1][1] ) ? trim( $matches[1][1] ) : false; $d_array[] = array( - CS_POST_TYPE => trim( $d[0] ), + 'download' => trim( $d[0] ), 'price' => $price - $tax, 'tax' => $tax, 'price_id' => $price_id, diff --git a/includes/admin/reporting/class-base-logs-list-table.php b/includes/admin/reporting/class-base-logs-list-table.php index e68056d283..86c82085a1 100644 --- a/includes/admin/reporting/class-base-logs-list-table.php +++ b/includes/admin/reporting/class-base-logs-list-table.php @@ -162,7 +162,7 @@ public function get_filtered_end_date() { * @return int Download ID. */ public function get_filtered_download() { - return absint( $this->get_request_var( CS_POST_TYPE, false ) ); + return absint( $this->get_request_var( 'download', false ) ); } /** diff --git a/includes/admin/reporting/class-export-download-history.php b/includes/admin/reporting/class-export-download-history.php index 9626409aa7..ddf32cff76 100644 --- a/includes/admin/reporting/class-export-download-history.php +++ b/includes/admin/reporting/class-export-download-history.php @@ -59,7 +59,7 @@ public function csv_cols() { 'date' => __( 'Date', 'commercestore' ), 'user' => __( 'Downloaded by', 'commercestore' ), 'ip' => __( 'IP Address', 'commercestore' ), - CS_POST_TYPE => __( 'Product', 'commercestore' ), + 'download' => __( 'Product', 'commercestore' ), 'file' => __( 'File', 'commercestore' ) ); return $cols; @@ -99,7 +99,7 @@ public function get_data() { 'date' => $log->post_date, 'user' => $user, 'ip' => get_post_meta( $log->ID, '_cs_log_ip', true ), - CS_POST_TYPE => get_the_title( $log->post_parent ), + 'download' => get_the_title( $log->post_parent ), 'file' => $file_name ); } diff --git a/includes/admin/reporting/class-file-downloads-logs-list-table.php b/includes/admin/reporting/class-file-downloads-logs-list-table.php index 8a38294b76..fb57b6f557 100644 --- a/includes/admin/reporting/class-file-downloads-logs-list-table.php +++ b/includes/admin/reporting/class-file-downloads-logs-list-table.php @@ -69,13 +69,13 @@ public function __construct() { public function column_default( $item, $column_name ) { $base_url = remove_query_arg( 'paged' ); switch ( $column_name ) { - case CS_POST_TYPE : + case 'download' : $download = new CS_Download( $item[ $column_name ] ); $column_value = ! empty( $item['price_id'] ) ? cs_get_download_name( $download->ID, $item['price_id'] ) : cs_get_download_name( $download->ID ); - return '' . $column_value . ''; + return '' . $column_value . ''; case 'customer' : return ! empty( $item[ 'customer' ]->id ) ? '' . $item['customer']->name . '' @@ -103,7 +103,7 @@ public function column_default( $item, $column_name ) { public function get_columns() { return array( 'ID' => __( 'Log ID', 'commercestore' ), - CS_POST_TYPE => cs_get_label_singular(), + 'download' => cs_get_label_singular(), 'customer' => __( 'Customer', 'commercestore' ), 'payment_id' => __( 'Order Number', 'commercestore' ), 'file' => __( 'File', 'commercestore' ), @@ -152,7 +152,7 @@ function get_logs( $log_query = array() ) { if ( empty( $this->file_search ) || ( ! empty( $this->file_search ) && strpos( strtolower( $file_name ), strtolower( $this->get_search() ) ) !== false ) ) { $logs_data[] = array( 'ID' => $log->id, - CS_POST_TYPE => $log->product_id, + 'download' => $log->product_id, 'customer' => new CS_Customer( $customer_id ), 'payment_id' => $log->order_id, 'price_id' => $log->price_id, diff --git a/includes/admin/reporting/class-sales-logs-list-table.php b/includes/admin/reporting/class-sales-logs-list-table.php index ec8aacf26f..fe725bb6b5 100644 --- a/includes/admin/reporting/class-sales-logs-list-table.php +++ b/includes/admin/reporting/class-sales-logs-list-table.php @@ -47,7 +47,7 @@ public function column_default( $item, $column_name ) { $currency = $item['currency']; switch ( $column_name ) { - case CS_POST_TYPE: + case 'download': $download_id = $item[ $column_name ]; $download = cs_get_download( $download_id ); $price_id = ! empty( $item['price_id'] ) @@ -55,7 +55,7 @@ public function column_default( $item, $column_name ) { : 0; $title = $download->get_name( $price_id ); - $return = '' . $title . ''; + $return = '' . $title . ''; break; case 'customer': @@ -96,7 +96,7 @@ public function get_columns() { return array( 'ID' => __( 'Order Number', 'commercestore' ), 'customer' => __( 'Customer', 'commercestore' ), - CS_POST_TYPE => cs_get_label_singular(), + 'download' => cs_get_label_singular(), 'amount' => __( 'Item Amount', 'commercestore' ), 'date' => __( 'Date', 'commercestore' ), ); @@ -235,7 +235,7 @@ public function get_logs( $log_query = array() ) { 'ID' => $order->get_number(), 'order_id' => $order->id, 'customer' => cs_get_customer( $order->customer_id ), - CS_POST_TYPE => $order_item->product_id, + 'download' => $order_item->product_id, 'price_id' => $order_item->price_id, 'item_price' => $order_item->amount, 'amount' => $order_item->total, diff --git a/includes/admin/reporting/export/class-batch-export-customers.php b/includes/admin/reporting/export/class-batch-export-customers.php index 9ebc47158b..54b88ae42b 100644 --- a/includes/admin/reporting/export/class-batch-export-customers.php +++ b/includes/admin/reporting/export/class-batch-export-customers.php @@ -207,8 +207,8 @@ public function set_properties( $request ) { ? absint( $request['taxonomy'] ) : null; - $this->download = isset( $request[CS_POST_TYPE] ) - ? absint( $request[CS_POST_TYPE] ) + $this->download = isset( $request['download'] ) + ? absint( $request['download'] ) : null; $this->price_id = ! empty( $request['cs_price_option'] ) && 0 !== $request['cs_price_option'] diff --git a/includes/admin/reporting/export/class-batch-export-file-downloads.php b/includes/admin/reporting/export/class-batch-export-file-downloads.php index 3078e1cfb2..93e136e812 100644 --- a/includes/admin/reporting/export/class-batch-export-file-downloads.php +++ b/includes/admin/reporting/export/class-batch-export-file-downloads.php @@ -44,7 +44,7 @@ public function csv_cols() { 'user' => __( 'Downloaded by', 'commercestore' ), 'ip' => __( 'IP Address', 'commercestore' ), 'user_agent' => __( 'User Agent', 'commercestore' ), - CS_POST_TYPE => __( 'Product', 'commercestore' ), + 'download' => __( 'Product', 'commercestore' ), 'file' => __( 'File', 'commercestore' ), ); @@ -102,7 +102,7 @@ public function get_data() { 'user' => $customer, 'ip' => $log->ip, 'user_agent' => $log->user_agent, - CS_POST_TYPE => get_the_title( $log->product_id ), + 'download' => get_the_title( $log->product_id ), 'file' => $file_name, ); } diff --git a/includes/admin/reporting/export/class-batch-export-sales.php b/includes/admin/reporting/export/class-batch-export-sales.php index aeabc2e176..7689649b87 100644 --- a/includes/admin/reporting/export/class-batch-export-sales.php +++ b/includes/admin/reporting/export/class-batch-export-sales.php @@ -42,7 +42,7 @@ public function csv_cols() { 'email' => __( 'Email', 'commercestore' ), 'first_name' => __( 'First Name', 'commercestore' ), 'last_name' => __( 'Last Name', 'commercestore' ), - CS_POST_TYPE => cs_get_label_singular(), + 'download' => cs_get_label_singular(), 'quantity' => __( 'Quantity', 'commercestore' ), 'amount' => __( 'Item Amount', 'commercestore' ), 'payment_id' => __( 'Payment ID', 'commercestore' ), @@ -104,7 +104,7 @@ public function get_data() { 'email' => $order->email, 'first_name' => isset( $user_info['first_name'] ) ? $user_info['first_name'] : '', 'last_name' => isset( $user_info['last_name'] ) ? $user_info['last_name'] : '', - CS_POST_TYPE => $download_title, + 'download' => $download_title, 'quantity' => $item->quantity, 'amount' => $order->total, 'payment_id' => $order->id, diff --git a/includes/admin/reporting/reports.php b/includes/admin/reporting/reports.php index 6c686cef00..709e07445d 100644 --- a/includes/admin/reporting/reports.php +++ b/includes/admin/reporting/reports.php @@ -562,7 +562,7 @@ function cs_register_downloads_report( $reports ) { $reports->add_report( 'downloads', array( 'label' => cs_get_label_plural(), 'priority' => 10, - 'icon' => CS_POST_TYPE, + 'icon' => CS_ICON, 'endpoints' => array( 'tiles' => $tiles, 'charts' => $charts, @@ -1798,7 +1798,7 @@ function cs_register_file_downloads_report( $reports ) { $reports->add_report( 'file_downloads', array( 'label' => __( 'File Downloads', 'commercestore' ), - 'icon' => CS_POST_TYPE, + 'icon' => CS_ICON, 'priority' => 30, 'endpoints' => array( 'tiles' => $tiles, @@ -2884,7 +2884,7 @@ function display_export_report() { html->product_dropdown( array( - 'name' => CS_POST_TYPE, + 'name' => 'download', 'id' => 'cs_customer_export_download', 'chosen' => true, /* translators: the plural post type label */ diff --git a/includes/admin/tools.php b/includes/admin/tools.php index 7ffbaca904..d44ca5b0e9 100644 --- a/includes/admin/tools.php +++ b/includes/admin/tools.php @@ -1659,7 +1659,7 @@ function cs_redirect_sales_log() { ); $args_to_remap = array( - CS_POST_TYPE => 'product-id', + 'download' => 'product-id', 'start-date' => 'start-date', 'end-date' => 'end-date' ); diff --git a/includes/ajax-functions.php b/includes/ajax-functions.php index 6eab049d3b..cec180b02e 100644 --- a/includes/ajax-functions.php +++ b/includes/ajax-functions.php @@ -953,8 +953,8 @@ function cs_ajax_add_order_item() { ? sanitize_text_field( $_POST['nonce'] ) : ''; - $download = isset( $_POST[CS_POST_TYPE] ) - ? cs_parse_product_dropdown_value( sanitize_text_field( $_POST[CS_POST_TYPE] ) ) + $download = isset( $_POST['download'] ) + ? cs_parse_product_dropdown_value( sanitize_text_field( $_POST['download'] ) ) : array(); $country = isset( $_POST['country'] ) diff --git a/includes/database/schemas/class-order-items.php b/includes/database/schemas/class-order-items.php index 5379e16d6c..36ce6dd171 100644 --- a/includes/database/schemas/class-order-items.php +++ b/includes/database/schemas/class-order-items.php @@ -108,7 +108,7 @@ class Order_Items extends Schema { 'name' => 'type', 'type' => 'varchar', 'length' => '20', - 'default' => CS_POST_TYPE, // VERIFY + 'default' => 'download', 'sortable' => true, 'transition' => true ), diff --git a/includes/payments/class-payments-query.php b/includes/payments/class-payments-query.php index 3686134dc1..03060e6c4e 100644 --- a/includes/payments/class-payments-query.php +++ b/includes/payments/class-payments-query.php @@ -91,7 +91,7 @@ public function __construct( $args = array() ) { 'search_in_notes' => false, 'children' => false, 'fields' => null, - CS_POST_TYPE => null, + 'download' => null, 'gateway' => null, 'post__in' => null, 'post__not_in' => null, @@ -548,7 +548,7 @@ public function download() { $this->args['id__in'] = $order_ids; - $this->__unset( CS_POST_TYPE ); + $this->__unset( CS_EX_DOWNLOAD_ARGS ); } /** diff --git a/includes/payments/functions.php b/includes/payments/functions.php index d1aa2f5077..47993eb884 100644 --- a/includes/payments/functions.php +++ b/includes/payments/functions.php @@ -343,7 +343,7 @@ function cs_count_payments( $args = array() ) { 's' => null, 'start-date' => null, 'end-date' => null, - CS_POST_TYPE => null, + 'download' => null, 'gateway' => null, 'type' => 'sale', ) ); @@ -403,9 +403,9 @@ function cs_count_payments( $args = array() ) { } } - if ( ! empty( $args[CS_POST_TYPE] ) && is_numeric( $args[CS_POST_TYPE] ) ) { + if ( ! empty( $item[CS_EX_DOWNLOAD_ARGS] ) && is_numeric( $item[CS_EX_DOWNLOAD_ARGS] ) ) { $join = "INNER JOIN {$wpdb->cs_order_items} cs_oi ON cs_o.id = cs_oi.order_id"; - $where .= $wpdb->prepare( ' AND cs_oi.product_id = %d', absint( $args[CS_POST_TYPE] ) ); + $where .= $wpdb->prepare( ' AND cs_oi.product_id = %d', absint( $item[CS_EX_DOWNLOAD_ARGS] ) ); } if ( ! empty( $args['gateway'] ) ) { diff --git a/includes/post-types.php b/includes/post-types.php index 51bd9951ea..d89f559462 100644 --- a/includes/post-types.php +++ b/includes/post-types.php @@ -428,7 +428,7 @@ function cs_updated_messages( $messages ) { $url2 = cs_get_label_singular(); $url3 = ''; - $messages[CS_POST_TYPE] = array( + $messages[CS_EX_DOWNLOAD_MESSAGES] = array( 1 => sprintf( __( '%2$s updated. %1$sView %2$s%3$s.', 'commercestore' ), $url1, $url2, $url3 ), 4 => sprintf( __( '%2$s updated. %1$sView %2$s%3$s.', 'commercestore' ), $url1, $url2, $url3 ), 6 => sprintf( __( '%2$s published. %1$sView %2$s%3$s.', 'commercestore' ), $url1, $url2, $url3 ), @@ -455,7 +455,7 @@ function cs_bulk_updated_messages( $bulk_messages, $bulk_counts ) { $singular = cs_get_label_singular(); $plural = cs_get_label_plural(); - $bulk_messages[CS_POST_TYPE] = array( + $bulk_messages[CS_EX_DOWNLOAD_MESSAGES_TYPE] = array( 'updated' => sprintf( _n( '%1$s %2$s updated.', '%1$s %3$s updated.', $bulk_counts['updated'], 'commercestore' ), $bulk_counts['updated'], $singular, $plural ), 'locked' => sprintf( _n( '%1$s %2$s not updated, somebody is editing it.', '%1$s %3$s not updated, somebody is editing them.', $bulk_counts['locked'], 'commercestore' ), $bulk_counts['locked'], $singular, $plural ), 'deleted' => sprintf( _n( '%1$s %2$s permanently deleted.', '%1$s %3$s permanently deleted.', $bulk_counts['deleted'], 'commercestore' ), $bulk_counts['deleted'], $singular, $plural ), diff --git a/includes/process-download.php b/includes/process-download.php index b76fa7e40a..7091be9fcf 100644 --- a/includes/process-download.php +++ b/includes/process-download.php @@ -22,8 +22,8 @@ * @return void */ function cs_process_download() { - if ( ! isset( $_GET['download_id'] ) && isset( $_GET[CS_POST_TYPE] ) ) { - $_GET['download_id'] = $_GET[CS_POST_TYPE]; + if ( ! isset( $_GET['download_id'] ) && isset( $_GET[CS_EX_DOWNLOAD_ARGS] ) ) { + $_GET['download_id'] = $_GET[CS_EX_DOWNLOAD_ARGS]; } $args = apply_filters( 'cs_process_download_args', array( @@ -44,12 +44,12 @@ function cs_process_download() { $args = cs_process_signed_download_url( $args ); // Backfill some legacy super globals for backwards compatibility - $_GET['download_id'] = $args[CS_POST_TYPE]; + $_GET['download_id'] = $item[CS_EX_DOWNLOAD_ARGS]; $_GET['email'] = $args['email']; $_GET['expire'] = $args['expire']; $_GET['download_key'] = $args['key']; $_GET['price_id'] = $args['price_id']; - } elseif ( ! empty( $args[CS_POST_TYPE] ) && ! empty( $args['key'] ) && ! empty( $args['email'] ) && ! empty( $args['expire'] ) && isset( $args['file_key'] ) ) { + } elseif ( ! empty( $item[CS_EX_DOWNLOAD_ARGS] ) && ! empty( $args['key'] ) && ! empty( $args['email'] ) && ! empty( $args['expire'] ) && isset( $args['file_key'] ) ) { // Validate a legacy URL without a token $args = cs_process_legacy_download_url( $args ); @@ -60,13 +60,13 @@ function cs_process_download() { $args['has_access'] = apply_filters( 'cs_file_download_has_access', $args['has_access'], $args['payment'], $args ); if ( $args['payment'] && $args['has_access'] ) { - do_action( 'cs_process_verified_download', $args[CS_POST_TYPE], $args['email'], $args['payment'], $args ); + do_action( 'cs_process_verified_download', $item[CS_EX_DOWNLOAD_ARGS], $args['email'], $args['payment'], $args ); // Determine the download method set in settings $method = cs_get_file_download_method(); // Payment has been verified, setup the download - $download_files = cs_get_download_files( $args[CS_POST_TYPE] ); + $download_files = cs_get_download_files( $item[CS_EX_DOWNLOAD_ARGS] ); $attachment_id = ! empty( $download_files[ $args['file_key'] ]['attachment_id'] ) ? absint( $download_files[ $args['file_key'] ]['attachment_id'] ) : false; $thumbnail_size = ! empty( $download_files[ $args['file_key'] ]['thumbnail_size'] ) ? sanitize_text_field( $download_files[ $args['file_key'] ]['thumbnail_size'] ) : false; $requested_file = isset( $download_files[ $args['file_key'] ]['file'] ) ? $download_files[ $args['file_key'] ]['file'] : ''; @@ -157,7 +157,7 @@ function cs_process_download() { $user_info['name'] = $user_data->display_name; } - cs_record_download_in_log( $args[CS_POST_TYPE], $args['file_key'], $user_info, cs_get_ip(), $args['payment'], $args['price_id'] ); + cs_record_download_in_log( $item[CS_EX_DOWNLOAD_ARGS], $args['file_key'], $user_info, cs_get_ip(), $args['payment'], $args['price_id'] ); $file_extension = cs_get_file_extension( $requested_file ); $ctype = cs_get_file_ctype( $file_extension ); @@ -182,7 +182,7 @@ function cs_process_download() { } @ini_set( 'zlib.output_compression', 'Off' ); - do_action( 'cs_process_download_headers', $requested_file, $args[CS_POST_TYPE], $args['email'], $args['payment'] ); + do_action( 'cs_process_download_headers', $requested_file, $item[CS_EX_DOWNLOAD_ARGS], $args['email'], $args['payment'] ); nocache_headers(); header( 'Robots: none' ); @@ -831,7 +831,7 @@ function cs_readfile_chunked( $file, $retbytes = true ) { function cs_process_legacy_download_url( $args ) { // Verify the payment - $args['payment'] = cs_verify_download_link( $args[CS_POST_TYPE], $args['key'], $args['email'], $args['expire'], $args['file_key'] ); + $args['payment'] = cs_verify_download_link( $item[CS_EX_DOWNLOAD_ARGS], $args['key'], $args['email'], $args['expire'], $args['file_key'] ); // Defaulting this to true for now because the method below doesn't work well $args['has_access'] = true; @@ -874,7 +874,7 @@ function cs_process_signed_download_url( $args ) { } $args['expire'] = $_GET['ttl']; - $args[CS_POST_TYPE] = $order_parts[1]; + $item[CS_EX_DOWNLOAD_ARGS] = $order_parts[1]; $args['payment'] = $order_parts[0]; $args['file_key'] = $order_parts[2]; $args['price_id'] = $order_parts[3]; @@ -884,7 +884,7 @@ function cs_process_signed_download_url( $args ) { // Access is granted if there's at least one `complete` order item that matches the order + download + price ID. $args['has_access'] = cs_order_grants_access_to_download_files( array( 'order_id' => $args['payment'], - 'product_id' => $args[CS_POST_TYPE], + 'product_id' => $item[CS_EX_DOWNLOAD_ARGS], 'price_id' => ! empty( $args['price_id'] ) ? $args['price_id'] : '' ) ); diff --git a/includes/subscriptions/includes/gateways/cs-recurring-stripe.php b/includes/subscriptions/includes/gateways/cs-recurring-stripe.php index aa9ab9ce43..c32c399bda 100644 --- a/includes/subscriptions/includes/gateways/cs-recurring-stripe.php +++ b/includes/subscriptions/includes/gateways/cs-recurring-stripe.php @@ -697,7 +697,7 @@ public function create_stripe_subscriptions( $intent ) { ), 'metadata' => array( 'payment_key' => $this->purchase_data['purchase_key'], - CS_POST_TYPE => $subscription['name'], + 'download' => $subscription['name'], 'download_id' => $subscription['id'], 'price_id' => $subscription['price_id'], 'caller' => __CLASS__ . '|' . __METHOD__ . '|' . __LINE__ . '|' . CS_RECURRING_VERSION, diff --git a/includes/subscriptions/includes/plugin-content-restriction.php b/includes/subscriptions/includes/plugin-content-restriction.php index bbbe088d4f..01acc1e72e 100644 --- a/includes/subscriptions/includes/plugin-content-restriction.php +++ b/includes/subscriptions/includes/plugin-content-restriction.php @@ -193,20 +193,20 @@ public function can_access_content( $return, $user_id, $restricted_to, $post_id foreach ( $restricted_to as $item ) { - if ( 'any' === $item[CS_POST_TYPE] ) { + if ( 'any' === $item[CS_EX_DOWNLOAD_ITEM] ) { $return['status'] = $subscriber->has_active_subscription() ? true : false; return $return; } // Get the Download object so we can use it in variable price checks. - $download = new CS_Download( $item[CS_POST_TYPE] ); + $download = new CS_Download( $item[CS_EX_DOWNLOAD_ITEM] ); if ( isset( $item['price_id'] ) && $download->has_variable_prices() ) { if ( is_numeric( $item['price_id'] ) ) { // Check if the variably-riced product is Recurring-enabled or not. - $recurring_enabled = CS_Recurring()->is_price_recurring( $item[CS_POST_TYPE], $item['price_id'] ); + $recurring_enabled = CS_Recurring()->is_price_recurring( $item[CS_EX_DOWNLOAD_ITEM], $item['price_id'] ); } elseif ( 'all' === $item['price_id'] ) { @@ -224,14 +224,14 @@ public function can_access_content( $return, $user_id, $restricted_to, $post_id } else { // Check if the product is Recurring-enabled or not. - $recurring_enabled = CS_Recurring()->is_recurring( $item[CS_POST_TYPE] ); + $recurring_enabled = CS_Recurring()->is_recurring( $item[CS_EX_DOWNLOAD_ITEM] ); } if ( $recurring_enabled ) { // If this subscriber has an active subscription to the variably-product in question. - if ( $subscriber->has_active_product_subscription( $item[CS_POST_TYPE] ) ) { + if ( $subscriber->has_active_product_subscription( $item[CS_EX_DOWNLOAD_ITEM] ) ) { $has_access = true; break; } @@ -317,19 +317,19 @@ public function restrict_shortcode_content( $content, $restricted_to, $atts ) { $custom_message = isset( $atts['message'] ) ? $atts['message'] : false; $products = array(); foreach ( $restricted_to as $item ) { - if ( cs_recurring()->is_recurring( $item[CS_POST_TYPE] ) ) { - $has_access = $subscriber->has_active_product_subscription( $item[CS_POST_TYPE] ); + if ( cs_recurring()->is_recurring( $item[CS_EX_DOWNLOAD_ITEM] ) ) { + $has_access = $subscriber->has_active_product_subscription( $item[CS_EX_DOWNLOAD_ITEM] ); } else { - if ( ! empty( $item[CS_POST_TYPE]['price_id'] ) && is_numeric( $item[CS_POST_TYPE]['price_id'] ) && cs_has_variable_prices( $item[CS_POST_TYPE] ) ) { - $has_access = cs_has_user_purchased( $user_id, $item[CS_POST_TYPE], $item[CS_POST_TYPE]['price_id'] ); + if ( ! empty( $item[CS_EX_DOWNLOAD_ITEM]['price_id'] ) && is_numeric( $item[CS_EX_DOWNLOAD_ITEM]['price_id'] ) && cs_has_variable_prices( $item[CS_EX_DOWNLOAD_ITEM] ) ) { + $has_access = cs_has_user_purchased( $user_id, $item[CS_EX_DOWNLOAD_ITEM], $item[CS_EX_DOWNLOAD_ITEM]['price_id'] ); } else { - $has_access = cs_has_user_purchased( $user_id, $item[CS_POST_TYPE] ); + $has_access = cs_has_user_purchased( $user_id, $item[CS_EX_DOWNLOAD_ITEM] ); } } if ( $has_access ) { return $content; } - $products[] = get_the_title( $item[CS_POST_TYPE] ); + $products[] = get_the_title( $item[CS_EX_DOWNLOAD_ITEM] ); } // At this point, $has_access is false and we just need to get the correct message. diff --git a/includes/template-functions.php b/includes/template-functions.php index 4dc99b713e..f190db1abd 100644 --- a/includes/template-functions.php +++ b/includes/template-functions.php @@ -994,7 +994,7 @@ function cs_download_shortcode_item( $atts, $i ) { $cs_download_shortcode_item_atts = $atts; $cs_download_shortcode_item_i = $i; - cs_get_template_part( 'shortcode', CS_POST_TYPE ); + cs_get_template_part( 'shortcode', CS_EX_DOWNLOAD_SHORTCODE ); } add_action( 'cs_download_shortcode_item', 'cs_download_shortcode_item', 10, 2 ); diff --git a/includes/theme-compatibility.php b/includes/theme-compatibility.php index c5acc86170..d1f2d8fa92 100644 --- a/includes/theme-compatibility.php +++ b/includes/theme-compatibility.php @@ -34,7 +34,7 @@ function cs_responsive_download_post_class( $classes = array(), $class = '', $po ) return $classes; - if ( ( $key = array_search( CS_POST_TYPE, $classes ) ) ) + if ( ( $key = array_search( CS_EX_DOWNLOAD_CSS_CLASS, $classes ) ) ) unset( $classes[ $key ] ); return $classes; From a66b158bdf64e539404fdf01e8dfad6bb0e007a8 Mon Sep 17 00:00:00 2001 From: Nick Temple Date: Wed, 23 Feb 2022 19:44:34 -0700 Subject: [PATCH 04/17] continuing teasing out 'download' --- commercestore.php | 5 ++++- includes/admin/admin-footer.php | 2 +- includes/admin/extensions/abstract-extension.php | 2 +- includes/database/tables/class-order-items.php | 2 +- includes/payments/class-payments-query.php | 8 ++++---- includes/process-download.php | 2 +- includes/scripts.php | 2 +- includes/subscriptions/subscriptions.php | 6 +++--- 8 files changed, 16 insertions(+), 13 deletions(-) diff --git a/commercestore.php b/commercestore.php index fe4996d4be..6f368d64c4 100644 --- a/commercestore.php +++ b/commercestore.php @@ -38,7 +38,7 @@ const CS_FEATURE_VARIABLE_PRICE = true; const CS_FEATURE_MARKETING = false; -const CS_DEFAULT_SLUG = 'store'; // Override with the CS_SLUG constant +const CS_DEFAULT_SLUG = 'download'; // Override with the CS_SLUG constant // @todo replace hardcoding of post_type and taxonomies with the following constants all throughout the codebase @@ -50,6 +50,9 @@ // Tease out the word 'download' that is used in different contexts. // search and replace back during build? +const CS_EX_ADMIN_PAGE = 'download'; +const CS_EX_DOWNLOAD_ADMIN_PAGE = 'download'; + const CS_EX_DOWNLOAD_CSS_CLASS = 'download'; const CS_EX_DOWNLOAD_SHORTCODE = 'download'; const CS_EX_DOWNLOAD_ITEM = 'download'; diff --git a/includes/admin/admin-footer.php b/includes/admin/admin-footer.php index 6d44c5ccba..1a50e586d6 100644 --- a/includes/admin/admin-footer.php +++ b/includes/admin/admin-footer.php @@ -23,7 +23,7 @@ function cs_admin_rate_us( $footer_text ) { global $typenow; - if ( $typenow == CS_POST_TYPE ) { // VERIFY + if ( $typenow == CS_POST_TYPE ) { $rate_text = sprintf( __( 'Thank you for using CommerceStore! Please rate us on WordPress.org', 'commercestore' ), 'https://commercestore.com', 'https://wordpress.org/support/plugin/commercestore/reviews/?rate=5#new-post' diff --git a/includes/admin/extensions/abstract-extension.php b/includes/admin/extensions/abstract-extension.php index 39505173b1..41eb471eed 100644 --- a/includes/admin/extensions/abstract-extension.php +++ b/includes/admin/extensions/abstract-extension.php @@ -156,7 +156,7 @@ protected function is_cs_settings_screen() { * @return bool */ protected function is_download_edit_screen() { - return cs_is_admin_page( CS_POST_TYPE, 'edit' ) || cs_is_admin_page( CS_POST_TYPE, 'new' ); + return cs_is_admin_page( CS_EX_DOWNLOAD_ADMIN_PAGE, 'edit' ) || cs_is_admin_page( CS_EX_DOWNLOAD_ADMIN_PAGE, 'new' ); } /** diff --git a/includes/database/tables/class-order-items.php b/includes/database/tables/class-order-items.php index 5be927b5ee..b85b1b1e8e 100644 --- a/includes/database/tables/class-order-items.php +++ b/includes/database/tables/class-order-items.php @@ -71,7 +71,7 @@ protected function set_schema() { product_name text NOT NULL default '', price_id bigint(20) unsigned default null, cart_index bigint(20) unsigned NOT NULL default '0', - type varchar(20) NOT NULL default CS_POST_TYPE, + type varchar(20) NOT NULL default 'download', status varchar(20) NOT NULL default 'pending', quantity int signed NOT NULL default '0', amount decimal(18,9) NOT NULL default '0', diff --git a/includes/payments/class-payments-query.php b/includes/payments/class-payments-query.php index 03060e6c4e..7ec8607edd 100644 --- a/includes/payments/class-payments-query.php +++ b/includes/payments/class-payments-query.php @@ -520,15 +520,15 @@ public function children() { * @since 1.8 */ public function download() { - if ( empty( $this->args[CS_POST_TYPE] ) ) { + if ( empty( $this->args[CS_EX_DOWNLOAD_ARGS] ) ) { return; } $order_ids = array(); - if ( is_array( $this->args[CS_POST_TYPE] ) ) { + if ( is_array( $this->args[CS_EX_DOWNLOAD_ARGS] ) ) { $orders = cs_get_order_items( array( - 'product_id__in' => (array) $this->args[CS_POST_TYPE], + 'product_id__in' => (array) $this->args[CS_EX_DOWNLOAD_ARGS], ) ); foreach ( $orders as $order ) { @@ -537,7 +537,7 @@ public function download() { } } else { $orders = cs_get_order_items( array( - 'product_id' => $this->args[CS_POST_TYPE], + 'product_id' => $this->args[CS_EX_DOWNLOAD_ARGS], ) ); foreach ( $orders as $order ) { diff --git a/includes/process-download.php b/includes/process-download.php index 7091be9fcf..9670f4ae20 100644 --- a/includes/process-download.php +++ b/includes/process-download.php @@ -27,7 +27,7 @@ function cs_process_download() { } $args = apply_filters( 'cs_process_download_args', array( - CS_POST_TYPE => ( isset( $_GET['download_id'] ) ) ? (int) $_GET['download_id'] : '', + 'download' => ( isset( $_GET['download_id'] ) ) ? (int) $_GET['download_id'] : '', 'email' => ( isset( $_GET['email'] ) ) ? rawurldecode( $_GET['email'] ) : '', 'expire' => ( isset( $_GET['expire'] ) ) ? rawurldecode( $_GET['expire'] ) : '', 'file_key' => ( isset( $_GET['file'] ) ) ? (int) $_GET['file'] : '', diff --git a/includes/scripts.php b/includes/scripts.php index 0b81ed1e70..a3fa88e26d 100644 --- a/includes/scripts.php +++ b/includes/scripts.php @@ -398,7 +398,7 @@ function cs_enqueue_admin_scripts( $hook = '' ) { } // Downloads page. - if ( cs_is_admin_page( CS_POST_TYPE ) ) { + if ( cs_is_admin_page( CS_EX_DOWNLOAD_ADMIN_PAGE ) ) { wp_enqueue_script( 'cs-admin-downloads' ); } diff --git a/includes/subscriptions/subscriptions.php b/includes/subscriptions/subscriptions.php index a9445892f5..62051da81c 100644 --- a/includes/subscriptions/subscriptions.php +++ b/includes/subscriptions/subscriptions.php @@ -445,7 +445,7 @@ public function register_post_statuses() { */ public function subscriptions_list() { add_submenu_page( - 'edit.php?post_type=download', + 'edit.php?post_type=' . CS_POST_TYPE, __( 'Subscriptions', 'commercestore' ), __( 'Subscriptions', 'commercestore' ), 'view_shop_reports', @@ -1556,9 +1556,9 @@ public function enable_child_payments( $query ) { $query_has_recurring = true; - if( ! empty( $query->initial_args[CS_POST_TYPE] ) ) { + if( ! empty( $query->initial_args[CS_EX_DOWNLOAD_ARGS] ) ) { $query_has_recurring = false; - $download = $query->initial_args[CS_POST_TYPE]; + $download = $query->initial_args[CS_EX_DOWNLOAD_ARGS]; if ( ! is_array( $download ) && strpos( $download, ',' ) ) { $download = explode( ',', $download ); From 26cc4d1852ff8b92a7bdd44c40e4bd37d978f08f Mon Sep 17 00:00:00 2001 From: Nick Temple Date: Wed, 23 Feb 2022 20:04:47 -0700 Subject: [PATCH 05/17] change category name --- commercestore.php | 8 ++++++-- includes/admin/admin-pages.php | 6 +++--- includes/admin/downloads/dashboard-columns.php | 16 ++++++++-------- .../import/class-batch-import-downloads.php | 6 +++--- .../class-categories-reports-table.php | 8 ++++---- .../reporting/class-download-reports-table.php | 4 ++-- .../export/class-batch-export-downloads.php | 2 +- includes/api/class-cs-api-v2.php | 6 +++--- includes/api/class-cs-api.php | 2 +- includes/class-cs-html-elements.php | 4 ++-- includes/class-structured-data.php | 2 +- includes/post-types.php | 14 +++++++------- includes/shortcodes.php | 8 ++++---- includes/template-functions.php | 2 +- includes/theme-compatibility.php | 2 +- includes/widgets.php | 18 +++++++++--------- tests/tests-widgets.php | 18 +++++++++--------- uninstall.php | 2 +- 18 files changed, 66 insertions(+), 62 deletions(-) diff --git a/commercestore.php b/commercestore.php index 6f368d64c4..ea566fd23d 100644 --- a/commercestore.php +++ b/commercestore.php @@ -40,8 +40,6 @@ const CS_FEATURE_MARKETING = false; const CS_DEFAULT_SLUG = 'download'; // Override with the CS_SLUG constant -// @todo replace hardcoding of post_type and taxonomies with the following constants all throughout the codebase - const CS_ICON = 'download'; // Change the icon here const CS_POST_TYPE = 'csproduct'; @@ -59,7 +57,13 @@ const CS_EX_DOWNLOAD_ARGS = 'download'; const CS_EX_DOWNLOAD_MESSAGES = 'download'; +class CSFilter { + const DOWNLOAD_CATEGORY_ARGS = 'cs_' . CS_CAT_TYPE . '_args'; + const DOWNLOAD_CATEGORY_LABEL = 'cs_' . CS_CAT_TYPE . '_labels'; + const DOWNLOAD_TAG_ARGS = 'cs_' . CS_TAG_TYPE . '_args'; + const DOWNLOAD_TAG_LABEL = 'cs_' . CS_TAG_TYPE . '_labels'; +} const CS_BASE_PLUGIN = __FILE__; diff --git a/includes/admin/admin-pages.php b/includes/admin/admin-pages.php index 522f8ffa4b..01990aba9b 100644 --- a/includes/admin/admin-pages.php +++ b/includes/admin/admin-pages.php @@ -202,17 +202,17 @@ function cs_is_admin_page( $passed_page = '', $passed_view = '', $include_non_ex switch ( $passed_view ) { case 'list-table': case 'new': - if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' !== $action && 'download_category' === $taxonomy ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' !== $action && CS_CAT_TYPE === $taxonomy ) { $found = true; } break; case 'edit': - if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' === $action && 'download_category' === $taxonomy ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' === $action && CS_CAT_TYPE === $taxonomy ) { $found = true; } break; default: - if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit-tags.php' && 'download_category' === $taxonomy ) { + if ( ( CS_POST_TYPE === $typenow || CS_POST_TYPE === $post_type ) && $pagenow === 'edit-tags.php' && CS_CAT_TYPE === $taxonomy ) { $found = true; } break; diff --git a/includes/admin/downloads/dashboard-columns.php b/includes/admin/downloads/dashboard-columns.php index fb7d72a553..c85036e887 100644 --- a/includes/admin/downloads/dashboard-columns.php +++ b/includes/admin/downloads/dashboard-columns.php @@ -23,13 +23,13 @@ * Post Type List Table */ function cs_download_columns( $download_columns ) { - $category_labels = cs_get_taxonomy_labels( 'download_category' ); + $category_labels = cs_get_taxonomy_labels( CS_CAT_TYPE ); $tag_labels = cs_get_taxonomy_labels( 'download_tag' ); return apply_filters( 'cs_download_columns', array( 'cb' => '', 'title' => __( 'Name', 'commercestore' ), - 'download_category' => $category_labels['menu_name'], + CS_CAT_TYPE => $category_labels['menu_name'], 'download_tag' => $tag_labels['menu_name'], 'price' => __( 'Price', 'commercestore' ), 'sales' => __( 'Sales', 'commercestore' ), @@ -55,8 +55,8 @@ function cs_render_download_columns( $column_name, $post_id ) { } switch ( $column_name ) { - case 'download_category': - $terms = get_the_term_list( $post_id, 'download_category', '', ', ', ''); + case CS_CAT_TYPE: + $terms = get_the_term_list( $post_id, CS_CAT_TYPE, '', ', ', ''); echo ! empty( $terms ) ? $terms : '—'; @@ -225,13 +225,13 @@ function cs_add_download_filters() { return; } - $terms = get_terms( 'download_category' ); + $terms = get_terms( CS_CAT_TYPE ); if ( count( $terms ) > 0 ) { - echo ""; + $category_labels = cs_get_taxonomy_labels( CS_CAT_TYPE ); echo ""; foreach ( $terms as $term ) { - $selected = isset( $_GET['download_category'] ) && $_GET['download_category'] === $term->slug ? ' selected="selected"' : ''; + $selected = isset( $_GET[CS_CAT_TYPE] ) && $_GET[CS_CAT_TYPE] === $term->slug ? ' selected="selected"' : ''; echo ''; } echo ""; diff --git a/includes/admin/import/class-batch-import-downloads.php b/includes/admin/import/class-batch-import-downloads.php index 58805aa808..7679cd5449 100644 --- a/includes/admin/import/class-batch-import-downloads.php +++ b/includes/admin/import/class-batch-import-downloads.php @@ -170,7 +170,7 @@ public function process_step() { $categories = $this->str_to_array( $row[ $this->field_mapping['categories'] ] ); - $this->set_taxonomy_terms( $download_id, $categories, 'download_category' ); + $this->set_taxonomy_terms( $download_id, $categories, CS_CAT_TYPE ); } @@ -481,7 +481,7 @@ private function set_image( $download_id = 0, $image = '', $post_author = 0 ) { * @since 2.6 * @return void */ - private function set_taxonomy_terms( $download_id = 0, $terms = array(), $taxonomy = 'download_category' ) { + private function set_taxonomy_terms( $download_id = 0, $terms = array(), $taxonomy = CS_CAT_TYPE ) { $terms = $this->maybe_create_terms( $terms, $taxonomy ); @@ -499,7 +499,7 @@ private function set_taxonomy_terms( $download_id = 0, $terms = array(), $taxono * @since 2.6 * @return array */ - private function maybe_create_terms( $terms = array(), $taxonomy = 'download_category' ) { + private function maybe_create_terms( $terms = array(), $taxonomy = CS_CAT_TYPE ) { // Return of term IDs $term_ids = array(); diff --git a/includes/admin/reporting/class-categories-reports-table.php b/includes/admin/reporting/class-categories-reports-table.php index 03d2172dd7..b1e84fdde9 100644 --- a/includes/admin/reporting/class-categories-reports-table.php +++ b/includes/admin/reporting/class-categories-reports-table.php @@ -152,7 +152,7 @@ public function get_data() { } else { $reports_data = array(); - $categories = get_terms( 'download_category', array( + $categories = get_terms( CS_CAT_TYPE, array( 'parent' => 0, 'hierarchical' => 0, 'hide_empty' => false @@ -161,7 +161,7 @@ public function get_data() { foreach ( $categories as $category ) { $category_slugs = array( $category->slug ); - $child_terms = get_terms( 'download_category', array( + $child_terms = get_terms( CS_CAT_TYPE, array( 'parent' => $category->term_id, 'hierarchical' => 0 ) ); @@ -178,7 +178,7 @@ public function get_data() { 'fields' => 'ids', 'tax_query' => array( array( - 'taxonomy' => 'download_category', + 'taxonomy' => CS_CAT_TYPE, 'field' => 'slug', 'terms' => $category_slugs ) @@ -228,7 +228,7 @@ public function get_data() { 'fields' => 'ids', 'tax_query' => array( array( - 'taxonomy' => 'download_category', + 'taxonomy' => CS_CAT_TYPE, 'field' => 'slug', 'terms' => $child_term->slug ) diff --git a/includes/admin/reporting/class-download-reports-table.php b/includes/admin/reporting/class-download-reports-table.php index ee77e7bdfa..9e7a89ad9f 100644 --- a/includes/admin/reporting/class-download-reports-table.php +++ b/includes/admin/reporting/class-download-reports-table.php @@ -162,7 +162,7 @@ public function bulk_actions( $which = '' ) { * @return void */ public function category_filter() { - if ( get_terms( 'download_category' ) ) { + if ( get_terms( CS_CAT_TYPE ) ) { echo CS()->html->category_dropdown( 'category', $this->get_category() ); } } @@ -192,7 +192,7 @@ public function query() { if ( ! empty( $category ) ) { $args['tax_query'] = array( array( - 'taxonomy' => 'download_category', + 'taxonomy' => CS_CAT_TYPE, 'terms' => $category ) ); diff --git a/includes/admin/reporting/export/class-batch-export-downloads.php b/includes/admin/reporting/export/class-batch-export-downloads.php index 5110cf39b4..4a42640283 100644 --- a/includes/admin/reporting/export/class-batch-export-downloads.php +++ b/includes/admin/reporting/export/class-batch-export-downloads.php @@ -166,7 +166,7 @@ public function get_data() { $row[ $key ] = implode( ' | ', $terms ); } } elseif ( 'categories' == $key ) { - $terms = get_the_terms( $download->ID, 'download_category' ); + $terms = get_the_terms( $download->ID, CS_CAT_TYPE ); if ( $terms ) { $terms = wp_list_pluck( $terms, 'name' ); diff --git a/includes/api/class-cs-api-v2.php b/includes/api/class-cs-api-v2.php index 7b5cf94698..87dc736d92 100644 --- a/includes/api/class-cs-api-v2.php +++ b/includes/api/class-cs-api-v2.php @@ -80,7 +80,7 @@ public function get_products( $args = array() ) { if ( is_numeric( $args['category'] ) ) { $query_args['tax_query'] = array( array( - 'taxonomy' => 'download_category', + 'taxonomy' => CS_CAT_TYPE, 'field' => 'ID', 'terms' => (int) $args['category'] ), @@ -93,7 +93,7 @@ public function get_products( $args = array() ) { $field = is_numeric( $category ) ? 'ID': 'slug'; $query_args['tax_query'][] = array( - 'taxonomy' => 'download_category', + 'taxonomy' => CS_CAT_TYPE, 'field' => $field, 'terms' => $category, ); @@ -101,7 +101,7 @@ public function get_products( $args = array() ) { } } else { - $query_args['download_category'] = $args['category']; + $query_args[CS_CAT_TYPE] = $args['category']; } } diff --git a/includes/api/class-cs-api.php b/includes/api/class-cs-api.php index 97ee27c8c7..8b8a2b5116 100644 --- a/includes/api/class-cs-api.php +++ b/includes/api/class-cs-api.php @@ -1157,7 +1157,7 @@ public function get_product_data( $product_info ) { $product['info']['content'] = $product_info->post_content; $product['info']['excerpt'] = $product_info->post_excerpt; $product['info']['thumbnail'] = wp_get_attachment_url( get_post_thumbnail_id( $product_info->ID ) ); - $product['info']['category'] = get_the_terms( $product_info, 'download_category' ); + $product['info']['category'] = get_the_terms( $product_info, CS_CAT_TYPE ); $product['info']['tags'] = get_the_terms( $product_info, 'download_tag' ); if ( user_can( $this->user_id, 'view_shop_reports' ) || $this->override ) { diff --git a/includes/class-cs-html-elements.php b/includes/class-cs-html-elements.php index 19a47c063d..c35a716ccf 100644 --- a/includes/class-cs-html-elements.php +++ b/includes/class-cs-html-elements.php @@ -479,14 +479,14 @@ public function discount_dropdown( $name = 'cs_discounts', $selected = 0, $statu * @return string $output Category dropdown */ public function category_dropdown( $name = 'cs_categories', $selected = 0 ) { - $categories = get_terms( 'download_category', apply_filters( 'cs_category_dropdown', array() ) ); + $categories = get_terms( CS_CAT_TYPE, apply_filters( 'cs_category_dropdown', array() ) ); $options = array(); foreach ( $categories as $category ) { $options[ absint( $category->term_id ) ] = esc_html( $category->name ); } - $category_labels = cs_get_taxonomy_labels( 'download_category' ); + $category_labels = cs_get_taxonomy_labels( CS_CAT_TYPE ); $output = $this->select( array( 'name' => $name, 'selected' => $selected, diff --git a/includes/class-structured-data.php b/includes/class-structured-data.php index 03ac6d8939..ea38f0449c 100644 --- a/includes/class-structured-data.php +++ b/includes/class-structured-data.php @@ -191,7 +191,7 @@ public function generate_download_data( $download = false ) { ); } - $download_categories = wp_get_post_terms( $download->ID, 'download_category' ); + $download_categories = wp_get_post_terms( $download->ID, CS_CAT_TYPE ); if ( is_array( $download_categories ) && ! empty( $download_categories ) ) { $download_categories = wp_list_pluck( $download_categories, 'name' ); $data['category'] = implode( ', ', $download_categories ); diff --git a/includes/post-types.php b/includes/post-types.php index d89f559462..1f73c18bcc 100644 --- a/includes/post-types.php +++ b/includes/post-types.php @@ -255,11 +255,11 @@ function cs_setup_download_taxonomies() { 'menu_name' => __( 'Categories', 'commercestore' ), ); - $category_args = apply_filters( 'cs_download_category_args', array( + $category_args = apply_filters( CSFilter::DOWNLOAD_CATEGORY_ARGS, array( 'hierarchical' => true, - 'labels' => apply_filters( 'cs_download_category_labels', $category_labels ), + 'labels' => apply_filters( CSFilter::DOWNLOAD_CATEGORY_LABEL, $category_labels ), 'show_ui' => true, - 'query_var' => 'download_category', + 'query_var' => CS_CAT_TYPE, 'rewrite' => array( 'slug' => $slug . '/category', 'with_front' => false, 'hierarchical' => true ), 'capabilities' => array( 'manage_terms' => 'manage_product_terms', @@ -269,8 +269,8 @@ function cs_setup_download_taxonomies() { ), ) ); - register_taxonomy( 'download_category', array( CS_POST_TYPE ), $category_args ); - register_taxonomy_for_object_type( 'download_category', CS_POST_TYPE ); + register_taxonomy( CS_CAT_TYPE, array( CS_POST_TYPE ), $category_args ); + register_taxonomy_for_object_type( CS_CAT_TYPE, CS_POST_TYPE ); /** Tags */ $tag_labels = array( @@ -315,9 +315,9 @@ function cs_setup_download_taxonomies() { * @param string $taxonomy The Taxonomy to get labels for * @return array Associative array of labels (name = plural) */ -function cs_get_taxonomy_labels( $taxonomy = 'download_category' ) { +function cs_get_taxonomy_labels( $taxonomy = CS_CAT_TYPE ) { $allowed_taxonomies = apply_filters( 'cs_allowed_download_taxonomies', array( - 'download_category', + CS_CAT_TYPE, 'download_tag', ) ); diff --git a/includes/shortcodes.php b/includes/shortcodes.php index 49390f59ce..187c5b35cc 100644 --- a/includes/shortcodes.php +++ b/includes/shortcodes.php @@ -448,7 +448,7 @@ function cs_downloads_query( $atts, $content = null ) { } else { - $term = get_term_by( 'slug', $category, 'download_category' ); + $term = get_term_by( 'slug', $category, CS_CAT_TYPE ); if( ! $term ) { continue; @@ -459,7 +459,7 @@ function cs_downloads_query( $atts, $content = null ) { } $query['tax_query'][] = array( - 'taxonomy' => 'download_category', + 'taxonomy' => CS_CAT_TYPE, 'field' => 'term_id', 'terms' => $term_id, ); @@ -483,7 +483,7 @@ function cs_downloads_query( $atts, $content = null ) { } else { - $term = get_term_by( 'slug', $category, 'download_category' ); + $term = get_term_by( 'slug', $category, CS_CAT_TYPE ); if( ! $term ) { continue; @@ -493,7 +493,7 @@ function cs_downloads_query( $atts, $content = null ) { } $query['tax_query'][] = array( - 'taxonomy' => 'download_category', + 'taxonomy' => CS_CAT_TYPE, 'field' => 'term_id', 'terms' => $term_id, 'operator' => 'NOT IN' diff --git a/includes/template-functions.php b/includes/template-functions.php index f190db1abd..dfc4e6dc11 100644 --- a/includes/template-functions.php +++ b/includes/template-functions.php @@ -850,7 +850,7 @@ function cs_add_download_post_classes( $classes, $class = '', $post_id = false ) $classes[] = 'cs-download'; // Add category slugs - $categories = get_the_terms( $post_id, 'download_category' ); + $categories = get_the_terms( $post_id, CS_CAT_TYPE ); if( ! empty( $categories ) ) { foreach( $categories as $key => $value ) { $classes[] = 'cs-download-cat-' . $value->slug; diff --git a/includes/theme-compatibility.php b/includes/theme-compatibility.php index d1f2d8fa92..af60631a0c 100644 --- a/includes/theme-compatibility.php +++ b/includes/theme-compatibility.php @@ -29,7 +29,7 @@ function cs_responsive_download_post_class( $classes = array(), $class = '', $po if ( ! is_singular( CS_POST_TYPE ) && ! is_post_type_archive( CS_POST_TYPE ) && - ! is_tax( 'download_category' ) && + ! is_tax( CS_CAT_TYPE ) && ! is_tax( 'download_tag' ) ) return $classes; diff --git a/includes/widgets.php b/includes/widgets.php index dfe1a9b63f..b7105aa9ac 100644 --- a/includes/widgets.php +++ b/includes/widgets.php @@ -153,7 +153,7 @@ function widget( $args, $instance ) { // Set defaults. $args['id'] = ( isset( $args['id'] ) ) ? $args['id'] : 'cs_categories_tags_widget'; $instance['title'] = ( isset( $instance['title'] ) ) ? $instance['title'] : ''; - $instance['taxonomy'] = ( isset( $instance['taxonomy'] ) ) ? $instance['taxonomy'] : 'download_category'; + $instance['taxonomy'] = ( isset( $instance['taxonomy'] ) ) ? $instance['taxonomy'] : CS_CAT_TYPE; $title = apply_filters( 'widget_title', $instance['title'], $instance, $args['id'] ); $tax = $instance['taxonomy']; @@ -192,7 +192,7 @@ function form( $instance ) { // Set up some default widget settings. $defaults = array( 'title' => '', - 'taxonomy' => 'download_category', + 'taxonomy' => CS_CAT_TYPE, 'count' => 'off', 'hide_empty' => 'off', ); @@ -206,11 +206,11 @@ function form( $instance ) {

@@ -306,12 +306,12 @@ public function widget( $args, $instance ) { $category_list = false; $category_label = ''; if ( $categories ) { - $category_terms = (array) get_the_terms( $download_id, 'download_category' ); + $category_terms = (array) get_the_terms( $download_id, CS_CAT_TYPE ); if ( $category_terms && ! is_wp_error( $category_terms ) ) { - $category_list = get_the_term_list( $download_id, 'download_category', '', ', ' ); + $category_list = get_the_term_list( $download_id, CS_CAT_TYPE, '', ', ' ); $category_count = count( $category_terms ); - $category_labels = cs_get_taxonomy_labels( 'download_category' ); + $category_labels = cs_get_taxonomy_labels( CS_CAT_TYPE ); $category_label = $category_count > 1 ? $category_labels['name'] : $category_labels['singular_name']; } } @@ -433,7 +433,7 @@ public function form( $instance ) {

- + id="get_field_id( 'categories' ) ); ?>" name="get_field_name( 'categories' ) ); ?>" type="checkbox" />

diff --git a/tests/tests-widgets.php b/tests/tests-widgets.php index fedc59c378..51b47b6202 100644 --- a/tests/tests-widgets.php +++ b/tests/tests-widgets.php @@ -198,7 +198,7 @@ public function test_categories_tags_widget_function() { $widgets = $GLOBALS['wp_widget_factory']->widgets; $categories_widget = $widgets['cs_categories_tags_widget']; $download = CS_Helper_Download::create_simple_download(); - $terms = wp_set_object_terms( $download->ID, array( 'test1', 'test2' ), 'download_category', false ); + $terms = wp_set_object_terms( $download->ID, array( 'test1', 'test2' ), CS_CAT_TYPE, false ); $this->go_to( $download->ID ); @@ -211,7 +211,7 @@ public function test_categories_tags_widget_function() { 'after_widget' => '', ), array( 'title' => 'Cart', - 'taxonomy' => 'download_category', + 'taxonomy' => CS_CAT_TYPE, 'count' => true, 'hide_empty' => true, ) ); @@ -236,11 +236,11 @@ public function test_categories_tags_widget_update() { $categories_widget = $widgets['cs_categories_tags_widget']; $updated = $categories_widget->update( - array( 'title' => 'Categories', 'taxonomy' => 'download_category', 'count' => true, 'hide_empty' => true ), + array( 'title' => 'Categories', 'taxonomy' => CS_CAT_TYPE, 'count' => true, 'hide_empty' => true ), array( 'title' => 'Tags', 'taxonomy' => 'download_tag', 'count' => true, 'hide_empty' => true ) ); - $this->assertEquals( $updated, array( 'title' => 'Categories', 'taxonomy' => 'download_category', 'count' => true, 'hide_empty' => true ) ); + $this->assertEquals( $updated, array( 'title' => 'Categories', 'taxonomy' => CS_CAT_TYPE, 'count' => true, 'hide_empty' => true ) ); } @@ -261,8 +261,8 @@ public function test_categories_tags_widget_form() { $this->assertRegExp( '/