コード例 #1
0
 function __construct($atts)
 {
     $this->found = false;
     $this->reassign_original_post = false;
     $this->toolset_object_relationship = Toolset_Object_Relationship::get_instance();
     $this->post_relationship = $this->toolset_object_relationship->post_relationship;
     if (isset($atts['id'])) {
         global $post, $authordata, $id;
         $post_id = 0;
         if (strpos($atts['id'], '$') === 0) {
             // Handle the parent if the id is $parent
             if ($atts['id'] == '$parent' && isset($post->post_parent)) {
                 $post_id = $post->post_parent;
             } else {
                 if ($atts['id'] == '$current_page') {
                     if (is_single() || is_page()) {
                         global $wp_query;
                         if (isset($wp_query->posts[0])) {
                             $current_post = $wp_query->posts[0];
                             $post_id = $current_post->ID;
                         }
                     }
                 } else {
                     // See if Views has the variable
                     global $WP_Views;
                     if (isset($WP_Views)) {
                         $post_id = $WP_Views->get_variable($atts['id'] . '_id');
                     }
                     if ($post_id == 0) {
                         // Try the local storage.
                         if (isset($this->post_relationship[$atts['id'] . '_id'])) {
                             $post_id = $this->post_relationship[$atts['id'] . '_id'];
                         }
                     }
                 }
             }
         } else {
             $post_id = intval($atts['id']);
         }
         if ($post_id > 0) {
             // if post does not exists
             if (get_post_status($post_id) === false) {
                 // set to true to reapply backup post in __destruct()
                 $this->reassign_original_post = true;
                 // save original post
                 $this->post = isset($post) && $post instanceof WP_Post ? clone $post : null;
                 $msg_post_does_not_exists = __(sprintf('A post with the ID %s does not exist.', '<b>' . $atts['id'] . '</b>'), 'wpv-views');
                 $post->post_title = $post->post_content = $post->post_excerpt = $msg_post_does_not_exists;
                 return;
             }
             $this->found = true;
             // save original post
             $this->post = isset($post) && $post instanceof WP_Post ? clone $post : null;
             if ($authordata) {
                 $this->authordata = clone $authordata;
             } else {
                 $this->authordata = null;
             }
             $this->id = $id;
             // set the global post values
             $id = $post_id;
             $post = get_post($id);
             $authordata = new WP_User($post->post_author);
         }
     }
 }
コード例 #2
0
ファイル: bootstrap.php プロジェクト: axeljohansson1988/oddcv
 public function register_inc()
 {
     $sections_loaded = self::$sections_loaded;
     if (!in_array('toolset_inc', $sections_loaded)) {
         $sections_loaded[] = 'toolset_inc';
         if (!class_exists('Toolset_Settings')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.settings.class.php';
             $this->settings = Toolset_Settings::get_instance();
         }
         if (!class_exists('Toolset_Localization')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.localization.class.php';
             $this->localization = new Toolset_Localization();
         }
         if (!class_exists('Toolset_WPLogger')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.wplogger.class.php';
         }
         if (!class_exists('Toolset_Object_Relationship')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.object.relationship.class.php';
             $this->object_relationship = Toolset_Object_Relationship::get_instance();
         }
         if (!class_exists('Toolset_Settings_Screen')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.settings.screen.class.php';
             $this->settings_screen = new Toolset_Settings_Screen();
         }
         if (!class_exists('Toolset_Export_Import_Screen')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.export.import.screen.class.php';
             $this->export_import_screen = new Toolset_Export_Import_Screen();
         }
         if (!class_exists('Toolset_Menu')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.menu.class.php';
             $this->menu = new Toolset_Menu();
         }
         if (!class_exists('Toolset_Promotion')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.promotion.class.php';
             $this->promotion = new Toolset_Promotion();
         }
         if (!class_exists('Toolset_Admin_Bar_Menu')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.admin.bar.menu.class.php';
             global $toolset_admin_bar_menu;
             $toolset_admin_bar_menu = Toolset_Admin_Bar_Menu::get_instance();
         }
         if (!class_exists('Toolset_WPML_Compatibility')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.wpml.compatibility.class.php';
             $this->wpml_compatibility = new Toolset_WPML_Compatibility();
         }
         require_once TOOLSET_COMMON_PATH . '/inc/toolset.compatibility.php';
         require_once TOOLSET_COMMON_PATH . '/inc/toolset.function.helpers.php';
         require_once TOOLSET_COMMON_PATH . '/deprecated.php';
         self::$sections_loaded = $sections_loaded;
     }
 }
コード例 #3
0
 public function register_inc()
 {
     if (!$this->is_section_loaded(self::TOOLSET_INCLUDES)) {
         $this->add_section_loaded(self::TOOLSET_INCLUDES);
         if (!class_exists('Toolset_Settings')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.settings.class.php';
             $this->settings = Toolset_Settings::get_instance();
         }
         if (!class_exists('Toolset_Localization')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.localization.class.php';
             $this->localization = new Toolset_Localization();
         }
         if (!class_exists('Toolset_WPLogger')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.wplogger.class.php';
         }
         if (!class_exists('Toolset_Object_Relationship')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.object.relationship.class.php';
             $this->object_relationship = Toolset_Object_Relationship::get_instance();
         }
         if (!class_exists('Toolset_Settings_Screen')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.settings.screen.class.php';
             $this->settings_screen = new Toolset_Settings_Screen();
         }
         if (!class_exists('Toolset_Export_Import_Screen')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.export.import.screen.class.php';
             $this->export_import_screen = new Toolset_Export_Import_Screen();
         }
         if (!class_exists('Toolset_Menu')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.menu.class.php';
             $this->menu = new Toolset_Menu();
         }
         if (!class_exists('Toolset_Promotion')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.promotion.class.php';
             $this->promotion = new Toolset_Promotion();
         }
         if (!class_exists('Toolset_Admin_Bar_Menu')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.admin.bar.menu.class.php';
             global $toolset_admin_bar_menu;
             $toolset_admin_bar_menu = Toolset_Admin_Bar_Menu::get_instance();
         }
         if (!class_exists('Toolset_Internal_Compatibility')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.internal.compatibility.class.php';
             $this->internal_compatibility = new Toolset_Internal_Compatibility();
         }
         if (!class_exists('Toolset_WPML_Compatibility')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.wpml.compatibility.class.php';
             $this->wpml_compatibility = new Toolset_WPML_Compatibility();
         }
         if (!class_exists('Toolset_Relevanssi_Compatibility')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.relevanssi.compatibility.class.php';
             $this->relevanssi_compatibility = new Toolset_Relevanssi_Compatibility();
         }
         if (!class_exists('Toolset_CssComponent')) {
             require_once TOOLSET_COMMON_PATH . '/inc/toolset.css.component.class.php';
             $toolset_bs_component = Toolset_CssComponent::getInstance();
         }
         require_once TOOLSET_COMMON_PATH . '/inc/toolset.compatibility.php';
         require_once TOOLSET_COMMON_PATH . '/inc/toolset.function.helpers.php';
         require_once TOOLSET_COMMON_PATH . '/deprecated.php';
         $this->apply_filters_on_sections_loaded('toolset_register_include_section');
     }
 }