/** * Display the International Programs blockquote shortcode. * * @param array $atts Attributes assigned to the blockquote display. * @param string $content Content used in the blockquote element itself. * * @return string */ public function display_ip_blockquote($atts, $content) { $default_atts = array('cite' => '', 'image' => '', 'image_placement' => '', 'wrapper' => ''); $atts = wp_parse_args($atts, $default_atts); $content = '<blockquote><span class="blockquote-internal"><span class="blockquote-content">' . wp_kses_post($content) . '</span>'; if (!empty($atts['cite'])) { $content .= '<cite>' . wp_kses_post($atts['cite']) . '</cite>'; } $content .= '</span></blockquote>'; $atts['wrapper'] = esc_attr($atts['wrapper']); $atts['wrapper'] = 'blockquote-container ' . $atts['wrapper']; if (isset($atts['image']) && 0 !== absint($atts['image'])) { if (empty($atts['image_placement'])) { $atts['wrapper'] .= ' blockquote-has-image blockquote-has-image-default'; $content = '<div class="column one">' . $content . '</div><div class="column two">' . wp_get_attachment_image($atts['image'], 'thumbnail', false) . '</div>'; } elseif ('together' === $atts['image_placement']) { $atts['wrapper'] .= ' blockquote-has-image blockquote-has-image-reverse'; $content = '<div class="column one">' . $content . wp_get_attachment_image($atts['image'], 'thumbnail', false) . '</div>'; } elseif ('reverse' === $atts['image_placement']) { $atts['wrapper'] .= ' blockquote-has-image blockquote-has-image-together'; $content = '<div class="column one">' . wp_get_attachment_image($atts['image'], 'thumbnail', false) . '</div><div class="column two">' . $content . '</div>'; } } $content = '<div class="' . esc_attr($atts['wrapper']) . '">' . $content . '</div>'; return $content; }
/** * Display meta in a formatted list * * @access public * @param bool $flat (default: false) * @param bool $return (default: false) * @param string $hideprefix (default: _) * @return string */ public function display($flat = false, $return = false, $hideprefix = '_') { $output = ''; $formatted_meta = $this->get_formatted($hideprefix); if (!empty($formatted_meta)) { $meta_list = array(); foreach ($formatted_meta as $meta_key => $meta) { if ($flat) { $meta_list[] = wp_kses_post($meta['label'] . ': ' . $meta['value']); } else { $meta_list[] = ' <dt class="variation-' . sanitize_html_class(sanitize_text_field($meta_key)) . '">' . wp_kses_post($meta['label']) . ':</dt> <dd class="variation-' . sanitize_html_class(sanitize_text_field($meta_key)) . '">' . wp_kses_post(wpautop($meta['value'])) . '</dd> '; } } if (!empty($meta_list)) { if ($flat) { $output .= implode(", \n", $meta_list); } else { $output .= '<dl class="variation">' . implode('', $meta_list) . '</dl>'; } } } if ($return) { return $output; } else { echo $output; } }
public static function get_media_item($item_data, $align = 'horizontal') { if (!is_object($item_data)) { return ''; } $title = ''; $caption = ''; $link = ''; $title_template = '<h4>%s</h4>'; if (!empty($item_data->link)) { $link_url = $item_data->link; $link = '<a class="swiper-link" href="' . $link_url . '">' . __('Details', 'the7mk2') . '</a>'; $title_template = '<h4><a href="' . $link_url . '">%s</a></h4>'; } if (!empty($item_data->title)) { $title = sprintf($title_template, wp_kses($item_data->title, array())); } if (!empty($item_data->description)) { $caption = wpautop(wp_kses_post($item_data->description)); } $image = dt_get_thumb_img(array('echo' => false, 'img_meta' => array($item_data->full, $item_data->width, $item_data->height), 'img_id' => $item_data->ID, 'alt' => $item_data->alt, 'wrap' => '<img %IMG_CLASS% %SRC% %SIZE% %ALT% />', 'prop' => false)); $info = $title . $caption . $link; if ($info) { $info = sprintf('<span class="link show-content"></span> <div class="swiper-caption"> %s <span class="close-link"></span> </div>', $info); } $html = sprintf('<div class="swiper-slide"> %s %s </div>', $image, $info); return $html; }
/** * Sanitize the input string. HTML tags can be permitted. * The permitted tags can be supplied in an array. * * @TODO: Finish the code needed to support the $permittedTags array. * * @param string $string * @param bool $allowHTML [optional] * @param array $permittedTags [optional] * @return string */ public function sanitizeString($string, $allowHTML = FALSE, $permittedTags = array()) { // Strip all tags except the permitted. if (!$allowHTML) { // Ensure all tags are closed. Uses WordPress method balanceTags(). $balancedText = balanceTags($string, TRUE); $strippedText = strip_tags($balancedText); // Strip all script and style tags. $strippedText = preg_replace('@<(script|style)[^>]*?>.*?</\\1>@si', '', $strippedText); // Escape text using the WordPress method and then strip slashes. $escapedText = stripslashes(esc_attr($strippedText)); // Remove line breaks and trim white space. $escapedText = preg_replace('/[\\r\\n\\t ]+/', ' ', $escapedText); return trim($escapedText); } else { // Strip all script and style tags. $strippedText = preg_replace('@<(script|style)[^>]*?>.*?</\\1>@si', '', $string); $strippedText = preg_replace('/<(script|style).*?>.*?<\\/\\1>/si', '', stripslashes($strippedText)); /* * Use WordPress method make_clickable() to make links clickable and * use kses for filtering. * * http://ottopress.com/2010/wp-quickie-kses/ */ return wptexturize(wpautop(make_clickable(wp_kses_post($strippedText)))); } }
/** * Display meta in a formatted list. * * @param bool $flat (default: false) * @param bool $return (default: false) * @param string $hideprefix (default: _) * @param string $delimiter Delimiter used to separate items when $flat is true * @return string|void */ public function display($flat = false, $return = false, $hideprefix = '_', $delimiter = ", \n") { $output = ''; $formatted_meta = $this->get_formatted($hideprefix); if (!empty($formatted_meta)) { $meta_list = array(); foreach ($formatted_meta as $meta) { if ($flat) { $meta_list[] = wp_kses_post($meta['label'] . ': ' . $meta['value']); } else { $meta_list[] = ' <dt class="variation-' . sanitize_html_class(sanitize_text_field($meta['key'])) . '">' . wp_kses_post($meta['label']) . ':</dt> <dd class="variation-' . sanitize_html_class(sanitize_text_field($meta['key'])) . '">' . wp_kses_post(wpautop(make_clickable($meta['value']))) . '</dd> '; } } if (!empty($meta_list)) { if ($flat) { $output .= implode($delimiter, $meta_list); } else { $output .= '<dl class="variation">' . implode('', $meta_list) . '</dl>'; } } } $output = apply_filters('woocommerce_order_items_meta_display', $output, $this); if ($return) { return $output; } else { echo $output; } }
function qi_theme_api_call($def, $action, $args) { global $wp_version, $theme_base, $api_url, $theme_version; // Add check for 'slug' existence inside $args // to avoid WordPress.org server error message // in some screens if (!property_exists($args, 'slug')) { return false; } if ($args->slug != $theme_base) { return false; } // Get the current version $args->version = $theme_version; $request_string = array('body' => array('action' => $action, 'request' => json_encode($args), 'api-key' => md5(esc_url(home_url('/')))), 'user-agent' => 'WordPress/' . $wp_version . '; ' . esc_url(home_url('/'))); $request = wp_remote_post($api_url, $request_string); if (is_wp_error($request)) { $res = new WP_Error('themes_api_failed', wp_kses_post(__('An Unexpected HTTP Error occurred during the API request.</p> <p><a href="?" onclick="document.location.reload(); return false;">Try again</a>', 'quadro')), $request->get_error_message()); } else { $res = unserialize($request['body']); if ($res === false) { $res = new WP_Error('themes_api_failed', esc_html__('An unknown error occurred', 'quadro'), $request['body']); } } return $res; }
function create_field($field) { // vars $o = array('id', 'class', 'name', 'value', 'placeholder'); $e = ''; // prepend if ($field['prepend'] !== "") { $field['class'] .= ' acf-is-prepended'; $e .= '<div class="acf-input-prepend">' . wp_kses_post($field['prepend']) . '</div>'; } // append if ($field['append'] !== "") { $field['class'] .= ' acf-is-appended'; $e .= '<div class="acf-input-append">' . wp_kses_post($field['append']) . '</div>'; } $e .= '<div class="acf-input-wrap">'; $e .= '<input type="email"'; foreach ($o as $k) { $e .= ' ' . $k . '="' . esc_attr($field[$k]) . '"'; } $e .= ' />'; $e .= '</div>'; // return echo $e; }
public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']); echo $before_widget; echo '<div class="twitter-widget-wrapper">'; if ($title) { echo $before_title . $title . $after_title; } if (function_exists('fw_ssd_twitter_feed')) { $tweets = fw_ssd_twitter_feed($instance['tweet_count'], $instance['username']); if (!is_wp_error($tweets) && !empty($tweets)) { $output = ''; $output .= '<ul>'; if (!empty($tweets['error'])) { $output .= '<li><div class="tweet-content">' . $tweets['error'] . '</div></li>'; } else { foreach ($tweets as $tweet) { if (!empty($tweet['tweet'])) { $output .= '<li><div class="tweet-content">' . $tweet['tweet'] . '</div> <span class="tweet-time">' . $tweet['time'] . '</span></li>'; } } } $output .= '</ul>'; } } echo wp_kses_post($output); echo '</div><!-- end twitter-widget-wrapper -->'; echo $after_widget; }
function shortcode_ui_dev_shortcode($attr, $content = '') { //Parse the attribute of the shortcode $attr = wp_parse_args($attr, array('source' => '', 'attachment' => 0)); ob_start(); ?> <section class="pullquote" style="padding: 20px; background: rgba(0,0,0,0.1);"> <p style="margin:0; padding: 0;"> <b>Content:</b> <?php echo wpautop(wp_kses_post($content)); ?> </br> <b>Source:</b> <?php echo esc_html($attr['source']); ?> </br> <b>Image:</b> <?php echo wp_kses_post(wp_get_attachment_image($attr['attachment'], array(50, 50))); ?> </br> </p> </section> <?php return ob_get_clean(); }
/** * Call to action section * */ function theshop_section_cta() { if (!get_theme_mod('cta_activate', 1)) { return; } $text = get_theme_mod('cta_text', 'Are you ready to see more?'); $button_title = get_theme_mod('cta_button_title', 'VISIT OUR SHOP'); $button_url = get_theme_mod('cta_button_url', '#'); ?> <section class="home-section cta-section"> <div class="container"> <p class="cta-text"><?php echo wp_kses_post($text); ?> </p> <a class="button" href="<?php echo esc_url($button_url); ?> "><?php echo esc_html($button_title); ?> </a> </div> </section> <?php }
function add_cat_to_db() { global $wpdb, $current_user; if ($_REQUEST['action'] == 'add') { $category_name = isset($_REQUEST['category_name']) && !empty($_REQUEST['category_name']) ? esc_html($_REQUEST['category_name']) : ''; $category_identifier = isset($_REQUEST['category_identifier']) && !empty($_REQUEST['category_identifier']) ? $category_identifier = sanitize_title_with_dashes($_REQUEST['category_identifier']) : ($category_identifier = sanitize_title_with_dashes($category_name . '-' . time())); $category_desc = isset($_REQUEST['category_desc']) && !empty($_REQUEST['category_desc']) ? wp_kses_post($_REQUEST['category_desc']) : ''; $display_category_desc = isset($_REQUEST['display_desc']) && !empty($_REQUEST['display_desc']) ? $_REQUEST['display_desc'] : ''; if (!function_exists('espresso_member_data')) { $current_user->ID = 1; } $category_meta['use_pickers'] = isset($_REQUEST['use_pickers']) && !empty($_REQUEST['use_pickers']) ? $_REQUEST['use_pickers'] : ''; $category_meta['event_background'] = isset($_REQUEST['event_background']) && !empty($_REQUEST['event_background']) ? $_REQUEST['event_background'] : ''; $category_meta['event_text_color'] = isset($_REQUEST['event_text_color']) && !empty($_REQUEST['event_text_color']) ? $_REQUEST['event_text_color'] : ''; $category_meta = serialize($category_meta); $sql = array('category_name' => $category_name, 'category_identifier' => $category_identifier, 'category_desc' => $category_desc, 'display_desc' => $display_category_desc, 'category_meta' => $category_meta, 'wp_user' => $current_user->ID); $sql_data = array('%s', '%s', '%s', '%s', '%s', '%d'); if ($wpdb->insert(EVENTS_CATEGORY_TABLE, $sql, $sql_data)) { ?> <div id="message" class="updated fade"><p><strong><?php _e('The category has been added.', 'event_espresso'); ?> </strong></p></div> <?php } else { ?> <div id="message" class="error"><p><strong><?php _e('The category was not saved.', 'event_espresso'); ?> </strong></p></div> <?php } } }
function widget($args, $instance) { extract($args); $title = apply_filters('PhoenixTeam_Widget_Twitter', $instance['title']); $username = $instance['username'] ? $instance['username'] : null; $number = isset($instance['qty']) ? $instance['qty'] : null; static $counter = 1; // IDs for Widget; // echo $args['before_widget']; // It's the right way, but doesn't work with VC :( echo '<div id="' . THEME_SLUG . '-twitter-' . esc_attr($counter) . '" class="footer-twitter widget_' . THEME_SLUG . '-twitter">'; if ($title) { echo '<h4 class="widget-title">' . esc_html($title) . '</h4>'; } // $tweets = $this->get_tweets($args['widget_id'], $instance); // Good old, but doesn't work with VC $tweets = $this->get_tweets(THEME_SLUG . '-twitter-' . $counter, $instance); if (!empty($tweets['tweets']) && empty($tweets['tweets']->errors)) { $user = current($tweets['tweets']); if (is_object($user)) { $user = $user->user; } echo '<ul class="tweet_list">'; $checker = 0; foreach ($tweets['tweets'] as $tweet) { if ($checker <= $number) { if (isset($tweet->text)) { if (is_object($tweet)) { $avatar = $user->profile_image_url; $username = $user->screen_name; $user_url = 'https://twitter.com/' . $username; $tweet_text = htmlentities($tweet->text, ENT_QUOTES, 'UTF-8'); $tweet_text = make_clickable($tweet_text); $tweet_text = popuplinks($tweet_text); if ($tweet_text) { echo '<li> <a class="tweet_avatar" href="' . esc_url($user_url) . '"> <img src="' . esc_url($avatar) . '" alt="' . esc_attr($username) . '" title="' . esc_attr($username) . '"> </a> <span class="tweet_text">' . wp_kses_post($tweet_text) . '</span> </li>'; $checker++; } } } else { if ($checker == 0) { echo '<li><span class="content">' . __("There's no tweets in your feed...", 'grandway') . '</span></li>'; break; } break; } } } echo '</ul>'; } elseif ($tweets['tweets']->errors) { _e('Authentication failed! Please check your Twitter app data.', 'grandway'); } elseif (!$tweets['tweets']) { _e("There's no tweets there", 'grandway'); } echo $args['after_widget']; $counter++; }
private static function get_login_options() { $login_options = array(); $targets = array(); if (wskl_is_option_enabled('fb_login')) { $targets[] = 'fb'; } if (wskl_is_option_enabled('naver_login')) { $targets[] = 'naver'; } foreach ($targets as $prefix) { $login_link_text = get_option(wskl_get_option_name($prefix . '_login_link_text'), '[icon]'); if ($login_link_text && !empty($login_link_text)) { switch ($prefix) { case 'fb': $img_url = plugin_dir_url(WSKL_MAIN_FILE) . "assets/image/social-login/facebook.png"; $alt = __('페이스북으로 로그인', 'wskl'); break; case 'naver': $img_url = plugin_dir_url(WSKL_MAIN_FILE) . "assets/image/social-login/naver.png"; $alt = __('네이버 아이디로 로그인', 'wskl'); break; default: $img_url = ''; $alt = ''; } $login_link_text = str_replace('[icon]', sprintf('<img src="%s" class="%s" alt="%s" title="%3$s">', esc_attr($img_url), esc_attr('auth-provider-icon '), esc_attr($alt)), $login_link_text); $login_link_text = wp_kses_post($login_link_text); $login_options[$prefix] = array('href' => esc_url("/index.php?sym-api=service-social-login-{$prefix}"), 'link_title' => $login_link_text, 'alt' => $alt); } } return $login_options; }
function update_event_category() { global $wpdb; $category_id = $_REQUEST['category_id']; $category_name = esc_html($_REQUEST['category_name']); $category_identifier = $_REQUEST['category_identifier'] == '' ? $category_identifier = sanitize_title_with_dashes($category_name . '-' . time()) : ($category_identifier = sanitize_title_with_dashes($_REQUEST['category_identifier'])); $category_desc = wp_kses_post($_REQUEST['category_desc']); $display_category_desc = $_REQUEST['display_desc']; $category_meta['use_pickers'] = isset($_REQUEST['use_pickers']) && !empty($_REQUEST['use_pickers']) ? $_REQUEST['use_pickers'] : ''; $category_meta['event_background'] = isset($_REQUEST['event_background']) && !empty($_REQUEST['event_background']) ? $_REQUEST['event_background'] : ''; $category_meta['event_text_color'] = isset($_REQUEST['event_text_color']) && !empty($_REQUEST['event_text_color']) ? $_REQUEST['event_text_color'] : ''; //echo "<pre>".print_r($_POST,true)."</pre>"; $category_meta = serialize($category_meta); $sql = array('category_name' => $category_name, 'category_identifier' => $category_identifier, 'category_desc' => $category_desc, 'display_desc' => $display_category_desc, 'category_meta' => $category_meta); $update_id = array('id' => $category_id); $sql_data = array('%s', '%s', '%s', '%s', '%s'); if ($wpdb->update(EVENTS_CATEGORY_TABLE, $sql, $update_id, $sql_data, array('%d'))) { ?> <div id="message" class="updated fade"><p><strong><?php _e('The category has been updated.', 'event_espresso'); ?> </strong></p></div> <?php } else { ?> <div id="message" class="error"><p><strong><?php _e('The category was not updated.', 'event_espresso'); ?> </strong></p></div> <?php } }
public function widget($args, $instance) { echo wp_kses_post($args['before_widget']); if (!empty($instance['title'])) { echo wp_kses_post($args['before_title']) . esc_html($instance['title']) . wp_kses_post($args['after_title']); } $barcelona_image = is_numeric($instance['image']) ? barcelona_get_thumbnail_url('barcelona-sq', $instance['image'], true, true) : ''; ?> <div class="about-me"> <?php if (!empty($barcelona_image)) { echo '<p class="about-image"><img src="' . esc_url($barcelona_image[0]) . '" alt="' . esc_attr($instance['name']) . '" /></p>'; } if (!empty($instance['name'])) { echo '<h2 class="about-name">' . esc_html($instance['name']) . '</h2>'; } if (!empty($instance['job_title'])) { echo '<h4 class="about-job-title">' . esc_html($instance['job_title']) . '</h4>'; } ?> <p class="description"> <?php echo wp_kses(nl2br($instance['description']), array('br' => array())); ?> </p> </div> <?php echo wp_kses_post($args['after_widget']); }
function customizer_do($wp_customize) { //////// PANELS //////// $wp_customize->add_panel('wider_flux_layout', array('title' => $this->db_key == 'wonderflux_display' ? esc_html__('Wonderflux', 'wp-flux-layout') : esc_html__('Flux Layout', 'wp-flux-layout'), 'description' => __(wp_kses_post('Flux Layout Generates a dynamic responsive CSS grid - any columns, any width (almost!). <a href="http://fluxlayout.com" target="_blank">Visit the Flux Layout website</a> for more information on how to use this.'), 'wp-flux-layout'))); //////// SECTIONS //////// $wp_customize->add_section('wider_fluxl_core', array('title' => esc_html__('Layout', 'wp-flux-layout'), 'description' => esc_html__('Setup the dimensions of your CSS layout columns (grid system).', 'wp-flux-layout'), 'panel' => 'wider_flux_layout')); $wp_customize->add_section('wider_fluxl_content', array('title' => esc_html__('Content and sidebar', 'wp-flux-layout'), 'description' => esc_html__('Setup the dimensions of your main content area and sidebar.', 'wp-flux-layout'), 'panel' => 'wider_flux_layout')); $wp_customize->add_section('wider_fluxl_config', array('title' => esc_html__('Configuration', 'wp-flux-layout'), 'description' => esc_html__('Configure other Wonderflux settings.', 'wp-flux-layout'), 'panel' => 'wider_flux_layout')); ////// CONTROLS ////// // Common Flux Layout controls $controls = array($this->db_key . '[columns_num]' => array('label' => esc_html__('Number of Vertical columns', 'wp-flux-layout'), 'desc' => esc_html__('Number of vertical columns in your main layout. Flux Layout also includes other common columns configurations automatically.', 'wp-flux-layout'), 'datatype' => $this->datatype, 'default' => $this->default_vals['columns_num'], 'transport' => 'refresh', 'section' => 'wider_fluxl_core', 'type' => 'select_range', 'val_low' => 2, 'val_high' => 100, 'val_step' => 1, 'sanitize' => 'numeric'), $this->db_key . '[container_w]' => array('label' => esc_html__('Main container width', 'wp-flux-layout'), 'desc' => esc_html__('% width of central main content container.', 'wp-flux-layout'), 'datatype' => $this->datatype, 'default' => $this->default_vals['container_w'], 'transport' => 'refresh', 'section' => 'wider_fluxl_core', 'type' => 'select_range', 'val_low' => 5, 'val_high' => 100, 'val_step' => 5, 'sanitize' => 'numeric'), $this->db_key . '[container_p]' => array('label' => esc_html__('Main container position', 'wp-flux-layout'), 'desc' => esc_html__('Position the main content of the site within the browser viewport.', 'wp-flux-layout'), 'datatype' => $this->datatype, 'default' => $this->default_vals['container_p'], 'transport' => 'refresh', 'section' => 'wider_fluxl_core', 'type' => 'select', 'choices' => array('left' => 'Left', 'middle' => 'Middle', 'right' => 'Right'), 'sanitize' => 'no_html'), $this->db_key . '[sidebar_p]' => array('label' => esc_html__('Sidebar position', 'wp-flux-layout'), 'desc' => esc_html__('Position sidebar left or right of the main content.', 'wp-flux-layout'), 'datatype' => $this->datatype, 'default' => $this->default_vals['sidebar_p'], 'transport' => 'refresh', 'section' => 'wider_fluxl_content', 'type' => 'select', 'choices' => array('left' => 'Left', 'right' => 'Right'), 'sanitize' => 'no_html')); // Wonderflux specific controls $wfx_controls = array($this->db_key . '[content_s]' => array('label' => esc_html__('Content width', 'wp-flux-layout'), 'desc' => esc_html__('Relative size to site width.', 'wp-flux-layout'), 'datatype' => $this->datatype, 'default' => $this->default_vals['content_s'], 'transport' => 'refresh', 'section' => 'wider_fluxl_core', 'type' => 'select', 'choices' => $this->common_size, 'sanitize' => 'no_html'), $this->db_key . '[sidebar_s]' => array('label' => esc_html__('Sidebar width', 'wp-flux-layout'), 'desc' => esc_html__('Relative size to site width.', 'wp-flux-layout'), 'datatype' => $this->datatype, 'default' => $this->default_vals['sidebar_s'], 'transport' => 'refresh', 'section' => 'wider_fluxl_core', 'type' => 'select', 'choices' => $this->common_size, 'sanitize' => 'no_html'), $this->db_key . '[rwd_full]' => array('label' => esc_html__('Sidebar/main content breakpoint', 'wp-flux-layout'), 'desc' => esc_html__('Media query breakpoint for when sidebar and content goes full width for smaller screens.', 'wp-flux-layout'), 'datatype' => $this->datatype, 'default' => $this->default_vals['rwd_full'], 'transport' => 'refresh', 'section' => 'wider_fluxl_content', 'type' => 'select', 'choices' => array('tiny' => 'Tiny', 'small' => 'Small', 'medium' => 'Medium', 'large' => 'Large'), 'sanitize' => 'no_html'), $this->db_key . '[sidebar_d]' => array('label' => esc_html__('Sidebar display', 'wp-flux-layout'), 'desc' => esc_html__('Do you want to show or hide the sidebar sitewide (can override with filter.)', 'wp-flux-layout'), 'datatype' => $this->datatype, 'default' => $this->default_vals['sidebar_d'], 'transport' => 'refresh', 'section' => 'wider_fluxl_content', 'type' => 'select', 'choices' => array('Y' => 'Show', 'N' => 'Hide'), 'sanitize' => 'no_html'), $this->db_key . '[content_s_px]' => array('label' => esc_html__('Media width', 'wp-flux-layout'), 'desc' => esc_html__('Sets WordPress $content_width. Pixel width of embeded media such as YouTube - Flux Layout makes this responsive for you.', 'wp-flux-layout'), 'datatype' => $this->datatype, 'default' => $this->default_vals['content_s_px'], 'transport' => 'refresh', 'section' => 'wider_fluxl_content', 'type' => 'select_range', 'val_low' => 200, 'val_high' => 1200, 'val_step' => 5, 'sanitize' => 'numeric'), $this->db_key . '[doc_type]' => array('label' => esc_html__('Document type', 'wp-flux-layout'), 'desc' => esc_html__('Default: transitional', 'wp-flux-layout'), 'datatype' => $this->datatype, 'default' => $this->default_vals['doc_type'], 'transport' => 'postMessage', 'section' => 'wider_fluxl_config', 'type' => 'select', 'choices' => array('transitional' => esc_attr__('transitional', 'wp-flux-layout'), 'strict' => esc_attr__('strict', 'wp-flux-layout'), 'frameset' => esc_attr__('frameset', 'wp-flux-layout'), '1.1' => esc_attr__('1.1', 'wp-flux-layout'), '1.1basic' => esc_attr__('1.1basic', 'wp-flux-layout'), 'html5' => esc_attr__('html5', 'wp-flux-layout'), 'XHTML/RDFa' => esc_attr__('XHTML/RDFa', 'wp-flux-layout')), 'sanitize' => 'no_html'), $this->db_key . '[doc_lang]' => array('label' => esc_html__('Document language', 'wp-flux-layout'), 'desc' => esc_html__('Default: en', 'wp-flux-layout'), 'datatype' => $this->datatype, 'default' => $this->default_vals['doc_lang'], 'transport' => 'postMessage', 'section' => 'wider_fluxl_config', 'type' => 'select', 'choices' => array('aa' => 'aa', 'ab' => 'ab', 'ae' => 'ae', 'af' => 'af', 'ak' => 'ak', 'am' => 'am', 'an' => 'an', 'ar' => 'ar', 'as' => 'as', 'av' => 'av', 'ay' => 'ay', 'az' => 'az', 'ba' => 'ba', 'be' => 'be', 'bg' => 'bg', 'bh' => 'bh', 'bi' => 'bi', 'bm' => 'bm', 'bn' => 'bn', 'bo' => 'bo', 'br' => 'br', 'bs' => 'bs', 'ca' => 'ca', 'ce' => 'ce', 'ch' => 'ch', 'co' => 'co', 'cr' => 'cr', 'cs' => 'cs', 'cu' => 'cu', 'cv' => 'cv', 'da' => 'da', 'de' => 'de', 'dv' => 'dv', 'dz' => 'dz', 'ee' => 'ee', 'el' => 'el', 'en' => 'en', 'eo' => 'eo', 'es' => 'es', 'et' => 'et', 'eu' => 'eu', 'eu' => 'eu', 'fa' => 'fa', 'ff' => 'ff', 'fi' => 'fi', 'fj' => 'fj', 'fo' => 'fo', 'fr' => 'fr', 'fy' => 'fy', 'ga' => 'ga', 'gd' => 'gd', 'gl' => 'gl', 'gn' => 'gn', 'gu' => 'gu', 'gv' => 'gv', 'ha' => 'ha', 'he' => 'he', 'hi' => 'hi', 'ho' => 'ho', 'hr' => 'hr', 'ht' => 'ht', 'hu' => 'hu', 'hy' => 'hy', 'hz' => 'hz', 'ia' => 'ia', 'id' => 'id', 'ie' => 'ie', 'ig' => 'ig', 'ii' => 'ii', 'ik' => 'ik', 'io' => 'io', 'is' => 'is', 'it' => 'it', 'iu' => 'iu', 'ja' => 'ja', 'jv' => 'jv', 'ka' => 'ka', 'kg' => 'kg', 'ki' => 'ki', 'kj' => 'kj', 'kk' => 'kk', 'kl' => 'kl', 'km' => 'km', 'kn' => 'kn', 'ko' => 'ko', 'kr' => 'kr', 'ks' => 'ks', 'ku' => 'ku', 'kv' => 'kv', 'kw' => 'kw', 'ky' => 'ky', 'la' => 'la', 'lb' => 'lb', 'lg' => 'lg', 'li' => 'li', 'ln' => 'ln', 'lo' => 'lo', 'lt' => 'lt', 'lu' => 'lu', 'lv' => 'lv', 'mg' => 'mg', 'mh' => 'mh', 'mi' => 'mi', 'mk' => 'mk', 'ml' => 'ml', 'mn' => 'mn', 'mr' => 'mr', 'ms' => 'ms', 'mt' => 'mt', 'my' => 'my', 'na' => 'na', 'nb' => 'nb', 'nd' => 'nd', 'ne' => 'ne', 'ng' => 'ng', 'nl' => 'nl', 'nn' => 'nn', 'no' => 'no', 'nr' => 'nr', 'nv' => 'nv', 'ny' => 'ny', 'oc' => 'oc', 'oj' => 'oj', 'om' => 'om', 'or' => 'or', 'os' => 'os', 'pa' => 'pa', 'pi' => 'pi', 'pl' => 'pl', 'ps' => 'ps', 'pt' => 'pt', 'qu' => 'qu', 'rm' => 'rm', 'rn' => 'rn', 'ro' => 'ro', 'ru' => 'ru', 'rw' => 'rw', 'sa' => 'sa', 'sc' => 'sc', 'sd' => 'sd', 'se' => 'se', 'sg' => 'sg', 'si' => 'si', 'sk' => 'sk', 'sl' => 'sl', 'sm' => 'sm', 'sn' => 'sn', 'so' => 'so', 'sq' => 'sq', 'sr' => 'sr', 'ss' => 'ss', 'st' => 'st', 'su' => 'su', 'sv' => 'sv', 'sw' => 'sw', 'ta' => 'ta', 'te' => 'te', 'tg' => 'tg', 'th' => 'th', 'ti' => 'ti', 'tk' => 'tk', 'tl' => 'tl', 'tn' => 'tn', 'to' => 'to', 'tr' => 'tr', 'ts' => 'ts', 'tt' => 'tt', 'tw' => 'tw', 'ty' => 'ty', 'ug' => 'ug', 'uk' => 'uk', 'ur' => 'ur', 'uz' => 'uz', 've' => 've', 'vi' => 'vi', 'vo' => 'vo', 'wa' => 'wa', 'wo' => 'wo', 'xh' => 'xh', 'yi' => 'yi', 'yo' => 'yo', 'za' => 'za', 'zh' => 'zh', 'zu' => 'zu'), 'sanitize' => 'no_html'), $this->db_key . '[page_t]' => array('label' => esc_html__('No sidebar template', 'wp-flux-layout'), 'desc' => esc_html__('Hide this Wonderflux page template if it does not suit your child theme (it will be removed from page template dropdown option in admin.)', 'wp-flux-layout'), 'datatype' => $this->datatype, 'default' => $this->default_vals['page_t'], 'transport' => 'postMessage', 'section' => 'wider_fluxl_config', 'type' => 'select', 'choices' => array('' => 'Show no sidebar template', 'no-sidebar' => 'Hide no sidebar template'), 'sanitize' => 'no_html')); // Merged extra Wonderflux controls into array for setup if required $controls = $this->db_key == 'wonderflux_display' ? array_merge($controls, $wfx_controls) : $controls; // Build the controls foreach ($controls as $opt => $val) { $wp_customize->add_setting($opt, array('type' => $val['datatype'], 'default' => isset($val['default']) ? $val['default'] : false, 'transport' => $val['transport'], 'sanitize_callback' => isset($val['sanitize']) ? array($this, 'sanitize_' . $val['sanitize']) : false, 'sanitize_js_callback' => isset($val['sanitize']) ? array($this, 'sanitize_' . $val['sanitize']) : false)); switch ($val['type']) { case 'image_upload': $wp_customize->add_control(new WP_Customize_Upload_Control($wp_customize, $opt, array('label' => $val['label'], 'section' => $val['section'], 'settings' => $opt, 'description' => isset($val['desc']) ? $val['desc'] : false))); break; case 'select': $wp_customize->add_control($opt, array('label' => $val['label'], 'section' => $val['section'], 'type' => $val['type'], 'choices' => $val['choices'], 'description' => isset($val['desc']) ? $val['desc'] : false)); break; case 'select_range': $vals = $this->helper_int_range($val['val_low'], $val['val_high'], $val['val_step']); $wp_customize->add_control($opt, array('label' => $val['label'], 'section' => $val['section'], 'type' => 'select', 'choices' => $vals, 'description' => isset($val['desc']) ? $val['desc'] : false)); break; default: $wp_customize->add_control($opt, array('label' => $val['label'], 'section' => $val['section'], 'type' => $val['type'], 'description' => isset($val['desc']) ? $val['desc'] : false)); break; } } }
function get_post_excerpt($post_or_post_id = null, $length = 100) { $post = null; $result = ""; if (!$post_or_post_id) { $post_or_post_id = get_the_ID(); } if (is_object($post_or_post_id)) { $post = $post_or_post_id; } else { if (is_numeric($post_or_post_id)) { $post = get_post($post_or_post_id); } else { return ''; //throw new Exception( '### Error in VcModule/get_post_excerpt, no post nor post_id given! ###' ); } } $excerpt = html_entity_decode($post->post_excerpt); if (empty($excerpt)) { $excerpt = html_entity_decode(strip_tags($post->post_content)); } if (strlen($excerpt) > $length) { $line = $excerpt; if (preg_match('/^.{1,' . $length . '}\\b/s', $excerpt, $match)) { $line = $match[0]; } $excerpt = $line . '...<br/>Läs mer!'; } return wp_kses_post($excerpt); }
/** * Invoked when the PHP version check fails * Load up the translations and add the error message to the admin notices. */ function wp_stream_fail_php_version() { load_plugin_textdomain('stream', false, dirname(plugin_basename(__FILE__)) . '/languages/'); $message = esc_html__('Stream requires PHP version 5.3+, plugin is currently NOT ACTIVE.', 'stream'); $html_message = sprintf('<div class="error">%s</div>', wpautop($message)); echo wp_kses_post($html_message); }
/** * Add Contextual Help to Backups tools page. * * Help is pulled from the readme FAQ. * * @return null */ function hmbkp_contextual_help() { // Pre WordPress 3.3 compat if (!method_exists(get_current_screen(), 'add_help_tab')) { return; } require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; if (!($plugin = get_transient('hmbkp_plugin_data'))) { $plugin = plugins_api('plugin_information', array('slug' => HMBKP_PLUGIN_SLUG)); // Cache for one day set_transient('hmbkp_plugin_data', $plugin, 1 * DAY_IN_SECONDS); } $warning = ''; // Check if help is for the right version. if (!empty($plugin->version) && version_compare(HMBKP_VERSION, $plugin->version, '!=')) { $warning = sprintf('<div id="message" class="updated inline"><p><strong>' . __('You are not using the latest stable version of BackUpWordPress', 'hmbkp') . '</strong> — ' . __('The information below is for version %1$s. View the %2$s file for help specific to version %3$s.', 'hmbkp') . '</p></div>', '<code>' . esc_attr($plugin->version) . '</code>', '<code>readme.txt</code>', '<code>' . esc_attr(HMBKP_VERSION) . '</code>'); } ob_start(); require_once HMBKP_PLUGIN_PATH . 'admin/constants.php'; $constants = ob_get_clean(); ob_start(); include_once HMBKP_PLUGIN_PATH . 'admin/faq.php'; $faq = ob_get_clean(); get_current_screen()->add_help_tab(array('title' => __('FAQ', 'hmbkp'), 'id' => 'hmbkp_faq', 'content' => wp_kses_post($faq))); get_current_screen()->add_help_tab(array('title' => __('Constants', 'hmbkp'), 'id' => 'hmbkp_constants', 'content' => wp_kses_post($constants))); get_current_screen()->set_help_sidebar('<p><strong>' . __('For more information:', 'hmbkp') . '</strong></p>' . '<p><a href="https://github.com/humanmade/backupwordpress" target="_blank">GitHub</a></p>' . '<p><a href="http://wordpress.org/tags/backupwordpress?forum_id=10" target="_blank">' . __('Support Forums', 'hmbkp') . '</a></p>' . '<p><a href="http://translate.hmn.md/" target="_blank">' . __('Help with translation', 'hmbkp') . '</a></p>'); }
/** * Sanitizes posted data from before saving an email * * @access public * @param mixed $posted * @return int email id of saved email */ function edd_pup_sanitize_save($data) { // Convert form data to array if (isset($data['form'])) { $form = $data['form']; $data = array(); parse_str($form, $data); } // Sanitize our data $data['message'] = wp_kses_post($data['message']); $data['email-id'] = isset($data['email-id']) ? absint($data['email-id']) : 0; $data['recipients'] = absint($data['recipients']); $data['from_name'] = sanitize_text_field($data['from_name']); $data['from_email'] = sanitize_email($data['from_email']); $data['title'] = sanitize_text_field($data['title'], 'ID:' . $data['email-id'], 'save'); $data['subject'] = sanitize_text_field($data['subject']); $data['bundle_1'] = sanitize_text_field($data['bundle_1']); $data['bundle_2'] = isset($data['bundle_2']) ? 1 : 0; // Sanitize products array and convert to ID => name format if (isset($data['products'])) { foreach ($data['products'] as $product) { $prodid = absint($product); $products[absint($prodid)] = get_the_title(absint($prodid)); } $data['products'] = $products; } return edd_pup_save_email($data, $data['email-id']); }
function widget($args, $instance) { $title = $instance['title']; $bio = $instance['bio']; $custom_email = $instance['custom_email']; $avatar_size = preg_replace("/[^0-9]/", "", $instance['avatar_size']); if (!$avatar_size) { $avatar_size = 48; } $avatar_align = $instance['avatar_align']; if (!$avatar_align) { $avatar_align = 'left'; } $read_more_text = $instance['read_more_text'] ? $instance['read_more_text'] : 'Read more'; $read_more_url = $instance['read_more_url']; echo ts_essentials_escape($args['before_widget']); if (!empty($title)) { echo ts_essentials_escape($args['before_title'] . apply_filters('widget_title', $title) . $args['after_title']); } echo '<div class="blog-author clearfix">'; $avatar = $custom_email ? '<span class="align' . esc_attr($avatar_align) . '">' . get_avatar($custom_email, $avatar_size) . '</span>' : ''; ?> <p><?php echo wp_kses_post($avatar . $bio); ?> </p> <?php if ($read_more_url) { echo '<div class="mimic-smaller read-more uppercase"><a href="' . esc_url($read_more_url) . '">' . esc_html($read_more_text) . '</a></div>'; } echo '</div>'; echo ts_essentials_escape($args['after_widget']); }
function ts_essentials_escape($str = '', $type = '', $context = '') { if (trim($str)) { if ($type == 'strip') { if ($context == 'widget_before_after') { return strip_tags($str, '<div><ul><li>'); } elseif ($context == 'widget_title_before_after') { return strip_tags($str, '<div><ul><li><h3><h4><h5><h6><strong><em><i><b><span>'); } elseif (substr($context, 0, 1) == '<') { return strip_tags($str, $context); } else { return strip_tags($str); } } elseif ($type == 'bal' || $type == 'balance') { return balanceTags($str); } elseif ($type == 'attr') { return esc_attr($str); } elseif ($type == 'html') { return esc_html($str); } elseif ($type == 'url') { return esc_url($str); } elseif ($type == 'js') { return esc_js($str); } elseif ($type == 'textarea') { return esc_textarea($str); } elseif ($type == 'sql') { return esc_sql($str); } elseif ($type == 'post') { return wp_kses_post($str); } } return $str; }
/** * 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['title'] = wp_kses_post($new_instance['title']); $instance['skype_username'] = wp_kses_post($new_instance['skype_username']); return $instance; }
/** * Site footer closing data line */ function footer_micro() { $date = wps_get_theme_option('company_launch_date') ? wps_get_theme_option('company_launch_date') : ''; // If no option found set to Site Name! $name = wps_get_theme_option('company_name') ? wps_get_theme_option('company_name') : get_bloginfo('name'); $disclaimer = wps_get_theme_option('site_disclaimer') ? wps_get_theme_option('site_disclaimer') . ' -' : ''; ?> <div class="page-micro"> <div class="wrapper"> <div class="layout layout--center"> <div class="layout__item"> <small class="page-micro__copy txt--center"><?php echo wp_kses_post($disclaimer); ?> <?php echo esc_html($name); ?> <?php echo esc_html($date); ?> - <?php echo esc_html(date('Y')); ?> </small> </div> </div> </div><!-- wrapper --> </div><!-- page-micro --> <?php }
public function update($new_instance, $old_instance) { $instance = array(); $instance['title'] = !empty($new_instance['title']) ? strip_tags($new_instance['title']) : ''; $instance['text'] = wp_kses_post($new_instance['text']); return $instance; }
public function get_posts() { $query = $_POST['query']; $hash = $this->get_query_hash($query); check_ajax_referer($hash); // $query is signed by nonce $wp_query = new \WP_Query($query); $posts = $wp_query->posts; if (!$posts) { exit('-1'); } $posted_opts = $_POST['opts']; $opts = array('hide_title' => $this->_bool($posted_opts['hide_title']), 'link' => in_array($posted_opts['link'], array('post', 'file', 'thickbox', 'none')) ? $posted_opts['link'] : wp_tiles()->options->get_option('link'), 'byline_template' => wp_kses_post($posted_opts['byline_template']), 'byline_template_textonly' => $this->_bool($posted_opts['byline_template_textonly']), 'images_only' => $this->_bool($posted_opts['images_only']), 'image_size' => $posted_opts['image_size'], 'text_only' => $this->_bool($posted_opts['text_only']), 'link_new_window' => $this->_bool($posted_opts['link_new_window'])); ob_start(); wp_tiles()->render_tile_html($posts, $opts); $html = ob_get_contents(); ob_end_clean(); $ret = array('tiles' => $html); $max_page = $wp_query->max_num_pages; $next_page = intval($wp_query->get('paged')) + 1; // Is there another page? if ($next_page <= $max_page) { $ret['has_more'] = true; $query['paged'] = $next_page; $ret['_ajax_nonce'] = $this->get_query_nonce($query); } else { $ret['has_more'] = false; } $this->_return($ret); }
/** * Outputs the field markup. * * @since 3.0.0 */ public function html() { ?> <textarea name="<?php echo $this->name; ?> " id="<?php echo $this->id; ?> " <?php echo $this->class ? 'class="' . $this->class . '" ' : ''; echo $this->placeholder ? 'placeholder="' . $this->placeholder . '" ' : ''; echo $this->style ? 'style="' . $this->style . '" ' : ''; echo $this->attributes; ?> ><?php echo $this->value; ?> </textarea> <?php echo $this->tooltip; if (!empty($this->description)) { echo '<p class="description">' . wp_kses_post($this->description) . '</p>'; } }
/** * Format the script in a way that will be compatible with WordPress. */ public function enqueue_script() { if (!self::$script_added && '' != self::$tooltip_script) { self::$script_added = true; echo '<script>jQuery(document).ready(function($) { "use strict"; ' . wp_kses_post(self::$tooltip_script) . '});</script>'; } }
/** * Process this field after being posted * @return array on success, WP_ERROR on failure */ public function get_cart_item_data() { $cart_item_data = array(); foreach ($this->addon['options'] as $key => $option) { $option_key = empty($option['label']) ? $key : sanitize_title($option['label']); $posted = isset($this->value[$option_key]) ? $this->value[$option_key] : ''; if ($posted === '') { continue; } $label = $this->get_option_label($option); $price = $this->get_option_price($option); switch ($this->addon['type']) { case "custom_price": $price = floatval(sanitize_text_field($posted)); if ($price >= 0) { $cart_item_data[] = array('name' => $label, 'value' => $price, 'price' => $price, 'display' => strip_tags(woocommerce_price($price))); } break; case "input_multiplier": $posted = absint($posted); $cart_item_data[] = array('name' => $label, 'value' => $posted, 'price' => $posted * $price); break; default: $cart_item_data[] = array('name' => $label, 'value' => wp_kses_post($posted), 'price' => $price); break; } } return $cart_item_data; }
/** * Display meta in a formatted list. * * @param bool $flat (default: false) * @param bool $return (default: false) * @param string $hideprefix (default: _) * @param string $delimiter Delimiter used to separate items when $flat is true * @return string|void */ public function display($flat = false, $return = false, $hideprefix = '_', $delimiter = ", \n") { $output = ''; $formatted_meta = $this->get_formatted($hideprefix); if (!empty($formatted_meta)) { $meta_list = array(); foreach ($formatted_meta as $meta) { if ($flat) { $meta_list[] = wp_kses_post($meta['label'] . ': ' . $meta['value']); } else { $meta_list[] = wp_kses_post($meta['label']) . ': ' . wp_kses_post($meta['value']); } } if (!empty($meta_list)) { if ($flat) { $output .= implode($delimiter, $meta_list); } else { $output .= '<br/>' . implode('', $meta_list) . ''; } } } $output = apply_filters('woocommerce_order_items_meta_display', $output, $this); if ($return) { return $output; } else { echo $output; } }