/** * Add or Edit Operation. */ function save() { if (isset($_REQUEST['_wpnonce'])) { $nonce = sanitize_text_field(wp_unslash($_REQUEST['_wpnonce'])); } if (isset($nonce) and !wp_verify_nonce($nonce, 'wpgmp-nonce')) { die('Cheating...'); } $this->verify($_POST); if (is_array($this->errors) and !empty($this->errors)) { $this->throw_errors(); } $extra_fields = array(); if (isset($_POST['location_extrafields'])) { foreach ($_POST['location_extrafields'] as $index => $label) { if ($label != '') { $extra_fields[$index] = sanitize_text_field(wp_unslash($label)); } } } update_option('wpgmp_api_key', sanitize_text_field(wp_unslash($_POST['wpgmp_api_key']))); update_option('wpgmp_scripts_place', sanitize_text_field(wp_unslash($_POST['wpgmp_scripts_place']))); update_option('wpgmp_location_extrafields', serialize($extra_fields)); $response['success'] = __('Setting(s) saved successfully.', WPGMP_TEXT_DOMAIN); return $response; }
/** * Performs json_decode and unslash. * * @since 1.0.0 * @param string $data * @return array */ function wpforms_decode($data) { if (!$data || empty($data)) { return false; } return wp_unslash(json_decode($data, true)); }
function wppb_description_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { $item_title = apply_filters('wppb_' . $form_location . '_description_item_title', wppb_icl_t('plugin profile-builder-pro', 'default_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'default_field_' . $field['id'] . '_description_translation', $field['description']); $input_value = ''; if ($form_location == 'edit_profile') { $input_value = get_the_author_meta('description', $user_id); } if (trim($input_value) == '') { $input_value = $field['default-value']; } $input_value = isset($request_data['description']) ? trim($request_data['description']) : $input_value; $extra_attr = apply_filters('wppb_extra_attribute', '', $field); if ($form_location != 'back_end') { $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } $output = ' <label for="description">' . $item_title . $error_mark . '</label> <textarea rows="' . $field['row-count'] . '" name="description" maxlength="' . apply_filters('wppb_maximum_character_length', '', $field) . '" class="default_field_description" id="description" wrap="virtual" ' . $extra_attr . '>' . esc_textarea(wp_unslash($input_value)) . '</textarea>'; if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } } return apply_filters('wppb_' . $form_location . '_description', $output, $form_location, $field, $user_id, $field_check_errors, $request_data); }
/** * Adding the HTML to the existing registration form */ function tutsplus_register_form_edit() { $twitter_name = !empty($_POST['twitter_name']) ? trim($_POST['twitter_name']) : ''; ?> <p> <label for="twitter_name"> <?php _e('Twitter name', 'sage'); ?> <br /> <input type="text" name="twitter_name" id="twitter_name" class="input" value="<?php echo esc_attr(wp_unslash($twitter_name)); ?> " size="25" /> </label> </p> <?php $terms = !empty($_POST['terms']) ? $_POST['terms'] : ''; ?> <p> <label for="terms"> <input type="checkbox" name="terms" id="terms" class="input" value="agreed" <?php checked($_POST['terms'], 'agreed', true); ?> /> <?php _e('I have read the terms and conditions', 'sage'); ?> </label> </p> <?php }
/** * Redirect to the custom login page */ function cubiq_login_init() { $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login'; if (isset($_POST['wp-submit'])) { $action = 'post-data'; } else { if (isset($_GET['reauth'])) { $action = 'reauth'; } } // redirect to change password form if ($action == 'rp' || $action == 'resetpass') { if (isset($_GET['key']) && isset($_GET['login'])) { $rp_path = wp_unslash('/login/'); $rp_cookie = 'wp-resetpass-' . COOKIEHASH; $value = sprintf('%s:%s', wp_unslash($_GET['login']), wp_unslash($_GET['key'])); setcookie($rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true); } wp_redirect(home_url('/login/?action=resetpass')); exit; } // redirect from wrong key when resetting password if ($action == 'lostpassword' && isset($_GET['error']) && ($_GET['error'] == 'expiredkey' || $_GET['error'] == 'invalidkey')) { wp_redirect(home_url('/login/?action=forgot&failed=wrongkey')); exit; } if ($action == 'post-data' || $action == 'reauth' || $action == 'logout') { return; } wp_redirect(home_url('/login/')); exit; }
/** * Displays the setup form * * @access public * @since 3.9 * @uses WPSC_Checkout_Form::get() * @uses WPSC_Checkout_Form::field_drop_down_options() * @uses WPSC_Checkout_Form::get_field_id_by_unique_name() * @uses WPSC_Payment_Gateway_Setting::get() * * @return void */ public function setup_form() { ?> <tr> <td colspan="2"> <p> <label for="wpsc-manual-gateway-setup"><?php _e('Instructions', 'wpsc'); ?> </label><br /> <textarea id="wpsc-manual-gateway-setup" cols='' rows='10' name='<?php echo esc_attr($this->setting->get_field_name('payment_instructions')); ?> '><?php echo esc_textarea(wp_unslash($this->setting->get('payment_instructions'))); ?> </textarea><br /> <small><?php _e('Enter the payment instructions that you wish to display to your customers when they make a purchase.', 'wpsc'); ?> </small><br /> <small><?php _e('For example, this is where you the Shop Owner might enter your bank account details or address so that your customer can make their manual payment.', 'wpsc'); ?> </small> </p> </td> </tr> <?php }
/** * sanitize content field on save * * @param str $content ad content * @return str $content sanitized ad content * @since 1.0.0 */ public function sanitize_content($content = '') { // remove slashes from content $content = wp_unslash($content); // use WordPress core content filter return $content = apply_filters('content_save_pre', $content); }
/** * Get bank details and place into a list format. * * Note: Since this is declared as a private function in WC_Gateway_BACS, it needs * to be copied here 1:1 * * @param int $order_id */ private function bank_details($order_id = '') { if (empty($this->account_details)) { return; } // Get order and store in $order $order = wc_get_order($order_id); // Get the order country and country $locale $country = $order->billing_country; $locale = $this->get_country_locale(); // Get sortcode label in the $locale array and use appropriate one $sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort Code', 'woocommerce'); $bacs_accounts = apply_filters('woocommerce_bacs_accounts', $this->account_details); if (!empty($bacs_accounts)) { echo '<h2>' . __('Our Bank Details', 'woocommerce') . '</h2>' . PHP_EOL; foreach ($bacs_accounts as $bacs_account) { $bacs_account = (object) $bacs_account; if ($bacs_account->account_name || $bacs_account->bank_name) { echo '<h3>' . wp_unslash(implode(' - ', array_filter(array($bacs_account->account_name, $bacs_account->bank_name)))) . '</h3>' . PHP_EOL; } echo '<ul class="order_details bacs_details">' . PHP_EOL; // BACS account fields shown on the thanks page and in emails $account_fields = apply_filters('woocommerce_bacs_account_fields', array('account_number' => array('label' => __('Account Number', 'woocommerce'), 'value' => $bacs_account->account_number), 'sort_code' => array('label' => $sortcode, 'value' => $bacs_account->sort_code), 'iban' => array('label' => __('IBAN', 'woocommerce'), 'value' => $bacs_account->iban), 'bic' => array('label' => __('BIC', 'woocommerce'), 'value' => $bacs_account->bic)), $order_id); foreach ($account_fields as $field_key => $field) { if (!empty($field['value'])) { echo '<li class="' . esc_attr($field_key) . '">' . esc_attr($field['label']) . ': <strong>' . wptexturize($field['value']) . '</strong></li>' . PHP_EOL; } } echo '</ul>'; } } }
/** * Output for End Location column. * @param array $item Route Row. */ public function column_route_end_location($item) { $modelFactory = new FactoryModelWPGMP(); $location_obj = $modelFactory->create_object('location'); $location = $location_obj->fetch(array(array('location_id', '=', intval(wp_unslash($item->route_end_location))))); echo $location[0]->location_title; }
public function update($data) { // TODO: Implement update() method. global $wpdb; $tableName = $wpdb->prefix . self::$tableName; $code_form = wp_unslash($_POST["search_shortcode_code_form"]); if (!empty($_POST["search_shortcode_from"])) { preg_match('/\\[(.+)\\]/', $_POST["search_shortcode_from"], $from_iata); if (!empty($from_iata[1])) { $from_city = explode(',', $_POST["search_shortcode_from"]); $origin = '"origin": { "name": "' . $from_city[0] . '", "iata": "' . $from_iata[1] . '" }'; $code_form = preg_replace('/"origin": \\{.*?\\}/s', $origin, $code_form); } } if (!empty($_POST["search_shortcode_to"])) { preg_match('/\\[(.+)\\]/', $_POST["search_shortcode_to"], $to_iata); if (!empty($to_iata[1])) { $to_city = explode(',', $_POST["search_shortcode_to"]); $destination = '"destination": { "name": "' . $to_city[0] . '", "iata": "' . $to_iata[1] . '" }'; $code_form = preg_replace('/"destination": \\{.*?\\}/s', $destination, $code_form); } } $inputData = array('title' => $_POST["search_shortcode_title"], 'date_add' => time(), 'type_shortcode' => $_POST["search_shortcode_type"], 'code_form' => $code_form, 'from_city' => $_POST["search_shortcode_from"], 'to_city' => $_POST["search_shortcode_to"]); $wpdb->update($tableName, $inputData, array('id' => $_POST['search_shortcodes_id'])); }
/** * sanitize useragent list * * @since 1.1 * */ public function useragent($array) { global $wp_filter; $localhost = false; $array = wp_unslash($array); if (!is_array($array)) { $array = array($array); } if (isset($array['localhost']) && 's' == sanitize_html_class($array['localhost']) && isset($wp_filter['stt2extat_allow_localhost'])) { $localhost = true; } $array_unique = array_unique(array_map('trim', array_keys($array))); $new_array = array(); foreach ($array_unique as $k) { $v = $array[$k]; if (isset($array[$k]) && '' != $v) { $k = stt2extat_parse_url(sanitize_text_field($k)); $v = sanitize_html_class($v); if ('' != $k && '' != $v) { $new_array[$k['host']] = $v; } } } if ($localhost) { $new_array = wp_parse_args(array('localhost' => 's'), $new_array); } $new_array = array_filter(array_map('trim', $new_array)); uksort($new_array, 'strcasecmp'); return $new_array; }
function after() { $plugin_file = $this->upgrader->plugin_info(); $install_actions = array(); $from = isset($_GET['from']) ? wp_unslash($_GET['from']) : 'plugins'; if ('import' == $from) { $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&from=import&plugin=' . urlencode($plugin_file), 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin & Run Importer') . '</a>'; } else { $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . urlencode($plugin_file), 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>'; } if (is_multisite() && current_user_can('manage_network_plugins')) { $install_actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&networkwide=1&plugin=' . urlencode($plugin_file), 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin for all sites in this network') . '" target="_parent">' . __('Network Activate') . '</a>'; unset($install_actions['activate_plugin']); } if (!$this->result || is_wp_error($this->result) || $this->multi) { unset($install_actions['activate_plugin'], $install_actions['network_activate']); } elseif (!current_user_can('activate_plugins')) { unset($install_actions['activate_plugin']); } /** * Filter the list of action links available following a single plugin installation. * * @since 2.7.0 * * @param array $install_actions Array of plugin action links. * @param object $api Object containing WordPress.org API plugin data. Empty * for non-API installs, such as when a plugin is installed * via upload. * @param string $plugin_file Path to the plugin file. */ $install_actions = apply_filters('install_plugin_complete_actions', $install_actions, $this->api, $plugin_file); if (!empty($install_actions)) { $this->feedback(implode(' | ', (array) $install_actions)); } }
public static function save_fields($options) { if (empty($_POST)) { return; } $update_options = array(); foreach ($options as $value) { $option_value = isset($_POST[$value['id']]) ? wp_unslash($_POST[$value['id']]) : null; switch (sanitize_title($value['type'])) { case 'text': case 'password': case 'number': $option_value = $option_value; break; case 'checkbox': $option_value = is_null($option_value) ? 'no' : 'yes'; break; case 'checkbox2': $option_value = is_null($option_value) ? 0 : 1; break; } if (!is_null($option_value)) { $update_options[$value['id']] = $option_value; } } foreach ($update_options as $name => $val) { update_option($name, $val); } return true; }
/** * When we save the post we don't want the extra embeds to be lingering outside * of the [simple-links] shortcode. * We strip them out here as the post saves so anywhere else is none the wiser * that the embeds ever existed * * @param array $post_data - wp_slashed array of post data * * @return array */ public function strip_embed_wraps_upon_save($post_data) { $content = wp_unslash($post_data['post_content']); $content = preg_replace("/\\[embed\\](\\[simple-links([^\\]]*)\\])\\[\\/embed\\]/", "\$1", $content); $post_data['post_content'] = wp_slash($content); return $post_data; }
public function incoming_trackback($commentdata) { if ('trackback' != $commentdata['comment_type']) { return $commentdata; } if (false === $this->conf['patch_incoming_trackback']) { return $commentdata; } $title = isset($_POST['title']) ? wp_unslash($_POST['title']) : ''; $excerpt = isset($_POST['excerpt']) ? wp_unslash($_POST['excerpt']) : ''; $blog_name = isset($_POST['blog_name']) ? wp_unslash($_POST['blog_name']) : ''; $blog_encoding = $this->blog_encoding; $from_encoding = isset($_POST['charset']) ? $_POST['charset'] : ''; if (!$from_encoding) { $from_encoding = preg_match("/^.*charset=([a-zA-Z0-9\\-_]+).*\$/i", $_SERVER['CONTENT_TYPE'], $matched) ? $matched[1] : ''; } $from_encoding = str_replace(array(',', ' '), '', strtoupper(trim($from_encoding))); $from_encoding = $this->guess_encoding($excerpt . $title . $blog_name, $from_encoding); $title = $this->convenc($title, $blog_encoding, $from_encoding); $blog_name = $this->convenc($blog_name, $blog_encoding, $from_encoding); $excerpt = $this->convenc($excerpt, $blog_encoding, $from_encoding); $title = strip_tags($title); $excerpt = strip_tags($excerpt); $title = strlen($title) > 250 ? mb_strcut($title, 0, 250, $blog_encoding) . '…' : $title; $excerpt = strlen($excerpt) > 255 ? mb_strcut($excerpt, 0, 252, $blog_encoding) . '…' : $excerpt; $commentdata['comment_author'] = wp_slash($blog_name); $commentdata['comment_content'] = wp_slash("<strong>{$title}</strong>\n\n{$excerpt}"); return $commentdata; }
/** * Constructor. * * @since 3.1.0 * @access public * * @see WP_List_Table::__construct() for more information on default arguments. * * @param array $args An associative array of arguments. */ public function __construct($args = array()) { if (!$this->current_action() && clearbase_empty_default($_GET, '_wp_http_referer', false)) { wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI']))); die; } parent::__construct($args); global $cb_post_id; add_filter('clearbase_workspace_action', array(&$this, 'filter_action')); add_filter('clearbase_workspace_form_attributes', array(&$this, 'filter_workspace_form')); add_filter('clearbase_workspace_url_args', array(&$this, 'filter_workspace_url_args')); //Implement the necessary things for attachments in a Clearbase folder $screen = get_current_screen(); $_REQUEST['post_mime_type'] = clearbase_get_value('media_filter', null, clearbase_get_folder_settings()); $_REQUEST['post_parent'] = $cb_post_id; $_REQUEST['orderby'] = 'menu_order'; $_REQUEST['order'] = clearbase_get_value('postmeta.attachment_order', 'DESC'); $this->isTrash = isset($_REQUEST['attachment-filter']) && 'trash' == $_REQUEST['attachment-filter']; add_filter('manage_media_columns', array(&$this, 'manage_media_columns')); add_filter("manage_{$screen->id}_sortable_columns", array(&$this, 'manage_sortable_columns')); add_filter('months_dropdown_results', array(&$this, 'manage_months_dropdown'), 10, 2); add_filter('media_row_actions', array(&$this, 'manage_row_actions'), 10, 2); add_filter('get_edit_post_link', array(&$this, 'edit_post_link'), 10, 3); add_action('manage_media_custom_column', array(&$this, 'render_column'), 10, 2); }
/** * Updates user data * * @return (array) */ public function update_user($user_id) { $input = $this->input(); $user['ID'] = $user_id; if (!(defined('IS_WPCOM') && IS_WPCOM)) { foreach ($input as $key => $value) { if (!is_array($value)) { $value = trim($value); } $value = wp_unslash($value); switch ($key) { case 'first_name': case 'last_name': $user[$key] = $value; break; case 'display_name': case 'name': $user['display_name'] = $value; break; } } } if (isset($input['roles'])) { if (is_array($input['roles'])) { $user['role'] = $input['roles'][0]; } else { $user['role'] = $input['roles']; } } $result = wp_update_user($user); if (is_wp_error($result)) { return $result; } return $this->get_user($user_id); }
function wppb_ecf_email_confirmation_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { if ($field['field'] == 'Email Confirmation') { $item_title = apply_filters('wppb_' . $form_location . '_email_confirmation_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); $extra_attr = apply_filters('wppb_extra_attribute', '', $field); if ($form_location == 'edit_profile') { $input_value = get_the_author_meta('user_email', $user_id); } else { $input_value = ''; } $input_value = isset($request_data['wppb_email_confirmation']) ? trim($request_data['wppb_email_confirmation']) : $input_value; $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; } $output = ' <label for="wppb_email_confirmation">' . $item_title . $error_mark . '</label> <input class="extra_field_email_confirmation" name="wppb_email_confirmation" type="text" id="wppb_email_confirmation" value="' . esc_attr(wp_unslash($input_value)) . '" ' . $extra_attr . '/>'; if (!empty($item_description)) { $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>'; } return apply_filters('wppb_' . $form_location . '_email_confirmation_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value); } }
function qum_yim_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data) { $item_title = apply_filters('qum_' . $form_location . '_yim_item_title', qum_icl_t('plugin quick-user-manager-pro', 'default_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = qum_icl_t('plugin quick-user-manager-pro', 'default_field_' . $field['id'] . '_description_translation', $field['description']); $input_value = ''; if ($form_location == 'edit_profile') { $input_value = get_the_author_meta('yim', $user_id); } if (trim($input_value) == '') { $input_value = $field['default-value']; } $input_value = isset($request_data['yim']) ? trim($request_data['yim']) : $input_value; if ($form_location != 'back_end') { $error_mark = $field['required'] == 'Yes' ? '<span class="qum-required" title="' . qum_required_field_error($field["field-title"]) . '">*</span>' : ''; if (array_key_exists($field['id'], $field_check_errors)) { $error_mark = '<img src="' . QUM_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . qum_required_field_error($field["field-title"]) . '"/>'; } $output = ' <label for="yim">' . $item_title . $error_mark . '</label> <input class="text-input" name="yim" maxlength="' . apply_filters('qum_maximum_character_length', 70) . '" type="text" class="default_field_yim" id="yim" value="' . esc_attr(wp_unslash($input_value)) . '" />'; if (!empty($item_description)) { $output .= '<span class="qum-description-delimiter">' . $item_description . '</span>'; } } return apply_filters('qum_' . $form_location . '_yim', $output, $form_location, $field, $user_id, $field_check_errors, $request_data); }
function wpcf7_birthday_validation_filter($result, $tag) { $tag = new WPCF7_Shortcode($tag); $name = $tag->name; $value = isset($_POST[$name]) ? trim(wp_unslash(strtr((string) $_POST[$name], "\n", " "))) : ''; if ('birthday' == $tag->type && $value != '') { if (preg_match('@^(0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[0-2])$@', $value) != 1) { $result['valid'] = false; $result['reason'][$name] = wpcf7_get_message('invalid_birthday'); } } if ('birthday*' == $tag->type) { if ($value == '') { $result['valid'] = false; $result['reason'][$name] = wpcf7_get_message('invalid_required'); } else { if (preg_match('@^(0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[0-2])$@', $value) != 1) { $result['valid'] = false; $result['reason'][$name] = wpcf7_get_message('invalid_birthday'); } } } if (isset($result['reason'][$name]) && ($id = $tag->get_id_option())) { $result['idref'][$name] = $id; } return $result; }
/** * Edit the page builder data when we're viewing the live editor version * * @param $value * @param $post_id * @param $meta_key * * @return array */ function siteorigin_panels_live_editor($value, $post_id, $meta_key) { if ($meta_key == 'panels_data' && !empty($_GET['siteorigin_panels_live_editor']) && current_user_can('edit_post', $post_id)) { $data = json_decode(wp_unslash($_POST['siteorigin_panels_data']), true); return array($data); } }
/** * Autosave the revisioned meta fields. * * Iterates thru the revisioned meta fields and checks each to see if they are set, * and have a changed value. If so, the meta value is saved and attached to the autosave. * * @since 4.5.0 * * @param Post object $new_autosave The new post being autosaved. */ public function _wp_autosave_post_revisioned_meta_fields($new_autosave) { /** * The post data arrives as either $_POST['data']['wp_autosave'] or the $_POST * itself. This sets $posted_data to the correct variable. */ $posted_data = isset($_POST['data']) ? $_POST['data']['wp_autosave'] : $_POST; /** * Go thru the revisioned meta keys and save them as part of the autosave, if * the meta key is part of the posted data, the meta value is not blank and * the the meta value has changes from the last autosaved value. */ foreach ($this->_wp_post_revision_meta_keys() as $meta_key) { if (isset($posted_data[$meta_key]) && get_post_meta($new_autosave['ID'], $meta_key, true) != wp_unslash($posted_data[$meta_key])) { /* * Use the underlying delete_metadata() and add_metadata() functions * vs delete_post_meta() and add_post_meta() to make sure we're working * with the actual revision meta. */ delete_metadata('post', $new_autosave['ID'], $meta_key); /** * One last check to ensure meta value not empty(). */ if (!empty($posted_data[$meta_key])) { /** * Add the revisions meta data to the autosave. */ add_metadata('post', $new_autosave['ID'], $meta_key, $posted_data[$meta_key]); } } } }
/** * Parse the Cue shortcode for display within a TinyMCE view. * * @since 1.3.0 */ function cue_ajax_parse_shortcode() { global $wp_scripts; if (empty($_POST['shortcode'])) { wp_send_json_error(); } $shortcode = do_shortcode(wp_unslash($_POST['shortcode'])); if (empty($shortcode)) { wp_send_json_error(array('type' => 'no-items', 'message' => __('No items found.'))); } $head = ''; $styles = wpview_media_sandbox_styles(); foreach ($styles as $style) { $head .= '<link type="text/css" rel="stylesheet" href="' . $style . '">'; } $head .= '<link rel="stylesheet" href="' . CUE_URL . 'assets/css/cue.min.css' . '">'; $head .= '<style type="text/css">.cue-tracks { max-height: none;}</style>'; if (!empty($wp_scripts)) { $wp_scripts->done = array(); } ob_start(); echo $shortcode; wp_print_scripts('cue'); wp_send_json_success(array('head' => $head, 'body' => ob_get_clean())); }
function eve_auth_set_key() { ?> <h2>EVE API Auth</h2> <p> Ensure only corp mates can register on your site. </p> <h2>Set corp API Key</h2> <p> You must provide a corp API key. <br/> This key sets the official corporation of this site. Only members of that corp will be able to register</p> <form method="post" action=""> <p> <label for="vcode"><?php _e('vcode', 'eve_auth'); ?> <br /> <input type="text" name="vcode" id="vcode" class="input" value="<?php echo esc_attr(wp_unslash($vcode)); ?> " size="80" /></label> <br/> <label for="key_id"><?php _e('key_id', 'eve_auth'); ?> <br /> <input type="text" name="key_id" id="key_id" class="input" value="<?php echo esc_attr(wp_unslash($key_id)); ?> " size="10" /></label> </p> <?php submit_button('Set Key', 'primary', 'newKey'); ?> </form> <?php }
function ajax_query() { // options $options = acf_parse_args($_POST, array('post_id' => 0, 's' => '', 'field_key' => '', 'nonce' => '')); // load field $field = acf_get_field($options['field_key']); if (!$field) { die; } // vars $r = array(); $s = false; // search if ($options['s'] !== '') { // search may be integer $s = strval($options['s']); // strip slashes $s = wp_unslash($s); } // loop through choices if (!empty($field['choices'])) { foreach ($field['choices'] as $k => $v) { // if searching, but doesn't exist if ($s !== false && stripos($v, $s) === false) { continue; } // append $r[] = array('id' => $k, 'text' => strval($v)); } } // return JSON echo json_encode($r); die; }
function ap_find_mentioned_users($content) { global $wpdb; // Find all mentions in content. preg_match_all('/(?:[\\s.]|^)@(\\w+)/', $content, $matches); if (is_array($matches) && count($matches) > 0 && !empty($matches[0])) { $user_logins = array(); // Remove duplicates. $unique_logins = array_unique($matches[0]); foreach ($unique_logins as $user_login) { $user_logins[] = sanitize_title_for_query(sanitize_user(wp_unslash($user_login), true)); } if (count($user_logins) == 0) { return false; } $user_logins_s = "'" . implode("','", $user_logins) . "'"; $key = md5($user_logins_s); $cache = wp_cache_get($key, 'ap_user_ids'); if (false !== $cache) { return $cache; } $query = $wpdb->prepare("SELECT id, user_login FROM {$wpdb->users} WHERE user_login IN ({$user_logins_s})"); $result = $wpdb->get_results($query); wp_cache_set($key, $result, 'ap_user_ids'); return $result; } return false; }
/** * Ajax callback function to search users that is used on exclude setting page * * @uses WP_User_Query WordPress User Query class. * @return void */ public static function get_users() { if (!defined('DOING_AJAX') || !current_user_can(WP_Stream_Admin::SETTINGS_CAP)) { return; } check_ajax_referer('stream_get_users', 'nonce'); $response = (object) array('status' => false, 'message' => esc_html__('There was an error in the request', 'stream')); $search = isset($_POST['find']) ? wp_unslash(trim($_POST['find'])) : ''; $request = (object) array('find' => $search); add_filter('user_search_columns', array(__CLASS__, 'add_display_name_search_columns'), 10, 3); $users = new WP_User_Query(array('search' => "*{$request->find}*", 'search_columns' => array('user_login', 'user_nicename', 'user_email', 'user_url'), 'orderby' => 'display_name', 'number' => WP_Stream_Admin::PRELOAD_AUTHORS_MAX)); remove_filter('user_search_columns', array(__CLASS__, 'add_display_name_search_columns'), 10); if (0 === $users->get_total()) { wp_send_json_error($response); } $response->status = true; $response->message = ''; $response->users = array(); require_once WP_STREAM_INC_DIR . 'class-wp-stream-author.php'; foreach ($users->results as $key => $user) { $author = new WP_Stream_Author($user->ID); $args = array('id' => $author->ID, 'text' => $author->display_name); $args['tooltip'] = esc_attr(sprintf(__("ID: %d\nUser: %s\nEmail: %s\nRole: %s", 'stream'), $author->id, $author->user_login, $author->user_email, ucwords($author->get_role()))); $args['icon'] = $author->get_avatar_src(32); $response->users[] = $args; } if (empty($search) || preg_match('/wp|cli|system|unknown/i', $search)) { $author = new WP_Stream_Author(0); $response->users[] = array('id' => $author->id, 'text' => $author->get_display_name(), 'icon' => $author->get_avatar_src(32), 'tooltip' => esc_html__('Actions performed by the system when a user is not logged in (e.g. auto site upgrader, or invoking WP-CLI without --user)', 'stream')); } wp_send_json_success($response); }
function rtmedia_login_register_modal_popup() { if (!is_user_logged_in()) { $uri = ''; if (isset($_REQUEST['REQUEST_URI'])) { $uri = esc_url_raw(wp_unslash($_REQUEST['REQUEST_URI'])); } ?> <div class="rtmedia-popup mfp-hide rtm-modal" id="rtmedia-login-register-modal"> <div id="rtm-modal-container"> <h2 class="rtm-modal-title"><?php esc_html_e('Please login', 'buddypress-media'); ?> </h2> <p><?php esc_html_e('You need to be logged in to upload Media or to create Album.', 'buddypress-media'); ?> </p> <p> <?php echo esc_html__('Click', 'buddypress-media') . ' <a href="' . esc_url(wp_login_url($uri)) . '" title="' . esc_attr__('Login', 'buddypress-media') . '">' . esc_html__('HERE', 'buddypress-media') . '</a>' . esc_html__(' to login.', 'buddypress-media'); ?> </p> </div> </div> <?php } }
function ajax_query() { // options $options = acf_parse_args($_GET, array('post_id' => 0, 's' => '', 'field_key' => '', 'nonce' => '')); // load field $field = acf_get_field($options['field_key']); if (!$field) { die; } // vars $r = array(); // strip slashes $options['s'] = wp_unslash($options['s']); if (!empty($field['choices'])) { foreach ($field['choices'] as $k => $v) { // search if ($options['s'] && stripos($v, $options['s']) === false) { continue; } // append $r[] = array('id' => $k, 'text' => strval($v)); } } // return JSON echo json_encode($r); die; }
function wpcf7_text_custom_validation_message($result, $tag) { $cmtagobj = new WPCF7_Shortcode($tag); $post_id = sanitize_text_field($_POST['_wpcf7']); $name = $cmtagobj->name; $key = "_cf7cm_" . $name; $val = get_post_meta($post_id, $key, true); $enable = get_post_meta($post_id, '_cf7cm_enable_errors'); if ($enable[0] != 0) { $value = isset($_POST[$name]) ? trim(wp_unslash(strtr((string) $_POST[$name], "\n", " "))) : ''; if ('text' == $cmtagobj->basetype) { if ($cmtagobj->is_required() && '' == $value) { $result->invalidate($cmtagobj, $val); } } if ('email' == $cmtagobj->basetype) { if ($cmtagobj->is_required() && '' == $value) { $result->invalidate($cmtagobj, $val); } elseif ('' != $value && !wpcf7_is_email($value)) { $key = "_cf7cm_" . $name . "-valid"; $val = get_post_meta($post_id, $key, true); if ($val) { $result->invalidate($cmtagobj, $val); } else { $result->invalidate($cmtagobj, wpcf7_get_message('invalid_email')); } } } if ('url' == $cmtagobj->basetype) { if ($cmtagobj->is_required() && '' == $value) { $result->invalidate($cmtagobj, $val); } elseif ('' != $value && !wpcf7_is_url($value)) { $result->invalidate($cmtagobj, wpcf7_get_message('invalid_url')); } } if ('tel' == $cmtagobj->basetype) { if ($cmtagobj->is_required() && '' == $value) { $result->invalidate($cmtagobj, $val); } elseif ('' != $value && !wpcf7_is_tel($value)) { $result->invalidate($cmtagobj, wpcf7_get_message('invalid_tel')); } } if (!empty($value)) { $maxlength = $cmtagobj->get_maxlength_option(); $minlength = $cmtagobj->get_minlength_option(); if ($maxlength && $minlength && $maxlength < $minlength) { $maxlength = $minlength = null; } $code_units = wpcf7_count_code_units($value); if (false !== $code_units) { if ($maxlength && $maxlength < $code_units) { $result->invalidate($cmtagobj, wpcf7_get_message('invalid_too_long')); } elseif ($minlength && $code_units < $minlength) { $result->invalidate($cmtagobj, wpcf7_get_message('invalid_too_short')); } } } } return $result; }