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


PHP sanitize_key函数代码示例

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


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

示例1: setup_wizard

 /**
  * Show the setup wizard
  */
 public function setup_wizard()
 {
     if (empty($_GET['page']) || 'wc-setup' !== $_GET['page']) {
         return;
     }
     $this->steps = array('introduction' => array('name' => __('Introduction', 'woocommerce'), 'view' => array($this, 'wc_setup_introduction'), 'handler' => ''), 'pages' => array('name' => __('Page Setup', 'woocommerce'), 'view' => array($this, 'wc_setup_pages'), 'handler' => array($this, 'wc_setup_pages_save')), 'locale' => array('name' => __('Store Locale', 'woocommerce'), 'view' => array($this, 'wc_setup_locale'), 'handler' => array($this, 'wc_setup_locale_save')), 'shipping_taxes' => array('name' => __('Shipping & Tax', 'woocommerce'), 'view' => array($this, 'wc_setup_shipping_taxes'), 'handler' => array($this, 'wc_setup_shipping_taxes_save')), 'payments' => array('name' => __('Payments', 'woocommerce'), 'view' => array($this, 'wc_setup_payments'), 'handler' => array($this, 'wc_setup_payments_save')), 'next_steps' => array('name' => __('Ready!', 'woocommerce'), 'view' => array($this, 'wc_setup_ready'), 'handler' => ''));
     $this->step = isset($_GET['step']) ? sanitize_key($_GET['step']) : current(array_keys($this->steps));
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     wp_register_script('select2', WC()->plugin_url() . '/assets/js/select2/select2' . $suffix . '.js', array('jquery'), '3.5.2');
     wp_register_script('wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array('jquery', 'select2'), WC_VERSION);
     wp_localize_script('wc-enhanced-select', 'wc_enhanced_select_params', array('i18n_matches_1' => _x('One result is available, press enter to select it.', 'enhanced select', 'woocommerce'), 'i18n_matches_n' => _x('%qty% results are available, use up and down arrow keys to navigate.', 'enhanced select', 'woocommerce'), 'i18n_no_matches' => _x('No matches found', 'enhanced select', 'woocommerce'), 'i18n_ajax_error' => _x('Loading failed', 'enhanced select', 'woocommerce'), 'i18n_input_too_short_1' => _x('Please enter 1 or more characters', 'enhanced select', 'woocommerce'), 'i18n_input_too_short_n' => _x('Please enter %qty% or more characters', 'enhanced select', 'woocommerce'), 'i18n_input_too_long_1' => _x('Please delete 1 character', 'enhanced select', 'woocommerce'), 'i18n_input_too_long_n' => _x('Please delete %qty% characters', 'enhanced select', 'woocommerce'), 'i18n_selection_too_long_1' => _x('You can only select 1 item', 'enhanced select', 'woocommerce'), 'i18n_selection_too_long_n' => _x('You can only select %qty% items', 'enhanced select', 'woocommerce'), 'i18n_load_more' => _x('Loading more results…', 'enhanced select', 'woocommerce'), 'i18n_searching' => _x('Searching…', 'enhanced select', 'woocommerce'), 'ajax_url' => admin_url('admin-ajax.php'), 'search_products_nonce' => wp_create_nonce('search-products'), 'search_customers_nonce' => wp_create_nonce('search-customers')));
     wp_enqueue_style('woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION);
     wp_enqueue_style('wc-setup', WC()->plugin_url() . '/assets/css/wc-setup.css', array('dashicons', 'install'), WC_VERSION);
     wp_register_script('wc-setup', WC()->plugin_url() . '/assets/js/admin/wc-setup.min.js', array('jquery', 'wc-enhanced-select'), WC_VERSION);
     wp_localize_script('wc-setup', 'wc_setup_params', array('locale_info' => json_encode(include WC()->plugin_path() . '/i18n/locale-info.php')));
     if (!empty($_POST['save_step']) && isset($this->steps[$this->step]['handler'])) {
         call_user_func($this->steps[$this->step]['handler']);
     }
     ob_start();
     $this->setup_wizard_header();
     $this->setup_wizard_steps();
     $this->setup_wizard_content();
     $this->setup_wizard_footer();
     exit;
 }
开发者ID:zengskie,项目名称:Heroku-WordPress-PostgreSQL,代码行数:28,代码来源:class-wc-admin-setup-wizard.php

示例2: register

 /**
  * Register a page type.
  *
  * @since 1.0.0
  *
  * @param string $type
  * @param array $args
  */
 public function register($type, $args = array())
 {
     $type = sanitize_key($type);
     $args = wp_parse_args($args, array('archive_body_class' => '', 'archive_template' => "templates/wpcom-archive-{$type}.php", 'single_body_class' => '', 'single_template' => "templates/wpcom-single-{$type}.php"));
     $this->types[$type] = $args;
     return $this;
 }
开发者ID:TyRichards,项目名称:ty_the_band,代码行数:15,代码来源:class-cedaro-theme-pagetypes.php

示例3: hybrid_register_sidebars

/**
 * Registers the default framework dynamic sidebars based on the sidebars the theme has added support 
 * for using add_theme_support().
 *
 * @since 0.7.0
 * @access private
 * @uses register_sidebar() Registers a sidebar with WordPress.
 * @link http://codex.wordpress.org/Function_Reference/register_sidebar
 * @return void
 */
function hybrid_register_sidebars()
{
    /* Get the theme-supported sidebars. */
    $supported_sidebars = get_theme_support('hybrid-core-sidebars');
    /* If the theme doesn't add support for any sidebars, return. */
    if (!is_array($supported_sidebars[0])) {
        return;
    }
    /* Get the available core framework sidebars. */
    $core_sidebars = hybrid_get_sidebars();
    /* Loop through the supported sidebars. */
    foreach ($supported_sidebars[0] as $sidebar) {
        /* Make sure the given sidebar is one of the core sidebars. */
        if (isset($core_sidebars[$sidebar])) {
            /* Set up some default sidebar arguments. */
            $defaults = array('before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-wrap widget-inside">', 'after_widget' => '</div></div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>');
            /* Allow developers to filter the default sidebar arguments. */
            $defaults = apply_filters(hybrid_get_prefix() . '_sidebar_defaults', $defaults, $sidebar);
            /* Parse the sidebar arguments and defaults. */
            $args = wp_parse_args($core_sidebars[$sidebar], $defaults);
            /* If no 'id' was given, use the $sidebar variable and sanitize it. */
            $args['id'] = isset($args['id']) ? sanitize_key($args['id']) : sanitize_key($sidebar);
            /* Allow developers to filter the sidebar arguments. */
            $args = apply_filters(hybrid_get_prefix() . '_sidebar_args', $args, $sidebar);
            /* Register the sidebar. */
            register_sidebar($args);
        }
    }
}
开发者ID:jacko5,项目名称:bjj,代码行数:39,代码来源:sidebars.php

示例4: update

 /**
  * Sanitize widget form values as they are saved.
  *
  * @param array $new_instance The new options
  * @param array $old_instance The previous options
  */
 public function update($new_instance, $old_instance)
 {
     $instance = array();
     $instance['page_id'] = absint($new_instance['page_id']);
     $instance['layout'] = sanitize_key($new_instance['layout']);
     return $instance;
 }
开发者ID:apeachdev,项目名称:bioconSite,代码行数:13,代码来源:widget-featured-page.php

示例5: wpuxss_eml_taxonomies_validate

 function wpuxss_eml_taxonomies_validate($input)
 {
     if (!$input) {
         $input = array();
     }
     foreach ($input as $taxonomy => $params) {
         $sanitized_taxonomy = sanitize_key($taxonomy);
         if ($sanitized_taxonomy !== $taxonomy) {
             $input[$sanitized_taxonomy] = $input[$taxonomy];
             unset($input[$taxonomy]);
             $taxonomy = $sanitized_taxonomy;
         }
         $input[$taxonomy]['hierarchical'] = isset($params['hierarchical']) ? 1 : 0;
         $input[$taxonomy]['sort'] = isset($params['sort']) ? 1 : 0;
         $input[$taxonomy]['show_admin_column'] = isset($params['show_admin_column']) ? 1 : 0;
         $input[$taxonomy]['show_in_nav_menus'] = isset($params['show_in_nav_menus']) ? 1 : 0;
         $input[$taxonomy]['assigned'] = isset($params['assigned']) ? 1 : 0;
         $input[$taxonomy]['admin_filter'] = isset($params['admin_filter']) ? 1 : 0;
         $input[$taxonomy]['media_uploader_filter'] = isset($params['media_uploader_filter']) ? 1 : 0;
         $input[$taxonomy]['media_popup_taxonomy_edit'] = isset($params['media_popup_taxonomy_edit']) ? 1 : 0;
         $input[$taxonomy]['rewrite']['with_front'] = isset($params['rewrite']['with_front']) ? 1 : 0;
         $input[$taxonomy]['rewrite']['slug'] = isset($params['rewrite']['slug']) ? wpuxss_eml_sanitize_slug($params['rewrite']['slug'], $taxonomy) : '';
         if (isset($params['labels'])) {
             $default_labels = array('menu_name' => $params['labels']['name'], 'all_items' => 'All ' . $params['labels']['name'], 'edit_item' => 'Edit ' . $params['labels']['singular_name'], 'view_item' => 'View ' . $params['labels']['singular_name'], 'update_item' => 'Update ' . $params['labels']['singular_name'], 'add_new_item' => 'Add New ' . $params['labels']['singular_name'], 'new_item_name' => 'New ' . $params['labels']['singular_name'] . ' Name', 'parent_item' => 'Parent ' . $params['labels']['singular_name'], 'search_items' => 'Search ' . $params['labels']['name']);
             foreach ($params['labels'] as $label => $value) {
                 $input[$taxonomy]['labels'][$label] = sanitize_text_field($value);
                 if (empty($value) && isset($default_labels[$label])) {
                     $input[$taxonomy]['labels'][$label] = sanitize_text_field($default_labels[$label]);
                 }
             }
         }
     }
     return $input;
 }
开发者ID:shellygraham,项目名称:livestock-framing,代码行数:34,代码来源:taxonomies.php

示例6: TS_VCSC_GetCurrentPostType

 function TS_VCSC_GetCurrentPostType()
 {
     global $post, $typenow, $current_screen;
     if ($post && $post->post_type) {
         // We have a post so we can just get the post type from that
         return $post->post_type;
     } else {
         if ($typenow) {
             // Check the global $typenow
             return $typenow;
         } else {
             if ($current_screen && $current_screen->post_type) {
                 // Check the global $current_screen Object
                 return $current_screen->post_type;
             } else {
                 if (isset($_REQUEST['post_type'])) {
                     // Check the Post Type QueryString
                     return sanitize_key($_REQUEST['post_type']);
                 }
             }
         }
     }
     //we do not know the post type!
     return null;
 }
开发者ID:baochung26,项目名称:happy-c,代码行数:25,代码来源:ts_vcsc_registrations_functions.php

示例7: save_styles

 function save_styles()
 {
     if (!Upfront_Permissions::current(Upfront_Permissions::SAVE)) {
         $this->_reject();
     }
     $name = sanitize_key(str_replace(' ', '_', trim($_POST['name'])));
     $styles = trim(stripslashes($_POST['styles']));
     $element_type = isset($_POST['elementType']) ? sanitize_key($_POST['elementType']) : 'unknown';
     // Fix storage key missing _dev in dev mode. Called from ajax, use POST.
     $storage_key = Upfront_Layout::get_storage_key();
     if (isset($_POST['dev']) && $_POST['dev'] === 'true' && strpos($storage_key, '_dev') === false) {
         $storage_key = $storage_key . '_dev';
     }
     $db_option = $storage_key . '_' . get_stylesheet() . '_styles';
     $current_styles = get_option($db_option, array());
     $current_styles = apply_filters('upfront_get_theme_styles', $current_styles);
     $styles = apply_filters('upfront-save_styles', $styles, $name, $element_type);
     if (!isset($current_styles[$element_type])) {
         $current_styles[$element_type] = array();
     }
     $current_styles[$element_type][$name] = $styles;
     global $wpdb;
     update_option($db_option, $current_styles);
     $this->_out(new Upfront_JsonResponse_Success(array('name' => $name, 'styles' => $styles)));
 }
开发者ID:sedici,项目名称:wpmu-istec,代码行数:25,代码来源:class_upfront_stylesheet_main.php

示例8: creative_blog_save_custom_meta_data

 function creative_blog_save_custom_meta_data($post_id)
 {
     global $creative_blog_page_layout, $post;
     // Verify the nonce before proceeding.
     if (!isset($_POST['custom_meta_box_nonce']) || !wp_verify_nonce($_POST['custom_meta_box_nonce'], basename(__FILE__))) {
         return;
     }
     // Stop WP from clearing custom fields on autosave
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     if ('page' == $_POST['post_type']) {
         if (!current_user_can('edit_page', $post_id)) {
             return $post_id;
         }
     } elseif (!current_user_can('edit_post', $post_id)) {
         return $post_id;
     }
     foreach ($creative_blog_page_layout as $field) {
         // Execute this saving function
         $old_meta_data = get_post_meta($post_id, $field['id'], true);
         $new_meta_data = sanitize_key($_POST[$field['id']]);
         if ($new_meta_data && $new_meta_data != $old_meta_data) {
             update_post_meta($post_id, $field['id'], $new_meta_data);
         } elseif ('' == $new_meta_data && $old_meta_data) {
             delete_post_meta($post_id, $field['id'], $old_meta_data);
         }
     }
     // end foreach
 }
开发者ID:mebishalnapit,项目名称:creative-blog,代码行数:30,代码来源:meta-boxes.php

示例9: add_endpoint

 /**
  * Registers a new rewrite endpoint for accessing the API
  *
  * @access public
  * @author Andrew Norcross
  * @param array $rewrite_rules WordPress Rewrite Rules
  * @since 0.0.1
  */
 public function add_endpoint($rewrite_rules)
 {
     // run the endpoint filter with sanitization
     $endpoint = apply_filters('rkv_remote_repo_endpoint', 'update');
     $endpoint = sanitize_key($endpoint, 'update');
     add_rewrite_endpoint($endpoint, EP_ALL);
 }
开发者ID:AGDesignStudio,项目名称:reaktiv-remote-repo,代码行数:15,代码来源:reaktiv-remote-repo.php

示例10: setup_wizard

 public function setup_wizard()
 {
     if (empty($_GET['page']) || 'mainwp-setup' !== $_GET['page']) {
         return;
     }
     $this->steps = array('introduction' => array('name' => __('Introduction', 'mainwp'), 'view' => array($this, 'mwp_setup_introduction'), 'handler' => ''), 'installation' => array('name' => __('Installation', 'mainwp'), 'view' => array($this, 'mwp_setup_installation'), 'handler' => array($this, 'mwp_setup_installation_save')), 'windows_localhost' => array('name' => __('Windows Localhost', 'mainwp'), 'view' => array($this, 'mwp_setup_windows_locahost'), 'handler' => array($this, 'mwp_setup_windows_locahost_save'), 'hidden' => true), 'system_check' => array('name' => __('System Checkup', 'mainwp'), 'view' => array($this, 'mwp_setup_system_requirements'), 'handler' => ''), 'hosting_setup' => array('name' => __('Hosting Setup', 'mainwp'), 'view' => array($this, 'mwp_setup_hosting'), 'handler' => array($this, 'mwp_setup_hosting_save')), 'optimization' => array('name' => __('Optimization', 'mainwp'), 'view' => array($this, 'mwp_setup_optimization'), 'handler' => array($this, 'mwp_setup_optimization_save')), 'notification' => array('name' => __('Notifications', 'mainwp'), 'view' => array($this, 'mwp_setup_notification'), 'handler' => array($this, 'mwp_setup_notification_save')), 'backup' => array('name' => __('Backups', 'mainwp'), 'view' => array($this, 'mwp_setup_backup'), 'handler' => array($this, 'mwp_setup_backup_save')), 'mainwp_register' => array('name' => __('Mainwp Extensions Sign Up', 'mainwp'), 'view' => array($this, 'mwp_setup_mainwp_register'), 'handler' => '', 'hidden' => true), 'purchase_extension' => array('name' => __('Order Extension', 'mainwp'), 'view' => array($this, 'mwp_setup_purchase_extension'), 'handler' => array($this, 'mwp_setup_purchase_extension_save'), 'hidden' => true), 'install_extension' => array('name' => __('Install Extension', 'mainwp'), 'view' => array($this, 'mwp_setup_install_extension'), 'handler' => array($this, 'mwp_setup_install_extension_save'), 'hidden' => true), 'primary_backup' => array('name' => __('Primary Backup System', 'mainwp'), 'view' => array($this, 'mwp_setup_primary_backup'), 'handler' => array($this, 'mwp_setup_primary_backup_save'), 'hidden' => true), 'uptime_robot' => array('name' => __('WP-Cron Trigger', 'mainwp'), 'view' => array($this, 'mwp_setup_uptime_robot'), 'handler' => array($this, 'mwp_setup_uptime_robot_save')), 'hide_wp_menus' => array('name' => __('Hide WP Menus', 'mainwp'), 'view' => array($this, 'mwp_setup_hide_wp_menu'), 'handler' => array($this, 'mwp_setup_hide_wp_menu_save')), 'next_steps' => array('name' => __('Finish', 'mainwp'), 'view' => array($this, 'mwp_setup_ready'), 'handler' => ''));
     $this->backup_extensions = array('updraftplus' => array('name' => 'MainWP UpdraftPlus Extension', 'product_id' => 'MainWP UpdraftPlus Extension', 'slug' => 'mainwp-updraftplus-extension/mainwp-updraftplus-extension.php'), 'backupwp' => array('name' => 'MainWP BackUpWordPress Extension', 'product_id' => 'MainWP BackUpWordPress Extension', 'slug' => 'mainwp-backupwordpress-extension/mainwp-backupwordpress-extension.php'));
     $this->step = isset($_GET['step']) ? sanitize_key($_GET['step']) : current(array_keys($this->steps));
     $this->check_redirect();
     wp_enqueue_script('mainwp-setup', MAINWP_PLUGIN_URL . 'js/mainwp-setup.js', array('jquery', 'jquery-ui-tooltip'), MAINWP_VERSION);
     wp_localize_script('mainwp-setup', 'mainwpSetupLocalize', array('nonce' => wp_create_nonce('mainwp-setup-nonce')));
     wp_enqueue_style('mainwp', MAINWP_PLUGIN_URL . 'css/mainwp.css', array(), MAINWP_VERSION);
     wp_enqueue_style('mainwp-font-awesome', MAINWP_PLUGIN_URL . 'css/font-awesome/css/font-awesome.min.css', array(), MAINWP_VERSION);
     wp_enqueue_style('jquery-ui-style');
     wp_enqueue_style('mainwp-setup', MAINWP_PLUGIN_URL . 'css/mainwp-setup.css', array('dashicons', 'install'), MAINWP_VERSION);
     if (!empty($_POST['save_step']) && isset($this->steps[$this->step]['handler'])) {
         call_user_func($this->steps[$this->step]['handler']);
     }
     ob_start();
     $this->setup_wizard_header();
     $this->setup_wizard_steps();
     $this->setup_wizard_content();
     $this->setup_wizard_footer();
     exit;
 }
开发者ID:reeslo,项目名称:mainwp,代码行数:25,代码来源:page-mainwp-setup-wizard.php

示例11: ubermenu_add_instance_callback

function ubermenu_add_instance_callback()
{
    check_ajax_referer('ubermenu-add-instance', 'ubermenu_nonce');
    $response = array();
    $serialized_settings = $_POST['ubermenu_data'];
    $dirty_settings = array();
    parse_str($serialized_settings, $dirty_settings);
    //ONLY ALLOW SETTINGS WE'VE DEFINED
    $data = wp_parse_args($dirty_settings, array('ubermenu_instance_id'));
    $new_id = $data['ubermenu_instance_id'];
    if ($new_id == '') {
        $response['error'] = 'Please enter an ID. ';
    } else {
        //$new_id = sanitize_title( $new_id );
        $new_id = sanitize_key($new_id);
        //update
        $menus = get_option(UBERMENU_MENU_INSTANCES, array());
        if (in_array($new_id, $menus)) {
            $response['error'] = 'That ID is already taken. ';
        } else {
            if (in_array($new_id, array('general', 'main', 'help', 'updates'))) {
                $response['error'] = 'That ID is reserved for plugin use.  Please choose another.';
            } else {
                $menus[] = $new_id;
                update_option(UBERMENU_MENU_INSTANCES, $menus);
            }
        }
        $response['id'] = $new_id;
    }
    $response['data'] = $data;
    echo json_encode($response);
    die;
}
开发者ID:Wordpress-Development,项目名称:Installation-Setup,代码行数:33,代码来源:settings.instance-manager.php

示例12: saveChart

 public static function saveChart()
 {
     global $wpdb;
     $q = $wpdb->query($wpdb->prepare("INSERT INTO " . WEBLATOR_CHARTS_PREFIX . "charts\n             (chart_name,\n             chart_type,\n             chart_is_live,\n             chart_max_width,\n             chart_legend,\n             chart_legend_position,\n             chart_legend_font_size,\n             chart_legend_font_style,\n             chart_legend_font_colour,\n             chart_percentage_values,\n             main_data_set_title,\n             scale_label_append,\n             scale_label_prepend,\n             created_date)\n\n             VALUES('%s','%d','%d','%d','%s','%s','%s','%s','%s', '%s', '%s', '%s', '%s', NOW())", sanitize_text_field($_POST["name"]), sanitize_text_field($_POST["chart"]), sanitize_text_field($_POST["is_live"]), sanitize_text_field($_POST["maxWidth"]), sanitize_text_field($_POST["legend"]), sanitize_text_field($_POST["legend_position"]), sanitize_text_field($_POST["legend_font_size"]), sanitize_text_field($_POST["legend_font_style"]), sanitize_text_field($_POST["legend_font_colour"]), sanitize_key($_POST["chart_percentage_values"]), sanitize_text_field($_POST["main_data_set_title"]), sanitize_text_field($_POST["scale_label_append"]), sanitize_text_field($_POST["scale_label_prepend"])));
     if (!$q) {
         echo 0;
         die;
     }
     $last_id = $wpdb->insert_id;
     foreach ($_POST["options"] as $k => $options) {
         $data_id = 0;
         if ($k > 0) {
             $styles = $_POST["over_style"][$k - 1];
             $wpdb->query($wpdb->prepare("\n                            INSERT INTO " . WEBLATOR_CHARTS_PREFIX . "data_sets (chart_id, fill_color, stroke_color, point_color, point_stroke_color, title) VALUES ('%d', '%s','%s','%s','%s', '%s')\n                        ", $last_id, sanitize_text_field($styles[0]), sanitize_text_field($styles[1]), sanitize_text_field($styles[2]), sanitize_text_field($styles[3]), sanitize_text_field($styles[4])));
             $data_id = $wpdb->insert_id;
         }
         foreach ($options as $key => $option) {
             $wpdb->query($wpdb->prepare("INSERT INTO " . WEBLATOR_CHARTS_PREFIX . "chart_options (chart_id, data_set_id, option_name, option_value, option_order, option_colour) VALUES('%d', '%d', '%s','%s','%d','%s')", $last_id, $data_id, sanitize_text_field($option[1]), sanitize_text_field($option[4]), sanitize_text_field($option[0]), sanitize_text_field($option[3])));
         }
     }
     $results = $wpdb->get_results("SELECT * FROM " . WEBLATOR_CHARTS_PREFIX . "style_options");
     foreach ($results as $result) {
         $wpdb->query($wpdb->prepare("INSERT INTO " . WEBLATOR_CHARTS_PREFIX . "charts_style_value (chart_id, style_id, style_value) VALUES (%d, %d, %s)", $last_id, $result->id, sanitize_text_field($result->style_default)));
     }
     foreach ($_POST["styles"] as $style) {
         $value = sanitize_text_field($style["value"]);
         $style_id = $style["id"];
         $wpdb->query($wpdb->prepare("\n                UPDATE " . WEBLATOR_CHARTS_PREFIX . "charts_style_value SET style_value = %s WHERE chart_id = %d AND style_id = %d\n            ", sanitize_text_field($value), $last_id, $style_id));
     }
     echo $last_id;
     die;
 }
开发者ID:andrewkhunn,项目名称:lancero,代码行数:32,代码来源:class-weblator-charts-ajax.php

示例13: __construct

 /**
  * BP_Groups_Invite_Template constructor.
  *
  * @since 1.5.0
  *
  * @param array $args
  */
 public function __construct($args = array())
 {
     // Backward compatibility with old method of passing arguments.
     if (!is_array($args) || func_num_args() > 1) {
         _deprecated_argument(__METHOD__, '2.0.0', sprintf(__('Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress'), __METHOD__, __FILE__));
         $old_args_keys = array(0 => 'user_id', 1 => 'group_id');
         $func_args = func_get_args();
         $args = bp_core_parse_args_array($old_args_keys, $func_args);
     }
     $r = wp_parse_args($args, array('page' => 1, 'per_page' => 10, 'page_arg' => 'invitepage', 'user_id' => bp_loggedin_user_id(), 'group_id' => bp_get_current_group_id()));
     $this->pag_arg = sanitize_key($r['page_arg']);
     $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $r['page']);
     $this->pag_num = bp_sanitize_pagination_arg('num', $r['per_page']);
     $iquery = new BP_Group_Member_Query(array('group_id' => $r['group_id'], 'type' => 'first_joined', 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'is_confirmed' => false, 'inviter_id' => $r['user_id']));
     $this->invite_data = $iquery->results;
     $this->total_invite_count = $iquery->total_users;
     $this->invites = array_values(wp_list_pluck($this->invite_data, 'ID'));
     $this->invite_count = count($this->invites);
     // If per_page is set to 0 (show all results), don't generate
     // pag_links.
     if (!empty($this->pag_num)) {
         $this->pag_links = paginate_links(array('base' => add_query_arg($this->pag_arg, '%#%'), 'format' => '', 'total' => ceil($this->total_invite_count / $this->pag_num), 'current' => $this->pag_page, 'prev_text' => '&larr;', 'next_text' => '&rarr;', 'mid_size' => 1, 'add_args' => array()));
     } else {
         $this->pag_links = '';
     }
 }
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:33,代码来源:class-bp-groups-invite-template.php

示例14: save_slider_settings

 /**
  * Save settings post meta fields added to Soliloquy metaboxes.
  *
  * @since 1.0.0
  *
  * @param int $post_id The post ID
  * @param object $post Current post object data
  */
 public function save_slider_settings($post_id, $post)
 {
     /** Bail out if we fail a security check */
     if (!isset($_POST[sanitize_key('soliloquy_settings_script')]) || !wp_verify_nonce($_POST[sanitize_key('soliloquy_settings_script')], 'soliloquy_settings_script')) {
         return $post_id;
     }
     /** Bail out if running an autosave, ajax or a cron */
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     if (defined('DOING_AJAX') && DOING_AJAX) {
         return;
     }
     if (defined('DOING_CRON') && DOING_CRON) {
         return;
     }
     /** Bail out if the user doesn't have the correct permissions to update the slider */
     if (!current_user_can('edit_post', $post_id)) {
         return $post_id;
     }
     /** All security checks passed, so let's store our data */
     $settings = isset($_POST['_soliloquy_settings']) ? $_POST['_soliloquy_settings'] : '';
     /** Sanitize all data before updating */
     $settings['width'] = absint($_POST['_soliloquy_settings']['width']) ? absint($_POST['_soliloquy_settings']['width']) : 600;
     $settings['height'] = absint($_POST['_soliloquy_settings']['height']) ? absint($_POST['_soliloquy_settings']['height']) : 300;
     $settings['transition'] = preg_replace('#[^a-z0-9-_]#', '', $_POST['_soliloquy_settings']['transition']);
     $settings['speed'] = absint($_POST['_soliloquy_settings']['speed']) ? absint($_POST['_soliloquy_settings']['speed']) : 7000;
     $settings['duration'] = absint($_POST['_soliloquy_settings']['duration']) ? absint($_POST['_soliloquy_settings']['duration']) : 600;
     $settings['preloader'] = isset($_POST['_soliloquy_settings']['preloader']) ? 1 : 0;
     do_action('tgmsp_save_slider_settings', $settings, $post_id, $post);
     /** Update post meta with sanitized values */
     update_post_meta($post_id, '_soliloquy_settings', $settings);
 }
开发者ID:dot2006,项目名称:jobify,代码行数:41,代码来源:Editor.php

示例15: import_from_meta

 /**
  * Bulk import redirects from URLs stored as meta values for posts.
  *
  * @subcommand import-from-meta
  * @synopsis --meta_key=<name-of-meta-key> [--start=<start-offset>] [--end=<end-offset>]
  */
 function import_from_meta($args, $assoc_args)
 {
     define('WP_IMPORTING', true);
     global $wpdb;
     $offset = isset($assoc_args['start']) ? intval($assoc_args['start']) : 0;
     $end_offset = isset($assoc_args['end']) ? intval($assoc_args['end']) : 99999999;
     $meta_key = isset($assoc_args['meta_key']) ? sanitize_key($assoc_args['meta_key']) : '';
     do {
         $redirects = $wpdb->get_results($wpdb->prepare("SELECT post_id, meta_value FROM {$wpdb->postmeta} WHERE meta_key = %s ORDER BY post_id ASC LIMIT %d, 1000", $meta_key, $offset));
         $i = 0;
         $total = count($redirects);
         WP_CLI::line("Found {$total} entries");
         foreach ($redirects as $redirect) {
             $i++;
             WP_CLI::line("Adding redirect for {$redirect->post_id} from {$redirect->meta_value}");
             WP_CLI::line("-- {$i} of {$total} (starting at offset {$offset})");
             WPCOM_Legacy_Redirector::insert_legacy_redirect($redirect->meta_value, $redirect->post_id);
             if (0 == $i % 100) {
                 if (function_exists('stop_the_insanity')) {
                     stop_the_insanity();
                 }
                 sleep(1);
             }
         }
         $offset += 1000;
     } while ($redirects && $offset < $end_offset);
 }
开发者ID:humanmade,项目名称:vip-mu-plugins-public,代码行数:33,代码来源:wp-cli.php


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