本文整理汇总了PHP中is_admin函数的典型用法代码示例。如果您正苦于以下问题:PHP is_admin函数的具体用法?PHP is_admin怎么用?PHP is_admin使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_admin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preDisplay
/**
* @see SugarView::preDisplay()
*/
public function preDisplay()
{
global $current_user;
if (!is_admin($current_user)) {
sugar_die("Unauthorized access to administration.");
}
}
示例2: init
function init()
{
wpv_register_type_view_template();
add_action('wp_ajax_set_view_template', array($this, 'ajax_action_callback'));
add_filter('the_content', array($this, 'the_content'), 1, 1);
add_filter('the_content', array($this, 'restore_wpautop'), 999, 1);
add_filter('the_excerpt', array($this, 'the_excerpt_for_archives'), 1, 1);
if (is_admin()) {
global $pagenow;
// Post/page language box
if ($pagenow == 'post.php' || $pagenow == 'post-new.php') {
add_action('admin_head', array($this, 'post_edit_template_options'));
add_action('admin_head', array($this, 'post_edit_tinymce'));
add_action('admin_footer', array($this, 'hide_view_template_author'));
add_action('admin_notices', array($this, 'show_admin_messages'));
// Post/page save actions
add_action('save_post', array($this, 'save_post_actions'), 10, 2);
add_filter('user_can_richedit', array($this, 'disable_rich_edit_for_views'));
} elseif ($pagenow == 'admin-ajax.php') {
// For when Types saves a child post
add_action('save_post', array($this, 'save_post_actions'), 10, 2);
}
add_action('admin_head', array($this, 'include_admin_css'));
add_action('wp_ajax_wpv_get_archive_view_template_taxonomy_summary', array($this, '_ajax_get_taxonomy_loop_summary'));
add_action('wp_ajax_wpv_get_archive_view_template_post_type_summary', array($this, '_ajax_get_post_type_loop_summary'));
add_action('wp_ajax_wpv_get_archive_view_template_post_type_edit', array($this, '_ajax_get_post_type_loop_edit'));
} else {
add_filter('edit_post_link', array($this, 'edit_post_link'), 10, 2);
add_filter('body_class', array($this, 'body_class'), 10, 2);
add_action('wp_footer', array($this, 'wpv_meta_html_extra'));
}
add_action('save_post', array($this, 'set_default_template'), 10, 2);
}
示例3: process
function process()
{
if (!is_admin($GLOBALS['current_user']) && in_array($this->action, $this->admin_actions)) {
$this->hasAccess = false;
}
parent::process();
}
示例4: do_redirect
/**
*
* DO_REDIRECT
*
* This function will redirect the user if it can resolve that this url request has a redirect.
*
* @author epstudios
*
*/
public function do_redirect()
{
if (is_admin()) {
return false;
}
$redirects = self::get_redirects(true);
// True for only active redirects.
if (empty($redirects)) {
return false;
}
// No redirects.
// Get current url
$url_request = self::get_url();
$query_string = explode('?', $url_request);
$query_string = isset($query_string[1]) ? $query_string[1] : false;
foreach ($redirects as $redirect) {
$from = urldecode($redirect->url_from);
if ($redirect->status != 'inactive' && rtrim(trim($url_request), '/') === self::format_from_url(trim($from))) {
// Match, this needs to be redirected
// increment this hit counter.
self::increment_field($redirect->id, 'count');
if ($redirect->status == '301') {
header('HTTP/1.1 301 Moved Permanently');
} elseif ($redirect->status == '302') {
header('HTTP/1.1 302 Moved Temporarily');
}
$to = $redirect->type == "url" && !is_numeric($redirect->url_to) ? urldecode($redirect->url_to) : get_permalink($redirect->url_to);
$to = $query_string ? $to . "?" . $query_string : $to;
header('Location: ' . $to, true, (int) $redirect->status);
exit;
}
}
}
示例5: __construct
public function __construct()
{
global $AmazonWooCommerce;
$this->the_plugin = $AmazonWooCommerce;
$this->module_folder = $this->the_plugin->cfg['paths']['plugin_dir_url'] . 'modules/depedencies/';
if (is_admin()) {
add_action("admin_enqueue_scripts", array(&$this, 'admin_print_styles'));
add_action("admin_print_scripts", array(&$this, 'admin_load_scripts'));
}
// load the ajax helper
require_once $this->the_plugin->cfg['paths']['plugin_dir_path'] . 'modules/dashboard/ajax.php';
new AmazonWooCommerceDashboardAjax($this->the_plugin);
// add the boxes
$this->addBox('website_preview', '', $this->website_preview(), array('size' => 'grid_1'));
$this->addBox('plugin_depedencies', '', $this->plugin_depedencies(), array('size' => 'grid_3'));
/*$this->addBox( 'dashboard_links', '', $this->links(), array(
'size' => 'grid_3'
) );
$this->addBox( 'products_performances', 'Top
<select class="AmazonWooCommerce-numer-items-in-top">
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="0">Show All</option>
</select>
Amazon Products Performances', $this->products_performances(), array(
'size' => 'grid_4'
) );*/
$this->addBox('aateam_products', 'Other products by AA-Team:', $this->aateam_products(), array('size' => 'grid_4'));
$this->addBox('support', 'Need AA-Team Support?', $this->support());
}
示例6: __construct
/**
* Constructor.
*
* @param array $details
* @return \YITH_WCWL
* @since 1.0.0
*/
public function __construct($details)
{
$this->details = $details;
$this->wcwl_init = YITH_WCWL_Init();
if (is_admin()) {
$this->wcwl_admin_init = YITH_WCWL_Admin_Init();
}
add_action('after_setup_theme', array($this, 'plugin_fw_loader'), 1);
// add rewrite rule
add_action('init', array($this, 'add_rewrite_rules'), 0);
add_filter('query_vars', array($this, 'add_public_query_var'));
add_action('init', array($this, 'add_to_wishlist'));
add_action('wp_ajax_add_to_wishlist', array($this, 'add_to_wishlist_ajax'));
add_action('wp_ajax_nopriv_add_to_wishlist', array($this, 'add_to_wishlist_ajax'));
add_action('init', array($this, 'remove_from_wishlist'));
add_action('wp_ajax_remove_from_wishlist', array($this, 'remove_from_wishlist_ajax'));
add_action('wp_ajax_nopriv_remove_from_wishlist', array($this, 'remove_from_wishlist_ajax'));
add_action('wp_ajax_reload_wishlist_and_adding_elem', array($this, 'reload_wishlist_and_adding_elem_ajax'));
add_action('wp_ajax_nopriv_reload_wishlist_and_adding_elem', array($this, 'reload_wishlist_and_adding_elem_ajax'));
add_action('woocommerce_add_to_cart', array($this, 'remove_from_wishlist_after_add_to_cart'));
add_filter('woocommerce_product_add_to_cart_url', array($this, 'redirect_to_cart'), 10, 2);
add_action('yith_wcwl_before_wishlist_title', array($this, 'print_notices'));
add_filter('woocommerce_add_to_cart_redirect', array($this, 'yith_wfbt_redirect_after_add_to_cart'), 10, 1);
// add filter for font-awesome compatibility
add_filter('option_yith_wcwl_add_to_wishlist_icon', array($this, 'update_font_awesome_classes'));
add_filter('option_yith_wcwl_add_to_cart_icon', array($this, 'update_font_awesome_classes'));
}
示例7: preDisplay
/**
* @see SugarView::preDisplay()
*/
public function preDisplay()
{
global $current_user;
if (!is_admin($current_user) && !is_admin_for_module($GLOBALS['current_user'], 'Emails') && !is_admin_for_module($GLOBALS['current_user'], 'Campaigns')) {
sugar_die("Unauthorized access to administration.");
}
}
示例8: __construct
function __construct()
{
// If we're in the admin area, load the settings class
if (is_admin()) {
require dirname(__FILE__) . '/settings.php';
$settingsClass = new LazyLoadXTSettings();
// If this is the first time we've enabled the plugin, setup default settings
register_activation_hook(__FILE__, array($settingsClass, 'first_time_activation'));
add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($settingsClass, 'lazyloadxt_action_links'));
} else {
// Store our settings in memory to reduce mysql calls
$this->settings = $this->get_settings();
$this->dir = plugin_dir_url(__FILE__);
// The CDN has an older version
if ($this->settings['cdn']) {
$this->lazyloadxt_ver = '1.0.5';
}
// Enqueue Lazy Load XT scripts and styles
add_action('wp_enqueue_scripts', array($this, 'load_scripts'));
// Replace the 'src' attr with 'data-src' in the_content
add_filter('the_content', array($this, 'filter_html'));
// If enabled replace the 'src' attr with 'data-src' in text widgets
if ($this->settings['textwidgets']) {
add_filter('widget_text', array($this, 'filter_html'));
}
// If enabled replace the 'src' attr with 'data-src' in the_post_thumbnail
if ($this->settings['thumbnails']) {
add_filter('post_thumbnail_html', array($this, 'filter_html'));
}
// If enabled replace the 'src' attr with 'data-src' in the_post_thumbnail
if ($this->settings['avatars']) {
add_filter('get_avatar', array($this, 'filter_html'));
}
}
}
示例9: amr_check_if_widget_debug
function amr_check_if_widget_debug()
{
global $said;
// only do these debug if we are logged in and are the administrator
if (is_admin()) {
return false;
}
// if running in backend, then do not do debug. 20151217
if (!is_user_logged_in() or !current_user_can('administrator')) {
return false;
}
if (isset($_REQUEST['do_widget_debug'])) {
if (empty($said)) {
$said = true;
} else {
return true;
}
$url_without_debug_query = esc_url(remove_query_arg('do_widget_debug'));
$eek = '<a href="' . $url_without_debug_query . '">Remove debug</a>';
echo '<br/>Note: Debug help is only shown to a logged-in Administrator.' . $eek . '<br />';
$text = amr_show_shortcode_widget_possibilities();
echo $text;
return true;
} else {
return false;
}
}
示例10: metaform
public function metaform()
{
$value = $this->getValue();
$data = $this->getData();
$attributes = $this->getAttr();
$form = array();
$options = array();
if (isset($data['options'])) {
if (!is_admin()) {
$new_options = array();
foreach ($data['options'] as $key => $option) {
$tmp = $option['value'];
$option['value'] = $option['types-value'];
$option['types-value'] = $tmp;
$new_options[$key] = $option;
unset($tmp);
}
$data['options'] = $new_options;
}
foreach ($data['options'] as $key => $option) {
$one_option_data = array('#value' => $option['value'], '#title' => stripslashes($option['title']));
/**
* add default value if needed
* issue: frontend, multiforms CRED
*/
// if (array_key_exists('types-value', $option)) {
// $one_option_data['#types-value'] = $option['types-value'];
// }
$options[] = $one_option_data;
}
}
/**
* for user fields we reset title and description to avoid double
* display
*/
$title = $this->getTitle();
if (empty($title)) {
$title = $this->getTitle(true);
}
$options = apply_filters('wpt_field_options', $options, $title, 'select');
/**
* default_value
*/
if (!empty($value) || $value == '0') {
$data['default_value'] = $value;
}
$is_multiselect = array_key_exists('multiple', $attributes) && 'multiple' == $attributes['multiple'];
$default_value = isset($data['default_value']) ? $data['default_value'] : null;
//Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/189219391/comments
if ($is_multiselect) {
$default_value = new RecursiveIteratorIterator(new RecursiveArrayIterator($default_value));
$default_value = iterator_to_array($default_value, false);
}
//##############################################################################################
/**
* metaform
*/
$form[] = array('#type' => 'select', '#title' => $this->getTitle(), '#description' => $this->getDescription(), '#name' => $this->getName(), '#options' => $options, '#default_value' => $default_value, '#multiple' => $is_multiselect, '#validate' => $this->getValidationData(), '#class' => 'form-inline', '#repetitive' => $this->isRepetitive());
return $form;
}
示例11: whitepaper_fonts
function whitepaper_fonts()
{
if (!is_admin()) {
wp_register_style('open-sans', '//fonts.googleapis.com/css?family=Open+Sans');
wp_enqueue_style('open-sans', get_stylesheet_uri(), array('open-sans'));
}
}
示例12: ox_adding_scripts
function ox_adding_scripts()
{
if (!function_exists('is_login_page')) {
function is_login_page()
{
return !strncmp($_SERVER['REQUEST_URI'], '/wp-login.php', strlen('/wp-login.php'));
}
}
if (!is_admin() && !is_login_page()) {
/*removed wp-embed.min.js*/
wp_deregister_script('wp-embed');
/*jquery*/
wp_deregister_script('jquery');
$infooter = !is_page(array($order_form_pages)) ? true : false;
wp_register_script('jquery', "http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js", false, '1.11.3', $infooter);
wp_enqueue_script('jquery');
/*bootstrap*/
wp_enqueue_style('bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css');
/*slicknav menu*/
wp_enqueue_script('slicknav', get_template_directory_uri() . '/js/jquery.slicknav.min.js', array('jquery'), '', true);
/*bxslider*/
wp_enqueue_style('bxslider', get_template_directory_uri() . '/css/jquery.bxslider.min.css');
wp_enqueue_script('bxslider', get_template_directory_uri() . '/js/jquery.bxslider.min.js', array('jquery'), '', true);
/*zopim chat*/
wp_enqueue_script('zopim', get_template_directory_uri() . '/js/zopimClear.js', array('jquery'), '', true);
/*custom css*/
wp_enqueue_style('custom', get_template_directory_uri() . '/style.css', array('bootstrap'));
/*custom js*/
wp_enqueue_script('custom', get_template_directory_uri() . '/js/custom.js', array('jquery'), '', true);
}
}
示例13: __construct
/**
* Constructor
* @since 1.3.0
*
* @param $file
*/
public function __construct($file)
{
$this->name = __('Grading', 'woothemes-sensei');
$this->file = $file;
$this->page_slug = 'sensei_grading';
// Admin functions
if (is_admin()) {
add_action('admin_menu', array($this, 'grading_admin_menu'), 20);
add_action('grading_wrapper_container', array($this, 'wrapper_container'));
if (isset($_GET['page']) && $_GET['page'] == $this->page_slug) {
add_action('admin_print_scripts', array($this, 'enqueue_scripts'));
add_action('admin_print_styles', array($this, 'enqueue_styles'));
}
add_action('admin_init', array($this, 'admin_process_grading_submission'));
add_action('admin_notices', array($this, 'add_grading_notices'));
// add_action( 'sensei_grading_notices', array( $this, 'sensei_grading_notices' ) );
}
// End If Statement
// Ajax functions
if (is_admin()) {
add_action('wp_ajax_get_lessons_dropdown', array($this, 'get_lessons_dropdown'));
add_action('wp_ajax_get_redirect_url', array($this, 'get_redirect_url'));
}
// End If Statement
}
示例14: __construct
function __construct()
{
// update setting
acf_update_setting('pro', true);
acf_update_setting('name', __('Advanced Custom Fields PRO', 'acf'));
// api
acf_include('pro/api/api-pro.php');
acf_include('pro/api/api-options-page.php');
// updates
acf_include('pro/core/updates.php');
// admin
if (is_admin()) {
// options page
acf_include('pro/admin/options-page.php');
// settings
acf_include('pro/admin/settings-updates.php');
}
// fields
acf_include('pro/fields/repeater.php');
acf_include('pro/fields/flexible-content.php');
acf_include('pro/fields/gallery.php');
// actions
add_action('init', array($this, 'wp_init'));
add_action('acf/input/admin_enqueue_scripts', array($this, 'input_admin_enqueue_scripts'));
add_action('acf/field_group/admin_enqueue_scripts', array($this, 'field_group_admin_enqueue_scripts'));
add_action('acf/field_group/admin_l10n', array($this, 'field_group_admin_l10n'));
// filters
add_filter('acf/get_valid_field', array($this, 'get_valid_field'), 11, 1);
add_filter('acf/update_field', array($this, 'update_field'), 1, 1);
add_filter('acf/prepare_field_for_export', array($this, 'prepare_field_for_export'));
add_filter('acf/prepare_field_for_import', array($this, 'prepare_field_for_import'));
}
示例15: init
public static function init()
{
if (!is_admin()) {
return;
}
if (!isset($_FILES['podlove_import_tracking'])) {
return;
}
set_time_limit(10 * MINUTE_IN_SECONDS);
// allow xml+gz uploads
add_filter('upload_mimes', function ($mimes) {
return array_merge($mimes, array('xml' => 'application/xml', 'gz|gzip' => 'application/x-gzip'));
});
require_once ABSPATH . '/wp-admin/includes/file.php';
$file = wp_handle_upload($_FILES['podlove_import_tracking'], array('test_form' => false));
if ($file && (!isset($file['error']) || !$file['error'])) {
update_option('podlove_import_tracking_file', $file['file']);
if (!($file = get_option('podlove_import_tracking_file'))) {
return;
}
$importer = new \Podlove\Modules\ImportExport\Import\TrackingImporter($file);
$importer->import();
} else {
echo '<div class="error"><p>' . $file['error'] . '</p></div>';
}
}