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


PHP wp_encode_emoji函数代码示例

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


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

示例1: fa_get_wpsmiliestrans

function fa_get_wpsmiliestrans()
{
    global $wpsmiliestrans;
    $wpsmilies = array_unique($wpsmiliestrans);
    foreach ($wpsmilies as $alt => $src_path) {
        $emoji = str_replace(array('&#x', ';'), '', wp_encode_emoji($src_path));
        $output .= '<a class="add-smily" data-smilies="' . $alt . '"><img class="wp-smiley" src="' . get_bloginfo('template_directory') . '/72x72/' . $emoji . 'png" /></a>';
    }
    return $output;
}
开发者ID:Germey,项目名称:WonderBlog,代码行数:10,代码来源:emoji.php

示例2: wp_insert_post


//.........这里部分代码省略.........
    } else {
        $menu_order = 0;
    }
    $post_password = isset($postarr['post_password']) ? $postarr['post_password'] : '';
    if ('private' == $post_status) {
        $post_password = '';
    }
    if (isset($postarr['post_parent'])) {
        $post_parent = (int) $postarr['post_parent'];
    } else {
        $post_parent = 0;
    }
    /**
     * Filter the post parent -- used to check for and prevent hierarchy loops.
     *
     * @since 3.1.0
     *
     * @param int   $post_parent Post parent ID.
     * @param int   $post_ID     Post ID.
     * @param array $new_postarr Array of parsed post data.
     * @param array $postarr     Array of sanitized, but otherwise unmodified post data.
     */
    $post_parent = apply_filters('wp_insert_post_parent', $post_parent, $post_ID, compact(array_keys($postarr)), $postarr);
    $post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent);
    // Don't unslash.
    $post_mime_type = isset($postarr['post_mime_type']) ? $postarr['post_mime_type'] : '';
    // Expected_slashed (everything!).
    $data = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'post_mime_type', 'guid');
    $emoji_fields = array('post_title', 'post_content', 'post_excerpt');
    foreach ($emoji_fields as $emoji_field) {
        if (isset($data[$emoji_field])) {
            $charset = $wpdb->get_col_charset($wpdb->posts, $emoji_field);
            if ('utf8' === $charset) {
                $data[$emoji_field] = wp_encode_emoji($data[$emoji_field]);
            }
        }
    }
    if ('attachment' === $post_type) {
        /**
         * Filter attachment post data before it is updated in or added to the database.
         *
         * @since 3.9.0
         *
         * @param array $data    An array of sanitized attachment post data.
         * @param array $postarr An array of unsanitized attachment post data.
         */
        $data = apply_filters('wp_insert_attachment_data', $data, $postarr);
    } else {
        /**
         * Filter slashed post data just before it is inserted into the database.
         *
         * @since 2.7.0
         *
         * @param array $data    An array of slashed post data.
         * @param array $postarr An array of sanitized, but otherwise unmodified post data.
         */
        $data = apply_filters('wp_insert_post_data', $data, $postarr);
    }
    $data = wp_unslash($data);
    $where = array('ID' => $post_ID);
    if ($update) {
        /**
         * Fires immediately before an existing post is updated in the database.
         *
         * @since 2.5.0
         *
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:67,代码来源:post.php

示例3: check_post_header

 public function check_post_header($post_id = true, &$obj = false)
 {
     if (empty($this->p->options['plugin_check_head'])) {
         return $post_id;
     }
     if (!is_object($obj) && ($obj = $this->p->util->get_post_object($post_id)) === false) {
         return $post_id;
     }
     // only check publicly available posts
     if (!isset($obj->post_status) || $obj->post_status !== 'publish') {
         return $post_id;
     }
     // only check registered front-end post types (to avoid menu items, product variations, etc.)
     $ptns = $this->p->util->get_post_types('names');
     if (empty($obj->post_type) || !in_array($obj->post_type, $ptns)) {
         return $post_id;
     }
     $charset = get_bloginfo('charset');
     $permalink = get_permalink($post_id);
     $permalink_html = wp_encode_emoji(htmlentities(urldecode($permalink), ENT_QUOTES, $charset, false));
     // double_encode = false
     $permalink_no_meta = add_query_arg(array('NGFB_META_TAGS_DISABLE' => 1), $permalink);
     $check_opts = apply_filters($this->p->cf['lca'] . '_check_head_meta_options', SucomUtil::preg_grep_keys('/^add_/', $this->p->options, false, ''), $post_id);
     if (current_user_can('manage_options')) {
         $notice_suffix = ' (' . sprintf(__('see <a href="%s">Theme Integration</a> settings', 'nextgen-facebook'), $this->p->util->get_admin_url('advanced#sucom-tabset_plugin-tab_integration')) . ')...';
     } else {
         $notice_suffix = '...';
     }
     $this->p->notice->inf(sprintf(__('Checking %1$s webpage header for duplicate meta tags', 'nextgen-facebook'), '<a href="' . $permalink . '">' . $permalink_html . '</a>') . $notice_suffix, true);
     // use the permalink and have get_head_meta() remove our own meta tags
     // to avoid issues with caching plugins that ignore query arguments
     if (($metas = $this->p->util->get_head_meta($permalink, '/html/head/link|/html/head/meta', true)) !== false) {
         foreach (array('link' => array('rel'), 'meta' => array('name', 'itemprop', 'property')) as $tag => $types) {
             if (isset($metas[$tag])) {
                 foreach ($metas[$tag] as $m) {
                     foreach ($types as $t) {
                         if (isset($m[$t]) && $m[$t] !== 'generator' && !empty($check_opts[$tag . '_' . $t . '_' . $m[$t]])) {
                             $this->p->notice->err('Possible conflict detected &mdash; your theme or another plugin is adding a <code>' . $tag . ' ' . $t . '="' . $m[$t] . '"</code> HTML tag to the head section of this webpage.', true);
                         }
                     }
                 }
             }
         }
     }
     return $post_id;
 }
开发者ID:leotaillard,项目名称:btws2016,代码行数:46,代码来源:post.php

示例4: wp_staticize_emoji

/**
 * Convert emoji to a static img element.
 *
 * @since 4.2.0
 *
 * @param string $text The content to encode.
 * @return string The encoded content.
 */
function wp_staticize_emoji($text)
{
    $text = wp_encode_emoji($text);
    /** This filter is documented in wp-includes/formatting.php */
    $cdn_url = apply_filters('emoji_url', set_url_scheme('//s.w.org/images/core/emoji/72x72/'));
    /** This filter is documented in wp-includes/formatting.php */
    $ext = apply_filters('emoji_ext', '.png');
    $output = '';
    /*
     * HTML loop taken from smiley function, which was taken from texturize function.
     * It'll never be consolidated.
     *
     * First, capture the tags as well as in between.
     */
    $textarr = preg_split('/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
    $stop = count($textarr);
    // Ignore processing of specific tags.
    $tags_to_ignore = 'code|pre|style|script|textarea';
    $ignore_block_element = '';
    for ($i = 0; $i < $stop; $i++) {
        $content = $textarr[$i];
        // If we're in an ignore block, wait until we find its closing tag.
        if ('' == $ignore_block_element && preg_match('/^<(' . $tags_to_ignore . ')>/', $content, $matches)) {
            $ignore_block_element = $matches[1];
        }
        // If it's not a tag and not in ignore block.
        if ('' == $ignore_block_element && strlen($content) > 0 && '<' != $content[0]) {
            $matches = array();
            if (preg_match_all('/(&#x1f1(e[6-9a-f]|f[0-9a-f]);){2}/', $content, $matches)) {
                if (!empty($matches[0])) {
                    foreach ($matches[0] as $flag) {
                        $chars = str_replace(array('&#x', ';'), '', $flag);
                        list($char1, $char2) = str_split($chars, 5);
                        $entity = sprintf('<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', $cdn_url . $char1 . '-' . $char2 . $ext, html_entity_decode($flag));
                        $content = str_replace($flag, $entity, $content);
                    }
                }
            }
            // Loosely match the Emoji Unicode range.
            $regex = '/(&#x[2-3][0-9a-f]{3};|&#x1f[1-6][0-9a-f]{2};)/';
            $matches = array();
            if (preg_match_all($regex, $content, $matches)) {
                if (!empty($matches[1])) {
                    foreach ($matches[1] as $emoji) {
                        $char = str_replace(array('&#x', ';'), '', $emoji);
                        $entity = sprintf('<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', $cdn_url . $char . $ext, html_entity_decode($emoji));
                        $content = str_replace($emoji, $entity, $content);
                    }
                }
            }
        }
        // Did we exit ignore block.
        if ('' != $ignore_block_element && '</' . $ignore_block_element . '>' == $content) {
            $ignore_block_element = '';
        }
        $output .= $content;
    }
    return $output;
}
开发者ID:zhoujiangyou,项目名称:WordPress,代码行数:67,代码来源:formatting.php

示例5: tokenizeContent

 /**
  * Generates the content tokens and puts them into the tokens array
  *
  * @param object $the_post the post object
  * @param array $tokens tokens array
  *
  * @return int keywords count
  */
 private function tokenizeContent($the_post, &$tokens)
 {
     $args = $this->args;
     $content = $the_post->post_content;
     if ($args['extract_shortcodes']) {
         // WP Table Reloaded support
         if (defined('WP_TABLE_RELOADED_ABSPATH')) {
             include_once WP_TABLE_RELOADED_ABSPATH . 'controllers/controller-frontend.php';
             $wpt_reloaded = new WP_Table_Reloaded_Controller_Frontend();
         }
         // TablePress support
         if (defined('TABLEPRESS_ABSPATH')) {
             $tp_controller = TablePress::load_controller('frontend');
             $tp_controller->init_shortcodes();
         }
         // Remove user defined shortcodes
         $shortcodes = explode(',', $args['exclude_shortcodes']);
         foreach ($shortcodes as $shortcode) {
             remove_shortcode(trim($shortcode));
             add_shortcode(trim($shortcode), array($this, 'return_empty_string'));
         }
         // Remove some shortcodes
         remove_shortcode('wpdreams_ajaxsearchpro');
         add_shortcode('wpdreams_ajaxsearchpro', array($this, 'return_empty_string'));
         remove_shortcode('wpdreams_ajaxsearchpro_results');
         add_shortcode('wpdreams_ajaxsearchpro_results', array($this, 'return_empty_string'));
         remove_shortcode('wpdreams_asp_settings');
         add_shortcode('wpdreams_asp_settings', array($this, 'return_empty_string'));
         remove_shortcode('contact-form');
         add_shortcode('contact-form', array($this, 'return_empty_string'));
         remove_shortcode('starrater');
         add_shortcode('starrater', array($this, 'return_empty_string'));
         remove_shortcode('responsive-flipbook');
         add_shortcode('responsive-flipbook', array($this, 'return_empty_string'));
         remove_shortcode('avatar_upload');
         add_shortcode('avatar_upload', array($this, 'return_empty_string'));
         remove_shortcode('product_categories');
         add_shortcode('product_categories', array($this, 'return_empty_string'));
         remove_shortcode('recent_products');
         add_shortcode('recent_products', array($this, 'return_empty_string'));
         $content = do_shortcode($content);
         // WP 4.2 emoji strip
         if (function_exists('wp_encode_emoji')) {
             $content = wp_encode_emoji($content);
         }
         if (defined('TABLEPRESS_ABSPATH')) {
             unset($tp_controller);
         }
         if (defined('WP_TABLE_RELOADED_ABSPATH')) {
             unset($wpt_reloaded);
         }
     }
     // Strip the remaining shortcodes
     $content = strip_shortcodes($content);
     $content = preg_replace('/<[a-zA-Z\\/][^>]*>/', ' ', $content);
     $content = strip_tags($content);
     $filtered_content = apply_filters('asp_post_content_before_tokenize', $content);
     if ($filtered_content == "") {
         return 0;
     }
     $content_keywords = $this->tokenize($filtered_content);
     foreach ($content_keywords as $keyword) {
         $this->insertToken($tokens, $keyword[0], $keyword[1], 'content');
     }
     return count($content_keywords);
 }
开发者ID:Juni4567,项目名称:meritscholarship,代码行数:74,代码来源:indextable.class.php

示例6: relevanssi_search


//.........这里部分代码省略.........
            $post_types = esc_sql(explode(',', $post_type));
        } else {
            $post_types = esc_sql($post_type);
        }
        $post_type = count($post_types) ? "'" . implode("', '", $post_types) . "'" : 'NULL';
    }
    if ($post_status) {
        if (!is_array($post_status)) {
            $post_statuses = esc_sql(explode(',', $post_status));
        } else {
            $post_statuses = esc_sql($post_status);
        }
        $post_status = count($post_statuses) ? "'" . implode("', '", $post_statuses) . "'" : 'NULL';
    }
    //Added by OdditY:
    //Exclude Post_IDs (Pages) for non-admin search ->
    $postex = '';
    if (!empty($expost)) {
        if ($expost != "") {
            $aexpids = explode(",", $expost);
            foreach ($aexpids as $exid) {
                $exid = esc_sql(trim($exid, ' -'));
                $postex .= " AND relevanssi.doc != '{$exid}'";
                // Clean: escaped
            }
        }
    }
    // <- OdditY End
    if ($expost) {
        //added by OdditY
        $query_restrictions .= $postex;
    }
    $remove_stopwords = true;
    if (function_exists('wp_encode_emoji')) {
        $q = wp_encode_emoji($q);
    }
    $phrases = relevanssi_recognize_phrases($q);
    if (function_exists('relevanssi_recognize_negatives')) {
        $negative_terms = relevanssi_recognize_negatives($q);
    } else {
        $negative_terms = false;
    }
    if (function_exists('relevanssi_recognize_positives')) {
        $positive_terms = relevanssi_recognize_positives($q);
    } else {
        $positive_terms = false;
    }
    $terms = relevanssi_tokenize($q, $remove_stopwords);
    if (count($terms) < 1) {
        // Tokenizer killed all the search terms.
        return $hits;
    }
    $terms = array_keys($terms);
    // don't care about tf in query
    if ($negative_terms) {
        $terms = array_diff($terms, $negative_terms);
        if (count($terms) < 1) {
            return $hits;
        }
    }
    // Go get the count from the options table, but keep running the full query if it's not available
    $D = get_option('relevanssi_doc_count');
    if (!$D || $D < 1) {
        $D = $wpdb->get_var("SELECT COUNT(DISTINCT(relevanssi.doc)) FROM {$relevanssi_table} AS relevanssi");
        // Clean: no external inputs
        update_option('relevanssi_doc_count', $D);
开发者ID:WackoMako,项目名称:stonedape,代码行数:67,代码来源:search.php

示例7: get_single_mt

 public function get_single_mt($tag = 'meta', $type = 'property', $name, $value = '', $cmt = '', $use_post = false)
 {
     // known exceptions for the 'property' $type
     if ($tag === 'meta' && $type === 'property' && (strpos($name, 'twitter:') === 0 || strpos($name, ':') === false)) {
         $type = 'name';
     }
     $ret = array();
     $attr = $tag === 'link' ? 'href' : 'content';
     $log_pre = $tag . ' ' . $type . ' ' . $name;
     $charset = get_bloginfo('charset');
     if (is_array($value)) {
         if ($this->p->debug->enabled) {
             $this->p->debug->log($log_pre . ' value is an array (skipped)');
         }
         return $ret;
     } elseif (is_object($value)) {
         if ($this->p->debug->enabled) {
             $this->p->debug->log($log_pre . ' value is an object (skipped)');
         }
         return $ret;
     }
     if (strpos($value, '%%')) {
         $value = $this->p->util->replace_inline_vars($value, $use_post);
     }
     switch ($name) {
         case 'og:image':
         case 'og:image:url':
         case 'og:video':
         case 'og:video:url':
             // add secure_url meta tag for open graph images and videos
             if (strpos($value, 'https://') === 0) {
                 $secure_value = $value;
                 $secure_name = preg_replace('/:url$/', '', $name) . ':secure_url';
                 $value = preg_replace('/^https:/', 'http:', $value);
                 $ret[] = array('', $tag, $type, $secure_name, $attr, $secure_value, $cmt);
             }
             break;
     }
     $ret[] = array('', $tag, $type, $name, $attr, $value, $cmt);
     // filtering of single meta tags can be enabled by defining NGFB_FILTER_SINGLE_TAGS as true
     if (defined('NGFB_FILTER_SINGLE_TAGS') && NGFB_FILTER_SINGLE_TAGS) {
         $ret = $this->filter_single_mt($ret, $use_post);
     }
     // $parts = array( $html, $tag, $type, $name, $attr, $value, $cmt );
     foreach ($ret as $num => $parts) {
         $log_pre = $parts[1] . ' ' . $parts[2] . ' ' . $parts[3];
         if ($this->p->debug->enabled) {
             $this->p->debug->log($log_pre . ' = "' . $parts[5] . '"');
         }
         if ($parts[5] === '' || $parts[5] === null) {
             // allow for 0
             if ($this->p->debug->enabled) {
                 $this->p->debug->log($log_pre . ' value is empty (skipped)');
             }
         } elseif ($parts[5] == -1) {
             // -1 is reserved
             if ($this->p->debug->enabled) {
                 $this->p->debug->log($log_pre . ' value is -1 (skipped)');
             }
         } elseif (!empty($this->p->options['add_' . $parts[1] . '_' . $parts[2] . '_' . $parts[3]])) {
             // change meta itemtype "image.url" to "url" (for example)
             if ($parts[1] === 'meta' && $parts[2] === 'itemprop' && strpos($parts[3], '.') !== 0) {
                 $parts[3] = preg_replace('/^.*\\./', '', $parts[3]);
             }
             switch ($parts[3]) {
                 case 'og:url':
                 case 'og:image':
                 case 'og:image:url':
                 case 'og:image:secure_url':
                 case 'og:video':
                 case 'og:video:url':
                 case 'og:video:url:secure_url':
                 case 'og:video:url:embed_url':
                 case 'twitter:image':
                 case 'twitter:player':
                 case 'canonical':
                 case 'url':
                     $parts[5] = SucomUtil::esc_url_encode($parts[5]);
                     break;
                 case 'og:title':
                 case 'og:description':
                 case 'twitter:title':
                 case 'twitter:description':
                 case 'description':
                 case 'name':
                     $parts[5] = wp_encode_emoji(htmlentities($parts[5], ENT_QUOTES, $charset, false));
                     // double_encode = false
                 // double_encode = false
                 default:
                     $parts[5] = htmlentities($parts[5], ENT_QUOTES, $charset, false);
                     // double_encode = false
                     break;
             }
             $parts[0] = (empty($parts[6]) ? '' : '<!-- ' . $parts[6] . ' -->') . '<' . $parts[1] . ' ' . $parts[2] . '="' . $parts[3] . '" ' . $parts[4] . '="' . $parts[5] . '"/>' . "\n";
             $ret[$num] = $parts;
         } elseif ($this->p->debug->enabled) {
             $this->p->debug->log($log_pre . ' is disabled (skipped)');
         }
     }
     return $ret;
//.........这里部分代码省略.........
开发者ID:leotaillard,项目名称:btws2016,代码行数:101,代码来源:head.php

示例8: relevanssi_index_doc


//.........这里部分代码省略.........
                }
                // TablePress support
                if (defined('TABLEPRESS_ABSPATH')) {
                    $My_TablePress_Controller = TablePress::load_controller('frontend');
                    $My_TablePress_Controller->init_shortcodes();
                }
                $disable_shortcodes = get_option('relevanssi_disable_shortcodes');
                $shortcodes = explode(',', $disable_shortcodes);
                foreach ($shortcodes as $shortcode) {
                    remove_shortcode(trim($shortcode));
                }
                remove_shortcode('contact-form');
                // Jetpack Contact Form causes an error message
                remove_shortcode('starrater');
                // GD Star Rating rater shortcode causes problems
                remove_shortcode('responsive-flipbook');
                // Responsive Flipbook causes problems
                remove_shortcode('avatar_upload');
                // WP User Avatar is incompatible
                remove_shortcode('product_categories');
                // A problematic WooCommerce shortcode
                remove_shortcode('recent_products');
                // A problematic WooCommerce shortcode
                remove_shortcode('php');
                // PHP Code for Posts
                $post_before_shortcode = $post;
                $contents = do_shortcode($contents);
                $post = $post_before_shortcode;
                if (defined('TABLEPRESS_ABSPATH')) {
                    unset($My_TablePress_Controller);
                }
                if (defined('WP_TABLE_RELOADED_ABSPATH')) {
                    unset($My_WP_Table_Reloaded);
                }
            }
        } else {
            if (function_exists("strip_shortcodes")) {
                // WP 2.5 doesn't have the function
                $contents = strip_shortcodes($contents);
            }
        }
        remove_shortcode('noindex');
        add_shortcode('noindex', 'relevanssi_noindex_shortcode');
        $contents = relevanssi_strip_invisibles($contents);
        if (function_exists('relevanssi_process_internal_links')) {
            $contents = relevanssi_process_internal_links($contents, $post->ID);
        }
        $contents = preg_replace('/<[a-zA-Z\\/][^>]*>/', ' ', $contents);
        $contents = strip_tags($contents);
        if (function_exists('wp_encode_emoji')) {
            $contents = wp_encode_emoji($contents);
        }
        $contents = apply_filters('relevanssi_post_content_before_tokenize', $contents, $post);
        $contents = relevanssi_tokenize($contents, true, $min_word_length);
        if (count($contents) > 0) {
            foreach ($contents as $content => $count) {
                $n++;
                isset($insert_data[$content]['content']) ? $insert_data[$content]['content'] += $count : ($insert_data[$content]['content'] = $count);
            }
        }
    }
    $type = 'post';
    if ($post->post_type == 'attachment') {
        $type = 'attachment';
    }
    $insert_data = apply_filters('relevanssi_indexing_data', $insert_data, $post);
    $values = array();
    foreach ($insert_data as $term => $data) {
        $content = 0;
        $title = 0;
        $comment = 0;
        $tag = 0;
        $link = 0;
        $author = 0;
        $category = 0;
        $excerpt = 0;
        $taxonomy = 0;
        $customfield = 0;
        $taxonomy_detail = '';
        $customfield_detail = '';
        $mysqlcolumn = 0;
        extract($data);
        $term = trim($term);
        $value = $wpdb->prepare("(%d, %s, REVERSE(%s), %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %s, %s, %s, %d)", $post->ID, $term, $term, $content, $title, $comment, $tag, $link, $author, $category, $excerpt, $taxonomy, $customfield, $type, $taxonomy_detail, $customfield_detail, $mysqlcolumn);
        array_push($values, $value);
    }
    $values = apply_filters('relevanssi_indexing_values', $values, $post);
    if (!empty($values)) {
        $values = implode(', ', $values);
        $query = "INSERT IGNORE INTO {$relevanssi_table} (doc, term, term_reverse, content, title, comment, tag, link, author, category, excerpt, taxonomy, customfield, type, taxonomy_detail, customfield_detail, mysqlcolumn)\n\t\t\tVALUES {$values}";
        $wpdb->query($query);
    }
    if ($post_was_null) {
        $post = null;
    }
    if ($previous_post) {
        $post = $previous_post;
    }
    return $n;
}
开发者ID:WP-Panda,项目名称:allergenics,代码行数:101,代码来源:indexing.php

示例9: gwolle_gb_maybe_encode_emoji

function gwolle_gb_maybe_encode_emoji($string, $field)
{
    global $wpdb;
    if (method_exists($wpdb, 'get_col_charset')) {
        $charset = $wpdb->get_col_charset($wpdb->gwolle_gb_entries, $field);
        if ('utf8' === $charset && function_exists('wp_encode_emoji')) {
            $string = wp_encode_emoji($string);
        }
    }
    return $string;
}
开发者ID:RainGrid,项目名称:site,代码行数:11,代码来源:bbcode_emoji.php

示例10: create_or_update_job

 /**
  * Create a post object for a given event
  *
  * Can't call `wp_insert_post()` because `wp_unique_post_slug()` breaks the plugin's expectations
  * Also doesn't call `wp_insert_post()` because this function is needed before post types and capabilities are ready.
  */
 public function create_or_update_job($timestamp, $action, $args, $update_id = null)
 {
     // Limit how many events to insert at once
     if (!Lock::check_lock(self::LOCK, JOB_CREATION_CONCURRENCY_LIMIT)) {
         return false;
     }
     global $wpdb;
     // Build minimum information needed to create a post
     $instance = md5(serialize($args['args']));
     $job_post = array('post_title' => $this->event_title($timestamp, $action, $instance), 'post_name' => $this->event_name($timestamp, $action, $instance), 'post_content_filtered' => maybe_serialize(array('action' => $action, 'instance' => $instance, 'args' => $args)), 'post_date' => date('Y-m-d H:i:s', $timestamp), 'post_date_gmt' => date('Y-m-d H:i:s', $timestamp), 'post_modified' => current_time('mysql'), 'post_modified_gmt' => current_time('mysql', true), 'post_type' => self::POST_TYPE, 'post_status' => self::POST_STATUS_PENDING, 'post_author' => 0, 'post_parent' => 0, 'comment_status' => 'closed', 'ping_status' => 'closed');
     // Some sanitization in place of `sanitize_post()`, which we can't use this early
     foreach (array('post_title', 'post_name', 'post_content_filtered') as $field) {
         $job_post[$field] = sanitize_text_field($job_post[$field]);
     }
     // Duplicate some processing performed in `wp_insert_post()`
     $charset = $wpdb->get_col_charset($wpdb->posts, 'post_title');
     if ('utf8' === $charset) {
         $job_post['post_title'] = wp_encode_emoji($job_post['post_title']);
     }
     $job_post = wp_unslash($job_post);
     // Set this so it isn't empty, even though it serves us no purpose
     $job_post['guid'] = esc_url(add_query_arg(self::POST_TYPE, $job_post['post_name'], home_url('/')));
     // Create the post, or update an existing entry to run again in the future
     if (is_int($update_id) && $update_id > 0) {
         $inserted = $wpdb->update($wpdb->posts, $job_post, array('ID' => $update_id));
         $this->posts_to_clean[] = $update_id;
     } else {
         $inserted = $wpdb->insert($wpdb->posts, $job_post);
     }
     // Clear caches for new posts once the post type is registered
     if ($inserted) {
         $this->posts_to_clean[] = $wpdb->insert_id;
     }
     // Delete internal cache
     wp_cache_delete(self::CACHE_KEY);
     // Allow more events to be created
     Lock::free_lock(self::LOCK);
 }
开发者ID:Automattic,项目名称:vip-mu-plugins-public,代码行数:44,代码来源:class-cron-options-cpt.php

示例11: get_description


//.........这里部分代码省略.........
             }
             // if there's no excerpt, then fallback to the content
             if (empty($desc)) {
                 $desc = $this->get_content($post_id, $use_post, $use_cache, $md_idx, $src_id);
             }
             // ignore everything before the first paragraph if true
             if ($this->p->options['plugin_p_strip']) {
                 if ($this->p->debug->enabled) {
                     $this->p->debug->log('removing all text before the first paragraph');
                 }
                 $desc = preg_replace('/^.*?<p>/i', '', $desc);
                 // question mark makes regex un-greedy
             }
         } elseif (SucomUtil::is_term_page()) {
             if (is_tag()) {
                 $desc = tag_description();
                 if (empty($desc)) {
                     $desc = sprintf('Tagged with %s', single_tag_title('', false));
                 }
             } elseif (is_category()) {
                 $desc = category_description();
                 if (empty($desc)) {
                     $desc = sprintf('%s Category', single_cat_title('', false));
                 }
             } else {
                 // other taxonomies
                 $term = $this->p->util->get_term_object();
                 if (!empty($term->description)) {
                     $desc = $term->description;
                 } elseif (!empty($term->name)) {
                     $desc = $term->name . ' Archives';
                 }
             }
         } elseif (SucomUtil::is_author_page()) {
             $author = $this->p->util->get_author_object();
             if (!empty($author->description)) {
                 $desc = $author->description;
             } elseif (!empty($author->display_name)) {
                 $desc = sprintf('Authored by %s', $author->display_name);
             }
         } elseif (is_day()) {
             $desc = sprintf('Daily Archives for %s', get_the_date());
         } elseif (is_month()) {
             $desc = sprintf('Monthly Archives for %s', get_the_date('F Y'));
         } elseif (is_year()) {
             $desc = sprintf('Yearly Archives for %s', get_the_date('Y'));
         }
     }
     // if there's still no description, then fallback to a generic version
     if (empty($desc)) {
         if (is_admin() && !empty($obj->post_status) && $obj->post_status == 'auto-draft') {
             if ($this->p->debug->enabled) {
                 $this->p->debug->log('post_status is auto-draft - using empty description');
             }
         } else {
             // pass options array to allow fallback if locale option does not exist
             $key = SucomUtil::get_locale_key('og_site_description', $this->p->options, $post_id);
             if (!empty($this->p->options[$key])) {
                 if ($this->p->debug->enabled) {
                     $this->p->debug->log('description is empty - custom site description (' . $key . ')');
                 }
                 $desc = $this->p->options[$key];
             } else {
                 if ($this->p->debug->enabled) {
                     $this->p->debug->log('description is empty - using blog description');
                 }
                 $desc = get_bloginfo('description', 'display');
             }
         }
     }
     if ($this->p->debug->enabled) {
         $this->p->debug->log('description strlen before html cleanup ' . strlen($desc));
     }
     $desc = $this->p->util->cleanup_html_tags($desc, true, $this->p->options['plugin_use_img_alt']);
     $desc = apply_filters($this->p->cf['lca'] . '_description_pre_limit', $desc);
     if ($textlen > 0) {
         if (!empty($add_hashtags) && !empty($hashtags)) {
             $textlen = $textlen - strlen($hashtags) - 1;
         }
         if ($this->p->debug->enabled) {
             $this->p->debug->log('description strlen before limit length ' . strlen($desc) . ' (limiting to ' . $textlen . ' chars)');
         }
         $desc = $this->p->util->limit_text_length($desc, $textlen, $trailing, false);
         // don't run cleanup_html_tags()
     } elseif ($this->p->debug->enabled) {
         $this->p->debug->log('description limit text length skipped');
     }
     if (!empty($add_hashtags) && !empty($hashtags)) {
         $desc .= ' ' . $hashtags;
     }
     if ($encode === true) {
         $desc = wp_encode_emoji(htmlentities($desc, ENT_QUOTES, get_bloginfo('charset'), false));
     }
     // double_encode = false
     if ($this->p->debug->enabled) {
         $this->p->debug->mark('render description');
     }
     // stop timer
     return apply_filters($this->p->cf['lca'] . '_description', $desc, $use_post, $add_hashtags, $md_idx, $src_id);
 }
开发者ID:leotaillard,项目名称:btws2016,代码行数:101,代码来源:webpage.php

示例12: chat_session_send_message

 /**
  * Send the message
  *
  * @global    object $wpdb
  * @global    int $blog_id
  *
  * @param    int $chat_id Chat ID
  * @param    string $name Name
  * @param    string $avatar URL or e-mail
  * @param    string $message Payload message
  * @param    string $moderator Moderator
  */
 function chat_session_send_message($message, $chat_session)
 {
     global $wpdb;
     //$wpdb->real_escape = true;
     //$time_stamp = date("Y-m-d H:i:s");
     $time_stamp_seconds = time();
     $time_stamp_formated = date("Y-m-d H:i:s", $time_stamp_seconds);
     $blog_id = $chat_session['blog_id'];
     $chat_id = $chat_session['id'];
     $session_type = trim($chat_session['session_type']);
     $name = trim($this->chat_auth['name']);
     $user_avatar = trim($this->chat_auth['avatar']);
     $auth_hash = trim($this->chat_auth['auth_hash']);
     $user_type = trim($this->chat_auth['type']);
     $ip_address = isset($_SERVER['HTTP_X_FORWARD_FOR']) ? $_SERVER['HTTP_X_FORWARD_FOR'] : $_SERVER['REMOTE_ADDR'];
     $message = trim($message);
     $moderator_str = trim($chat_session['moderator']);
     if ($message == '') {
         return false;
     }
     $log_row_id = $this->chat_session_get_meta($chat_session, 'log_row_id');
     //echo "log_row_id[". $log_row_id ."]<br />";
     // If we don't find a record we insert a new one
     if (empty($log_row_id) || $log_row_id == "__EMPTY__") {
         $sql_str = $wpdb->prepare("INSERT INTO " . WPMUDEV_Chat::tablename('log') . " (`blog_id`, `chat_id`, `session_type`, `start`, `end`, `box_title`, `archived`) VALUES (%d, %s, %s, %s, %s, %s, %s);", $chat_session['blog_id'], $chat_session['id'], $chat_session['session_type'], $time_stamp_formated, '', $chat_session['box_title'], 'no');
         //echo "sql_str[". $sql_str ."]<br />";
         //die();
         $ret = $wpdb->query($sql_str);
         if (isset($wpdb->insert_id) && $wpdb->insert_id > 0) {
             $this->chat_session_set_meta($chat_session, 'log_row_id', $wpdb->insert_id);
             $log_row_id = $wpdb->insert_id;
         }
     }
     // If DB charset is not utf8mb4, emojis needs to be encoded as html entities.
     if (!strpos($wpdb->charset, 'mb4') && function_exists('wp_encode_emoji')) {
         $message = wp_encode_emoji($message);
     }
     $sql_str = $wpdb->prepare("INSERT INTO " . WPMUDEV_Chat::tablename('message') . "\r\r\n\t\t\t\t\t(`blog_id`, `chat_id`, `session_type`, `timestamp`, `name`, `avatar`, `auth_hash`, `ip_address`, `message`, `moderator`, `deleted`, `archived`, `log_id`, `user_type`) VALUES (%d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s);", $blog_id, $chat_id, $session_type, $time_stamp_formated, $name, $user_avatar, $auth_hash, $ip_address, $message, $moderator_str, 'no', 'no', $log_row_id, $user_type);
     $ret = $wpdb->query($sql_str);
     if (isset($wpdb->insert_id) && $wpdb->insert_id > 0) {
         $this->chat_session_set_meta($chat_session, 'last_row_id', $wpdb->insert_id);
         return $wpdb->insert_id;
     }
 }
开发者ID:VLabsInc,项目名称:WordPressPlatforms,代码行数:56,代码来源:wordpress-chat.php

示例13: sanitize_content

 public static function sanitize_content($value)
 {
     global $wpdb;
     $options = get_option('iwt_options');
     $allowed = wp_kses_allowed_html('post');
     if (array_key_exists('contentelements', $options) && json_decode($options['contentelements']) != null) {
         $allowed = json_decode($options['contentelements'], true);
     }
     $charset = $wpdb->get_col_charset($wpdb->posts, $emoji_field);
     if ('utf8' === $charset) {
         $value = wp_encode_emoji($value);
     }
     return wp_kses((string) $value, $allowed);
 }
开发者ID:davidized,项目名称:wp-indieweb-post-kinds,代码行数:14,代码来源:class-kind-meta.php

示例14: apply_filters

 * @param int   $post_ID     Post ID.
 * @param array $new_postarr Array of parsed post data.
 * @param array $postarr     Array of sanitized, but otherwise unmodified post data.
 */
$post_parent = apply_filters('wp_insert_post_parent', $post_parent, $post_ID, compact(array_keys($postarr)), $postarr);
$post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent);
// Don't unslash.
$post_mime_type = isset($postarr['post_mime_type']) ? $postarr['post_mime_type'] : '';
// Expected_slashed (everything!).
$data = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'post_mime_type', 'guid');
$emoji_fields = array('post_title', 'post_content', 'post_excerpt');
foreach ($emoji_fields as $emoji_field) {
    if (isset($data[$emoji_field])) {
        $charset = $wpdb->get_col_charset($wpdb->posts, $emoji_field);
        if ('utf8' === $charset) {
            $data[$emoji_field] = wp_encode_emoji($data[$emoji_field]);
        }
    }
}
if ('attachment' === $post_type) {
    /**
     * Filter attachment post data before it is updated in or added to the database.
     *
     * @since 3.9.0
     *
     * @param array $data    An array of sanitized attachment post data.
     * @param array $postarr An array of unsanitized attachment post data.
     */
    $data = apply_filters('wp_insert_attachment_data', $data, $postarr);
} else {
    /**
开发者ID:supermt,项目名称:WordPressAPI,代码行数:31,代码来源:postin.php

示例15: send_message

 /**
  * Send the message
  *
  * @global    object $wpdb
  * @global    int $blog_id
  *
  * @param    int $chat_id Chat ID
  * @param    string $name Name
  * @param    string $avatar URL or e-mail
  * @param    string $message Payload message
  * @param    string $moderator Moderator
  */
 function send_message($chat_id, $name, $avatar, $message, $moderator)
 {
     global $wpdb, $blog_id;
     $wpdb->real_escape = true;
     $time_stamp = date("Y-m-d H:i:s");
     $moderator_str = 'no';
     if (empty($message)) {
         return false;
     }
     if ($moderator) {
         $moderator_str = 'yes';
     }
     $table = Chat::tablename('message');
     // If Table charset is not utf8mb4, emojis needs to be encoded as html entities.
     if (!strpos($wpdb->charset, 'mb4') && function_exists('wp_encode_emoji')) {
         $message = wp_encode_emoji($message);
     }
     $sql = $wpdb->prepare("INSERT INTO {$table} (blog_id, chat_id, timestamp, name, avatar, message, archived, moderator) VALUES (%d, %d, %s, %s, %s, %s, %s, %s)", $blog_id, $chat_id, $time_stamp, $name, $avatar, $message, 'no', $moderator_str);
     return $wpdb->query($sql);
 }
开发者ID:bmounteer,项目名称:SpeakOnIt,代码行数:32,代码来源:chat.php


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