state = $this->check_plugin_state(); $this->id = $id; } /** * Check plugin state. * * @return string */ private function check_plugin_state() { if ( file_exists( ABSPATH . 'wp-content/plugins/' . $this->path ) ) { include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); if ( is_plugin_active( $this->path ) ) { return $this->check_activation(); } return 'activate'; } return 'install'; } /** * This method check if user registered his account for SIB. * * @return string */ public function check_activation() { if ( ! class_exists( 'SIB_Manager' ) ) { return 'install'; } if ( SIB_Manager::is_done_validation() == true ) { return 'configure'; } return 'create_account'; } /** * Enqueue function */ public function enqueue() { if ( $this->state === 'activate' || $this->state === 'install' ) { Hestia_Plugin_Install_Helper::instance()->enqueue_scripts(); } } /** * Render content for the control. * * @since Hestia 1.0 */ public function render_content() { $text = ''; $display_button = false; $sib_account = false; if ( $this->state === 'install' || $this->state === 'activate' ) { $text = esc_html__( 'Here is where you must add the "SendinBlue Newsletter" widget.', 'hestia' ); $display_button = true; $sib_account = false; } if ( $this->state === 'create_account' ) { $text = sprintf( /* translators: %s Path in plugin wrapped*/ esc_html__( 'After installing the plugin, you need to navigate to %s and configure the plugin.', 'hestia' ), sprintf( /* translators: %s Path in plugin*/ '%s', esc_html__( 'SendinBlue > Home', 'hestia' ) ) ); $display_button = false; $sib_account = true; } if ( $this->state === 'configure' ) { $text = sprintf( esc_html__( 'Here is where you must add the "SendinBlue Newsletter" widget.', 'hestia' ) . ' %s', sprintf( '%s', esc_html__( 'Read full documentation', 'hestia' ) ) ); $display_button = false; $sib_account = false; } if ( ! empty( $text ) ) { echo wp_kses_post( $text ); } if ( $display_button === true ) { echo $this->create_plugin_install_button( $this->plugin, array( 'redirect' => admin_url( 'customize.php' ) . '?autofocus[control]=' . $this->id, ) ); } if ( $sib_account === true ) { echo '
'; echo '' . esc_html__( 'Create SendinBlue Account', 'hestia' ) . ''; } } /** * Check plugin state. * * @param string $slug slug. * * @return bool */ public function create_plugin_install_button( $slug, $settings = array() ) { return Hestia_Plugin_Install_Helper::instance()->get_button_html( $slug, $settings ); } }