*/ class Addonify_Wishlist_Admin { /** * Settings page slug * * @since 1.0.0 * @access private * @var string $settings_page_slug Default settings page slug for this plugin */ private $settings_page_slug = 'addonify_wishlist'; /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. */ public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; } /** * Register the stylesheets for the admin area. * * @since 1.0.0 */ public function enqueue_styles() { // load styles in this plugin page only. if ( isset( $_GET['page'] ) && $_GET['page'] == $this->settings_page_slug ) { // phpcs:ignore wp_enqueue_style( "{$this->plugin_name}-icon", plugin_dir_url( __FILE__ ) . 'app/fonts/addonify-wishlist/icon.css', array(), $this->version, 'all' ); } // Load global admin styles. wp_enqueue_style( "{$this->plugin_name}-global-admin", plugin_dir_url( __FILE__ ) . 'resources/global.css', array(), $this->version, 'all' ); } /** * Admin initial functions. */ public function admin_init() { $this->maybe_update_user_review_status(); } /** * Generate admin menu for this plugin. * * @since 1.0.0 */ public function add_menu_callback() { // do not show menu if woocommerce is not active. if ( ! class_exists( 'woocommerce' ) ) { return; } global $admin_page_hooks; $parent_menu_slug = array_search( 'addonify', $admin_page_hooks, true ); if ( ! $parent_menu_slug ) { add_menu_page( 'Addonify Settings', 'Addonify', 'manage_options', $this->settings_page_slug, array( $this, 'get_settings_screen_contents' ), 'dashicons-superhero', 70 ); add_submenu_page( $this->settings_page_slug, 'Wishlist Settings', 'Wishlist', 'manage_options', $this->settings_page_slug, array( $this, 'get_settings_screen_contents' ), 1 ); } else { add_submenu_page( $parent_menu_slug, 'Wishlist Settings', 'Wishlist', 'manage_options', $this->settings_page_slug, array( $this, 'get_settings_screen_contents' ), 1 ); } } /** * Show action links on the plugin screen. * * @param mixed $links Plugin Action links. * @return array */ public function plugin_action_links( $links ) { $action_links = array( 'settings' => '' . __( 'Settings', 'addonify-wishlist' ) . '', ); return array_merge( $action_links, $links ); } /** * Show row meta on the plugin screen. * * @param mixed $links Plugin Row Meta. * @param mixed $file Plugin Base file. * * @return array */ public function plugin_row_meta( $links, $file ) { if ( ADDONIFY_WISHLIST_BASENAME !== $file ) { return $links; } $row_meta = array( 'docs' => '' . esc_html__( 'Documentation', 'addonify-wishlist' ) . '', 'github' => '' . esc_html__( 'GitHub', 'addonify-wishlist' ) . '', 'support' => '' . esc_html__( 'Community support', 'addonify-wishlist' ) . '', ); return array_merge( $links, $row_meta ); } /** * Get contents from settings page templates and print it * Called from "add_menu_callback". * * @since 1.0.0 */ public function get_settings_screen_contents() { ?>
ID ) === 'page' && (int) $post->ID === (int) $wishlist_page_id ) { $states[] = __( 'Addonify Wishlist Page', 'addonify-wishlist' ); } return $states; } /** * Review notice update on user choice. */ public function maybe_update_user_review_status() { if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) { wp_safe_redirect( esc_url( admin_url() ) ); exit; } if ( isset( $_GET['addonify-Wishlist-review-notice-already-did'] ) || isset( $_GET['addonify-Wishlist-review-notice-maybe-later'] ) ) { if ( ! isset( $_GET['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['nonce'] ) ), 'addonify_wishlist_review_nonce' ) ) { wp_safe_redirect( esc_url( admin_url() ) ); exit; } } if ( isset( $_GET['addonify-Wishlist-review-notice-already-did'] ) ) { //phpcs:ignore update_option( 'addonify_wishlist_plugin_review_status', 'reviewed' ); wp_safe_redirect( esc_url( admin_url() ) ); exit; } if ( isset( $_GET['addonify-Wishlist-review-notice-maybe-later'] ) ) { //phpcs:ignore set_transient( 'addonify_wishlist_ask_for_review_transient', '1', 3 * DAY_IN_SECONDS ); wp_safe_redirect( esc_url( admin_url() ) ); exit; } } /** * Show add a review admin notice. * * @since 2.0.0 */ public function show_add_a_review_notice() { global $pagenow; if ( 'index.php' !== $pagenow ) { return; } $nonce = wp_create_nonce( 'addonify_wishlist_review_nonce' ); ?>

true, 'nonce' => $nonce, ), admin_url() ) ?> true, 'nonce' => $nonce, ), admin_url() ) ?>