当前位置: 首页>>代码示例>>PHP>>正文


PHP EM_Object::ms_global_switch方法代码示例

本文整理汇总了PHP中EM_Object::ms_global_switch方法的典型用法代码示例。如果您正苦于以下问题:PHP EM_Object::ms_global_switch方法的具体用法?PHP EM_Object::ms_global_switch怎么用?PHP EM_Object::ms_global_switch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EM_Object的用法示例。


在下文中一共展示了EM_Object::ms_global_switch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: em_admin_ms_locations

/**
 * Looks at the request values, saves/updates and then displays the right menu in the admin
 * @return null
 */
function em_admin_ms_locations()
{
    //TODO EM_Location is globalized, use it fully here
    global $EM_Location;
    EM_Object::ms_global_switch();
    //Take actions
    if (!empty($_REQUEST['action']) && ($_REQUEST['action'] == "edit" || $_REQUEST['action'] == "location_save")) {
        em_admin_location();
    } else {
        // no action, just a locations list
        em_admin_locations();
    }
    EM_Object::ms_global_switch_back();
}
开发者ID:hscale,项目名称:webento,代码行数:18,代码来源:em-ms-locations.php

示例2: meta_box_ms_categories

    public static function meta_box_ms_categories()
    {
        global $EM_Event;
        EM_Object::ms_global_switch();
        $categories = EM_Categories::get(array('hide_empty' => false));
        ?>

		<?php 
        if (count($categories) > 0) {
            ?>

			<p class="ms-global-categories">
			 <?php 
            $selected = $EM_Event->get_categories()->get_ids();
            ?>

			 <?php 
            $walker = new EM_Walker_Category();
            ?>

			 <?php 
            $args_em = array('hide_empty' => 0, 'name' => 'event_categories[]', 'hierarchical' => true, 'id' => EM_TAXONOMY_CATEGORY, 'taxonomy' => EM_TAXONOMY_CATEGORY, 'selected' => $selected, 'walker' => $walker);
            ?>

			 <?php 
            echo walk_category_dropdown_tree($categories, 0, $args_em);
            ?>

			</p>
		<?php 
        } else {
            ?>

			<p><?php 
            sprintf(__('No categories available, <a href="%s">create one here first</a>', 'dbem'), get_bloginfo('wpurl') . '/wp-admin/admin.php?page=events-manager-categories');
            ?>
</p>
		<?php 
        }
        ?>

		<!-- END Categories -->
		<?php 
        EM_Object::ms_global_switch_back();
    }
开发者ID:batruji,项目名称:metareading,代码行数:45,代码来源:em-event-post-admin.php

示例3: save

 function save()
 {
     global $wpdb, $current_user, $blog_id, $EM_SAVING_LOCATION;
     $EM_SAVING_LOCATION = true;
     //TODO shuffle filters into right place
     if (get_site_option('dbem_ms_mainblog_locations')) {
         self::ms_global_switch();
     }
     if (!$this->can_manage('edit_locations', 'edit_others_locations') && !(get_option('dbem_events_anonymous_submissions') && empty($this->location_id))) {
         return apply_filters('em_location_save', false, $this);
     }
     remove_action('save_post', array('EM_Location_Post_Admin', 'save_post'), 10, 1);
     //disable the default save post action, we'll do it manually this way
     do_action('em_location_save_pre', $this);
     $post_array = array();
     //Deal with updates to a location
     if (!empty($this->post_id)) {
         //get the full array of post data so we don't overwrite anything.
         if (EM_MS_GLOBAL) {
             if (!empty($this->blog_id)) {
                 $post_array = (array) get_blog_post($this->blog_id, $this->post_id);
             } else {
                 $post_array = (array) get_blog_post(get_current_site()->blog_id, $this->post_id);
             }
         } else {
             $post_array = (array) get_post($this->post_id);
         }
     }
     //Overwrite new post info
     $post_array['post_type'] = EM_POST_TYPE_LOCATION;
     $post_array['post_title'] = $this->location_name;
     $post_array['post_content'] = $this->post_content;
     //decide on post status
     if (count($this->errors) == 0) {
         if (EM_MS_GLOBAL && !is_main_site() && get_site_option('dbem_ms_mainblog_locations')) {
             //if in global ms mode and user is a valid role to publish on their blog, then we will publish the location on the main blog
             restore_current_blog();
             $post_array['post_status'] = $this->can_manage('publish_locations') ? 'publish' : 'pending';
             EM_Object::ms_global_switch();
             //switch 'back' to main blog
         } else {
             $post_array['post_status'] = $this->can_manage('publish_locations') ? 'publish' : 'pending';
         }
     } else {
         $post_array['post_status'] = 'draft';
     }
     //Anonymous submission
     if (!is_user_logged_in() && get_option('dbem_events_anonymous_submissions') && empty($this->location_id)) {
         $post_array['post_author'] = get_option('dbem_events_anonymous_user');
         if (!is_numeric($post_array['post_author'])) {
             $post_array['post_author'] = 0;
         }
     }
     //Save post and continue with meta
     $post_id = wp_insert_post($post_array);
     $post_save = false;
     $meta_save = false;
     if (!is_wp_error($post_id) && !empty($post_id)) {
         $post_save = true;
         //refresh this event with wp post
         $post_data = get_post($post_id);
         $this->post_id = $post_id;
         $this->location_slug = $post_data->post_name;
         $this->location_owner = $post_data->post_author;
         $this->post_status = $post_data->post_status;
         $this->get_status();
         //now save the meta
         $meta_save = $this->save_meta();
         //save the image
         $this->image_upload();
         $image_save = count($this->errors) == 0;
     } elseif (is_wp_error($post_id)) {
         //location not saved, add an error
         $this->add_error($post_id->get_error_message());
     }
     if (get_site_option('dbem_ms_mainblog_locations')) {
         self::ms_global_switch_back();
     }
     $return = apply_filters('em_location_save', $post_save && $meta_save && $image_save, $this);
     $EM_SAVING_LOCATION = false;
     return $return;
 }
开发者ID:javipaur,项目名称:TiendaVirtual,代码行数:82,代码来源:em-location.php

示例4: em_admin_init

function em_admin_init()
{
    //in MS global mode and locations are stored in the main blog, then a user must have at least a subscriber role
    if (EM_MS_GLOBAL && is_user_logged_in() && !is_main_site() && get_site_option('dbem_ms_mainblog_locations')) {
        EM_Object::ms_global_switch();
        $user = new WP_User(get_current_user_id());
        if (count($user->roles) == 0) {
            $user->set_role('subscriber');
        }
        EM_Object::ms_global_switch_back();
    }
}
开发者ID:mjrobison,项目名称:FirstCareCPR,代码行数:12,代码来源:em-admin.php

示例5: em_init_actions


//.........这里部分代码省略.........
            }
            wp_redirect(wp_get_referer());
            exit;
        } elseif ($_REQUEST['action'] == 'event_attach' && !empty($_REQUEST['undo_id']) && wp_verify_nonce($_REQUEST['_wpnonce'], 'event_attach_' . get_current_user_id() . '_' . $EM_Event->event_id)) {
            //Detach event and move on
            if ($EM_Event->attach($_REQUEST['undo_id'])) {
                $EM_Notices->add_confirm($EM_Event->feedback_message, true);
            } else {
                $EM_Notices->add_error($EM_Event->errors, true);
            }
            wp_redirect(wp_get_referer());
            exit;
        }
        //AJAX Exit
        if (isset($events_result) && !empty($_REQUEST['em_ajax'])) {
            if ($events_result) {
                $return = array('result' => true, 'message' => $EM_Event->feedback_message);
            } else {
                $return = array('result' => false, 'message' => $EM_Event->feedback_message, 'errors' => $EM_Event->errors);
            }
        }
    }
    //Location Actions
    if (!empty($_REQUEST['action']) && substr($_REQUEST['action'], 0, 8) == 'location') {
        global $EM_Location, $EM_Notices;
        //Load the location object, with saved event if requested
        if (!empty($_REQUEST['location_id'])) {
            $EM_Location = new EM_Location($_REQUEST['location_id']);
        } else {
            $EM_Location = new EM_Location();
        }
        if ($_REQUEST['action'] == 'location_save' && current_user_can('edit_locations')) {
            if (get_site_option('dbem_ms_mainblog_locations')) {
                EM_Object::ms_global_switch();
            }
            //switch to main blog if locations are global
            //Check Nonces
            em_verify_nonce('location_save');
            //Grab and validate submitted data
            if ($EM_Location->get_post() && $EM_Location->save()) {
                //EM_location gets the location if submitted via POST and validates it (safer than to depend on JS)
                $EM_Notices->add_confirm($EM_Location->feedback_message, true);
                $redirect = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : wp_get_referer();
                wp_redirect($redirect);
                exit;
            } else {
                $EM_Notices->add_error($EM_Location->get_errors());
                $result = false;
            }
            if (get_site_option('dbem_ms_mainblog_locations')) {
                EM_Object::ms_global_switch_back();
            }
        } elseif (!empty($_REQUEST['action']) && $_REQUEST['action'] == "location_delete") {
            //delete location
            //get object or objects
            if (!empty($_REQUEST['locations']) || !empty($_REQUEST['location_id'])) {
                $args = !empty($_REQUEST['locations']) ? $_REQUEST['locations'] : $_REQUEST['location_id'];
                $locations = EM_Locations::get($args);
                foreach ($locations as $location) {
                    if (!$location->delete()) {
                        $EM_Notices->add_error($location->get_errors());
                        $errors = true;
                    }
                }
                if (empty($errors)) {
                    $result = true;
开发者ID:rajankz,项目名称:webspace,代码行数:67,代码来源:em-actions.php

示例6: array

<?php

$args = !empty($args) ? $args : array();
/* @var $args array */
?>
<!-- START Category Search -->
<div class="em-search-category em-search-field">
	<label><?php 
echo esc_html($args['category_label']);
?>
</label>
	<?php 
EM_Object::ms_global_switch();
//in case in global tables mode of MultiSite, grabs main site categories, if not using MS Global, nothing happens
wp_dropdown_categories(array('hide_empty' => 0, 'orderby' => 'name', 'name' => 'category', 'hierarchical' => true, 'taxonomy' => EM_TAXONOMY_CATEGORY, 'selected' => $args['category'], 'show_option_none' => $args['categories_label'], 'class' => 'em-events-search-category'));
EM_Object::ms_global_switch_back();
//if switched above, switch back
?>
</div>
<!-- END Category Search -->
开发者ID:mpaskew,项目名称:isc-dev,代码行数:20,代码来源:categories.php


注:本文中的EM_Object::ms_global_switch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。