Example #1
0
 private function widgets()
 {
     // Delete all widgets
     delete_option('sidebars_widgets');
     // Get all the available sidebars
     $sidebars = wpem_wp_cli_exec(array('sidebar', 'list'), array('fields' => 'id', 'format' => 'csv'));
     $sidebars = explode("\n", $sidebars);
     // There is no standard ID for the "main" sidebar, so we need to check a few
     $sidebar = in_array('sidebar', $sidebars) ? 'sidebar' : (in_array('primary', $sidebars) ? 'primary' : 'sidebar-1');
     if ('standard' === $this->site_type) {
         // Search widget
         wpem_wp_cli_exec(array('widget', 'add', 'search', $sidebar, 1));
     }
     if ('blog' === $this->site_type) {
         // Search widget
         wpem_wp_cli_exec(array('widget', 'add', 'search', $sidebar, 1));
         // Recent Posts widget
         wpem_wp_cli_exec(array('widget', 'add', 'recent-posts', $sidebar, 2), array('title' => __('Recent Posts', 'wp-easy-mode'), 'number' => 5));
         // Archives widget
         wpem_wp_cli_exec(array('widget', 'add', 'archives', $sidebar, 3), array('title' => __('Archives', 'wp-easy-mode'), 'count' => 0, 'dropdown' => 0));
     }
     if ('store' === $this->site_type) {
         // WooCommerce Search widget
         wpem_wp_cli_exec(array('widget', 'add', 'woocommerce_product_search', $sidebar, 1));
         // WooCommerce Product Categories widget
         wpem_wp_cli_exec(array('widget', 'add', 'woocommerce_product_categories', $sidebar, 2), array('title' => __('Browse Products', 'wp-easy-mode'), 'orderby' => 'name', 'dropdown' => 0, 'count' => 0, 'hierarchical' => 1, 'show_children_only' => 0));
     }
 }
 /**
  * Step callback
  */
 public function callback()
 {
     $stylesheet = filter_input(INPUT_POST, 'wpem_selected_theme');
     $stylesheet = !empty($stylesheet) ? sanitize_key($stylesheet) : WP_DEFAULT_THEME;
     $log = new WPEM_Log();
     $log->add_step_field('wpem_selected_theme', $stylesheet);
     wpem_wp_cli_exec(array('theme', 'install', $stylesheet), array('activate' => true));
 }
 /**
  * Install WooCommerce plugin
  */
 private function install_woocommerce()
 {
     wpem_wp_cli_exec(array('plugin', 'install', 'woocommerce'), array('activate' => true));
     // Don't redirect after activation
     delete_transient('_wc_activation_redirect');
 }