예제 #1
0
 /**
  * Use Contact step data in Social widget
  */
 private function widget_social()
 {
     $social_profiles = array_filter((array) get_option('wpem_social_profiles', []));
     if (!$social_profiles) {
         delete_option('widget_wpcw_social');
         return;
     }
     $widget = (array) get_option('widget_wpcw_social', []);
     unset($widget['_multiwidget']);
     if (!$widget) {
         return;
     }
     $keys = array_keys($widget);
     $key = array_shift($keys);
     include_once wpem()->base_dir . 'includes/social-networks.php';
     // Remove all default social networks from the widget
     foreach ($social_networks as $network => $data) {
         if (isset($social_networks[$network])) {
             unset($widget[$key][$network]);
         }
     }
     $fields = [];
     if (isset($widget[$key]['title'])) {
         // Add the title field to the new list
         $fields['title'] = $widget[$key]['title'];
         // Remove the title from the original widget
         unset($widget[$key]['title']);
     }
     // Prepend new social networks to the fields list
     foreach (wpem_get_social_profiles() as $network) {
         $fields[$network] = ['value' => wpem_get_social_profile_url($network), 'order' => ''];
     }
     // Merge updated fields with the original widget
     $widget[$key] = $fields + $widget[$key];
     // Refresh field order
     $widget[$key] = $this->refresh_widget_field_order($widget[$key]);
     $widget['_multiwidget'] = 1;
     update_option('widget_wpcw_social', $widget);
 }
예제 #2
0
 /**
  * Register admin menu and assets
  *
  * @action admin_menu
  */
 public function menu()
 {
     add_dashboard_page(_x('WP Easy Mode', 'Main plugin title', 'wp-easy-mode'), _x('Easy Mode', 'Menu title', 'wp-easy-mode'), $this->cap, wpem()->page_slug, [$this, 'screen']);
     $suffix = SCRIPT_DEBUG ? '' : '.min';
     wp_register_style('font-awesome', wpem()->assets_url . 'css/font-awesome.min.css', [], '4.5.0');
     wp_register_style('wpem-fullscreen', wpem()->assets_url . "css/fullscreen{$suffix}.css", ['dashicons', 'buttons', 'install'], wpem()->version);
     wp_register_script('jquery-blockui', wpem()->assets_url . 'js/jquery.blockui.min.js', ['jquery'], '2.70.0');
     wp_register_script('wpem', wpem()->assets_url . "js/common{$suffix}.js", ['jquery'], wpem()->version);
     wp_register_script('wpem-contact', wpem()->assets_url . "js/contact{$suffix}.js", ['wpem'], wpem()->version);
     wp_register_script('wpem-theme', wpem()->assets_url . "js/theme{$suffix}.js", ['wpem', 'wp-pointer', 'wpem-pointers'], wpem()->version);
     wp_localize_script('wpem', 'wpem_vars', ['step' => wpem_get_current_step()->name, 'i18n' => ['exit_confirm' => esc_attr__('Are you sure you want to exit and configure WordPress on your own?', 'wp-easy-mode')]]);
     /**
      * Filter the list of themes to display
      *
      * @var array
      */
     $themes = (array) apply_filters('wpem_themes', ['twentysixteen', 'twentyfifteen', 'twentyfourteen']);
     wp_localize_script('wpem-theme', 'wpem_theme_vars', ['themes' => array_map('esc_js', array_values(array_unique($themes))), 'i18n' => ['expand' => esc_attr__('Expand Sidebar', 'wp-easy-mode'), 'collapse' => esc_attr__('Collapse Sidebar', 'wp-easy-mode')], 'preview_url' => static::demo_site_url(['blogname' => get_option('blogname'), 'blogdescription' => get_option('blogdescription'), 'email' => wpem_get_contact_info('email'), 'phone' => wpem_get_contact_info('phone'), 'fax' => wpem_get_contact_info('fax'), 'address' => wpem_get_contact_info('address'), 'social' => implode(',', wpem_get_social_profiles())], false), 'ajax_url' => admin_url('admin-ajax.php'), 'customizer_url' => wpem_get_customizer_url(['return' => self_admin_url(), 'wpem' => 1])]);
 }