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


PHP can_edit_network函数代码示例

本文整理汇总了PHP中can_edit_network函数的典型用法代码示例。如果您正苦于以下问题:PHP can_edit_network函数的具体用法?PHP can_edit_network怎么用?PHP can_edit_network使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: isset

$action = $wp_list_table->current_action();
$s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
$temp_args = array('enabled', 'disabled', 'error');
$_SERVER['REQUEST_URI'] = remove_query_arg($temp_args, $_SERVER['REQUEST_URI']);
$referer = remove_query_arg($temp_args, wp_get_referer());
if (!empty($_REQUEST['paged'])) {
    $referer = add_query_arg('paged', (int) $_REQUEST['paged'], $referer);
}
$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
if (!$id) {
    wp_die(__('Invalid site ID.'));
}
$wp_list_table->prepare_items();
$details = get_blog_details($id);
if (!can_edit_network($details->site_id)) {
    wp_die(__('You do not have permission to access this page.'), 403);
}
$is_main_site = is_main_site($id);
if ($action) {
    switch_to_blog($id);
    $allowed_themes = get_option('allowedthemes');
    switch ($action) {
        case 'enable':
            check_admin_referer('enable-theme_' . $_GET['theme']);
            $theme = $_GET['theme'];
            $action = 'enabled';
            $n = 1;
            if (!$allowed_themes) {
                $allowed_themes = array($theme => true);
            } else {
开发者ID:nstungxd,项目名称:F2CA5,代码行数:31,代码来源:site-themes.php

示例2: display_rows


//.........这里部分代码省略.........
                        $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
                        if (current_user_can('delete_user', $user->ID) && !in_array($user->user_login, $super_admins)) {
                            $actions['delete'] = '<a href="' . ($delete = esc_url(network_admin_url(add_query_arg('_wp_http_referer', urlencode(wp_unslash($_SERVER['REQUEST_URI'])), wp_nonce_url('users.php', 'deleteuser') . '&amp;action=deleteuser&amp;id=' . $user->ID))) . '" class="delete">' . __('Delete') . '</a>');
                        }
                        /**
                         * Filter the action links displayed under each user
                         * in the Network Admin Users list table.
                         *
                         * @since 3.2.0
                         *
                         * @param array   $actions An array of action links to be displayed.
                         *                         Default 'Edit', 'Delete'.
                         * @param WP_User $user    WP_User object.
                         */
                        $actions = apply_filters('ms_user_row_actions', $actions, $user);
                        echo $this->row_actions($actions);
                        ?>
						</td>
					<?php 
                        break;
                    case 'name':
                        echo "<td {$attributes}>{$user->first_name} {$user->last_name}</td>";
                        break;
                    case 'email':
                        echo "<td {$attributes}><a href='" . esc_url("mailto:{$user->user_email}") . "'>{$user->user_email}</a></td>";
                        break;
                    case 'registered':
                        if ('list' == $mode) {
                            $date = 'Y/m/d';
                        } else {
                            $date = 'Y/m/d \\<\\b\\r \\/\\> g:i:s a';
                        }
                        echo "<td {$attributes}>" . mysql2date($date, $user->user_registered) . "</td>";
                        break;
                    case 'blogs':
                        $blogs = get_blogs_of_user($user->ID, true);
                        echo "<td {$attributes}>";
                        if (is_array($blogs)) {
                            foreach ((array) $blogs as $key => $val) {
                                if (!can_edit_network($val->site_id)) {
                                    continue;
                                }
                                $path = $val->path == '/' ? '' : $val->path;
                                echo '<span class="site-' . $val->site_id . '" >';
                                echo '<a href="' . esc_url(network_admin_url('site-info.php?id=' . $val->userblog_id)) . '">' . str_replace('.' . get_current_site()->domain, '', $val->domain . $path) . '</a>';
                                echo ' <small class="row-actions">';
                                $actions = array();
                                $actions['edit'] = '<a href="' . esc_url(network_admin_url('site-info.php?id=' . $val->userblog_id)) . '">' . __('Edit') . '</a>';
                                $class = '';
                                if (get_blog_status($val->userblog_id, 'spam') == 1) {
                                    $class .= 'site-spammed ';
                                }
                                if (get_blog_status($val->userblog_id, 'mature') == 1) {
                                    $class .= 'site-mature ';
                                }
                                if (get_blog_status($val->userblog_id, 'deleted') == 1) {
                                    $class .= 'site-deleted ';
                                }
                                if (get_blog_status($val->userblog_id, 'archived') == 1) {
                                    $class .= 'site-archived ';
                                }
                                $actions['view'] = '<a class="' . $class . '" href="' . esc_url(get_home_url($val->userblog_id)) . '">' . __('View') . '</a>';
                                /**
                                 * Filter the action links displayed next the sites a user belongs to
                                 * in the Network Admin Users list table.
                                 *
                                 * @since 3.1.0
                                 *
                                 * @param array $actions     An array of action links to be displayed.
                                 *                           Default 'Edit', 'View'.
                                 * @param int   $userblog_id The site ID.
                                 */
                                $actions = apply_filters('ms_user_list_site_actions', $actions, $val->userblog_id);
                                $i = 0;
                                $action_count = count($actions);
                                foreach ($actions as $action => $link) {
                                    ++$i;
                                    $i == $action_count ? $sep = '' : ($sep = ' | ');
                                    echo "<span class='{$action}'>{$link}{$sep}</span>";
                                }
                                echo '</small></span><br/>';
                            }
                        }
                        ?>
						</td>
					<?php 
                        break;
                    default:
                        echo "<td {$attributes}>";
                        /** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */
                        echo apply_filters('manage_users_custom_column', '', $column_name, $user->ID);
                        echo "</td>";
                        break;
                }
            }
            ?>
			</tr>
			<?php 
        }
    }
开发者ID:luskyj89,项目名称:mt-wordpress,代码行数:101,代码来源:class-wp-ms-users-list-table.php

示例3: column_blogs

 /**
  * Handles the blogs/sites column output.
  *
  * @since 4.3.0
  * @access public
  *
  * @param WP_User $user The current WP_User object.
  */
 public function column_blogs($user)
 {
     $blogs = get_blogs_of_user($user->ID, true);
     if (!is_array($blogs)) {
         return;
     }
     foreach ($blogs as $val) {
         if (!can_edit_network($val->site_id)) {
             continue;
         }
         $path = $val->path === '/' ? '' : $val->path;
         echo '<span class="site-' . $val->site_id . '" >';
         echo '<a href="' . esc_url(network_admin_url('site-info.php?id=' . $val->userblog_id)) . '">' . str_replace('.' . get_current_site()->domain, '', $val->domain . $path) . '</a>';
         echo ' <small class="row-actions">';
         $actions = array();
         $actions['edit'] = '<a href="' . esc_url(network_admin_url('site-info.php?id=' . $val->userblog_id)) . '">' . __('Edit') . '</a>';
         $class = '';
         if ($val->spam == 1) {
             $class .= 'site-spammed ';
         }
         if ($val->mature == 1) {
             $class .= 'site-mature ';
         }
         if ($val->deleted == 1) {
             $class .= 'site-deleted ';
         }
         if ($val->archived == 1) {
             $class .= 'site-archived ';
         }
         $actions['view'] = '<a class="' . $class . '" href="' . esc_url(get_home_url($val->userblog_id)) . '">' . __('View') . '</a>';
         /**
          * Filter the action links displayed next the sites a user belongs to
          * in the Network Admin Users list table.
          *
          * @since 3.1.0
          *
          * @param array $actions     An array of action links to be displayed.
          *                           Default 'Edit', 'View'.
          * @param int   $userblog_id The site ID.
          */
         $actions = apply_filters('ms_user_list_site_actions', $actions, $val->userblog_id);
         $i = 0;
         $action_count = count($actions);
         foreach ($actions as $action => $link) {
             ++$i;
             $sep = $i == $action_count ? '' : ' | ';
             echo "<span class='{$action}'>{$link}{$sep}</span>";
         }
         echo '</small></span><br/>';
     }
 }
开发者ID:nickbert77,项目名称:WordPress,代码行数:59,代码来源:class-wp-ms-users-list-table.php

示例4: display_rows

    function display_rows()
    {
        global $current_site, $mode;
        $alt = '';
        $super_admins = get_super_admins();
        foreach ($this->items as $user) {
            $alt = 'alternate' == $alt ? '' : 'alternate';
            $status_list = array('spam' => 'site-spammed', 'deleted' => 'site-deleted');
            foreach ($status_list as $status => $col) {
                if ($user->{$status}) {
                    $alt .= " {$col}";
                }
            }
            ?>
			<tr class="<?php 
            echo $alt;
            ?>
">
			<?php 
            list($columns, $hidden) = $this->get_column_info();
            foreach ($columns as $column_name => $column_display_name) {
                $class = "class='{$column_name} column-{$column_name}'";
                $style = '';
                if (in_array($column_name, $hidden)) {
                    $style = ' style="display:none;"';
                }
                $attributes = "{$class}{$style}";
                switch ($column_name) {
                    case 'cb':
                        ?>
						<th scope="row" class="check-column">
							<input type="checkbox" id="blog_<?php 
                        echo $user->ID;
                        ?>
" name="allusers[]" value="<?php 
                        echo esc_attr($user->ID);
                        ?>
" />
						</th>
					<?php 
                        break;
                    case 'username':
                        $avatar = get_avatar($user->user_email, 32);
                        if (get_current_user_id() == $user->ID) {
                            $edit_link = esc_url(network_admin_url('profile.php'));
                        } else {
                            $edit_link = esc_url(network_admin_url(add_query_arg('wp_http_referer', urlencode(stripslashes($_SERVER['REQUEST_URI'])), 'user-edit.php?user_id=' . $user->ID)));
                        }
                        echo "<td {$attributes}>";
                        ?>
							<?php 
                        echo $avatar;
                        ?>
<strong><a href="<?php 
                        echo $edit_link;
                        ?>
" class="edit"><?php 
                        echo stripslashes($user->user_login);
                        ?>
</a><?php 
                        if (in_array($user->user_login, $super_admins)) {
                            echo ' - ' . __('Super Admin');
                        }
                        ?>
</strong>
							<br/>
							<?php 
                        $actions = array();
                        $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
                        if (current_user_can('delete_user', $user->ID) && !in_array($user->user_login, $super_admins)) {
                            $actions['delete'] = '<a href="' . ($delete = esc_url(network_admin_url(add_query_arg('_wp_http_referer', urlencode(stripslashes($_SERVER['REQUEST_URI'])), wp_nonce_url('edit.php', 'deleteuser') . '&amp;action=deleteuser&amp;id=' . $user->ID))) . '" class="delete">' . __('Delete') . '</a>');
                        }
                        $actions = apply_filters('ms_user_row_actions', $actions, $user);
                        echo $this->row_actions($actions);
                        ?>
						</td>
					<?php 
                        break;
                    case 'name':
                        echo "<td {$attributes}>{$user->first_name} {$user->last_name}</td>";
                        break;
                    case 'email':
                        echo "<td {$attributes}><a href='mailto:{$user->user_email}'>{$user->user_email}</a></td>";
                        break;
                    case 'registered':
                        if ('list' == $mode) {
                            $date = 'Y/m/d';
                        } else {
                            $date = 'Y/m/d \\<\\b\\r \\/\\> g:i:s a';
                        }
                        echo "<td {$attributes}>" . mysql2date($date, $user->user_registered) . "</td>";
                        break;
                    case 'blogs':
                        $blogs = get_blogs_of_user($user->ID, true);
                        echo "<td {$attributes}>";
                        if (is_array($blogs)) {
                            foreach ((array) $blogs as $key => $val) {
                                if (!can_edit_network($val->site_id)) {
                                    continue;
                                }
//.........这里部分代码省略.........
开发者ID:vpatrinica,项目名称:jfdesign,代码行数:101,代码来源:class-wp-ms-users-list-table.php

示例5: edit_site_Network_Admin_GForms_TMP

    /**
     * Display Edit Site Section of Settings Page
     */
    function edit_site_Network_Admin_GForms_TMP()
    {
        $unauthorized = false;
        if (!is_multisite()) {
            $unauthorized = __('Multisite support is not enabled.');
        }
        if (!current_user_can('manage_sites')) {
            $unauthorized = __('You do not have sufficient permissions to edit this site.');
        }
        $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
        if (!$id) {
            $unauthorized = __('Invalid site ID.');
        }
        $details = get_blog_details($id);
        if (!can_edit_network($details->site_id)) {
            $unauthorized = __('You do not have permission to access this page.');
        }
        if ($unauthorized) {
            echo "<p>{$unauthorized}</p>\n";
            return;
        }
        $site_url_no_http = preg_replace('#^http(s)?://#', '', get_blogaddress_by_id($id));
        $title_site_url_linked = sprintf(__('API Enabled: <a href="%1$s">%2$s</a>'), get_blogaddress_by_id($id), $site_url_no_http);
        $gforms_tmp_admin_client_id = \get_blog_option($id, 'gforms_tmp_admin_client_id', false);
        $gforms_tmp_admin_client_name = \get_blog_option($id, 'gforms_tmp_admin_client_name', false);
        $gforms_tmp_active = \get_blog_option($id, 'gforms_tmp_active', false);
        $gforms_tmp_last_update = \get_blog_option($id, 'gforms_tmp_last_update', false);
        $date = 'Y/m/d g:i:s a';
        $is_main_site = \is_main_site($id);
        if (isset($_GET['update'])) {
            $messages = array();
            if ('updated' == $_GET['update']) {
                $messages[1] = __('Site updated.');
            } else {
                $messages[0] = __('Site could not be updated.');
            }
        }
        if (!empty($messages)) {
            foreach ($messages as $status => $msg) {
                echo '<div id="message" class="' . ($status ? 'updated' : 'error') . '"><p>' . $msg . '</p></div>';
            }
        }
        ?>

<div class="wrap">

	<div id="icon-options-general" class="icon32">
		<br>
	</div>

	<h2 id="edit-site"><?php 
        echo $title_site_url_linked;
        ?>
</h2>

	<br />

	<form method="post"
		action="<?php 
        echo network_admin_url('admin.php?page=' . $this::slug . '&action=edit');
        ?>
">

                <?php 
        wp_nonce_field('gforms-tmp-edit-site');
        ?>

                <input type="hidden" name="id"
			value="<?php 
        echo esc_attr($id);
        ?>
" /> <input type="hidden"
			name="action" value="site_update_network_admin_gforms_tmp" />

		<table class="form-table">

			<tr class="form-field form-required">

				<th scope="row"><?php 
        _e('Domain');
        ?>
</th>

                        <?php 
        $protocol = is_ssl() ? 'https://' : 'http://';
        if ($is_main_site) {
            ?>

                            <td><code><?php 
            echo $protocol;
            echo esc_attr($details->domain);
            ?>
</code></td>

                        <?php 
        } else {
            ?>
//.........这里部分代码省略.........
开发者ID:arstropica,项目名称:gforms_tmp,代码行数:101,代码来源:class.network_admin_gforms_tmp.php

示例6: output_edit_page

/**
 * Output alias editing page
 */
function output_edit_page()
{
    $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
    if (!$id) {
        wp_die(__('Invalid site ID.'));
    }
    $id = absint($id);
    $details = get_blog_details($id);
    if (!can_edit_network($details->site_id) || (int) $details->blog_id !== $id) {
        wp_die(__('You do not have permission to access this page.'));
    }
    // Are we editing?
    $mapping = null;
    $form_action = network_admin_url('admin.php?action=mercator-add');
    if (!empty($_REQUEST['mapping'])) {
        $mapping_id = absint($_REQUEST['mapping']);
        $mapping = Mapping::get($mapping_id);
        if (is_wp_error($mapping) || empty($mapping)) {
            wp_die(__('Invalid alias ID.', 'mercator'));
        }
        $form_action = network_admin_url('admin.php?action=mercator-edit');
    }
    // Handle form submission
    $messages = array();
    if (!empty($_POST['submit'])) {
        $messages = handle_edit_page_submit($id, $mapping);
    }
    output_page_header($id, $messages);
    if (empty($mapping) || !empty($_POST['_wpnonce'])) {
        $domain = empty($_POST['domain']) ? '' : wp_unslash($_POST['domain']);
        $active = !empty($_POST['active']);
    } else {
        $domain = $mapping->get_domain();
        $active = $mapping->is_active();
    }
    ?>
	<form method="post" action="<?php 
    echo esc_url($form_action);
    ?>
">
		<table class="form-table">
			<tr>
				<th scope="row">
					<label for="mercator-domain"><?php 
    echo esc_html_x('Domain Name', 'field name', 'mercator');
    ?>
</label>
				</th>
				<td>
					<input type="text" class="regular-text code"
						name="domain" id="mercator-domain"
						value="<?php 
    echo esc_attr($domain);
    ?>
" />
				</td>
			</tr>
			<tr>
				<th scope="row">
					<?php 
    echo esc_html_x('Active', 'field name', 'mercator');
    ?>
				</th>
				<td>
					<label>
						<input type="checkbox"
							name="active" <?php 
    checked($active);
    ?>
 />

						<?php 
    esc_html_e('Mark alias as active', 'mercator');
    ?>
					</label>
				</td>
			</tr>
		</table>

		<input type="hidden" name="id" value="<?php 
    echo esc_attr($id);
    ?>
" />
		<?php 
    if (empty($mapping)) {
        wp_nonce_field('mercator-add-' . $id);
        submit_button(__('Add Alias', 'mercator'));
    } else {
        echo '<input type="hidden" name="mapping" value="' . esc_attr($mapping->get_id()) . '" />';
        wp_nonce_field('mercator-edit-' . $mapping->get_id());
        submit_button(__('Save Alias', 'mercator'));
    }
    ?>
	</form>
<?php 
    output_page_footer();
}
开发者ID:fansided,项目名称:Mercator,代码行数:100,代码来源:admin.php


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