'' . esc_html__( 'Settings', 'woocommerce-smart-coupons' ) . '', 'faqs' => '' . esc_html__( 'FAQ\'s', 'woocommerce-smart-coupons' ) . '', 'docs' => '' . __( 'Docs', 'woocommerce-smart-coupons' ) . '', 'support' => '' . __( 'Support', 'woocommerce-smart-coupons' ) . '', 'review' => '' . __( 'Review', 'woocommerce-smart-coupons' ) . '', ); return array_merge( $action_links, $links ); } /** * Handle Smart Coupons review notice action */ public function wc_sc_review_notice_action() { check_ajax_referer( 'wc-sc-review-notice-action', 'security' ); $post_do = ( ! empty( $_POST['do'] ) ) ? wc_clean( wp_unslash( $_POST['do'] ) ) : ''; // phpcs:ignore $option = strtotime( '+1 month' ); if ( 'remove' === $post_do ) { $option = 'no'; } update_option( 'wc_sc_is_show_review_notice', $option, 'no' ); wp_send_json( array( 'success' => 'yes' ) ); } /** * Handle Smart Coupons version 4.0.0 notice action */ public function wc_sc_40_notice_action() { check_ajax_referer( 'wc-sc-40-notice-action', 'security' ); update_option( 'wc_sc_is_show_40_notice', 'no', 'no' ); wp_send_json( array( 'success' => 'yes' ) ); } /** * Show plugin review notice */ public function show_plugin_notice() { global $pagenow, $post; $valid_post_types = array( 'shop_coupon', 'shop_order', 'product' ); $valid_pagenow = array( 'edit.php', 'post.php', 'plugins.php' ); $is_show_review_notice = get_option( 'wc_sc_is_show_review_notice' ); $is_coupon_enabled = get_option( 'woocommerce_enable_coupons' ); $get_post_type = ( ! empty( $post->ID ) ) ? $this->get_post_type( $post->ID ) : ''; $get_page = ( ! empty( $_GET['page'] ) ) ? wc_clean( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore $get_tab = ( ! empty( $_GET['tab'] ) ) ? wc_clean( wp_unslash( $_GET['tab'] ) ) : ''; // phpcs:ignore $design = get_option( 'wc_sc_setting_coupon_design', 'basic' ); $is_page = ( in_array( $pagenow, $valid_pagenow, true ) || in_array( $get_post_type, $valid_post_types, true ) || ( 'admin.php' === $pagenow && ( 'wc-smart-coupons' === $get_page || 'wc-smart-coupons' === $get_tab ) ) ); if ( $is_page && 'yes' !== $is_coupon_enabled ) { ?>

' . esc_html__( 'Important', 'woocommerce-smart-coupons' ) . ': ' . esc_html__( 'Setting "Enable the use of coupon codes" is disabled.', 'woocommerce-smart-coupons' ) . ' ' . sprintf( '%s', esc_url( add_query_arg( array( 'page' => 'wc-settings', 'tab' => 'general', ), admin_url( 'admin.php' ) ) ), esc_html__( 'Enable', 'woocommerce-smart-coupons' ) ) . ' ' . esc_html__( 'it to use', 'woocommerce-smart-coupons' ) . ' ' . esc_html__( 'WooCommerce Smart Coupons', 'woocommerce-smart-coupons' ) . ' ' . esc_html__( 'features.', 'woocommerce-smart-coupons' ); ?>

= absint( $is_show_review_notice ) ) { if ( ! wp_script_is( 'jquery' ) ) { wp_enqueue_script( 'jquery' ); } ?>

' . esc_html__( 'WooCommerce Smart Coupons', 'woocommerce-smart-coupons' ) . ' ' . esc_html__( 'so far?', 'woocommerce-smart-coupons' ) . '
' . esc_html__( 'Please consider', 'woocommerce-smart-coupons' ) . ' ' . esc_html__( 'leaving a review', 'woocommerce-smart-coupons' ) . ' ' . esc_html__( '! If things aren\'t going quite as expected, we\'re happy to help -- please reach out to', 'woocommerce-smart-coupons' ) . ' ' . esc_html__( 'our support team', 'woocommerce-smart-coupons' ) . '.'; ?>

' . esc_html__( 'WooCommerce Smart Coupons', 'woocommerce-smart-coupons' ) . '', '' . esc_html__( 'Smart Coupons settings', 'woocommerce-smart-coupons' ) . '' ); ?>

ID ) ) ? $this->get_post_type( $post->ID ) : ''; $get_page = ( ! empty( $_GET['page'] ) ) ? wc_clean( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore $get_tab = ( ! empty( $_GET['tab'] ) ) ? wc_clean( wp_unslash( $_GET['tab'] ) ) : ''; // phpcs:ignore $sc_pages = array( 'wc-smart-coupons', 'sc-about', 'sc-faqs' ); if ( in_array( $get_page, $sc_pages, true ) || 'shop_coupon' === $get_post_type || 'wc-smart-coupons' === $get_tab ) { ?> 5-star rating here' ) ); } } return $sc_rating_text; } /** * Function to 'Connect your store' notice on Smart Coupons pages in admin * * @param string $sc_text Text in footer (right). * @return string $sc_text */ public function wc_sc_update_footer_text( $sc_text ) { global $post, $pagenow; if ( ! empty( $pagenow ) ) { $get_post_type = ( ! empty( $post->ID ) ) ? $this->get_post_type( $post->ID ) : ''; $get_page = ( ! empty( $_GET['page'] ) ) ? wc_clean( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore $get_tab = ( ! empty( $_GET['tab'] ) ) ? wc_clean( wp_unslash( $_GET['tab'] ) ) : ''; // phpcs:ignore $sc_pages = array( 'wc-smart-coupons', 'sc-about', 'sc-faqs' ); if ( in_array( $get_page, $sc_pages, true ) || 'shop_coupon' === $get_post_type || 'wc-smart-coupons' === $get_tab ) { /* translators: %s: link to submit idea for Smart Coupons on WooCommerce idea board */ $sc_text = sprintf( __( 'Have a feature request? Submit it %s.', 'woocommerce-smart-coupons' ), '' . __( 'here', 'woocommerce-smart-coupons' ) . '' ); } } return $sc_text; } /** * Function to 'Connect your store' notice on Smart Coupons pages in admin * * @param array $screen_ids List of existing screen ids. * @return array $screen_ids */ public function add_wc_connect_store_notice_on_sc_pages( $screen_ids ) { array_push( $screen_ids, 'woocommerce_page_wc-smart-coupons' ); return $screen_ids; } /** * Function to render admin notice * * @param string $type Notice type. * @param string $title Notice title. * @param string $message Notice message. * @param string $action Notice actions. * @param bool $dismissible Notice dismissible. * @return void. */ public function show_notice( $type = 'info', $title = '', $message = '', $action = '', $dismissible = false ) { $css_classes = array( 'notice', 'notice-' . $type, ); if ( true === $dismissible ) { $css_classes[] = 'is-dismissible'; } ?>
%s

', esc_html( $title ) ); } if ( ! empty( $message ) ) { printf( '

%s

', esc_html( $message ) ); } if ( ! empty( $action ) ) { printf( '

%s

', wp_kses_post( $action ) ); } ?>
get_status( '4.28.0' ); if ( 'pending' === $update_status ) { // Notice for pending update. $this->db_update_pending_notice(); } elseif ( 'processing' === $update_status ) { // Notice for processing update. $this->db_update_processing_notice(); } elseif ( 'completed' === $update_status ) { // Notice for completed update. $this->db_update_completed_notice(); $wcsc_db->set_status( '4.28.0', 'done' ); } } /** * Function to show pending database update notice */ public function db_update_pending_notice() { global $woocommerce_smart_coupon; $plugin_version = $woocommerce_smart_coupon->get_smart_coupons_version(); /* translators: %s: Plugin name */ $title = sprintf( __( '%s database update required', 'woocommerce-smart-coupons' ), 'WooCommerce Smart Coupons' ); $message = __( 'The database update process runs in the background and may take a little while, so please be patient.', 'woocommerce-smart-coupons' ); $update_url = wp_nonce_url( add_query_arg( array( 'page' => 'wc-settings', 'tab' => 'wc-smart-coupons', 'wc_sc_update' => '4.28.0', ), admin_url( 'admin.php' ) ), 'wc_sc_db_process', 'wc_sc_db_update_nonce' ); $action_button = sprintf( '%2$s', esc_url( $update_url ), __( 'Update database', 'woocommerce-smart-coupons' ) ); $this->show_notice( 'warning', $title, $message, $action_button ); } /** * Function to show database update processing notice. */ public function db_update_processing_notice() { if ( 'woocommerce_page_wc-status' === $this->get_current_screen_id() && isset( $_GET['tab'] ) && 'action-scheduler' === wc_clean( wp_unslash( $_GET['tab'] ) ) ) { // phpcs:ignore return; } $actions_url = add_query_arg( array( 'page' => 'wc-status', 'tab' => 'action-scheduler', 's' => 'move_applied_coupon_options_to_transient', 'status' => 'pending', ), admin_url( 'admin.php' ) ); $cron_disabled = defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON; /* translators: %s: Plugin name */ $message = sprintf( __( '%s is updating the database in the background. The database update process may take a little while, so please be patient.', 'woocommerce-smart-coupons' ), 'WooCommerce Smart Coupons' ); if ( true === $cron_disabled ) { $message .= '
' . __( 'Note: WP CRON has been disabled on your install which may prevent this update from completing.', 'woocommerce-smart-coupons' ); } $action_button = sprintf( '%2$s', esc_url( $actions_url ), __( 'View status', 'woocommerce-smart-coupons' ) ); $this->show_notice( 'info', '', $message, $action_button ); } /** * Function to show database update completed notice. */ public function db_update_completed_notice() { /* translators: %s: Plugin name */ $message = sprintf( __( '%s database update completed. Thank you for updating to the latest version!', 'woocommerce-smart-coupons' ), 'WooCommerce Smart Coupons' ); $this->show_notice( 'success', '', $message, '', true ); } /** * Function to get current screen id. * * @return string. */ public function get_current_screen_id() { $screen = get_current_screen(); return $screen ? $screen->id : ''; } } } WC_SC_Admin_Notifications::get_instance();