config = $config; $this->architect_engineer_architect_engineer_prepare_class(); /*admin menu*/ add_action( 'admin_menu', array( $this, 'architect_engineer_tm_admin_menu' ) ); /* enqueue script and style for about page */ add_action( 'admin_enqueue_scripts', array( $this, 'architect_engineer_style_and_scripts' ) ); /* ajax callback for dismissable required actions */ add_action( 'wp_ajax_tm_theme_info_update_recommend_action', array( $this, 'architect_engineer_update_recommended_action_callback' ) ); } /** * Prepare and setup class properties. */ public function architect_engineer_architect_engineer_prepare_class() { $theme = wp_get_theme(); $this->theme_name = esc_html( $theme->get( 'Name' ) ); $this->theme_slug = $theme->get_template(); $this->theme_version = $theme->get( 'Version' ); $this->page_title = $this->theme_name . esc_html__( ' Info', 'architect-engineer' ); $this->menu_title = $this->theme_name . esc_html__( ' Theme', 'architect-engineer' ); $this->tabs = isset( $this->config['tabs'] ) ? $this->config['tabs'] : array(); } /** * Return the valid array of recommended actions. * @return array The valid array of recommended actions. */ /** * Dismiss required actions */ public function architect_engineer_update_recommended_action_callback() { /*getting for provided array*/ $recommended_actions = isset( $this->config['recommended_actions'] ) ? $this->config['recommended_actions'] : array(); /*from js action*/ $action_id = esc_attr( ( isset( $_GET['id'] ) ) ? $_GET['id'] : 0 ); $todo = esc_attr( ( isset( $_GET['todo'] ) ) ? $_GET['todo'] : '' ); /*getting saved actions*/ $saved_actions = get_option( $this->theme_slug . '_recommended_actions' ); echo esc_html( wp_unslash( $action_id ) ); /* this is needed and it's the id of the dismissable required action */ if ( ! empty( $action_id ) ) { if( 'reset' == $todo ){ $saved_actions_new = array(); if ( ! empty( $recommended_actions ) ) { foreach ( $recommended_actions as $recommended_action ) { $saved_actions[ $recommended_action['id'] ] = true; } update_option( $this->theme_slug . '_recommended_actions', $saved_actions_new ); } } /* if the option exists, update the record for the specified id */ elseif ( !empty( $saved_actions) and is_array( $saved_actions ) ) { switch ( esc_html( $todo ) ) { case 'add'; $saved_actions[ $action_id ] = true; break; case 'dismiss'; $saved_actions[ $action_id ] = false; break; } update_option( $this->theme_slug . '_recommended_actions', $saved_actions ); /* create the new option,with false for the specified id */ } else { $saved_actions_new = array(); if ( ! empty( $recommended_actions ) ) { foreach ( $recommended_actions as $recommended_action ) { echo esc_html($recommended_action['id']); echo " ". esc_html($todo); if ( $recommended_action['id'] == $action_id ) { switch ( esc_html( $todo ) ) { case 'add'; $saved_actions_new[ $action_id ] = true; break; case 'dismiss'; $saved_actions_new[ $action_id ] = false; break; } } } } update_option( $this->theme_slug . '_recommended_actions', $saved_actions_new ); } } exit; } private function architect_engineer_get_recommended_actions() { $saved_actions = get_option( $this->theme_slug . '_recommended_actions' ); if ( ! is_array( $saved_actions ) ) { $saved_actions = array(); } $recommended_actions = isset( $this->config['recommended_actions'] ) ? $this->config['recommended_actions'] : array(); $valid = array(); if( isset( $recommended_actions ) && is_array( $recommended_actions ) ){ foreach ( $recommended_actions as $recommended_action ) { if ( ( ! isset( $recommended_action['check'] ) || ( isset( $recommended_action['check'] ) && ( $recommended_action['check'] == false ) ) ) && ( ! isset( $saved_actions[ $recommended_action['id'] ] ) || ( isset( $saved_actions[ $recommended_action['id']] ) && ($saved_actions[ $recommended_action['id']] == true ) ) ) ) { $valid[] = $recommended_action; } } } return $valid; } private function architect_engineer_count_recommended_actions() { $count = 0; $actions_count = $this->architect_engineer_get_recommended_actions(); if ( ! empty( $actions_count ) ) { $count = count( $actions_count ); } return $count; } /** * Adding Theme Info Menu under Appearance. */ function architect_engineer_tm_admin_menu() { if ( ! empty( $this->page_title ) && ! empty( $this->menu_title ) ) { $count = $this->architect_engineer_count_recommended_actions(); $menu_title = $count > 0 ? $this->menu_title . '' . esc_html( $count ) . '' : $this->menu_title; /* Example * add_theme_page('My Plugin Theme', 'My Plugin', 'edit_theme_options', 'my-unique-identifier', 'my_plugin_function'); * */ add_theme_page( $this->page_title, $menu_title, 'edit_theme_options', $this->theme_slug . '-info', array( $this, 'architect_engineer_tm_theme_info_screen_main', ) ); } } /** * Render the info content screen. */ public function architect_engineer_tm_theme_info_screen_main() { $theme_name_config = esc_attr ( wp_get_theme()->get('Name') ); if ( ! empty( $this->config['info_title'] ) ) { $welcome_title = $this->config['info_title']; } if ( ! empty( $this->config['info_content'] ) ) { $welcome_content = $this->config['info_content']; } if ( ! empty( $this->config['quick_links'] ) ) { $quick_links = $this->config['quick_links']; } if ( ! empty( $welcome_title ) || ! empty( $welcome_content ) || ! empty( $quick_links ) || ! empty( $this->tabs ) ) { echo '
'; echo '
'; echo '
'; if ( ! empty( $welcome_title ) ) { echo '

'; echo esc_html( $welcome_title ); if ( ! empty( $this->theme_version ) ) { echo esc_html( $this->theme_version ) . ' '; } echo '

'; } if ( ! empty( $welcome_content ) ) { echo '
' . wp_kses_post( $welcome_content ) . '
'; } /*quick links*/ if( !empty( $quick_links ) && is_array( $quick_links ) ){ echo '"; } echo '
'; echo '
'; echo 'screenshot'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo '
'; echo '
'; /* Display tabs */ if ( ! empty( $this->tabs ) ) { $current_tab = isset( $_GET['tab'] ) ? wp_unslash( $_GET['tab'] ) : 'architect_engineer_demo_impoter'; echo ''; /* Display content for current tab, dynamic method according to key provided*/ if ( method_exists( $this, $current_tab ) ) { echo "
"; $this->$current_tab(); echo "
"; } } echo '
'; } } /** * Getting started tab */ public function architect_engineer_demo_impoter() { echo '
'; if ( ! empty( $this->config['architect_engineer_demo_impoter_steps'] ) ) { $architect_engineer_demo_impoter_steps = $this->config['architect_engineer_demo_impoter_steps']; if ( ! empty( $architect_engineer_demo_impoter_steps ) ) { ?> get_screenshot(); ?>

<?php echo esc_attr( $theme->get('Name') ); ?>
'; } /** * Getting started tab */ public function architect_engineer_pro_templates() { echo '
'; ?>
node; if (isset($product_obj->inCollection) && !$product_obj->inCollection) { continue; } $demo_url = isset($product->node->metafield->value) ? $product->node->metafield->value : ''; $product_url = isset($product->node->onlineStoreUrl) ? $product->node->onlineStoreUrl : ''; $image_src = isset($product->node->images->edges[0]->node->src) ? $product->node->images->edges[0]->node->src : ''; $price = isset($product->node->variants->edges[0]->node->price) ? '$' . $product->node->variants->edges[0]->node->price : ''; ?>
<?php echo esc_attr($product_obj->title); ?>

title); ?>

Price:
hasNextPage) && $get_filtered_products['pagination']->hasNextPage) { ?>
'; } /** * Recommended Actions tab */ public function architect_engineer_check_plugin_status( $slug ) { $path = WPMU_PLUGIN_DIR . '/' . $slug . '/' . $slug . '.php'; if ( ! file_exists( $path ) ) { $path = WP_PLUGIN_DIR . '/' . $slug . '/' . $slug . '.php'; if ( ! file_exists( $path ) ) { $path = false; } } if ( file_exists( $path ) ) { include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound $needs = is_plugin_active( $slug . '/' . $slug . '.php' ) ? 'deactivate' : 'activate'; return array( 'status' => is_plugin_active( $slug . '/' . $slug . '.php' ), 'needs' => $needs ); } return array( 'status' => false, 'needs' => 'install' ); } public function architect_engineer_create_action_link( $state, $slug ) { switch ( $state ) { case 'install': return wp_nonce_url( add_query_arg( array( 'action' => 'install-plugin', 'plugin' => $slug ), network_admin_url( 'update.php' ) ), 'install-plugin_' . $slug ); break; case 'deactivate': return add_query_arg( array( 'action' => 'deactivate', 'plugin' => rawurlencode( $slug . '/' . $slug . '.php' ), 'plugin_status' => 'all', 'paged' => '1', '_wpnonce' => wp_create_nonce( 'deactivate-plugin_' . $slug . '/' . $slug . '.php' ) ), network_admin_url( 'plugins.php' ) ); break; case 'activate': return add_query_arg( array( 'action' => 'activate', 'plugin' => rawurlencode( $slug . '/' . $slug . '.php' ), 'plugin_status' => 'all', 'paged' => '1', '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $slug . '/' . $slug . '.php' ) ), network_admin_url( 'plugins.php' ) ); break; } } public function recommended_actions() { $recommended_actions = isset( $this->config['recommended_actions'] ) ? $this->config['recommended_actions'] : array(); $hooray = true; if ( ! empty( $recommended_actions ) ) { echo '