diff --git a/.buildkite/pipeline.sh b/.buildkite/pipeline.sh index f35c0c6bcd..80672dbd8d 100755 --- a/.buildkite/pipeline.sh +++ b/.buildkite/pipeline.sh @@ -7,7 +7,7 @@ set -eu echo "steps:" phpVersions=('7.4') -wpVersions=('5.9' 'latest') +wpVersions=('latest') # Exclude combinations with - exclusions=('7.3-4.9.15' '7.4-4.9.15' '7.4-5.0.10' '7.4-5.1.6' '7.4-5.2.7') @@ -37,19 +37,3 @@ for phpVersion in ${phpVersions[@]}; do echo " run: wordpress" done done - -echo " - env:" -echo " TEST_INPLACE: \"0\"" -echo " TEST_PHP_VERSION: \""$phpVersion"\"" -echo " TEST_WP_VERSION: "$wpVersion"" -echo " WP_MULTISITE: \"1\"" -echo " label: 'PHP: "$phpVersion" | WP: "$wpVersion" | Multisite: Yes'" -echo " plugins:" -echo " - docker-compose#v3.7.0:" -echo " config: docker-compose-phpunit.yml" -echo " env:" -echo " - WP_MULTISITE" -echo " - TEST_INPLACE" -echo " propagate-uid-gid: true" -echo " pull-retries: 3" -echo " run: wordpress" diff --git a/commercestore.php b/commercestore.php index e5f44d42c3..817c8579a6 100644 --- a/commercestore.php +++ b/commercestore.php @@ -38,12 +38,44 @@ 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_ICON = 'download'; // Change the reports icon here + +const CS_POST_TYPE = 'infoproduct'; // 'download' const CS_TAG_TYPE = CS_POST_TYPE . '_tag'; const CS_CAT_TYPE = CS_POST_TYPE . '_category'; +const CS_LOG_TYPE = 'cs_log_type'; + +// Custom Post Types - Not fully implemented across the board +const CS_PRODUCT_CPT = CS_POST_TYPE; +const CS_PAYMENT_CPT = 'cs_payment'; +const CS_DISCOUNT_CPT = 'cs_discount'; +const CS_LOG_CPT = 'cs_log'; + + +const CS_QUERY_VAR = CS_POST_TYPE; // 'download'; + +// 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'; +const CS_EX_DOWNLOAD_ARGS = 'download'; +const CS_EX_DOWNLOAD_MESSAGES = 'download'; +const CS_EX_DOWNLOAD_MESSAGES_TYPE = 'download'; + +class CSFilter { + const CATEGORY_ARGS = 'cs_' . CS_CAT_TYPE . '_args'; + const CATEGORY_LABELS = 'cs_' . CS_CAT_TYPE . '_labels'; + + const TAG_ARGS = 'cs_' . CS_TAG_TYPE . '_args'; + const TAG_LABELS = 'cs_' . CS_TAG_TYPE . '_labels'; +} + const CS_BASE_PLUGIN = __FILE__; diff --git a/includes/admin/admin-actions.php b/includes/admin/admin-actions.php index ba543b6dd5..9a06b4e1de 100644 --- a/includes/admin/admin-actions.php +++ b/includes/admin/admin-actions.php @@ -45,7 +45,7 @@ function cs_products_tabs( $views ) { return $views; } -add_filter( 'views_edit-download', 'cs_products_tabs', 10, 1 ); +add_filter( 'views_edit-' . CS_POST_TYPE, 'cs_products_tabs', 10, 1 ); /** * When the Download list table loads, call the function to view our tabs. @@ -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 ) ) { @@ -94,11 +94,11 @@ function cs_admin_adjust_submenus() { // Loop through each taxonomy and remove the menu foreach ( $taxonomies as $taxonomy ) { - remove_submenu_page( 'edit.php?post_type=download', 'edit-tags.php?taxonomy=' . $taxonomy . '&post_type=download' ); + remove_submenu_page( 'edit.php?post_type=' . CS_POST_TYPE, 'edit-tags.php?taxonomy=' . $taxonomy . '&post_type=' . CS_POST_TYPE ); } // Remove the "Add New" link for downloads - remove_submenu_page( 'edit.php?post_type=download', 'post-new.php?post_type=download' ); + remove_submenu_page( 'edit.php?post_type=' . CS_POST_TYPE, 'post-new.php?post_type=' . CS_POST_TYPE); } add_action( 'admin_menu', 'cs_admin_adjust_submenus', 999 ); @@ -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 ) ) { @@ -131,7 +131,7 @@ function cs_taxonomies_modify_menu_highlight() { } // Force the submenu file - $submenu_file = 'edit.php?post_type=download'; + $submenu_file = 'edit.php?post_type=' . CS_POST_TYPE; } add_filter( 'admin_head', 'cs_taxonomies_modify_menu_highlight', 9999 ); @@ -154,13 +154,13 @@ 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; } // Force the submenu file - $submenu_file = 'edit.php?post_type=download'; + $submenu_file = 'edit.php?post_type=' . CS_POST_TYPE; } add_filter( 'admin_head', 'cs_add_new_modify_menu_highlight', 9999 ); @@ -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-deprecated-functions.php b/includes/admin/admin-deprecated-functions.php index c08e4b1104..b0c33dee0e 100644 --- a/includes/admin/admin-deprecated-functions.php +++ b/includes/admin/admin-deprecated-functions.php @@ -31,7 +31,7 @@ function cs_tools_banned_emails_display() {

+ action="">

@@ -69,7 +69,7 @@ function cs_trigger_purchase_delete( $data ) { cs_delete_purchase( $payment_id ); - cs_redirect( admin_url( '/edit.php?post_type=download&page=cs-payment-history&cs-message=payment_deleted' ) ); + cs_redirect( admin_url( '/edit.php?post_type=' . CS_POST_TYPE . '&page=cs-payment-history&cs-message=payment_deleted' ) ); } } add_action( 'cs_delete_payment', 'cs_trigger_purchase_delete' ); diff --git a/includes/admin/admin-footer.php b/includes/admin/admin-footer.php index 57a5feae24..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 == 'download' ) { + 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/admin-pages.php b/includes/admin/admin-pages.php index 319f9b949e..579ac63739 100644 --- a/includes/admin/admin-pages.php +++ b/includes/admin/admin-pages.php @@ -83,12 +83,12 @@ function cs_add_options_link() { $customer_view_role = apply_filters( 'cs_view_customers_role', 'view_shop_reports' ); // Setup pages - $cs_payments_page = add_submenu_page( 'edit.php?post_type=download', __( 'Orders', 'commercestore' ), __( 'Orders', 'commercestore' ), 'edit_shop_payments', 'cs-payment-history', 'cs_payment_history_page' ); - $cs_customers_page = add_submenu_page( 'edit.php?post_type=download', __( 'Customers', 'commercestore' ), __( 'Customers', 'commercestore' ), $customer_view_role, 'cs-customers', 'cs_customers_page' ); - $cs_discounts_page = add_submenu_page( 'edit.php?post_type=download', __( 'Discounts', 'commercestore' ), __( 'Discounts', 'commercestore' ), 'manage_shop_discounts', 'cs-discounts', 'cs_discounts_page' ); - $cs_reports_page = add_submenu_page( 'edit.php?post_type=download', __( 'Reports', 'commercestore' ), __( 'Reports', 'commercestore' ), 'view_shop_reports', 'cs-reports', 'cs_reports_page' ); - $cs_settings_page = add_submenu_page( 'edit.php?post_type=download', __( 'CS Settings', 'commercestore' ), __( 'Settings', 'commercestore' ), 'manage_shop_settings', 'cs-settings', 'cs_options_page' ); - $cs_tools_page = add_submenu_page( 'edit.php?post_type=download', __( 'CS Tools', 'commercestore' ), __( 'Tools', 'commercestore' ), 'manage_shop_settings', 'cs-tools', 'cs_tools_page' ); + $cs_payments_page = add_submenu_page( 'edit.php?post_type=' . CS_POST_TYPE, __( 'Orders', 'commercestore' ), __( 'Orders', 'commercestore' ), 'edit_shop_payments', 'cs-payment-history', 'cs_payment_history_page' ); + $cs_customers_page = add_submenu_page( 'edit.php?post_type=' . CS_POST_TYPE, __( 'Customers', 'commercestore' ), __( 'Customers', 'commercestore' ), $customer_view_role, 'cs-customers', 'cs_customers_page' ); + $cs_discounts_page = add_submenu_page( 'edit.php?post_type=' . CS_POST_TYPE, __( 'Discounts', 'commercestore' ), __( 'Discounts', 'commercestore' ), 'manage_shop_discounts', 'cs-discounts', 'cs_discounts_page' ); + $cs_reports_page = add_submenu_page( 'edit.php?post_type=' . CS_POST_TYPE, __( 'Reports', 'commercestore' ), __( 'Reports', 'commercestore' ), 'view_shop_reports', 'cs-reports', 'cs_reports_page' ); + $cs_settings_page = add_submenu_page( 'edit.php?post_type=' . CS_POST_TYPE, __( 'CS Settings', 'commercestore' ), __( 'Settings', 'commercestore' ), 'manage_shop_settings', 'cs-settings', 'cs_options_page' ); + $cs_tools_page = add_submenu_page( 'edit.php?post_type=' . CS_POST_TYPE, __( 'CS Tools', 'commercestore' ), __( 'Tools', 'commercestore' ), 'manage_shop_settings', 'cs-tools', 'cs_tools_page' ); // Setup hidden upgrades page $cs_upgrades_screen = add_submenu_page( null, __( 'CS Upgrades', 'commercestore' ), __( 'CS Upgrades', 'commercestore' ), 'manage_shop_settings', 'cs-upgrades', 'cs_upgrades_screen' ); @@ -97,7 +97,7 @@ function cs_add_options_link() { $submenu['index.php'][] = array( __( 'Store Reports', 'commercestore' ), 'view_shop_reports', - 'edit.php?post_type=download&page=cs-reports', + 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-reports', ); } add_action( 'admin_menu', 'cs_add_options_link', 10 ); @@ -112,7 +112,7 @@ function cs_add_options_link() { function cs_add_extentions_link() { global $cs_add_ons_page; - $cs_add_ons_page = add_submenu_page( 'edit.php?post_type=download', __( 'CS Extensions', 'commercestore' ), __( 'Extensions', 'commercestore' ), 'manage_shop_settings', 'cs-addons', 'cs_add_ons_page' ); + $cs_add_ons_page = add_submenu_page( 'edit.php?post_type=' . CS_POST_TYPE, __( 'CS Extensions', 'commercestore' ), __( 'Extensions', 'commercestore' ), 'manage_shop_settings', 'cs-addons', 'cs_add_ons_page' ); } add_action( 'admin_menu', 'cs_add_extentions_link', 99999 ); @@ -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 && CS_CAT_TYPE === $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 && CS_CAT_TYPE === $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' && CS_CAT_TYPE === $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-api-keys-table.php b/includes/admin/class-api-keys-table.php index 8b57d72f05..8b60105f6f 100644 --- a/includes/admin/class-api-keys-table.php +++ b/includes/admin/class-api-keys-table.php @@ -179,7 +179,7 @@ public function bulk_actions( $which = '' ) { $cs_api_is_bottom = true; ?> - + diff --git a/includes/admin/class-cs-notices.php b/includes/admin/class-cs-notices.php index 901278a751..5256a7b8a0 100644 --- a/includes/admin/class-cs-notices.php +++ b/includes/admin/class-cs-notices.php @@ -221,7 +221,7 @@ private function add_page_notices() { if ( empty( $purchase_page ) || ( 'trash' === get_post_status( $purchase_page ) ) ) { $this->add_notice( array( 'id' => 'cs-no-purchase-page', - 'message' => sprintf( __( 'No checkout page is configured. Set one in Settings.', 'commercestore' ), admin_url( 'edit.php?post_type=download&page=cs-settings&tab=general§ion=pages' ) ), + 'message' => sprintf( __( 'No checkout page is configured. Set one in Settings.', 'commercestore' ), admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-settings&tab=general§ion=pages' ) ), 'class' => 'error', 'is_dismissible' => false ) ); @@ -316,7 +316,7 @@ private function add_data_notices() { 'id' => 'cs-recount-earnings', 'class' => 'error', 'is_dismissible' => false, - 'message' => sprintf( __( 'CommerceStore 2.5 contains a built in recount tool. Please deactivate the CommerceStore - Recount Earnings plugin', 'commercestore' ), admin_url( 'edit.php?post_type=download&page=cs-tools&tab=general' ), admin_url( 'plugins.php' ) ) + 'message' => sprintf( __( 'CommerceStore 2.5 contains a built in recount tool. Please deactivate the CommerceStore - Recount Earnings plugin', 'commercestore' ), admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-tools&tab=general' ), admin_url( 'plugins.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/customers/class-customer-table.php b/includes/admin/customers/class-customer-table.php index fff5ab120a..cf9d0e4fab 100644 --- a/includes/admin/customers/class-customer-table.php +++ b/includes/admin/customers/class-customer-table.php @@ -115,11 +115,11 @@ public function column_name( $item ) { $state = ''; $status = $this->get_status(); $name = ! empty( $item['name'] ) ? $item['name'] : '—'; - $view_url = admin_url( 'edit.php?post_type=download&page=cs-customers&view=overview&id=' . $item['id'] ); + $view_url = admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-customers&view=overview&id=' . $item['id'] ); $actions = array( 'view' => '' . __( 'Edit', 'commercestore' ) . '', - 'logs' => '' . __( 'Logs', 'commercestore' ) . '', - 'delete' => '' . __( 'Delete', 'commercestore' ) . '', + 'logs' => '' . __( 'Logs', 'commercestore' ) . '', + 'delete' => '' . __( 'Delete', 'commercestore' ) . '', ); $item_status = ! empty( $item['status'] ) diff --git a/includes/admin/customers/customer-actions.php b/includes/admin/customers/customer-actions.php index 141d457f75..b2826d7c61 100644 --- a/includes/admin/customers/customer-actions.php +++ b/includes/admin/customers/customer-actions.php @@ -243,7 +243,7 @@ function cs_add_customer_email( $args = array() ) { } } else { - $redirect = admin_url( 'edit.php?post_type=download&page=cs-customers&view=overview&id=' . $customer_id . '&cs-message=email-added' ); + $redirect = admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-customers&view=overview&id=' . $customer_id . '&cs-message=email-added' ); $output = array( 'success' => true, 'message' => __( 'Email successfully added to customer.', 'commercestore' ), @@ -303,14 +303,14 @@ function cs_remove_customer_email() { $customer = new CS_Customer( $_GET['id'] ); if ( $customer->remove_email( $_GET['email'] ) ) { - $url = add_query_arg( 'cs-message', 'email-removed', admin_url( 'edit.php?post_type=download&page=cs-customers&view=overview&id=' . $customer->id ) ); + $url = add_query_arg( 'cs-message', 'email-removed', admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-customers&view=overview&id=' . $customer->id ) ); $user = wp_get_current_user(); $user_login = ! empty( $user->user_login ) ? $user->user_login : cs_get_bot_name(); $customer_note = sprintf( __( 'Email address %s removed by %s', 'commercestore' ), sanitize_email( $_GET['email'] ), $user_login ); $customer->add_note( $customer_note ); } else { - $url = add_query_arg( 'cs-message', 'email-remove-failed', admin_url( 'edit.php?post_type=download&page=cs-customers&view=overview&id=' . $customer->id ) ); + $url = add_query_arg( 'cs-message', 'email-remove-failed', admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-customers&view=overview&id=' . $customer->id ) ); } cs_redirect( $url ); @@ -344,14 +344,14 @@ function cs_set_customer_primary_email() { $customer = new CS_Customer( $_GET['id'] ); if ( $customer->set_primary_email( $_GET['email'] ) ) { - $url = add_query_arg( 'cs-message', 'primary-email-updated', admin_url( 'edit.php?post_type=download&page=cs-customers&view=overview&id=' . $customer->id ) ); + $url = add_query_arg( 'cs-message', 'primary-email-updated', admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-customers&view=overview&id=' . $customer->id ) ); $user = wp_get_current_user(); $user_login = ! empty( $user->user_login ) ? $user->user_login : cs_get_bot_name(); $customer_note = sprintf( __( 'Email address %s set as primary by %s', 'commercestore' ), sanitize_email( $_GET['email'] ), $user_login ); $customer->add_note( $customer_note ); } else { - $url = add_query_arg( 'cs-message', 'primary-email-failed', admin_url( 'edit.php?post_type=download&page=cs-customers&view=overview&id=' . $customer->id ) ); + $url = add_query_arg( 'cs-message', 'primary-email-failed', admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-customers&view=overview&id=' . $customer->id ) ); } cs_redirect( $url ); @@ -390,7 +390,7 @@ function cs_customer_delete( $args = array() ) { } if ( cs_get_errors() ) { - cs_redirect( admin_url( 'edit.php?post_type=download&page=cs-customers&view=overview&id=' . $customer_id ) ); + cs_redirect( admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-customers&view=overview&id=' . $customer_id ) ); } $customer = new CS_Customer( $customer_id ); @@ -421,16 +421,16 @@ function cs_customer_delete( $args = array() ) { } } - $redirect = admin_url( 'edit.php?post_type=download&page=cs-customers&cs-message=customer-deleted' ); + $redirect = admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-customers&cs-message=customer-deleted' ); } else { cs_set_error( 'cs-customer-delete-failed', __( 'Error deleting customer', 'commercestore' ) ); - $redirect = admin_url( 'edit.php?post_type=download&page=cs-customers&view=delete&id=' . $customer_id ); + $redirect = admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-customers&view=delete&id=' . $customer_id ); } } else { cs_set_error( 'cs-customer-delete-invalid-id', __( 'Invalid Customer ID', 'commercestore' ) ); - $redirect = admin_url( 'edit.php?post_type=download&page=cs-customers' ); + $redirect = admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-customers' ); } cs_redirect( $redirect ); @@ -515,7 +515,7 @@ function cs_process_admin_user_verification() { $customer = new CS_Customer( $_GET['id'] ); cs_set_user_to_verified( $customer->user_id ); - $url = add_query_arg( 'cs-message', 'user-verified', admin_url( 'edit.php?post_type=download&page=cs-customers&view=overview&id=' . $customer->id ) ); + $url = add_query_arg( 'cs-message', 'user-verified', admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-customers&view=overview&id=' . $customer->id ) ); cs_redirect( $url ); } diff --git a/includes/admin/customers/customer-functions.php b/includes/admin/customers/customer-functions.php index 4e0af30290..51097357bf 100644 --- a/includes/admin/customers/customer-functions.php +++ b/includes/admin/customers/customer-functions.php @@ -149,7 +149,7 @@ function cs_render_customer_column( $value, $column_name, $user_id ) { if ( $customer->id > 0 ) { $name = '#' . $customer->id . ' '; $name .= ! empty( $customer->name ) ? $customer->name : '' . __( 'Unnamed Customer', 'commercestore' ) . ''; - $view_url = admin_url( 'edit.php?post_type=download&page=cs-customers&view=overview&id=' . $customer->id ); + $view_url = admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-customers&view=overview&id=' . $customer->id ); return '' . $name . ''; } diff --git a/includes/admin/customers/customers.php b/includes/admin/customers/customers.php index 12716cf741..7d72d16889 100644 --- a/includes/admin/customers/customers.php +++ b/includes/admin/customers/customers.php @@ -460,7 +460,7 @@ function cs_customers_view( $customer = null ) { ?>

- + @@ -600,7 +600,7 @@ function cs_customers_view( $customer = null ) {
  • - + - +
    email, 30 ); ?> name; ?> @@ -1150,7 +1150,7 @@ function cs_verify_customer_notice( $customer ) { return; } - $url = wp_nonce_url( admin_url( 'edit.php?post_type=download&page=cs-customers&view=overview&cs_action=verify_user_admin&id=' . $customer->id ), 'cs-verify-user' ); + $url = wp_nonce_url( admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-customers&view=overview&cs_action=verify_user_admin&id=' . $customer->id ), 'cs-verify-user' ); echo '

    '; _e( 'This customer\'s user account is pending verification.', 'commercestore' ); diff --git a/includes/admin/dashboard-widgets.php b/includes/admin/dashboard-widgets.php index d1d09b0764..39234f0022 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' ); @@ -273,7 +273,7 @@ function cs_dashboard_at_a_glance_widget( $items ) { $text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); if ( current_user_can( 'edit_products' ) ) { - $text = sprintf( '%1$s', $text ); + $text = sprintf( '%1$s', $text ); } else { $text = sprintf( '%1$s', $text ); } diff --git a/includes/admin/discounts/add-discount.php b/includes/admin/discounts/add-discount.php index 3f963facc7..b4846ca43e 100644 --- a/includes/admin/discounts/add-discount.php +++ b/includes/admin/discounts/add-discount.php @@ -210,7 +210,7 @@ - + - + @@ -228,7 +228,7 @@

    - +

    diff --git a/includes/admin/discounts/discount-codes.php b/includes/admin/discounts/discount-codes.php index 6f2bb2a99a..4c3d9c1197 100644 --- a/includes/admin/discounts/discount-codes.php +++ b/includes/admin/discounts/discount-codes.php @@ -52,7 +52,7 @@ function cs_discounts_page_content() { do_action( 'cs_discounts_page_top' ); ?> - + search_box( __( 'Search Discounts', 'commercestore' ), 'cs-discounts' ); ?> @@ -66,4 +66,4 @@ function cs_discounts_page_content() { - +

    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..aa9d128826 100644 --- a/includes/admin/downloads/dashboard-columns.php +++ b/includes/admin/downloads/dashboard-columns.php @@ -23,14 +23,14 @@ * Post Type List Table */ function cs_download_columns( $download_columns ) { - $category_labels = cs_get_taxonomy_labels( 'download_category' ); - $tag_labels = cs_get_taxonomy_labels( 'download_tag' ); + $category_labels = cs_get_taxonomy_labels( CS_CAT_TYPE ); + $tag_labels = cs_get_taxonomy_labels( CS_TAG_TYPE ); return apply_filters( 'cs_download_columns', array( 'cb' => '', 'title' => __( 'Name', 'commercestore' ), - 'download_category' => $category_labels['menu_name'], - 'download_tag' => $tag_labels['menu_name'], + CS_CAT_TYPE => $category_labels['menu_name'], + CS_TAG_TYPE => $tag_labels['menu_name'], 'price' => __( 'Price', 'commercestore' ), 'sales' => __( 'Sales', 'commercestore' ), 'earnings' => __( 'Gross Revenue', 'commercestore' ), @@ -50,19 +50,19 @@ 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; } 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 : '—'; break; - case 'download_tag': - $terms = get_the_term_list( $post_id, 'download_tag', '', ', ', ''); + case CS_TAG_TYPE: + $terms = get_the_term_list( $post_id, CS_TAG_TYPE, '', ', ', ''); echo ! empty( $terms ) ? $terms : '—'; @@ -91,7 +91,7 @@ function cs_render_download_columns( $column_name, $post_id ) { break; case 'earnings': if ( current_user_can( 'view_product_stats', $post_id ) ) { - echo ''; + echo ''; echo cs_currency_filter( cs_format_amount( cs_get_download_earnings_stats( $post_id ) ) ); echo ''; } else { @@ -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,30 +220,30 @@ 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; } - $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 ""; } - $terms = get_terms( 'download_tag' ); + $terms = get_terms( CS_TAG_TYPE ); if ( count( $terms ) > 0 ) { - echo ""; + $tag_labels = cs_get_taxonomy_labels( CS_TAG_TYPE ); echo ""; foreach ( $terms as $term ) { - $selected = isset( $_GET['download_tag']) && $_GET['download_tag'] === $term->slug ? ' selected="selected"' : ''; + $selected = isset( $_GET[CS_TAG_TYPE]) && $_GET[CS_TAG_TYPE] === $term->slug ? ' selected="selected"' : ''; echo ''; } echo ""; @@ -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..a708129c7d 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; } @@ -1327,13 +1327,13 @@ function cs_render_stats_meta_box() {

    - +


    -
    +

    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..56271e81fc 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' => '', @@ -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 ); } @@ -179,7 +179,7 @@ public function process_step() { $tags = $this->str_to_array( $row[ $this->field_mapping['tags'] ] ); - $this->set_taxonomy_terms( $download_id, $tags, 'download_tag' ); + $this->set_taxonomy_terms( $download_id, $tags, CS_TAG_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(); @@ -550,7 +550,7 @@ private function maybe_create_terms( $terms = array(), $taxonomy = 'download_cat * @return string */ public function get_list_table_url() { - return admin_url( 'edit.php?post_type=download' ); + return admin_url( 'edit.php?post_type=' . CS_POST_TYPE ); } /** diff --git a/includes/admin/import/class-batch-import-payments.php b/includes/admin/import/class-batch-import-payments.php index ce08a87212..8fb6982a97 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, @@ -621,7 +621,7 @@ public function get_percentage_complete() { * @return string */ public function get_list_table_url() { - return admin_url( 'edit.php?post_type=download&page=cs-payment-history' ); + return admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-payment-history' ); } /** diff --git a/includes/admin/payments/orders.php b/includes/admin/payments/orders.php index 640393932b..0253e9384e 100644 --- a/includes/admin/payments/orders.php +++ b/includes/admin/payments/orders.php @@ -239,7 +239,7 @@ function cs_order_details_customer( $order ) { - +
    @@ -538,9 +538,9 @@ function cs_order_details_logs( $order ) { do_action( 'cs_view_order_details_logs_before', $order->id ); ?> -

    -

    -

    +

    +

    +

    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..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 ) ); @@ -173,12 +173,12 @@ 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( array( - 'taxonomy' => 'download_category', + 'taxonomy' => CS_CAT_TYPE, 'field' => 'slug', 'terms' => $category_slugs ) @@ -223,12 +223,12 @@ 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( 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 6d0e57bf25..a02cc8db45 100644 --- a/includes/admin/reporting/class-download-reports-table.php +++ b/includes/admin/reporting/class-download-reports-table.php @@ -78,7 +78,7 @@ public function column_default( $item, $column_name ) { case 'average_earnings' : return cs_currency_filter( cs_format_amount( $item[ $column_name ] ) ); case 'details' : - return '' . __( 'View Detailed Report', 'commercestore' ) . ''; + return '' . __( 'View Detailed Report', 'commercestore' ) . ''; default: return $item[ $column_name ]; } @@ -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; @@ -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() ); } } @@ -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', @@ -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/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..7619ae0b80 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 . '' @@ -84,7 +84,7 @@ public function column_default( $item, $column_name ) { case 'payment_id' : $number = cs_get_payment_number( $item['payment_id'] ); return ! empty( $number ) - ? '' . esc_html( $number ) . '' + ? '' . esc_html( $number ) . '' : '—'; case 'ip' : return '' . esc_html( $item['ip'] ) . ''; @@ -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..f2ebc0d3a5 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': @@ -63,7 +63,7 @@ public function column_default( $item, $column_name ) { ? $item['customer']->name : '' . __( 'Unnamed Customer', 'commercestore' ) . ''; - $return = '#' . $item['customer']->id . ' ' . $name . ''; + $return = '#' . $item['customer']->id . ' ' . $name . ''; break; case 'item_price': @@ -75,7 +75,7 @@ public function column_default( $item, $column_name ) { break; case 'ID': - $return = '' . $item['ID'] . ''; + $return = '' . $item['ID'] . ''; break; default: @@ -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..2cb04afd95 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', @@ -159,14 +159,14 @@ public function get_data() { break; } } elseif ( 'tags' == $key ) { - $terms = get_the_terms( $download->ID, 'download_tag' ); + $terms = get_the_terms( $download->ID, CS_TAG_TYPE ); if ( $terms ) { $terms = wp_list_pluck( $terms, 'name' ); $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' ); @@ -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..06d56596ed 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_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' => 'download', + 'icon' => CS_ICON, 'priority' => 30, 'endpoints' => array( 'tiles' => $tiles, @@ -2588,7 +2588,7 @@ function cs_register_export_report( $reports ) { 'icon' => 'migrate', 'priority' => 1000, 'capability' => 'export_shop_reports', - 'display_callback' => 'display_export_report', + 'display_callback' => 'cs_display_export_report', 'filters' => false, ) ); } catch ( \CS_Exception $exception ) { @@ -2601,7 +2601,7 @@ function cs_register_export_report( $reports ) { * * @since 3.0 */ -function display_export_report() { +function cs_display_export_report() { global $wpdb; wp_enqueue_script( 'cs-admin-tools-export' ); @@ -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..bcaffc7807 100644 --- a/includes/admin/tools.php +++ b/includes/admin/tools.php @@ -209,7 +209,7 @@ function cs_tools_clear_doing_upgrade_display() {

    + action="">

    @@ -277,7 +277,7 @@ function cs_tools_betas_display() {

    + action=""> $product ) : ?> @@ -975,9 +975,9 @@ class="button-secondary"/>

    -

    Reports page.', 'commercestore' ), admin_url( 'edit.php?post_type=download&page=cs-reports&tab=export' ) ); ?>

    +

    Reports page.', 'commercestore' ), admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-reports&tab=export' ) ); ?>

    + action="">

    @@ -992,7 +992,7 @@ class="button-secondary"/>

    + action="">

    @@ -1223,7 +1223,7 @@ function cs_tools_sysinfo_display() {

    - + @@ -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/tools/logs.php b/includes/admin/tools/logs.php index a881963f43..eafdc2caf0 100644 --- a/includes/admin/tools/logs.php +++ b/includes/admin/tools/logs.php @@ -57,7 +57,7 @@ function cs_logs_view_page( $logs_table, $tag = '' ) { */ do_action( "cs_logs_{$tag}_top" ); ?> - + @@ -219,7 +219,7 @@ function cs_log_views() {
    - +
    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..2518ee2899 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'] ) @@ -1305,7 +1305,7 @@ function cs_ajax_customer_details() { 'date_created' => esc_html( $customer->date_created ), 'date_created_i18n' => esc_html( cs_date_i18n( $customer->date_created ) ), '_links' => array( - 'self' => esc_url_raw( admin_url( 'edit.php?post_type=download&page=cs-customers&view=overview&id=' . $customer->id ) ), + 'self' => esc_url_raw( admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-customers&view=overview&id=' . $customer->id ) ), ), ); diff --git a/includes/api/class-cs-api-v2.php b/includes/api/class-cs-api-v2.php index 316e3b55d7..a57b665fb9 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(), @@ -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']; } } @@ -113,7 +113,7 @@ public function get_products( $args = array() ) { if ( is_numeric( $args['tag'] ) ) { $query_args['tax_query'] = array( array( - 'taxonomy' => 'download_tag', + 'taxonomy' => CS_TAG_TYPE, 'field' => 'ID', 'terms' => (int) $args['tag'] ), @@ -126,7 +126,7 @@ public function get_products( $args = array() ) { $field = is_numeric( $tag ) ? 'ID': 'slug'; $query_args['tax_query'][] = array( - 'taxonomy' => 'download_tag', + 'taxonomy' => CS_TAG_TYPE, 'field' => $field, 'terms' => $tag, ); @@ -134,7 +134,7 @@ public function get_products( $args = array() ) { } } else { - $query_args['download_tag'] = $args['tag']; + $query_args[CS_TAG_TYPE] = $args['tag']; } } @@ -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 c70ec9c5ed..90aaaa6fc2 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 ); @@ -1157,8 +1157,8 @@ 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']['tags'] = get_the_terms( $product_info, 'download_tag' ); + $product['info']['category'] = get_the_terms( $product_info, CS_CAT_TYPE ); + $product['info']['tags'] = get_the_terms( $product_info, CS_TAG_TYPE ); if ( user_can( $this->user_id, 'view_shop_reports' ) || $this->override ) { $product['stats']['total']['sales'] = cs_get_download_sales_stats( $product_info->ID ); @@ -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 { @@ -2037,23 +2037,23 @@ public function process_api_key( $args ) { case 'generate': if ( $this->generate_api_key( $user_id ) ) { delete_transient( 'cs-total-api-keys' ); - cs_redirect( add_query_arg( 'cs-message', 'api-key-generated', 'edit.php?post_type=download&page=cs-tools&tab=api_keys' ) ); + cs_redirect( add_query_arg( 'cs-message', 'api-key-generated', 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-tools&tab=api_keys' ) ); exit(); } else { - cs_redirect( add_query_arg( 'cs-message', 'api-key-failed', 'edit.php?post_type=download&page=cs-tools&tab=api_keys' ) ); + cs_redirect( add_query_arg( 'cs-message', 'api-key-failed', 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-tools&tab=api_keys' ) ); exit(); } break; case 'regenerate': $this->generate_api_key( $user_id, true ); delete_transient( 'cs-total-api-keys' ); - cs_redirect( add_query_arg( 'cs-message', 'api-key-regenerated', 'edit.php?post_type=download&page=cs-tools&tab=api_keys' ) ); + cs_redirect( add_query_arg( 'cs-message', 'api-key-regenerated', 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-tools&tab=api_keys' ) ); exit(); break; case 'revoke': $this->revoke_api_key( $user_id ); delete_transient( 'cs-total-api-keys' ); - cs_redirect( add_query_arg( 'cs-message', 'api-key-revoked', 'edit.php?post_type=download&page=cs-tools&tab=api_keys' ) ); + cs_redirect( add_query_arg( 'cs-message', 'api-key-revoked', 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-tools&tab=api_keys' ) ); exit(); break; default; diff --git a/includes/cart/functions.php b/includes/cart/functions.php index c39830330e..4d7ce94117 100644 --- a/includes/cart/functions.php +++ b/includes/cart/functions.php @@ -490,7 +490,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-discount.php b/includes/class-cs-discount.php index ed08e96df0..311859a90b 100644 --- a/includes/class-cs-discount.php +++ b/includes/class-cs-discount.php @@ -1822,7 +1822,7 @@ public function edit_url() { return esc_url( add_query_arg( array( 'cs-action' => 'edit_discount', 'discount' => $this->id, - ), admin_url( 'edit.php?post_type=download&page=cs-discounts' ) ) ); + ), admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-discounts' ) ) ); } /** 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..c35a716ccf 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'], @@ -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-cs-license-handler.php b/includes/class-cs-license-handler.php index 97dd1aa70d..f19128033d 100644 --- a/includes/class-cs-license-handler.php +++ b/includes/class-cs-license-handler.php @@ -500,7 +500,7 @@ public function notices() { $messages[] = sprintf( __( 'You have invalid or expired license keys for CommerceStore. Fix this', 'commercestore' ), - admin_url( 'edit.php?post_type=download&page=cs-settings&tab=licenses' ) + admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-settings&tab=licenses' ) ); $showed_invalid_message = true; @@ -528,7 +528,7 @@ public function plugin_row_license_missing( $plugin_data, $version_info ) { $license = get_option( $this->item_shortname . '_license_active' ); if ( ( ! is_object( $license ) || empty( $license->license ) || 'valid' !== $license->license ) && empty( $showed_imissing_key_message[ $this->item_shortname ] ) ) { - echo ' ' . __( 'Enter valid license key for automatic updates.', 'commercestore' ) . ''; + echo ' ' . __( 'Enter valid license key for automatic updates.', 'commercestore' ) . ''; $showed_imissing_key_message[ $this->item_shortname ] = true; } 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..ea38f0449c 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 ); } @@ -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/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/deprecated-functions.php b/includes/deprecated-functions.php index 57b5fd9823..f861a1b680 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 . '
    ' ); } @@ -1647,7 +1647,7 @@ function cs_sendwp_remote_install_handler () { 'register_url' => sendwp_get_server_url() . '_/signup', 'client_name' => sendwp_get_client_name(), 'client_secret' => sendwp_get_client_secret(), - 'client_redirect' => admin_url( '/edit.php?post_type=download&page=cs-settings&tab=emails&cs-message=sendwp-connected' ), + 'client_redirect' => admin_url( '/edit.php?post_type=' . CS_POST_TYPE . '&page=cs-settings&tab=emails&cs-message=sendwp-connected' ), ) ); } add_action( 'wp_ajax_cs_sendwp_remote_install', 'cs_sendwp_remote_install_handler' ); 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/connect.php b/includes/gateways/paypal/admin/connect.php index 37322405e2..2784ea6a50 100644 --- a/includes/gateways/paypal/admin/connect.php +++ b/includes/gateways/paypal/admin/connect.php @@ -402,7 +402,7 @@ function get_account_info() { $account_status .= sprintf( /* Translators: %1$s opening anchor tag; %2$s closing anchor tag; %3$s: opening line item/status/strong tags; %4$s closing strong tag; %5$s: closing list item tag */ __( '%3$sGateway Status: %4$s PayPal is not currently active. %1$sEnable PayPal%2$s in the general gateway settings to start using it.%5$s', 'commercestore' ), - '', + '', '', '
  • ', '', 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/gateways/paypal/admin/settings.php b/includes/gateways/paypal/admin/settings.php index b25d877c3d..1f6cfe40fa 100644 --- a/includes/gateways/paypal/admin/settings.php +++ b/includes/gateways/paypal/admin/settings.php @@ -18,7 +18,7 @@ * @return string */ function get_settings_url() { - return admin_url( 'edit.php?post_type=download&page=cs-settings&tab=gateways§ion=paypal_commerce' ); + return admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-settings&tab=gateways§ion=paypal_commerce' ); } /** diff --git a/includes/gateways/stripe/includes/admin/admin-actions.php b/includes/gateways/stripe/includes/admin/admin-actions.php index 1406c49ad1..6a58c163b0 100644 --- a/includes/gateways/stripe/includes/admin/admin-actions.php +++ b/includes/gateways/stripe/includes/admin/admin-actions.php @@ -18,9 +18,9 @@ function csx_process_preapproved_charge() { $charge = csx_charge_preapproved( $payment_id ); if ( $charge ) { - wp_redirect( esc_url_raw( add_query_arg( array( 'cs-message' => 'preapproval-charged' ), admin_url( 'edit.php?post_type=download&page=cs-payment-history' ) ) ) ); exit; + wp_redirect( esc_url_raw( add_query_arg( array( 'cs-message' => 'preapproval-charged' ), admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-payment-history' ) ) ) ); exit; } else { - wp_redirect( esc_url_raw( add_query_arg( array( 'cs-message' => 'preapproval-failed' ), admin_url( 'edit.php?post_type=download&page=cs-payment-history' ) ) ) ); exit; + wp_redirect( esc_url_raw( add_query_arg( array( 'cs-message' => 'preapproval-failed' ), admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-payment-history' ) ) ) ); exit; } } @@ -57,7 +57,7 @@ function csx_process_preapproved_cancel() { cs_update_payment_status( $payment_id, 'cancelled' ); delete_post_meta( $payment_id, '_csx_stripe_customer_id' ); - wp_redirect( esc_url_raw( add_query_arg( array( 'cs-message' => 'preapproval-cancelled' ), admin_url( 'edit.php?post_type=download&page=cs-payment-history' ) ) ) ); exit; + wp_redirect( esc_url_raw( add_query_arg( array( 'cs-message' => 'preapproval-cancelled' ), admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-payment-history' ) ) ) ); exit; } add_action( 'cs_cancel_stripe_preapproval', 'csx_process_preapproved_cancel' ); @@ -90,7 +90,7 @@ function csx_admin_messages() { } if( isset( $_GET['cs_gateway_connect_error'], $_GET['cs-message'] ) ) { - echo '

    ' . sprintf( __( 'There was an error connecting your Stripe account. Message: %s. Please try again.', 'commercestore' ), esc_html( urldecode( $_GET['cs-message'] ) ), esc_url( admin_url( 'edit.php?post_type=download&page=cs-settings&tab=gateways§ion=cs-stripe' ) ) ) . '

    '; + echo '

    ' . sprintf( __( 'There was an error connecting your Stripe account. Message: %s. Please try again.', 'commercestore' ), esc_html( urldecode( $_GET['cs-message'] ) ), esc_url( admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-settings&tab=gateways§ion=cs-stripe' ) ) ) . '

    '; add_filter( 'wp_parse_str', function( $ar ) { if( isset( $ar['cs_gateway_connect_error'] ) ) { unset( $ar['cs_gateway_connect_error'] ); diff --git a/includes/gateways/stripe/includes/admin/admin-filters.php b/includes/gateways/stripe/includes/admin/admin-filters.php index 27ad9d6ab1..40de85e819 100644 --- a/includes/gateways/stripe/includes/admin/admin-filters.php +++ b/includes/gateways/stripe/includes/admin/admin-filters.php @@ -54,9 +54,9 @@ function csx_payment_status_filters( $views ) { $cancelled_count = ' (' . $payment_count->cancelled . ')'; $current = isset( $_GET['status'] ) ? $_GET['status'] : ''; - $views['preapproval'] = sprintf( '%s', esc_url( add_query_arg( 'status', 'preapproval', admin_url( 'edit.php?post_type=download&page=cs-payment-history' ) ) ), $current === 'preapproval' ? ' class="current"' : '', __( 'Preapproved', 'commercestore' ) . $preapproval_count ); - $views['pending_preapproval'] = sprintf( '%s', esc_url( add_query_arg( 'status', 'preapproval_pending', admin_url( 'edit.php?post_type=download&page=cs-payment-history' ) ) ), $current === 'preapproval_pending' ? ' class="current"' : '', __( 'Preapproval Pending', 'commercestore' ) . $preapproval_pending_count ); - $views['cancelled'] = sprintf( '%s', esc_url( add_query_arg( 'status', 'cancelled', admin_url( 'edit.php?post_type=download&page=cs-payment-history' ) ) ), $current === 'cancelled' ? ' class="current"' : '', __( 'Cancelled', 'commercestore' ) . $cancelled_count ); + $views['preapproval'] = sprintf( '%s', esc_url( add_query_arg( 'status', 'preapproval', admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-payment-history' ) ) ), $current === 'preapproval' ? ' class="current"' : '', __( 'Preapproved', 'commercestore' ) . $preapproval_count ); + $views['pending_preapproval'] = sprintf( '%s', esc_url( add_query_arg( 'status', 'preapproval_pending', admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-payment-history' ) ) ), $current === 'preapproval_pending' ? ' class="current"' : '', __( 'Preapproval Pending', 'commercestore' ) . $preapproval_pending_count ); + $views['cancelled'] = sprintf( '%s', esc_url( add_query_arg( 'status', 'cancelled', admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-payment-history' ) ) ), $current === 'cancelled' ? ' class="current"' : '', __( 'Cancelled', 'commercestore' ) . $cancelled_count ); return $views; } @@ -96,10 +96,10 @@ function csx_payments_column_data( $value, $payment_id, $column_name ) { $value .= '

    '; if ( in_array( $status, array( 'preapproval', 'preapproval_pending' ), true ) ) { - $actions[] = '' . __( 'Process', 'commercestore' ) . ''; + $actions[] = '' . __( 'Process', 'commercestore' ) . ''; if ( 'cancelled' !== $status ) { - $actions[] = '' . __( 'Cancel', 'commercestore' ) . ''; + $actions[] = '' . __( 'Cancel', 'commercestore' ) . ''; } } @@ -109,4 +109,4 @@ function csx_payments_column_data( $value, $payment_id, $column_name ) { } return $value; } -add_filter( 'cs_payments_table_column', 'csx_payments_column_data', 20, 3 ); \ No newline at end of file +add_filter( 'cs_payments_table_column', 'csx_payments_column_data', 20, 3 ); diff --git a/includes/gateways/stripe/includes/admin/notices.php b/includes/gateways/stripe/includes/admin/notices.php index b9ee9cc427..ad15172991 100644 --- a/includes/gateways/stripe/includes/admin/notices.php +++ b/includes/gateways/stripe/includes/admin/notices.php @@ -45,7 +45,7 @@ function csx_admin_notices_register() { sprintf( /* translators: %1$s Opening anchor tag, do not translate. %2$s Closing anchor tag, do not translate. */ __( 'The Stripe extension for Easy Digital Downloads supports Stripe Connect for easier setup and improved security. %1$sClick here%2$s to learn more about connecting your Stripe account.', 'commercestore' ), - '', + '', '' ), array( @@ -83,7 +83,7 @@ function csx_admin_notices_register() { __( '%1$sCredit card payments with Stripe are currently disabled.%2$s', 'commercestore' ), '', '' - ) + ) . '
    ' . sprintf( /* translators: %1$s Opening code tag, do not translate. %2$s Closing code tag, do not translate. */ diff --git a/includes/gateways/stripe/includes/admin/settings.php b/includes/gateways/stripe/includes/admin/settings.php index 0448861221..1cea281eeb 100644 --- a/includes/gateways/stripe/includes/admin/settings.php +++ b/includes/gateways/stripe/includes/admin/settings.php @@ -26,7 +26,7 @@ function csx_add_settings( $settings ) { $stripe_connect_url = add_query_arg( array( 'live_mode' => (int) ! cs_is_test_mode(), 'state' => str_pad( wp_rand( wp_rand(), PHP_INT_MAX ), 100, wp_rand(), STR_PAD_BOTH ), - 'customer_site_url' => admin_url( 'edit.php?post_type=download&page=cs-settings&tab=gateways§ion=cs-stripe' ), + 'customer_site_url' => admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-settings&tab=gateways§ion=cs-stripe' ), ), 'https://commercestore.com/?cs_gateway_connect_init=stripe_connect' ); $test_mode = cs_is_test_mode(); @@ -289,13 +289,13 @@ function csx_process_gateway_connect_completion() { $cs_credentials_url = add_query_arg( array( 'live_mode' => (int) ! cs_is_test_mode(), 'state' => sanitize_text_field( $_GET['state'] ), - 'customer_site_url' => admin_url( 'edit.php?post_type=download' ), + 'customer_site_url' => admin_url( 'edit.php?post_type=' . CS_POST_TYPE ), ), 'https://commercestore.com/?cs_gateway_connect_credentials=stripe_connect' ); $response = wp_remote_get( esc_url_raw( $cs_credentials_url ) ); if( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) { - $message = '

    ' . sprintf( __( 'There was an error getting your Stripe credentials. Please try again. If you continue to have this problem, please contact support.', 'commercestore' ), esc_url( admin_url( 'edit.php?post_type=download&page=cs-settings&tab=gateways§ion=cs-stripe' ) ) ) . '

    '; + $message = '

    ' . sprintf( __( 'There was an error getting your Stripe credentials. Please try again. If you continue to have this problem, please contact support.', 'commercestore' ), esc_url( admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-settings&tab=gateways§ion=cs-stripe' ) ) ) . '

    '; wp_die( $message ); } @@ -311,8 +311,8 @@ function csx_process_gateway_connect_completion() { } cs_update_option( 'stripe_connect_account_id', sanitize_text_field( $data['stripe_user_id'] ) ); - wp_redirect( esc_url_raw( admin_url( 'edit.php?post_type=download&page=cs-settings&tab=gateways§ion=cs-stripe' ) ) ); + wp_redirect( esc_url_raw( admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-settings&tab=gateways§ion=cs-stripe' ) ) ); exit; } -add_action( 'admin_init', 'csx_process_gateway_connect_completion' ); \ No newline at end of file +add_action( 'admin_init', 'csx_process_gateway_connect_completion' ); diff --git a/includes/misc-functions.php b/includes/misc-functions.php index 2da201f285..cba39f1062 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 bda23b26ef..37bf97a221 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 29575c2dc3..b692c6152c 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 dfa2315147..accf32a0b2 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_EX_DOWNLOAD_ARGS] ) ) { return; } $order_ids = array(); - if ( is_array( $this->args['download'] ) ) { + if ( is_array( $this->args[CS_EX_DOWNLOAD_ARGS] ) ) { $orders = cs_get_order_items( array( - 'product_id__in' => (array) $this->args['download'], + '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['download'], + 'product_id' => $this->args[CS_EX_DOWNLOAD_ARGS], ) ); foreach ( $orders as $order ) { @@ -548,7 +548,7 @@ public function download() { $this->args['id__in'] = $order_ids; - $this->__unset( 'download' ); + $this->__unset( CS_EX_DOWNLOAD_ARGS ); } /** diff --git a/includes/payments/functions.php b/includes/payments/functions.php index 4718762c55..484707132d 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( $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['download'] ) ); + $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 82dd3b3740..1ff0966e01 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 ); } @@ -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::CATEGORY_ARGS, array( 'hierarchical' => true, - 'labels' => apply_filters( 'cs_download_category_labels', $category_labels ), + 'labels' => apply_filters( CSFilter::CATEGORY_LABELS, $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( 'download' ), $category_args ); - register_taxonomy_for_object_type( 'download_category', 'download' ); + 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( @@ -288,11 +288,11 @@ function cs_setup_download_taxonomies() { 'choose_from_most_used' => sprintf( __( 'Choose from most used %s tags', 'commercestore' ), cs_get_label_singular() ), ); - $tag_args = apply_filters( 'cs_download_tag_args', array( + $tag_args = apply_filters( CSFilter::TAG_ARGS, array( 'hierarchical' => false, - 'labels' => apply_filters( 'cs_download_tag_labels', $tag_labels ), + 'labels' => apply_filters( CSFilter::TAG_LABELS, $tag_labels ), 'show_ui' => true, - 'query_var' => 'download_tag', + 'query_var' => CS_TAG_TYPE, 'rewrite' => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ), 'capabilities' => array( 'manage_terms' => 'manage_product_terms', @@ -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( CS_TAG_TYPE, array( CS_POST_TYPE ), $tag_args ); + register_taxonomy_for_object_type( CS_TAG_TYPE, CS_POST_TYPE ); } add_action( 'init', 'cs_setup_download_taxonomies', 0 ); @@ -315,10 +315,10 @@ 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', - 'download_tag', + CS_CAT_TYPE, + CS_TAG_TYPE, ) ); if ( ! in_array( $taxonomy, $allowed_taxonomies, true ) ) { @@ -428,7 +428,7 @@ function cs_updated_messages( $messages ) { $url2 = cs_get_label_singular(); $url3 = ''; - $messages['download'] = 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['download'] = 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 ), @@ -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..7091be9fcf 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_EX_DOWNLOAD_ARGS] ) ) { + $_GET['download_id'] = $_GET[CS_EX_DOWNLOAD_ARGS]; } $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'] = $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['download'] ) && ! 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['download'], $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['download'] ); + $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['download'], $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['download'], $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['download'], $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['download'] = $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['download'], + 'product_id' => $item[CS_EX_DOWNLOAD_ARGS], '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/data/payment-gateways/class-gateway-stats-list-table.php b/includes/reports/data/payment-gateways/class-gateway-stats-list-table.php index 028f426a16..442f853e88 100644 --- a/includes/reports/data/payment-gateways/class-gateway-stats-list-table.php +++ b/includes/reports/data/payment-gateways/class-gateway-stats-list-table.php @@ -131,7 +131,7 @@ public function get_data() { $reports_data[] = array( 'ID' => $gateway_id, - 'label' => '' . esc_html( $gateway['admin_label'] ) . '', + 'label' => '' . esc_html( $gateway['admin_label'] ) . '', 'complete_sales' => cs_format_amount( $complete_count, false ), 'pending_sales' => cs_format_amount( $pending_count, false ), 'refunded_sales' => cs_format_amount( $refunded_count, false ), diff --git a/includes/reports/reports-functions.php b/includes/reports/reports-functions.php index a94e584ff7..ed9962d98d 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..a3fa88e26d 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_EX_DOWNLOAD_ADMIN_PAGE ) ) { wp_enqueue_script( 'cs-admin-downloads' ); } diff --git a/includes/shortcodes.php b/includes/shortcodes.php index e8533a5d40..6a111844fa 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'] ); @@ -415,7 +415,7 @@ function cs_downloads_query( $atts, $content = null ) { } else { - $term = get_term_by( 'slug', $tag, 'download_tag' ); + $term = get_term_by( 'slug', $tag, CS_TAG_TYPE ); if( ! $term ) { continue; @@ -425,7 +425,7 @@ function cs_downloads_query( $atts, $content = null ) { } $query['tax_query'][] = array( - 'taxonomy' => 'download_tag', + 'taxonomy' => CS_TAG_TYPE, 'field' => 'term_id', 'terms' => $term_id ); @@ -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' @@ -517,7 +517,7 @@ function cs_downloads_query( $atts, $content = null ) { } else { - $term = get_term_by( 'slug', $tag, 'download_tag' ); + $term = get_term_by( 'slug', $tag, CS_TAG_TYPE ); if( ! $term ) { continue; @@ -527,7 +527,7 @@ function cs_downloads_query( $atts, $content = null ) { } $query['tax_query'][] = array( - 'taxonomy' => 'download_tag', + 'taxonomy' => CS_TAG_TYPE, 'field' => 'term_id', 'terms' => $term_id, 'operator' => 'NOT IN' diff --git a/includes/subscriptions/includes/admin/class-subscriptions-list-table.php b/includes/subscriptions/includes/admin/class-subscriptions-list-table.php index 3e45d12395..fe78539fd6 100644 --- a/includes/subscriptions/includes/admin/class-subscriptions-list-table.php +++ b/includes/subscriptions/includes/admin/class-subscriptions-list-table.php @@ -152,7 +152,7 @@ function column_customer_id( $item ) { $subscriber = new CS_Recurring_Subscriber( $item->customer_id ); $customer = ! empty( $subscriber->name ) ? $subscriber->name : $subscriber->email; - return '' . $customer . ''; + return '' . $customer . ''; } @@ -211,7 +211,7 @@ function column_renewal_date( $item ) { * @return string */ function column_parent_payment_id( $item ) { - return '' . cs_get_payment_number( $item->parent_payment_id ) . ''; + return '' . cs_get_payment_number( $item->parent_payment_id ) . ''; } /** @@ -248,7 +248,7 @@ function column_product_id( $item ) { * @return string */ function column_actions( $item ) { - return '' . __( 'View', 'commercestore' ) . ''; + return '' . __( 'View', 'commercestore' ) . ''; } diff --git a/includes/subscriptions/includes/admin/customers.php b/includes/subscriptions/includes/admin/customers.php index 644dd5aa03..5fdefe91ac 100644 --- a/includes/subscriptions/includes/admin/customers.php +++ b/includes/subscriptions/includes/admin/customers.php @@ -32,7 +32,7 @@ function cs_recurring_customer_subscriptions_list( $customer ) {
  • - diff --git a/includes/subscriptions/includes/admin/metabox.php b/includes/subscriptions/includes/admin/metabox.php index 86abd5af7b..099b8b83a0 100644 --- a/includes/subscriptions/includes/admin/metabox.php +++ b/includes/subscriptions/includes/admin/metabox.php @@ -590,7 +590,7 @@ function cs_display_subscription_payment_meta( $payment_id ) {
    - id ); ?> + id ); ?>

    #%d', 'commercestore' ), $sub_url, $sub->id ); ?> (get_status_label() ); ?>)

    @@ -601,7 +601,7 @@ function cs_display_subscription_payment_meta( $payment_id ) {
  • date ) ); ?> - + number ?> @@ -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..42d5e2c9e9 100644 --- a/includes/subscriptions/includes/admin/settings.php +++ b/includes/subscriptions/includes/admin/settings.php @@ -238,16 +238,16 @@ function cs_recurring_renewal_reminders_settings( $args ) {
  • product_id ); ?> recurring_amount ), cs_get_payment_currency_code( $subscription->parent_payment_id ) ), $subscription->period ); ?> get_status_label(); ?> +
    get_notice_period_label( $key ) ); ?> -  | -  | - +  | +  | +

    - +

    get_notice_period_label( $key ) ); ?> -  | -  | - +  | +  | +

    - +

    'download', + 'post_type' => CS_POST_TYPE, 'page' => 'cs-settings', 'tab' => 'emails', 'section' => 'recurring', diff --git a/includes/subscriptions/includes/admin/subscriptions.php b/includes/subscriptions/includes/admin/subscriptions.php index 34741fc1f5..f05063475b 100644 --- a/includes/subscriptions/includes/admin/subscriptions.php +++ b/includes/subscriptions/includes/admin/subscriptions.php @@ -81,7 +81,7 @@ function cs_recurring_new_subscription_details() {

    Note: This tool allows you to create a new subscription record. It will not create a payment profile in your merchant processor. Payment profiles in the merchant processor must be created through your merchant portal. Once created in the merchant portal, details such as transaction ID and billing profile id, can be entered here.', 'commercestore' ); ?>

    -
    +
    @@ -302,7 +302,7 @@ function cs_recurring_subscription_details() {
    - +
    @@ -376,14 +376,14 @@ function cs_recurring_subscription_details() { customer_id ); ?> - name ) ? $subscriber->name : $subscriber->email; ?> + name ) ? $subscriber->name : $subscriber->email; ?> - parent_payment_id, admin_url( 'edit.php?post_type=download&page=cs-payment-history&view=view-order-details' ) ) . '">' . $sub->parent_payment_id . ''; ?> + parent_payment_id, admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-payment-history&view=view-order-details' ) ) . '">' . $sub->parent_payment_id . ''; ?> @@ -557,7 +557,7 @@ function cs_recurring_subscription_details() { status_nicename; ?> + echo ' ' . $payment->ID; ?>" href="ID ); ?>"> @@ -732,7 +732,7 @@ function cs_recurring_process_subscription_update() { } - wp_redirect( admin_url( 'edit.php?post_type=download&page=cs-subscriptions&cs-message=updated&id=' . $subscription->id ) ); + wp_redirect( admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-subscriptions&cs-message=updated&id=' . $subscription->id ) ); exit; } @@ -854,7 +854,7 @@ function cs_recurring_process_subscription_creation() { $payment->update_meta( '_cs_subscription_payment', true ); - wp_redirect( admin_url( 'edit.php?post_type=download&page=cs-subscriptions&cs-message=updated&id=' . $subscription->id ) ); + wp_redirect( admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-subscriptions&cs-message=updated&id=' . $subscription->id ) ); exit; } @@ -888,7 +888,7 @@ function cs_recurring_process_subscription_cancel() { $subscription = new CS_Subscription( absint( $_POST['sub_id'] ) ); $subscription->cancel(); - wp_redirect( admin_url( 'edit.php?post_type=download&page=cs-subscriptions&cs-message=cancelled&id=' . $subscription->id ) ); + wp_redirect( admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-subscriptions&cs-message=cancelled&id=' . $subscription->id ) ); exit; } @@ -937,7 +937,7 @@ function cs_recurring_process_add_renewal_payment() { $message = 'renewal-not-added'; } - wp_redirect( admin_url( 'edit.php?post_type=download&page=cs-subscriptions&cs-message=' . $message . '&id=' . $sub->id ) ); + wp_redirect( admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-subscriptions&cs-message=' . $message . '&id=' . $sub->id ) ); exit; } @@ -979,7 +979,7 @@ function cs_recurring_process_renewal_charge_retry() { $message = 'retry-failed&error-message=' . urlencode( $result->get_error_message() ); } - wp_redirect( admin_url( 'edit.php?post_type=download&page=cs-subscriptions&cs-message=' . $message . '&id=' . $sub->id ) ); + wp_redirect( admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-subscriptions&cs-message=' . $message . '&id=' . $sub->id ) ); exit; } @@ -1016,7 +1016,7 @@ function cs_recurring_process_add_subscription_note() { $message = 'subscription-note-not-added'; } - wp_redirect( admin_url( 'edit.php?post_type=download&page=cs-subscriptions&cs-message=' . $message . '&id=' . $sub->id ) ); + wp_redirect( admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-subscriptions&cs-message=' . $message . '&id=' . $sub->id ) ); exit; } @@ -1059,7 +1059,7 @@ function cs_recurring_process_subscription_deletion() { $subscription->delete(); - wp_redirect( admin_url( 'edit.php?post_type=download&page=cs-subscriptions&cs-message=deleted' ) ); + wp_redirect( admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-subscriptions&cs-message=deleted' ) ); exit; } diff --git a/includes/subscriptions/includes/cs-recurring-emails.php b/includes/subscriptions/includes/cs-recurring-emails.php index 3233d065c8..5ff27f8985 100644 --- a/includes/subscriptions/includes/cs-recurring-emails.php +++ b/includes/subscriptions/includes/cs-recurring-emails.php @@ -106,7 +106,7 @@ public function send_subscription_cancelled_admin( $subscription_id, CS_Subscrip $message = apply_filters( 'cs_recurring_subscription_cancelled_message', cs_get_option( 'subscription_cancelled_admin_message' ) ); $message = $this->filter_reminder_template_tags( $message, $subscription_id ); - $message = str_replace( '{subscription_link}', admin_url( 'edit.php?post_type=download&page=cs-subscriptions&id=' . $subscription_id ), $message ); + $message = str_replace( '{subscription_link}', admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-subscriptions&id=' . $subscription_id ), $message ); CS()->emails->send( $email_to, $subject, $message ); 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-gateway.php b/includes/subscriptions/includes/gateways/cs-recurring-gateway.php index 8381cf07e3..7cc327915b 100644 --- a/includes/subscriptions/includes/gateways/cs-recurring-gateway.php +++ b/includes/subscriptions/includes/gateways/cs-recurring-gateway.php @@ -956,7 +956,7 @@ public function process_cancellation( $data ) { if( is_admin() ) { - wp_redirect( admin_url( 'edit.php?post_type=download&page=cs-subscriptions&cs-message=cancelled&id=' . $subscription->id ) ); + wp_redirect( admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-subscriptions&cs-message=cancelled&id=' . $subscription->id ) ); exit; } else { @@ -1013,7 +1013,7 @@ public function process_reactivation( $data ) { if( is_admin() ) { - wp_redirect( admin_url( 'edit.php?post_type=download&page=cs-subscriptions&cs-message=reactivated&id=' . $subscription->id ) ); + wp_redirect( admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-subscriptions&cs-message=reactivated&id=' . $subscription->id ) ); exit; } else { 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..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['download'] ) { + 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['download'] ); + $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['download'], $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['download'] ); + $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['download'] ) ) { + 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['download'] ) ) { - $has_access = $subscriber->has_active_product_subscription( $item['download'] ); + 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['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_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['download'] ); + $has_access = cs_has_user_purchased( $user_id, $item[CS_EX_DOWNLOAD_ITEM] ); } } if ( $has_access ) { return $content; } - $products[] = get_the_title( $item['download'] ); + $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/subscriptions/includes/plugin-software-licensing.php b/includes/subscriptions/includes/plugin-software-licensing.php index f418646c2a..2e1e6fb92b 100644 --- a/includes/subscriptions/includes/plugin-software-licensing.php +++ b/includes/subscriptions/includes/plugin-software-licensing.php @@ -970,7 +970,7 @@ public function licenses_table( $license ) { } echo '
    '; - echo '' . __( 'View Subscription', 'commercestore' ) . ''; + echo '' . __( 'View Subscription', 'commercestore' ) . ''; } } @@ -1001,7 +1001,7 @@ public function subscription_details( CS_Subscription $subscription ) { get_license_status( $license->ID ); ?> - + diff --git a/includes/subscriptions/subscriptions.php b/includes/subscriptions/subscriptions.php index 6ecb08d737..a79b1e9f3a 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', @@ -553,7 +553,7 @@ public function payments_view( $views ) { if ( function_exists( 'cs_count_orders' ) ) { return $views; } - $base = admin_url( 'edit.php?post_type=download&page=cs-payment-history' ); + $base = admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-payment-history' ); $payment_count = wp_count_posts( 'cs_payment' ); $current = isset( $_GET['status'] ) ? $_GET['status'] : ''; @@ -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_EX_DOWNLOAD_ARGS] ) ) { $query_has_recurring = false; - $download = $query->initial_args['download']; + $download = $query->initial_args[CS_EX_DOWNLOAD_ARGS]; 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..7dba446ff9 100644 --- a/includes/template-functions.php +++ b/includes/template-functions.php @@ -58,7 +58,7 @@ function cs_get_purchase_link( $args = array() ) { } - cs_set_error( 'set_checkout', sprintf( __( 'No checkout page has been configured. Visit Settings to set one.', 'commercestore' ), admin_url( 'edit.php?post_type=download&page=cs-settings&tab=general§ion=pages' ) ) ); + cs_set_error( 'set_checkout', sprintf( __( 'No checkout page has been configured. Visit Settings to set one.', 'commercestore' ), admin_url( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-settings&tab=general§ion=pages' ) ) ); cs_print_errors(); $no_checkout_error_displayed = true; @@ -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; } @@ -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; @@ -858,7 +858,7 @@ function cs_add_download_post_classes( $classes, $class = '', $post_id = false ) } // Add tag slugs - $tags = get_the_terms( $post_id, 'download_tag' ); + $tags = get_the_terms( $post_id, CS_TAG_TYPE ); if( ! empty( $tags ) ) { foreach( $tags as $key => $value ) { $classes[] = 'cs-download-tag-' . $value->slug; @@ -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_EX_DOWNLOAD_SHORTCODE ); } 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..4cbd70cbda 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_tax( 'download_category' ) && - ! is_tax( 'download_tag' ) + ! is_singular( CS_POST_TYPE ) && + ! is_post_type_archive( CS_POST_TYPE ) && + ! is_tax( CS_CAT_TYPE ) && + ! is_tax( CS_TAG_TYPE ) ) return $classes; - if ( ( $key = array_search( 'download', $classes ) ) ) + if ( ( $key = array_search( CS_EX_DOWNLOAD_CSS_CLASS, $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..0e73930221 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 ) {

    @@ -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; } @@ -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']; } } @@ -321,12 +321,12 @@ public function widget( $args, $instance ) { $tag_label = ''; if ( $tags ) { - $tag_terms = (array) get_the_terms( $download_id, 'download_tag' ); + $tag_terms = (array) get_the_terms( $download_id, CS_TAG_TYPE ); if ( $tag_terms && ! is_wp_error( $tag_terms ) ) { - $tag_list = get_the_term_list( $download_id, 'download_tag', '', ', ' ); + $tag_list = get_the_term_list( $download_id, CS_TAG_TYPE, '', ', ' ); $tag_count = count( $tag_terms ); - $tag_taxonomy = cs_get_taxonomy_labels( 'download_tag' ); + $tag_taxonomy = cs_get_taxonomy_labels( CS_TAG_TYPE ); $tag_label = $tag_count > 1 ? $tag_taxonomy['name'] : $tag_taxonomy['singular_name']; } } @@ -398,11 +398,11 @@ public function form( $instance ) {

    > - + publish < 1000 ) : ?> 'download', + 'post_type' => CS_POST_TYPE, 'posts_per_page' => -1, 'post_status' => 'publish', ); @@ -433,14 +433,14 @@ public function form( $instance ) {

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

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

    diff --git a/tests/ajax.php b/tests/ajax.php index f0f36111a2..964228229d 100644 --- a/tests/ajax.php +++ b/tests/ajax.php @@ -220,7 +220,8 @@ public function test_check_for_download_price_variations() { $expected = ''; //$this->assertEquals( $expected, $this->_last_response ); } - +/* @todo: can't have a class defined inside a function + * public function test_cs_test_ajax_works() { $this->markTestIncomplete( 'Needs to be reworked per #3475' ); $this->assertTrue( cs_test_ajax_works() ); @@ -243,4 +244,6 @@ public function enabled() { return true; } $this->assertTrue( cs_test_ajax_works() ); $this->assertEmpty( get_transient( '_cs_ajax_works' ) ); } +*/ + } diff --git a/tests/discounts/tests-discounts.php b/tests/discounts/tests-discounts.php index c8620e8a47..f6a8bba5fc 100644 --- a/tests/discounts/tests-discounts.php +++ b/tests/discounts/tests-discounts.php @@ -397,7 +397,7 @@ public function test_discount_is_product_requirements_met() { * @covers ::edit_url() */ public function test_discount_edit_url() { - $this->assertStringContainsString( 'edit.php?post_type=download&page=cs-discounts', self::$discount->edit_url() ); + $this->assertStringContainsString( 'edit.php?post_type=' . CS_POST_TYPE . '&page=cs-discounts', self::$discount->edit_url() ); } /** diff --git a/tests/helpers/class-helper-download.php b/tests/helpers/class-helper-download.php index 991b3a27cf..478c6c5b6a 100644 --- a/tests/helpers/class-helper-download.php +++ b/tests/helpers/class-helper-download.php @@ -31,7 +31,7 @@ public static function create_simple_download() { $post_id = wp_insert_post( array( 'post_title' => 'Test Download Product', 'post_name' => 'test-download-product', - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_status' => 'publish' ) ); @@ -76,7 +76,7 @@ public static function create_variable_download() { $post_id = wp_insert_post( array( 'post_title' => 'Variable Test Download Product', 'post_name' => 'variable-test-download-product', - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_status' => 'publish' ) ); @@ -137,7 +137,7 @@ public static function create_variable_download_with_multi_price_purchase() { $post_id = wp_insert_post( array( 'post_title' => 'Variable Multi Test Download Product', 'post_name' => 'variable-multi-test-download-product', - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_status' => 'publish' ) ); @@ -206,7 +206,7 @@ public static function create_bundled_download() { $post_id = wp_insert_post( array( 'post_title' => 'Bundled Test Download Product', 'post_name' => 'bundled-test-download-product', - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_status' => 'publish' ) ); diff --git a/tests/tests-api.php b/tests/tests-api.php index ccbc3c9ae3..1ac3da4361 100644 --- a/tests/tests-api.php +++ b/tests/tests-api.php @@ -49,7 +49,7 @@ public static function wpsetUpBeforeClass() : void { $post_id = self::factory()->post->create( array( 'post_title' => 'Test Download', - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_status' => 'publish', ) ); diff --git a/tests/tests-cart.php b/tests/tests-cart.php index 3dc34dd8b6..f5a38bf47a 100644 --- a/tests/tests-cart.php +++ b/tests/tests-cart.php @@ -47,7 +47,7 @@ public static function wpsetUpBeforeClass() : void { $post_id = static::factory()->post->create( array( 'post_title' => 'Test Download', - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_status' => 'publish', ) ); @@ -99,7 +99,7 @@ public static function wpsetUpBeforeClass() : void { // Create a second Download. $post_id = static::factory()->post->create( array( 'post_title' => 'Test Download 2', - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_status' => 'publish', ) ); diff --git a/tests/tests-checkout.php b/tests/tests-checkout.php index 8625e97ac3..7dd3d0fae5 100644 --- a/tests/tests-checkout.php +++ b/tests/tests-checkout.php @@ -17,7 +17,7 @@ public static function wpsetUpBeforeClass() : void { $post_id = static::factory()->post->create( array( 'post_title' => 'Test Download', - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_status' => 'publish', ) ); diff --git a/tests/tests-downloads.php b/tests/tests-downloads.php index cd0bdd0c9f..8233c02601 100644 --- a/tests/tests-downloads.php +++ b/tests/tests-downloads.php @@ -90,7 +90,7 @@ public function test_cs_download() { $download2->create( $args ); $this->assertNotEmpty( $download2->ID ); - $this->assertEquals( 'download', $download2->post_type ); + $this->assertEquals( CS_POST_TYPE, $download2->post_type ); $this->assertEquals( 'draft', $download2->post_status ); $this->assertEquals( 0, $download2->sales ); $this->assertEquals( 0.00, $download2->earnings ); @@ -124,7 +124,7 @@ public function test_cs_download() { $download3->increase_earnings( '0.50' ); $this->assertNotEmpty( $download3->ID ); $this->assertEquals( $this->_post->ID, $download3->ID ); - $this->assertEquals( 'download', $download3->post_type ); + $this->assertEquals( CS_POST_TYPE, $download3->post_type ); $this->assertEquals( 'publish', $download3->post_status ); $this->assertEquals( 0.00, $download3->price ); $this->assertEquals( 0.00, $download3->get_price() ); diff --git a/tests/tests-emails.php b/tests/tests-emails.php index ccd7f1cb57..46ca4f6c13 100644 --- a/tests/tests-emails.php +++ b/tests/tests-emails.php @@ -23,7 +23,7 @@ class Tests_Emails extends CS_UnitTestCase { * Set up fixtures once. */ public static function wpsetUpBeforeClass() : void { - $post_id = self::factory()->post->create( array( 'post_title' => 'Test Download', 'post_type' => 'download', 'post_status' => 'publish' ) ); + $post_id = self::factory()->post->create( array( 'post_title' => 'Test Download', 'post_type' => CS_POST_TYPE, 'post_status' => 'publish' ) ); $_variable_pricing = array( array( diff --git a/tests/tests-fees.php b/tests/tests-fees.php index fd8dfcaa0c..f53a4bda5b 100644 --- a/tests/tests-fees.php +++ b/tests/tests-fees.php @@ -10,7 +10,7 @@ class Tests_Fee extends CS_UnitTestCase { public function set_up() { parent::set_up(); - $post_id = $this->factory->post->create( array( 'post_title' => 'Test Download', 'post_type' => 'download', 'post_status' => 'publish' ) ); + $post_id = $this->factory->post->create( array( 'post_title' => 'Test Download', 'post_type' => CS_PRODUCT_CPT, 'post_status' => 'publish' ) ); $this->_post = get_post( $post_id ); cs_add_to_cart( $this->_post->ID ); diff --git a/tests/tests-html-elements.php b/tests/tests-html-elements.php index 279d5c3edc..9003f7930d 100644 --- a/tests/tests-html-elements.php +++ b/tests/tests-html-elements.php @@ -13,7 +13,7 @@ class Test_HTML_Elements extends CS_UnitTestCase { * @covers ::product_dropdown */ public function test_product_dropdown() { - $expected = ''; $this->assertStringContainsString( $expected, CS()->html->product_dropdown() ); } diff --git a/tests/tests-misc.php b/tests/tests-misc.php index d6218798e6..ec42329d57 100644 --- a/tests/tests-misc.php +++ b/tests/tests-misc.php @@ -625,7 +625,7 @@ public function test_get_current_page_url_if_home_should_return_home_url() { */ public function test_get_current_page_url_if_a_download_page_should_return_that_url() { $this->go_to( get_permalink( self::$download->ID ) ); - $this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/?download=test-download-product', cs_get_current_page_url() ); + $this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/?'. CS_POST_TYPE.'=test-download-product', cs_get_current_page_url() ); } /** @@ -636,7 +636,7 @@ public function test_get_current_page_url_if_no_caching_should_return_url_with_n $this->go_to( get_permalink( self::$download->ID ) ); - $this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/?download=test-download-product&nocache=true', cs_get_current_page_url( true ) ); + $this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/?'.CS_POST_TYPE.'=test-download-product&nocache=true', cs_get_current_page_url( true ) ); remove_filter( 'cs_is_caching_plugin_active', '__return_true' ); } diff --git a/tests/tests-post-type-labels.php b/tests/tests-post-type-labels.php index a0e1559976..28a9b66bfe 100644 --- a/tests/tests-post-type-labels.php +++ b/tests/tests-post-type-labels.php @@ -52,7 +52,7 @@ public function test_taxonomy_labels() { // Negative test for our change to exclude singular post type label in #3212 $this->assertTrue( in_array( 'Categories', $category_labels ) ); - $tag_labels = cs_get_taxonomy_labels( 'download_tag' ); + $tag_labels = cs_get_taxonomy_labels( CS_TAG_TYPE ); $this->assertInternalType( 'array', $tag_labels ); $this->assertArrayHasKey( 'name', $tag_labels ); $this->assertArrayHasKey( 'singular_name', $tag_labels ); diff --git a/tests/tests-post-types.php b/tests/tests-post-types.php index 4e31ab493c..fde3509eca 100644 --- a/tests/tests-post-types.php +++ b/tests/tests-post-types.php @@ -19,30 +19,34 @@ public function tear_down() { */ public function test_downloads_post_type() { global $wp_post_types; - $this->assertArrayHasKey( 'download', $wp_post_types ); + $this->assertArrayHasKey( CS_POST_TYPE, $wp_post_types ); } public function test_downloads_post_type_labels() { global $wp_post_types; - $this->assertEquals( 'Products', $wp_post_types['download']->labels->name ); - $this->assertEquals( 'Product', $wp_post_types['download']->labels->singular_name ); - $this->assertEquals( 'Add New', $wp_post_types['download']->labels->add_new ); - $this->assertEquals( 'Add New Product', $wp_post_types['download']->labels->add_new_item ); - $this->assertEquals( 'Edit Product', $wp_post_types['download']->labels->edit_item ); - $this->assertEquals( 'View Product', $wp_post_types['download']->labels->view_item ); - $this->assertEquals( 'Search Products', $wp_post_types['download']->labels->search_items ); - $this->assertEquals( 'No Products found', $wp_post_types['download']->labels->not_found ); - $this->assertEquals( 'No Products found in Trash', $wp_post_types['download']->labels->not_found_in_trash ); - $this->assertEquals( 'Products', $wp_post_types['download']->labels->all_items ); - $this->assertEquals( 'Products', $wp_post_types['download']->labels->menu_name ); - $this->assertEquals( 'Product', $wp_post_types['download']->labels->name_admin_bar ); - $this->assertEquals( 1, $wp_post_types['download']->publicly_queryable ); - $this->assertEquals( 'product', $wp_post_types['download']->capability_type ); - $this->assertEquals( 1, $wp_post_types['download']->map_meta_cap ); - $this->assertEquals( 'products', $wp_post_types['download']->rewrite['slug'] ); - $this->assertEquals( 1, $wp_post_types['download']->has_archive ); - $this->assertEquals( 'download', $wp_post_types['download']->query_var ); - $this->assertEquals( 'Products', $wp_post_types['download']->label ); + + $post_type = $wp_post_types[CS_POST_TYPE]; + + + $this->assertEquals( 'Products', $post_type->labels->name ); + $this->assertEquals( 'Product',$post_type->labels->singular_name ); + $this->assertEquals( 'Add New',$post_type->labels->add_new ); + $this->assertEquals( 'Add New Product',$post_type->labels->add_new_item ); + $this->assertEquals( 'Edit Product',$post_type->labels->edit_item ); + $this->assertEquals( 'View Product',$post_type->labels->view_item ); + $this->assertEquals( 'Search Products',$post_type->labels->search_items ); + $this->assertEquals( 'No Products found',$post_type->labels->not_found ); + $this->assertEquals( 'No Products found in Trash',$post_type->labels->not_found_in_trash ); + $this->assertEquals( 'Products',$post_type->labels->all_items ); + $this->assertEquals( 'Products',$post_type->labels->menu_name ); + $this->assertEquals( 'Product',$post_type->labels->name_admin_bar ); + $this->assertEquals( 1,$post_type->publicly_queryable ); + $this->assertEquals( 'product',$post_type->capability_type ); + $this->assertEquals( 1,$post_type->map_meta_cap ); + $this->assertEquals( CS_DEFAULT_SLUG,$post_type->rewrite['slug'] ); + $this->assertEquals( 1,$post_type->has_archive ); + $this->assertEquals( CS_POST_TYPE,$post_type->query_var ); + $this->assertEquals( 'Products',$post_type->label ); } public function test_payment_post_type() { diff --git a/tests/tests-query-filters.php b/tests/tests-query-filters.php index 213c39cda4..58691a3a15 100644 --- a/tests/tests-query-filters.php +++ b/tests/tests-query-filters.php @@ -117,7 +117,7 @@ public function test_cs_block_attachments_not_restricted_bail() { $parent_post_id = $this->factory->post->create( array( 'post_title' => 'Test Download Product', 'post_name' => 'test-download-product', - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_status' => 'publish' ) ); @@ -179,7 +179,7 @@ public function test_cs_block_attachments_die() { $parent_post_id = $this->factory->post->create( array( 'post_title' => 'Test Download Product', 'post_name' => 'test-download-product', - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_status' => 'publish' ) ); diff --git a/tests/tests-shortcodes.php b/tests/tests-shortcodes.php index e0c8c8640d..c47dc6ad8e 100644 --- a/tests/tests-shortcodes.php +++ b/tests/tests-shortcodes.php @@ -17,7 +17,7 @@ public static function wpsetUpBeforeClass() : void { self::$user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); wp_set_current_user( self::$user_id ); - $post_id = self::factory()->post->create( array( 'post_title' => 'Test Download', 'post_type' => 'download', 'post_status' => 'publish' ) ); + $post_id = self::factory()->post->create( array( 'post_title' => 'Test Download', 'post_type' => CS_POST_TYPE, 'post_status' => 'publish' ) ); $_variable_pricing = array( array( @@ -247,7 +247,7 @@ public function test_purchase_collection_shortcode() { } public function test_download_price_shortcode() { - $post_id = self::factory()->post->create( array( 'post_type' => 'download' ) ); + $post_id = self::factory()->post->create( array( 'post_type' => CS_POST_TYPE ) ); $meta = array( 'cs_price' => '54.43', @@ -298,13 +298,13 @@ public function test_profile_pending_single_load() { public function test_downloads_shortcode_pagination() { $output = cs_downloads_query( array() ); - $this->assertStringNotContainsString( 'id="cs_download_pagination"', $output ); + $this->assertStringNotContainsString( 'id="cs_'.CS_POST_TYPE.'_pagination"', $output ); // Create a second post so we can see pagination - self::factory()->post->create( array( 'post_title' => 'Test Download #2', 'post_type' => 'download', 'post_status' => 'publish' ) ); + self::factory()->post->create( array( 'post_title' => 'Test Download #2', 'post_type' => CS_POST_TYPE, 'post_status' => 'publish' ) ); $output2 = cs_downloads_query( array( 'number' => 1 ) ); - $this->assertStringContainsString( 'id="cs_download_pagination"', $output2 ); + $this->assertStringContainsString( 'id="cs_' . CS_POST_TYPE . '_pagination"', $output2 ); cs_set_user_to_pending( self::$user_id ); @@ -313,9 +313,9 @@ public function test_downloads_shortcode_pagination() { public function test_downloads_shortcode_nopaging() { // Create a posts so we can see pagination - self::factory()->post->create( array( 'post_title' => 'Test Download #2', 'post_type' => 'download', 'post_status' => 'publish' ) ); - self::factory()->post->create( array( 'post_title' => 'Test Download #3', 'post_type' => 'download', 'post_status' => 'publish' ) ); - self::factory()->post->create( array( 'post_title' => 'Test Download #4', 'post_type' => 'download', 'post_status' => 'publish' ) ); + self::factory()->post->create( array( 'post_title' => 'Test Download #2', 'post_type' => CS_POST_TYPE, 'post_status' => 'publish' ) ); + self::factory()->post->create( array( 'post_title' => 'Test Download #3', 'post_type' => CS_POST_TYPE, 'post_status' => 'publish' ) ); + self::factory()->post->create( array( 'post_title' => 'Test Download #4', 'post_type' => CS_POST_TYPE, 'post_status' => 'publish' ) ); $output2 = cs_downloads_query( array( 'number' => 1, 'pagination' => 'false' ) ); $this->assertStringNotContainsString( 'id="cs_download_pagination"', $output2 ); diff --git a/tests/tests-structured-data.php b/tests/tests-structured-data.php index f58c6b2a8f..b3844b0a9b 100644 --- a/tests/tests-structured-data.php +++ b/tests/tests-structured-data.php @@ -34,7 +34,7 @@ public function test_get_data_with_no_data() { * @covers CS_Structured_Data::get_data() */ public function test_generate_structured_data_for_download() { - CS()->structured_data->generate_structured_data( 'download', self::$download->ID ); + CS()->structured_data->generate_structured_data( CS_POST_TYPE, self::$download->ID ); $data = CS()->structured_data->get_data(); diff --git a/tests/tests-tax.php b/tests/tests-tax.php index 4f66d4368c..6e75d2a740 100644 --- a/tests/tests-tax.php +++ b/tests/tests-tax.php @@ -26,7 +26,7 @@ class Tests_Taxes extends CS_UnitTestCase { public static function wpsetUpBeforeClass() : void { $post_id = self::factory()->post->create( array( 'post_title' => 'Test Download', - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_status' => 'publish', ) ); diff --git a/tests/tests-templates.php b/tests/tests-templates.php index 886216ad62..e39164adbf 100644 --- a/tests/tests-templates.php +++ b/tests/tests-templates.php @@ -12,7 +12,7 @@ class Tests_Templates extends CS_UnitTestCase { public function set_up() { parent::set_up(); - $post_id = $this->factory->post->create( array( 'post_title' => 'A Test Download', 'post_type' => 'download', 'post_status' => 'publish' ) ); + $post_id = $this->factory->post->create( array( 'post_title' => 'A Test Download', 'post_type' => CS_POST_TYPE, 'post_status' => 'publish' ) ); $_variable_pricing = array( array( @@ -83,7 +83,7 @@ public function test_get_purchase_link() { remove_filter( 'cs_item_quantities_enabled', '__return_true' ); // Test a single price point as well - $single_id = $this->factory->post->create( array( 'post_title' => 'A Test Single Price Download', 'post_type' => 'download', 'post_status' => 'publish' ) ); + $single_id = $this->factory->post->create( array( 'post_title' => 'A Test Single Price Download', 'post_type' => CS_POST_TYPE, 'post_status' => 'publish' ) ); $meta = array( 'cs_price' => '10.00', '_cs_download_limit' => 20, diff --git a/tests/tests-theme-compatibility.php b/tests/tests-theme-compatibility.php index 4323c025dc..1d1c9929f1 100644 --- a/tests/tests-theme-compatibility.php +++ b/tests/tests-theme-compatibility.php @@ -47,28 +47,27 @@ public function test_cs_responsive_download_post_class_post() { * * @since 2.2.4 */ - /* + public function test_cs_responsive_download_post_class_download() { // Prepare test $post_id = $this->factory->post->create( array( 'post_title' => 'Test Download Product', 'post_name' => 'test-download-product', - 'post_type' => 'download', + 'post_type' => CS_POST_TYPE, 'post_status' => 'publish' ) ); $this->go_to( get_permalink( $post_id ) ); // Test some regular values in a post (should be unaffected) // @todo - what is this get_post_class testing against download actually supposed to be testing? - $this->assertContains( 'download', get_post_class() ); - $this->assertContains( 'type-download', get_post_class() ); + $this->assertContains( CS_POST_TYPE, get_post_class() ); + $this->assertContains( 'type-' . CS_POST_TYPE, get_post_class() ); // Reset to origin $this->go_to( '' ); wp_delete_post( $post_id, true ); - } -*/ + } diff --git a/tests/tests-widgets.php b/tests/tests-widgets.php index 9e8fd12d53..57a65f2c7f 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' => 'Tags', 'taxonomy' => 'download_tag', 'count' => true, 'hide_empty' => true ) + array( 'title' => 'Categories', 'taxonomy' => CS_CAT_TYPE, 'count' => true, 'hide_empty' => true ), + array( 'title' => 'Tags', 'taxonomy' => CS_TAG_TYPE, '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->assertMatchesRegularExpression( '/