esc_url( admin_url( 'themes.php?page=pt-one-click-demo-import' )), ) ); wp_localize_script( 'amaz-store-admin-load', 'THAdmin', $data); } } function tab_constant(){ $theme_data = wp_get_theme(); $tab_array = array(); $tab_array['header'] = array('theme_brand' => __('ThemeHunk','amaz-store'), 'theme_brand_url' => esc_url($theme_data->get( 'AuthorURI' )), 'welcome'=>sprintf(esc_html__('Welcome To %1s Theme', 'amaz-store'), esc_html($theme_data->get( 'Name' ),'amaz-store'), $theme_data->get( 'Version' ) ), 'welcome_desc' => esc_html($theme_data->get( 'Name' ).' is a Free WooCommerce theme for creating clean and professional shopping stores.', 'amaz-store' ), 'v'=> 'Version '.$theme_data->get( 'Version' ) ); return $tab_array; } function tab_page() { $text_array = $this->tab_constant(); $theme_header =$text_array['header']; include('tab-html.php' ); } // Home Page Setup function default_home() { $pages = get_pages(array( 'meta_key' => '_wp_page_template', 'meta_value' => 'frontpage.php' )); $post_id = isset($pages[0]->ID)?$pages[0]->ID:false; if(empty($pages)){ $post_id = wp_insert_post(array ( 'post_type' => 'page', 'post_title' => __('Home Page','amaz-store'), 'post_content' => '', 'post_status' => 'publish', 'comment_status' => 'closed', // if you prefer 'ping_status' => 'closed', // if you prefer 'page_template' =>'frontpage.php', //Sets the template for the page. )); } if($post_id){ update_option( 'page_on_front', $post_id ); update_option( 'show_on_front', 'page' ); } wp_die(); // this is required to terminate immediately and return a proper response } function _check_homepage_setup(){ $fid = get_option( 'page_on_front'); $pages = get_pages(array( 'meta_key' => '_wp_page_template', 'meta_value' => 'frontpage.php' )); $post_id = isset($pages[0]->ID)?$pages[0]->ID:false; return ($fid == $post_id)?true:false; } /* * Plugin install * Active plugin * Setup Homepage */ public function th_activeplugin(){ if ( ! current_user_can( 'install_plugins' ) || ! isset( $_POST['init'] ) || ! $_POST['init'] ) { wp_send_json_error( array( 'success' => false, 'message' => __( 'No plugin specified', 'amaz-store' ), ) ); } $plugin_init = ( isset( $_POST['init'] ) ) ? esc_attr( $_POST['init'] ) : ''; $activate = activate_plugin( $plugin_init); if ( is_wp_error( $activate ) ) { wp_send_json_error( array( 'success' => false, 'message' => $activate->get_error_message(), ) ); } wp_send_json_success( array( 'success' => true, 'message' => __( 'Plugin Successfully Activated', 'amaz-store' ), ) ); } function plugin_install_button($plugin){ $button = ''; echo $button; } /** * Include Welcome page content */ public function plugin_install($rplugins = 'recommend-plugins'){ $recommend_plugins = get_theme_support( $rplugins ); if ( is_array( $recommend_plugins ) && isset( $recommend_plugins[0] ) ){ $pluginArr =array(); foreach($recommend_plugins[0] as $slug=>$plugin){ $plugin_init = $plugin['active_filename']; $status = is_dir( WP_PLUGIN_DIR . '/' . $slug ); $button_class = 'install-now button '.$slug; if ( is_plugin_active( $plugin_init ) ) { $button_class = 'button disabled '.$slug; $button_txt = esc_html__( 'Activated', 'amaz-store' ); $detail_link = $install_url = ''; } if ( ! is_plugin_active( $plugin_init ) ){ $button_txt = esc_html__( 'Install Now', 'amaz-store' ); if ( ! $status ) { $install_url = wp_nonce_url( add_query_arg( array( 'action' => 'install-plugin', 'plugin' => $slug ), network_admin_url( 'update.php' ) ), 'install-plugin_'.$slug ); } else { $install_url = add_query_arg(array( 'action' => 'activate', 'plugin' => rawurlencode( $plugin_init ), 'plugin_status' => 'all', 'paged' => '1', '_wpnonce' => wp_create_nonce('activate-plugin_' . $plugin_init ), ), network_admin_url('plugins.php')); $button_class = 'activate-now button-primary '.$slug; $button_txt = esc_html__( 'Activate Now', 'amaz-store' ); } } $detail_link = add_query_arg( array( 'tab' => 'plugin-information', 'plugin' => $slug, 'TB_iframe' => 'true', 'width' => '772', 'height' => '500', ), network_admin_url( 'plugin-install.php' ) ); $pluginArr['plugin_name'] = $plugin['name']; $pluginArr['slug']= $slug; $pluginArr['thumb']= "https://ps.w.org/". $slug."/assets/".$plugin['img']; $pluginArr['plugin_init']= $plugin_init; $pluginArr['detail_link']= $detail_link; $pluginArr['button_txt']= $button_txt; $pluginArr['button_class']= $button_class; $this->plugin_install_button($pluginArr); } } // plugin check } } // class end $boj = new Amaz_Store_theme_option(); ?>