config = $config; self::$instance->setup_config(); self::$instance->setup_actions(); } } } /** * Setup the class props based on the config array. * * @since 1.0.0 */ public function setup_config() { $theme = wp_get_theme(); if ( is_child_theme() ) { $this->theme_name = $theme->parent()->get( 'Name' ); $this->theme = $theme->parent(); } else { $this->theme_name = $theme->get( 'Name' ); $this->theme = $theme->parent(); } $this->theme_version = $theme->get( 'Version' ); $this->theme_slug = $theme->get_template(); $this->page_slug = $this->theme_slug . '-about'; $this->action_key = $this->theme_slug . '-recommended_actions'; $this->menu_name = isset( $this->config['menu_name'] ) ? $this->config['menu_name'] : $this->theme_name; $this->page_name = isset( $this->config['page_name'] ) ? $this->config['page_name'] : $this->theme_name; $this->logo_url = isset( $this->config['logo_url'] ) ? $this->config['logo_url'] : get_template_directory_uri() . '/inc/theme-info/images/pt-logo.png'; $this->logo_link = isset( $this->config['logo_link'] ) ? $this->config['logo_link'] : 'https://cyclonethemes.com/'; $this->tabs = isset( $this->config['tabs'] ) ? $this->config['tabs'] : array(); $this->notification = isset( $this->config['notification'] ) ? $this->config['notification'] : ( '
' . sprintf( esc_html__( 'Welcome! Thank you for choosing %1$s! To fully take advantage of the best our theme can offer please make sure you visit our %2$swelcome page%3$s.', 'fire-blog' ), $this->theme_name, '', '' ) . '
' . sprintf( esc_html__( 'Get started with %s', 'fire-blog' ), $this->theme_name ) . '' . esc_html__( 'Hide this notice', 'fire-blog' ) . '
' ); } /** * Setup actions. * * @since 1.0.0 */ public function setup_actions() { add_action( 'admin_menu', array( $this, 'register' ) ); add_action( 'load-themes.php', array( $this, 'activation_admin_notice' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'load_assets' ) ); add_action( 'wp_ajax_pt_about_action_dismiss_recommended_action', array( $this, 'dismiss_recommended_action_callback' ) ); add_action( 'wp_ajax_nopriv_pt_about_action_dismiss_recommended_action', array( $this, 'dismiss_recommended_action_callback' ) ); } /** * Register the page under Appearance. * * @since 1.0.0 */ public function register() { if ( ! empty( $this->menu_name ) && ! empty( $this->page_name ) ) { $count = $this->get_total_recommended_actions(); $title = $this->page_name; if ( $count > 0 ) { $title .= '' . esc_html( $count ) . ''; } add_theme_page( $this->menu_name, $title, 'edit_theme_options', $this->page_slug, array( $this, 'render_about_page' ) ); } } /** * Get total recommended actions count. * * @since 1.0.0 * * @return int Total count. */ private function get_total_recommended_actions() { $actions = $this->get_recommended_actions(); return count( $actions ); } /** * Return valid array of recommended actions. * * @return array Valid array of recommended actions. */ private function get_recommended_actions() { $saved_actions = get_option( $this->action_key ); if ( ! is_array( $saved_actions ) ) { $saved_actions = array(); } $valid = array(); $action_config = isset( $this->config['recommended_actions'] ) ? $this->config['recommended_actions'] : array(); if ( ! empty( $action_config['content'] ) ) { foreach ( $action_config['content'] as $item ) { if ( isset( $item['check'] ) && true === $item['check'] ) { continue; } if ( isset( $saved_actions[ $item['id'] ] ) && false === $saved_actions[ $item['id'] ] ) { continue; } $valid[] = $item; } } return $valid; } /** * Render quick links. * * @since 1.0.0 */ public function render_quick_links() { $quick_links = ( isset( $this->config['quick_links'] ) ) ? $this->config['quick_links'] : array(); if ( empty( $quick_links ) ) { return; } echo ''; foreach ( $quick_links as $link ) { $link_class = 'button'; if ( isset( $link['button'] ) ) { $link_class .= ' button-' . esc_attr( $link['button'] ); } echo '' . esc_html( $link['text'] ) . ' '; } echo '
'; } /** * Render main page. * * @since 1.0.0 */ public function render_about_page() { if ( ! empty( $this->config['welcome_title'] ) ) { $welcome_title = $this->config['welcome_title']; } if ( ! empty( $this->config['welcome_content'] ) ) { $welcome_content = $this->config['welcome_content']; } if ( ! empty( $welcome_title ) || ! empty( $welcome_content ) || ! empty( $this->tabs ) ) { echo '' . esc_html( $getting_started_item['text'] ) . '
'; } if ( ! empty( $getting_started_item['button_link'] ) && ! empty( $getting_started_item['button_label'] ) ) { echo ''; $button_class = ''; if ( $getting_started_item['is_button'] ) { $button_class = 'button button-primary'; } $count = $this->get_total_recommended_actions(); if ( $getting_started_item['recommended_actions'] && isset( $count ) ) { if ( 0 === $count ) { echo ''; } else { echo ''; } } $button_new_tab = '_self'; if ( isset( $getting_started_item['is_new_tab'] ) ) { if ( $getting_started_item['is_new_tab'] ) { $button_new_tab = '_blank'; } } echo '' . esc_html( $getting_started_item['button_label'] ) . ''; echo '
'; } echo '' . wp_kses_post( $action_value['description'] ) . '
'; } if ( ! empty( $action_value['help'] ) ) { echo '' . wp_kses_post( $support_step['text'] ) . '
'; } if ( ! empty( $support_step['button_link'] ) && ! empty( $support_step['button_label'] ) ) { echo ''; $button_class = ''; if ( $support_step['is_button'] ) { $button_class = 'button button-primary'; } $button_new_tab = '_self'; if ( isset( $support_step['is_new_tab'] ) ) { if ( $support_step['is_new_tab'] ) { $button_new_tab = '_blank'; } } echo '' . esc_html( $support_step['button_label'] ) . ''; echo '
'; } echo ''; echo ' | ' . esc_html__( 'Fire Blog','fire-blog' ) . ' | '; echo '' . esc_html__( 'Fire Blog PRO','fire-blog' ) . ' | '; echo '||||
---|---|---|---|---|---|---|
';
if ( ! empty( $title ) ) {
echo '' . wp_kses_post( $title ) . ''; } if ( ! empty( $desc ) ) { echo '' . wp_kses_post( $desc ) . ' '; } echo ' | ';
}
if ( ! empty( $free )) {
if( 'yes' === $free ){
echo ''; } elseif ( 'no' === $free ){ echo ' | '; } else{ echo ' | '.esc_html($free ).' | '; } } if ( ! empty( $pro )) { if( 'yes' === $pro ){ echo ''; } elseif ( 'no' === $pro ){ echo ' | '; } else{ echo ' | '.esc_html($pro ).' | '; } } echo '
'; echo ' | Fire Blog PRO | '; echo '