Ejemplo n.º 1
0
 function setupTheme()
 {
     global $content_width;
     if (!isset($content_width)) {
         $content_width = 1050;
     }
     /***/
     $Menu = new ThemeMenu();
     $Post = new ThemePost();
     $Page = new ThemePage();
     $Image = new ThemeImage();
     $Comment = new ThemeComment();
     $WidgetArea = new ThemeWidgetArea();
     $MaintenanceMode = new ThemeMaintenanceMode();
     $WidgetPostRecent = new ThemeWidgetPostRecent();
     $WidgetPostMostComment = new ThemeWidgetPostMostComment();
     /***/
     $Image->register();
     $WidgetArea->register();
     /***/
     add_theme_support('menus');
     add_theme_support('post-thumbnails');
     add_theme_support('automatic-feed-links');
     /***/
     if (function_exists('register_nav_menu')) {
         register_nav_menu('menu_top', 'Menu Top');
     }
     /***/
     add_filter('widget_text', 'do_shortcode');
     add_filter('wp_title', array($Page, 'displayTitle'));
     add_filter('image_size_names_choose', array($Image, 'addImageSupport'));
     add_filter('excerpt_more', array($this, 'filterExcerptMore'));
     add_filter('excerpt_length', array($this, 'automaticExcerptLength'), 999);
     /***/
     add_editor_style('editor-style.css');
     /***/
     if (!class_exists('PBComponentMenu')) {
         add_filter('wp_setup_nav_menu_item', array($Menu, 'setupNavigationMenuItemField'));
         add_action('wp_update_nav_menu_item', array($Menu, 'updateNavigationMenuItemField'), 10, 3);
         add_filter('wp_edit_nav_menu_walker', array($Menu, 'editNavigationMenuWalker'), 10, 2);
     }
     /***/
     add_action('save_post', array($this, 'adminSaveMetaBox'));
     add_action('add_meta_boxes', array($Page, 'adminInitMetaBox'));
     add_action('add_meta_boxes', array($Post, 'adminInitMetaBox'));
     add_action('add_meta_boxes', array($this, 'adminInitMetaBox'));
     add_action('init', array($WidgetArea, 'adminInit'));
     add_action('save_post', array($WidgetArea, 'adminSaveMetaBox'));
     add_action('add_meta_boxes', array($WidgetArea, 'adminInitMetaBox'));
     add_filter('manage_edit-' . THEME_CONTEXT . '_widget_area_columns', array($WidgetArea, 'adminManageEditColumn'));
     add_action('manage_' . THEME_CONTEXT . '_widget_area_posts_custom_column', array($WidgetArea, 'adminManageColumn'));
     add_filter('manage_edit-' . THEME_CONTEXT . '_widget_area_sortable_columns', array($WidgetArea, 'adminManageEditSortableColumn'));
     add_action('wp_ajax_comment_add', array($Comment, 'addComment'));
     add_action('wp_ajax_nopriv_comment_add', array($Comment, 'addComment'));
     add_action('wp_ajax_comment_get', array($Comment, 'getComment'));
     add_action('wp_ajax_nopriv_comment_get', array($Comment, 'getComment'));
     add_action('tgmpa_register', array($this, 'addPlugin'));
     add_action('admin_notices', array($this, 'adminNotice'));
     add_action('init', array($MaintenanceMode, 'init'));
     /***/
     $WidgetPostRecent->register();
     $WidgetPostMostComment->register();
     /***/
     load_theme_textdomain(THEME_DOMAIN, THEME_PATH . 'languages/');
     /***/
     $install = (int) Themeoption::getOption('install');
     if ($install == 1) {
         return;
     }
     $data = array();
     $option = $this->themeDefaultOption;
     $Template = new ThemeTemplate($data, THEME_PATH_TEMPLATE . 'footer_bottom_content.php');
     $option['footer_bottom_content'] = $Template->output();
     $ResponsiveMode = new ThemeResponsiveMode($this->responsiveMode);
     $media = $ResponsiveMode->getMedia();
     foreach ($media as $index => $value) {
         $option['custom_css_responsive_' . $index] = '';
     }
     $optionCurrent = ThemeOption::getOptionObject();
     $optionSave = array();
     foreach ($option as $index => $value) {
         if (!array_key_exists($index, $optionCurrent)) {
             $optionSave[$index] = $value;
         }
     }
     $optionSave = array_merge($optionSave, $optionCurrent);
     foreach ($optionSave as $index => $value) {
         if (!array_key_exists($index, $option)) {
             unset($optionSave[$index]);
         }
     }
     $optionSave['install'] = 1;
     ThemeOption::resetOption();
     ThemeOption::updateOption($optionSave);
     $GoogleFont = new ThemeGoogleFont();
     $GoogleFont->download();
     $this->createCSSFile();
     /***/
     $argument = array('post_type' => array('post', 'page'), 'post_status' => 'any', 'posts_per_page' => -1);
     $query = new WP_Query($argument);
     if ($query === false) {
         return;
     }
     foreach ($query->posts as $value) {
         $meta = ThemeOption::getPostMeta($value);
         if (is_array($meta)) {
             continue;
         }
         $meta = array('menu_top' => -1, 'widget_area_sidebar' => -1, 'widget_area_sidebar_location' => -1, 'widget_area_footer' => -1, 'footer_bottom_enable' => -1, 'header_enable' => -1, 'header_background_image_repeat' => -1, 'header_background_image_size_1' => -1);
         if ($value->post_type == 'post') {
             $meta['post_type'] = 'image';
             $meta['post_tag_visible'] = -1;
             $meta['post_author_visible'] = -1;
             $meta['post_category_visible'] = -1;
             $meta['post_comment_count_visible'] = -1;
             $meta['post_navigation_visible'] = -1;
         }
         update_post_meta($value->ID, THEME_OPTION_PREFIX, $meta);
     }
 }
Ejemplo n.º 2
0
 /**
  * Ajax remove images
  */
 public function ajaxRemoveImages()
 {
     $path = Input::get('path');
     $img = ThemeImage::find(Input::get('id'));
     if (count($img) > 0) {
         $img->delete();
     }
     if (File::exists($path)) {
         File::delete($path);
         return Response::json(array('success' => true));
     } else {
         return Response::json(array('success' => false));
     }
 }