/**
  * 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;
 }
 /**
  * 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;
 }
Example #3
0
/**
 * 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);
        }
    }
}
 /**
  * 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;
 }
 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;
 }
 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;
 }
 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)));
 }
 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
 }
 /**
  * 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);
 }
 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;
 }
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;
}
 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;
 }
 /**
  * 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 = '';
     }
 }
Example #14
0
 /**
  * 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);
 }
 /**
  * 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);
 }
 /**
  * Set a session variable
  *
  * @param string $key
  * @param mixed $value
  */
 public function set($key, $value)
 {
     if ($value !== $this->get($key)) {
         $this->_data[sanitize_key($key)] = maybe_serialize($value);
         $this->_dirty = true;
     }
 }
function cfbgr_migrate_xprofile_as_member_types()
{
    global $wpdb;
    $buddypress = buddypress();
    // Description of this tool, displayed to the user
    $statement = __('Migrating/Resetting xProfile data as member types: %s', 'buddypress-group-restrictions');
    // Default to failure text
    $result = __('No xProfile data needs to be migrated or reset.', 'buddypress-group-restrictions');
    // Default to unrepaired
    $repair = 0;
    $field = (int) bp_get_option('cfbgr_xfield_id', 0);
    if (empty($field)) {
        return array(0, sprintf($statement, $result));
    }
    $member_types = bp_get_member_types();
    // Walk through all users on the site
    $user_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->users}");
    foreach ($user_ids as $user_id) {
        $value = sanitize_key(xprofile_get_field_data($field, $user_id));
        // Do we have a matching member type ?
        if (isset($member_types[$value])) {
            // Set member types if empty or different
            if ($value !== bp_get_member_type($user_id)) {
                bp_set_member_type($user_id, $value);
                $repair += 1;
            }
        }
    }
    $result = sprintf(__('%d migrated or reset', 'buddypress-group-restrictions'), $repair);
    // All done!
    return array(0, sprintf($statement, $result));
}
Example #18
0
 /**
  * Create post type table column
  *
  * @param PostType|string $post_type
  * @param string $title
  * @param callable $function
  * @param bool $sortable
  * @param int $position
  */
 public function __construct($post_type, $title, $function, $sortable = false, $position = -1)
 {
     if (is_array($title)) {
         $this->_title = $title[1];
         $this->_key = sanitize_key($title[0]);
     } else {
         $this->_title = $title;
         $this->_key = sanitize_key($title);
     }
     $this->_position = $position;
     $this->_sortable = $sortable;
     $this->_function = $function;
     if ($post_type instanceof PostType) {
         $post_type = $post_type->get_key();
     }
     add_action("manage_edit-{$post_type}_columns", function ($columns) {
         return $this->_add_column($columns, [$this->_key => $this->_title], $this->_position);
     });
     add_action("manage_{$post_type}_posts_custom_column", function ($column) {
         if ($column == $this->_key) {
             return Action::execute($this->_function, $column);
         }
         return null;
     });
     if ($sortable) {
         add_filter("manage_edit-{$post_type}_sortable_columns", function ($columns) {
             return array_merge($columns, [$this->_key => $this->_key]);
         });
     }
 }
Example #19
0
 function after_validate_fields($instance = '')
 {
     if (isset($instance['menu_id']) && isset($instance['menu_label']) && !empty($instance['menu_id']) && !empty($instance['menu_label'])) {
         $key = sanitize_key($instance['menu_label']);
         if (isset($instance['custom_container_id']) && !empty($instance['custom_container_id'])) {
             $key = $instance['custom_container_id'];
         } else {
             $instance['custom_container_id'] = $key;
         }
         $menu_link = '#HOME_URL#' . $key;
         $is_link = false;
         $menu_item_id = $menu_item_position = 0;
         $menu_items = wp_get_nav_menu_items($instance['menu_id']);
         foreach ($menu_items as $menu_item) {
             if ($menu_item->url == $menu_link) {
                 $menu_item_id = $menu_item->ID;
                 $menu_item_position = $menu_item->menu_order;
                 break;
             }
         }
         wp_update_nav_menu_item($instance['menu_id'], $menu_item_id, array('menu-item-title' => $instance['menu_label'], 'menu-item-classes' => 'internal', 'menu-item-url' => $menu_link, 'menu-item-position' => $menu_item_position, 'menu-item-status' => 'publish'));
         update_option('menu_check', true);
     }
     return $instance;
 }
Example #20
0
 /**
  * Initialize the class.
  *
  * @since 1.0.0
  */
 function __construct($config = array(), $strings = array())
 {
     $config = wp_parse_args($config, array('remote_api_url' => 'https://array.is', 'theme_slug' => get_template(), 'api_slug' => get_template() . '-wordpress-theme', 'item_name' => '', 'license' => '', 'version' => '', 'author' => '', 'download_id' => '', 'renew_url' => ''));
     // Set config arguments
     $this->remote_api_url = $config['remote_api_url'];
     $this->item_name = $config['item_name'];
     $this->theme_slug = sanitize_key($config['theme_slug']);
     $this->api_slug = sanitize_key($config['api_slug']);
     $this->version = $config['version'];
     $this->author = $config['author'];
     $this->download_id = $config['download_id'];
     $this->renew_url = $config['renew_url'];
     // Populate version fallback
     if ('' == $config['version']) {
         $theme = wp_get_theme($this->theme_slug);
         $this->version = $theme->get('Version');
     }
     // Strings passed in from the updater config
     $this->strings = $strings;
     add_action('admin_init', array($this, 'updater'));
     add_action('admin_init', array($this, 'register_option'));
     add_action('admin_init', array($this, 'license_action'));
     add_action('admin_menu', array($this, 'license_menu'));
     add_action('update_option_' . $this->theme_slug . '_license_key', array($this, 'activate_license'), 10, 2);
     add_filter('http_request_args', array($this, 'disable_wporg_request'), 5, 2);
 }
 /**
  * Adds a new Fee
  *
  * @since 1.5
  *
  * @param array $args Fee arguments
  *
  * @uses EDD_Fees::get_fees()
  * @uses EDD_Session::set()
  *
  * @return mixed
  */
 public function add_fee($args = array())
 {
     // Backwards compatabliity with pre 2.0
     if (func_num_args() > 1) {
         $args = func_get_args();
         $amount = $args[0];
         $label = isset($args[1]) ? $args[1] : '';
         $id = isset($args[2]) ? $args[2] : '';
         $type = 'fee';
         $args = array('amount' => $amount, 'label' => $label, 'id' => $id, 'type' => $type, 'no_tax' => false, 'download_id' => 0);
     } else {
         $defaults = array('amount' => 0, 'label' => '', 'id' => '', 'no_tax' => false, 'type' => 'fee', 'download_id' => 0);
         $args = wp_parse_args($args, $defaults);
         if ($args['type'] != 'fee' && $args['type'] != 'item') {
             $args['type'] = 'fee';
         }
     }
     if ('item' === $args['type'] && !empty($args['download_id'])) {
         unset($args['download_id']);
     }
     $fees = $this->get_fees('all');
     // Determine the key
     $key = empty($args['id']) ? sanitize_key($args['label']) : sanitize_key($args['id']);
     // Remove the unneeded id key
     unset($args['id']);
     // Sanitize the amount
     $args['amount'] = edd_sanitize_amount($args['amount']);
     // Set the fee
     $fees[$key] = $args;
     // Update fees
     EDD()->session->set('edd_cart_fees', $fees);
     return $fees;
 }
 /**
  * Process content of CSV file
  *
  * @access public
  * @return void
  * */
 public function csv_generate()
 {
     if (isset($_POST['_wpnonce-mhm-export-customer-email'])) {
         check_admin_referer('mhm-export-customer-email', '_wpnonce-mhm-export-customer-email');
         $sitename = sanitize_key(get_bloginfo('name'));
         if (!empty($sitename)) {
             $sitename .= '.';
         }
         $filename = $sitename . date('ymdHis', current_time('timestamp')) . '.csv';
         $data = $this->csv_data();
         if ($_POST['cname'] == 'no') {
             for ($i = 0; $i < count($data); $i++) {
                 unset($data[$i][0]);
             }
         }
         if ($_POST['duplicate'] == 'yes') {
             $data = array_map('unserialize', array_unique(array_map('serialize', $data)));
         }
         $this->csv_header($filename);
         ob_start();
         $file = @fopen('php://output', 'w');
         foreach ($data as $list) {
             @fputcsv($file, $list, ',');
         }
         @fclose($file);
         ob_end_flush();
         exit;
     }
 }
Example #23
0
 /**
  * Get array of available shortcodes objects.
  *
  * @param array $options. 'group' - get shortcodes for passed group. Default is false. 'grouped' - get shortcodes goruped by groupes.
  * @return array
  * @author peshkov@UD
  */
 public static function get($options = array())
 {
     $shortcodes = array();
     $options = wp_parse_args($options, array('group' => false, 'grouped' => false));
     if (!empty($options['group'])) {
         $group = sanitize_key($options['group']);
         foreach (self::$shortcodes as $k => $v) {
             if ($v->group['id'] == $group) {
                 $shortcodes[$k] = $v;
             }
         }
     } else {
         if ($options['grouped']) {
             foreach (self::$shortcodes as $k => $v) {
                 if (!isset($shortcodes[$v->group['id']]) || !is_array($shortcodes[$v->group['id']])) {
                     $shortcodes[$v->group['id']] = array('name' => $v->group['name'], 'properties' => array());
                 }
                 $shortcodes[$v->group['id']]['properties'][$k] = $v;
             }
         } else {
             $shortcodes = self::$shortcodes;
         }
     }
     return $shortcodes;
 }
 /**
  * Get the configuration options for the Kirki customizer.
  *
  * @uses 'kirki/config' filter.
  */
 public function get_all()
 {
     if (is_null($this->config)) {
         // Get configuration from the filter
         $this->config = apply_filters('kirki/config', array());
         // Merge a default configuration with the one we got from the user to make sure nothing is missing
         $default_config = array('stylesheet_id' => 'kirki-styles', 'capability' => 'edit_theme_options', 'logo_image' => '', 'description' => '', 'url_path' => get_template_directory_uri() . '/inc/custom-controls', 'options_type' => 'theme_mod', 'compiler' => array());
         $this->config = array_merge($default_config, $this->config);
         // The logo image
         $this->config['logo_image'] = esc_url_raw($this->config['logo_image']);
         // The customizer description
         $this->config['description'] = esc_html($this->config['description']);
         // The URL path to Kirki. Used when Kirki is embedded in a theme for example.
         $this->config['url_path'] = esc_url_raw($this->config['url_path']);
         // Compiler configuration. Still experimental and under construction.
         $this->config['compiler'] = array('mode' => isset($this->config['compiler']['mode']) ? sanitize_key($this->config['compiler']['mode']) : '', 'filter' => isset($this->config['compiler']['filter']) ? esc_html($this->config['compiler']['filter']) : '');
         // Get the translation strings.
         $this->config['i18n'] = !isset($this->config['i18n']) ? array() : $this->config['i18n'];
         $this->config['i18n'] = array_merge($this->translation_strings(), $this->config['i18n']);
         // If we're using options instead of theme_mods then sanitize the option name & type here.
         if ('option' == $this->config['options_type'] && isset($this->config['option_name']) && '' != $this->config['option_name']) {
             $option_name = $this->config['option_name'];
             $this->config['option_name'] = sanitize_key($this->config['option_name']);
         } else {
             $this->config['option_name'] = '';
         }
     }
     return $this->config;
 }
Example #25
0
 protected function _style($src)
 {
     if (DevTests::isAdmin()) {
         return;
     }
     wp_enqueue_style(sanitize_key($src), $src, false, '1.0');
 }
Example #26
0
function thincc_ajax()
{
    $sitename = sanitize_key(get_bloginfo('name'));
    if (!empty($sitename)) {
        $sitename .= '.';
    }
    $filename = $sitename . 'wordpress.' . date('Y-m-d');
    $options = process_thincc_options($_POST);
    if (isset($_POST['download']) && $_POST['download'] == '0') {
        $options['version'] = 'thin';
        $options['inline'] = true;
        $manifest = new \CC\Manifest(\PressBooks\Book::getBookStructure('', true), $options);
        $manifest->build_manifest();
        header('Content-Description: File Transfer');
        header('Content-Disposition: attachment; filename=' . $filename . '.xml');
        header('Content-Type: text/plain; charset=' . get_option('blog_charset'), true);
        echo '<pre>', htmlentities($manifest), '</pre>';
    } else {
        if (!isset($options['version'])) {
            $options['version'] = '1.2';
        }
        $manifest = new \CC\Manifest(\PressBooks\Book::getBookStructure('', true), $options);
        $manifest->build_manifest();
        $file = $manifest->build_zip();
        header('Content-Type: application/vnd.ims.imsccv1p2+application/zip');
        header('Content-Length: ' . filesize($file));
        header('Content-Disposition: attachment; filename="' . $filename . '.zip"');
        readfile($file);
    }
}
 /**
  * Construct Upload parameters.
  *
  * @since 2.3.0
  * @since 2.4.0 Add the $upload_dir_filter_args argument to the $arguments array
  *
  * @param array|string $args {
  *     @type int    $original_max_filesize  Maximum file size in kilobytes. Defaults to php.ini settings.
  *     @type array  $allowed_mime_types     List of allowed file extensions (eg: array( 'jpg', 'gif', 'png' ) ).
  *                                          Defaults to WordPress allowed mime types.
  *     @type string $base_dir               Component's upload base directory. Defaults to WordPress 'uploads'.
  *     @type string $action                 The upload action used when uploading a file, $_POST['action'] must be set
  *                                          and its value must equal $action {@link wp_handle_upload()} (required).
  *     @type string $file_input             The name attribute used in the file input. (required).
  *     @type array  $upload_error_strings   A list of specific error messages (optional).
  *     @type array  $required_wp_files      The list of required WordPress core files. Default: array( 'file' ).
  *     @type int    $upload_dir_filter_args 1 to receive the original Upload dir array in the Upload dir filter, 0 otherwise.
  *                                          Defaults to 0 (optional).
  * }
  */
 public function __construct($args = '')
 {
     // Upload action and the file input name are required parameters.
     if (empty($args['action']) || empty($args['file_input'])) {
         return false;
     }
     // Sanitize the action ID and the file input name.
     $this->action = sanitize_key($args['action']);
     $this->file_input = sanitize_key($args['file_input']);
     /**
      * Max file size defaults to php ini settings or, in the case of
      * a multisite config, the root site fileupload_maxk option
      */
     $this->default_args['original_max_filesize'] = (int) wp_max_upload_size();
     $params = bp_parse_args($args, $this->default_args, $this->action . '_upload_params');
     foreach ($params as $key => $param) {
         if ('upload_error_strings' === $key) {
             $this->{$key} = $this->set_upload_error_strings($param);
             // Sanitize the base dir.
         } elseif ('base_dir' === $key) {
             $this->{$key} = sanitize_title($param);
             // Sanitize the upload dir filter arg to pass.
         } elseif ('upload_dir_filter_args' === $key) {
             $this->{$key} = (int) $param;
             // Action & File input are already set and sanitized.
         } elseif ('action' !== $key && 'file_input' !== $key) {
             $this->{$key} = $param;
         }
     }
     // Set the path/url and base dir for uploads.
     $this->set_upload_dir();
 }
Example #28
0
function x_get_font_data($font_family, $font_family_data_key)
{
    $fonts_data = x_fonts_data();
    $font_family = sanitize_key($font_family);
    $font_data = $fonts_data[$font_family][$font_family_data_key];
    return $font_data;
}
 public function ajaxResponseSave()
 {
     if (!isset($_POST['post'])) {
         wp_send_json_error('Invalid request.');
     }
     $post = json_decode(stripslashes(html_entity_decode($_POST['post'])), true);
     if (!isset($post['elements'])) {
         wp_send_json_error('Missing element data.');
     }
     if (!isset($post['type'])) {
         $post['type'] = 'block';
     }
     if (!isset($post['title'])) {
         $post['title'] = __('Untitled', csl18n());
     }
     $post['slug'] = uniqid(sanitize_key($post['title']) . '_');
     // SAVE
     $post_id = wp_insert_post(array('post_type' => 'cs_user_templates'));
     update_post_meta($post_id, 'cs_template_title', $post['title']);
     update_post_meta($post_id, 'cs_template_elements', $post['elements']);
     update_post_meta($post_id, 'cs_template_type', $post['type']);
     update_post_meta($post_id, 'cs_template_slug', $post['slug']);
     // Set section before responding so it can be added immediately
     $post['section'] = $post['type'] == 'page' ? 'user-pages' : 'user-blocks';
     $result = array('template' => $post);
     // Suppress PHP error output unless debugging
     if (CS()->common()->isDebug()) {
         return wp_send_json_success($result);
     }
     return @wp_send_json_success($result);
 }
 /**
  * Constructor.
  * Inits shortcode and adds it to global variable $_shortcodes
  *
  */
 public function __construct($options = array())
 {
     // Set properties
     if (is_array($options)) {
         foreach ($options as $k => $v) {
             if (in_array($k, array('id', 'params', 'description', 'group'))) {
                 if ($k == 'group') {
                     $this->group = array('id' => sanitize_key($v), 'name' => $v);
                 } else {
                     $this->{$k} = $v;
                 }
             }
         }
     }
     // All params must have the same structure
     if (is_array($this->params)) {
         foreach ($this->params as $k => $val) {
             $this->params[$k] = $this->_param_sync($k, $val);
         }
     }
     // Add current shortcode to global variable
     $r = Manager::add($this);
     if (is_wp_error($r)) {
         $this->errors[] = $r;
     }
 }