is_active() ) { $show_upsell = false; } if ( $show_upsell ) { add_action( 'admin_notices', array( $this, 'dashboard_upsell_notice' ) ); add_action( 'wp_ajax_dismiss_otter_notice', array( $this, 'dismiss_dashboard_notice' ) ); } } /** * Register Metabox * * @param string $post_type Post type. * * @since 2.0.3 * @access public */ public function register_metabox( $post_type ) { add_meta_box( 'otter_woo_builder', __( 'WooCommerce Builder by Otter', 'otter-blocks' ), array( $this, 'render_metabox_upsell' ), 'product', 'side', 'high' ); } /** * Render Metabox * * @param string $post_type Post type. * * @since 2.0.3 * @access public */ public function render_metabox_upsell( $post_type ) { if ( ! self::is_pro_installed() ) { ?>

%1$s %2$s %4$s

', esc_html( $plugin_name ), esc_html( $message ), esc_url( admin_url( 'update-core.php' ) ), esc_html__( 'Update', 'otter-blocks' ) ); } /** * Notice for Dashboard upsell. * * @since 2.0.8 * @access public */ public function dashboard_upsell_notice() { ?>

%1$s %2$s %4$s %5$s

', esc_html( $prefix ), esc_html( $message ), esc_url_raw( tsdk_utmify( self::get_url(), 'noticeusing', 'editor' ) ), esc_html__( 'Learn more', 'otter-blocks' ), esc_html__( 'Dismiss notice', 'otter-blocks' ) ); } /** * Dismiss Dashboard upsell. * * @since 2.0.8 * @access public */ public function dismiss_dashboard_notice() { if ( ! isset( $_POST['nonce'] ) ) { return; } if ( ! wp_verify_nonce( sanitize_text_field( $_POST['nonce'] ), 'dismiss_otter_notice' ) ) { return; } $notifications = get_option( 'themeisle_blocks_settings_notifications', array() ); $notifications['dashboard_upsell'] = true; update_option( 'themeisle_blocks_settings_notifications', $notifications ); wp_die(); } /** * Add new cron schedule. * * @param array $schedules Cron Schedules. * * @since 2.0.8 * @access public */ public function add_cron_schedules( $schedules = array() ) { // Adds once monthly to the existing schedules. $schedules['monthly'] = array( 'display' => __( 'Monthly', 'otter-blocks' ), 'interval' => 2635200, ); return $schedules; } /** * Schedule cron events. * * @since 2.0.8 * @access public */ public function schedule_cron_events() { if ( ! wp_next_scheduled( 'otter_montly_scheduled_events' ) ) { wp_schedule_event( current_time( 'timestamp', true ), 'monthly', 'otter_montly_scheduled_events' ); } } /** * Rest dashboard notice settings. * * @since 2.0.8 * @access public */ public function reset_dashboard_notice() { $notifications = get_option( 'themeisle_blocks_settings_notifications', array() ); if ( isset( $notifications['dashboard_upsell'] ) && true === boolval( $notifications['dashboard_upsell'] ) ) { $notifications['dashboard_upsell'] = false; update_option( 'themeisle_blocks_settings_notifications', $notifications ); } } /** * Add Pro Link to Plugins Page * * @param array $links Action Links. * * @since 2.1.6 * @access public */ public function add_pro_link( $links ) { if ( defined( 'OTTER_PRO_VERSION' ) ) { return $links; } $links[] = sprintf( '%s', esc_url_raw( tsdk_utmify( self::get_url(), 'pluginspage', 'action' ) ), __( 'Get Otter Pro', 'otter-blocks' ) ); return $links; } /** * Load offers. * * @return void */ public function load_offers() { if ( ! self::is_pro_installed() ) { $offer = new LimitedOffers(); if ( $offer->can_show_dashboard_banner() && $offer->is_active() ) { $offer->load_dashboard_hooks(); } } } /** * Singleton method. * * @static * * @return Pro * @since 2.0.3 * @access public */ public static function instance() { if ( is_null( self::$instance ) ) { self::$instance = new self(); self::$instance->init(); } return self::$instance; } /** * Throw error on object clone * * The whole idea of the singleton design pattern is that there is a single * object therefore, we don't want the object to be cloned. * * @access public * @return void * @since 2.0.3 */ public function __clone() { // Cloning instances of the class is forbidden. _doing_it_wrong( __FUNCTION__, 'Cheatin’ huh?', '1.0.0' ); } /** * Disable unserializing of the class * * @access public * @return void * @since 2.0.3 */ public function __wakeup() { // Unserializing instances of the class is forbidden. _doing_it_wrong( __FUNCTION__, 'Cheatin’ huh?', '1.0.0' ); } }