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


PHP sanitize_post函数代码示例

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


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

示例1: upsert_post

 public function upsert_post($post, $silent = false)
 {
     global $wpdb;
     // reject the post if it's not a WP_Post
     if (!$post instanceof WP_Post) {
         return;
     }
     $post = $post->to_array();
     // reject posts without an ID
     if (!isset($post['ID'])) {
         return;
     }
     $now = current_time('mysql');
     $now_gmt = get_gmt_from_date($now);
     $defaults = array('ID' => 0, 'post_author' => '0', 'post_content' => '', 'post_content_filtered' => '', 'post_title' => '', 'post_name' => '', 'post_excerpt' => '', 'post_status' => 'draft', 'post_type' => 'post', 'comment_status' => 'closed', 'comment_count' => '0', 'ping_status' => '', 'post_password' => '', 'to_ping' => '', 'pinged' => '', 'post_parent' => 0, 'menu_order' => 0, 'guid' => '', 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_modified' => $now, 'post_modified_gmt' => $now_gmt);
     $post = array_intersect_key($post, $defaults);
     $post = sanitize_post($post, 'db');
     unset($post['filter']);
     $exists = $wpdb->get_var($wpdb->prepare("SELECT EXISTS( SELECT 1 FROM {$wpdb->posts} WHERE ID = %d )", $post['ID']));
     if ($exists) {
         $wpdb->update($wpdb->posts, $post, array('ID' => $post['ID']));
     } else {
         $wpdb->insert($wpdb->posts, $post);
     }
     clean_post_cache($post['ID']);
 }
开发者ID:kanei,项目名称:vantuch.cz,代码行数:26,代码来源:class.jetpack-sync-wp-replicastore.php

示例2: wpsc_attachment_fields_filter

 public static function wpsc_attachment_fields_filter($form_fields, $post)
 {
     if (!$post->post_parent) {
         return $form_fields;
     }
     $parent = get_post($post->post_parent);
     if ($parent->post_type !== 'wpsc-product') {
         return $form_fields;
     }
     $edit_post = sanitize_post($post, 'edit');
     if (is_array($form_fields) && count($form_fields) > 0) {
         $number_field = 0;
         $field_post_excerpt = array('label' => 'Caption', 'input' => 'html', 'html' => wp_caption_input_textarea($edit_post));
         foreach ($form_fields as $form_key => $form_values) {
             if ($number_field == 1 && is_array($field_post_excerpt)) {
                 $new_form_fields['post_excerpt'] = $field_post_excerpt;
                 $field_post_excerpt = '';
             }
             $new_form_fields[$form_key] = $form_values;
             $number_field++;
         }
         $form_fields = $new_form_fields;
     }
     $exclude_image = (int) get_post_meta($post->ID, '_wpsc_exclude_image', true);
     $label = __('Exclude image', 'wpsc_dgallery');
     $html = '<input type="checkbox" ' . checked($exclude_image, 1, false) . ' name="attachments[' . $post->ID . '][wpsc_exclude_image]" id="attachments[' . $post->ID . '][wpsc_exclude_image]" />';
     $form_fields['wpsc_exclude_image'] = array('label' => $label, 'input' => 'html', 'html' => $html, 'value' => '', 'helps' => __('Enabling this option will hide it from the product page image gallery. If assigned to variations below the image will show when option is selected. (Show Product Variations in Gallery is a', 'wpsc_dgallery') . ' <a href="http://a3rev.com/shop/wp-e-commerce-dynamic-gallery/" target="_blank">' . __('Pro Version', 'wpsc_dgallery') . '</a> ' . __('only feature', 'wpsc_dgallery') . ')');
     return $form_fields;
 }
开发者ID:pankajsinghjarial,项目名称:SYLC,代码行数:29,代码来源:class-wpsc-dynamic-gallery-hook-filter.php

示例3: maybe_set_preview

 /**
  * @param array $posts
  * @return array
  */
 public static function maybe_set_preview($posts)
 {
     if (is_array($posts) && isset($_GET['preview']) && $_GET['preview'] && isset($_GET['preview_id']) && $_GET['preview_id'] && current_user_can('edit_post', $_GET['preview_id'])) {
         // No need to check the nonce, that already happened in _show_post_preview on init
         $preview_id = $_GET['preview_id'];
         foreach ($posts as &$post) {
             if (is_object($post) && $post->ID == $preview_id) {
                 // Based on _set_preview( $post ), but adds import_custom
                 $preview = wp_get_post_autosave($preview_id);
                 if (is_object($preview)) {
                     $preview = sanitize_post($preview);
                     $post->post_content = $preview->post_content;
                     $post->post_title = $preview->post_title;
                     $post->post_excerpt = $preview->post_excerpt;
                     $post->import_custom($preview_id);
                     add_filter('get_the_terms', '_wp_preview_terms_filter', 10, 3);
                 }
             }
         }
     }
     return $posts;
 }
开发者ID:jarednova,项目名称:timber,代码行数:26,代码来源:PostCollection.php

示例4: wp_insert_attachment

/**
 * wp_insert_attachment() - Insert an attachment
 *
 * {@internal Missing Long Description}}
 *
 * @package WordPress
 * @subpackage Post
 * @since 2.0
 *
 * @uses $wpdb
 * @uses $user_ID
 *
 * @param object $object attachment object
 * @param string $file filename
 * @param int $post_parent parent post ID
 * @return int {@internal Missing Description}}
 */
function wp_insert_attachment($object, $file = false, $parent = 0)
{
    global $wpdb, $user_ID;
    $defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_ID, 'ping_status' => get_option('default_ping_status'), 'post_parent' => 0, 'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_password' => '', 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '');
    $object = wp_parse_args($object, $defaults);
    if (!empty($parent)) {
        $object['post_parent'] = $parent;
    }
    $object = sanitize_post($object, 'db');
    // export array as variables
    extract($object, EXTR_SKIP);
    // Make sure we set a valid category
    if (0 == count($post_category) || !is_array($post_category)) {
        $post_category = array(get_option('default_category'));
    }
    if (empty($post_author)) {
        $post_author = $user_ID;
    }
    $post_type = 'attachment';
    $post_status = 'inherit';
    // Are we updating or creating?
    $update = false;
    if (!empty($ID)) {
        $update = true;
        $post_ID = (int) $ID;
    }
    // Create a valid post name.
    if (empty($post_name)) {
        $post_name = sanitize_title($post_title);
    } else {
        $post_name = sanitize_title($post_name);
    }
    // expected_slashed ($post_name)
    $post_name_check = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM {$wpdb->posts} WHERE post_name = '{$post_name}' AND post_status = 'inherit' AND ID != %d LIMIT 1", $post_ID));
    if ($post_name_check) {
        $suffix = 2;
        while ($post_name_check) {
            $alt_post_name = $post_name . "-{$suffix}";
            // expected_slashed ($alt_post_name, $post_name)
            $post_name_check = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM {$wpdb->posts} WHERE post_name = '{$alt_post_name}' AND post_status = 'inherit' AND ID != %d AND post_parent = %d LIMIT 1", $post_ID, $post_parent));
            $suffix++;
        }
        $post_name = $alt_post_name;
    }
    if (empty($post_date)) {
        $post_date = current_time('mysql');
    }
    if (empty($post_date_gmt)) {
        $post_date_gmt = current_time('mysql', 1);
    }
    if (empty($post_modified)) {
        $post_modified = $post_date;
    }
    if (empty($post_modified_gmt)) {
        $post_modified_gmt = $post_date_gmt;
    }
    if (empty($comment_status)) {
        if ($update) {
            $comment_status = 'closed';
        } else {
            $comment_status = get_option('default_comment_status');
        }
    }
    if (empty($ping_status)) {
        $ping_status = get_option('default_ping_status');
    }
    if (isset($to_ping)) {
        $to_ping = preg_replace('|\\s+|', "\n", $to_ping);
    } else {
        $to_ping = '';
    }
    if (isset($post_parent)) {
        $post_parent = (int) $post_parent;
    } else {
        $post_parent = 0;
    }
    if (isset($menu_order)) {
        $menu_order = (int) $menu_order;
    } else {
        $menu_order = 0;
    }
    if (!isset($post_password)) {
        $post_password = '';
//.........这里部分代码省略.........
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:101,代码来源:post.php

示例5: do_action_ref_array


//.........这里部分代码省略.........
         $this->found_posts = apply_filters_ref_array('found_posts', array($this->found_posts, &$this));
         $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']);
     }
     // Check post status to determine if post should be displayed.
     if (!empty($this->posts) && ($this->is_single || $this->is_page)) {
         $status = get_post_status($this->posts[0]);
         $post_status_obj = get_post_status_object($status);
         //$type = get_post_type($this->posts[0]);
         if (!$post_status_obj->public) {
             if (!is_user_logged_in()) {
                 // User must be logged in to view unpublished posts.
                 $this->posts = array();
             } else {
                 if ($post_status_obj->protected) {
                     // User must have edit permissions on the draft to preview.
                     if (!current_user_can($edit_cap, $this->posts[0]->ID)) {
                         $this->posts = array();
                     } else {
                         $this->is_preview = true;
                         if ('future' != $status) {
                             $this->posts[0]->post_date = current_time('mysql');
                         }
                     }
                 } elseif ($post_status_obj->private) {
                     if (!current_user_can($read_cap, $this->posts[0]->ID)) {
                         $this->posts = array();
                     }
                 } else {
                     $this->posts = array();
                 }
             }
         }
         if ($this->is_preview && current_user_can($edit_cap, $this->posts[0]->ID)) {
             $this->posts[0] = apply_filters_ref_array('the_preview', array($this->posts[0], &$this));
         }
     }
     // Put sticky posts at the top of the posts array
     $sticky_posts = get_option('sticky_posts');
     if ($this->is_home && $page <= 1 && is_array($sticky_posts) && !empty($sticky_posts) && !$q['caller_get_posts']) {
         $num_posts = count($this->posts);
         $sticky_offset = 0;
         // Loop over posts and relocate stickies to the front.
         for ($i = 0; $i < $num_posts; $i++) {
             if (in_array($this->posts[$i]->ID, $sticky_posts)) {
                 $sticky_post = $this->posts[$i];
                 // Remove sticky from current position
                 array_splice($this->posts, $i, 1);
                 // Move to front, after other stickies
                 array_splice($this->posts, $sticky_offset, 0, array($sticky_post));
                 // Increment the sticky offset.  The next sticky will be placed at this offset.
                 $sticky_offset++;
                 // Remove post from sticky posts array
                 $offset = array_search($sticky_post->ID, $sticky_posts);
                 unset($sticky_posts[$offset]);
             }
         }
         // If any posts have been excluded specifically, Ignore those that are sticky.
         if (!empty($sticky_posts) && !empty($q['post__not_in'])) {
             $sticky_posts = array_diff($sticky_posts, $q['post__not_in']);
         }
         // Fetch sticky posts that weren't in the query results
         if (!empty($sticky_posts)) {
             $stickies__in = implode(',', array_map('absint', $sticky_posts));
             // honor post type(s) if not set to any
             $stickies_where = '';
             if ('any' != $post_type && '' != $post_type) {
                 if (is_array($post_type)) {
                     $post_types = join("', '", $post_type);
                 } else {
                     $post_types = $post_type;
                 }
                 $stickies_where = "AND {$wpdb->posts}.post_type IN ('" . $post_types . "')";
             }
             $stickies = $wpdb->get_results("SELECT * FROM {$wpdb->posts} WHERE {$wpdb->posts}.ID IN ({$stickies__in}) {$stickies_where}");
             foreach ($stickies as $sticky_post) {
                 // Ignore sticky posts the current user cannot read or are not published.
                 if ('publish' != $sticky_post->post_status) {
                     continue;
                 }
                 array_splice($this->posts, $sticky_offset, 0, array($sticky_post));
                 $sticky_offset++;
             }
         }
     }
     if (!$q['suppress_filters']) {
         $this->posts = apply_filters_ref_array('the_posts', array($this->posts, &$this));
     }
     $this->post_count = count($this->posts);
     // Sanitize before caching so it'll only get done once
     for ($i = 0; $i < $this->post_count; $i++) {
         $this->posts[$i] = sanitize_post($this->posts[$i], 'raw');
     }
     if ($q['cache_results']) {
         update_post_caches($this->posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache']);
     }
     if ($this->post_count > 0) {
         $this->post = $this->posts[0];
     }
     return $this->posts;
 }
开发者ID:owaismeo,项目名称:wordpress-10,代码行数:101,代码来源:query.php

示例6: save_job

 public function save_job($job_id, WP_Post $job)
 {
     $bbl_post_public = Babble::get('post_public');
     $bbl_taxonomies = Babble::get('taxonomies');
     if ($this->no_recursion) {
         return;
     }
     if ('bbl_job' != $job->post_type) {
         return;
     }
     $edit_post_nonce = isset($_POST['_bbl_translation_edit_post']) ? $_POST['_bbl_translation_edit_post'] : false;
     $edit_terms_nonce = isset($_POST['_bbl_translation_edit_terms']) ? $_POST['_bbl_translation_edit_terms'] : false;
     $edit_meta_nonce = isset($_POST['_bbl_translation_edit_meta']) ? $_POST['_bbl_translation_edit_meta'] : false;
     $origin_post_nonce = isset($_POST['_bbl_translation_origin_post']) ? $_POST['_bbl_translation_origin_post'] : false;
     $origin_term_nonce = isset($_POST['_bbl_translation_origin_term']) ? $_POST['_bbl_translation_origin_term'] : false;
     $lang_code_nonce = isset($_POST['_bbl_translation_lang_code']) ? $_POST['_bbl_translation_lang_code'] : false;
     if ($lang_code_nonce and wp_verify_nonce($lang_code_nonce, "bbl_translation_lang_code_{$job->ID}")) {
         wp_set_object_terms($job->ID, stripslashes(sanitize_text_field($_POST['bbl_lang_code'])), 'bbl_job_language', false);
     }
     $language = get_the_terms($job, 'bbl_job_language');
     if (empty($language)) {
         return false;
     } else {
         $lang_code = reset($language)->name;
     }
     $objects = $this->get_job_objects($job);
     if ($origin_post_nonce and wp_verify_nonce($origin_post_nonce, "bbl_translation_origin_post_{$job->ID}")) {
         if ($origin_post = get_post(absint($_POST['bbl_origin_post']))) {
             add_post_meta($job->ID, 'bbl_job_post', "{$origin_post->post_type}|{$origin_post->ID}", true);
             foreach ($this->get_post_terms_to_translate($origin_post, $lang_code) as $taxo => $terms) {
                 foreach ($terms as $term_id => $term) {
                     add_post_meta($job->ID, 'bbl_job_term', "{$taxo}|{$term_id}", false);
                 }
             }
             foreach ($this->get_post_meta_to_translate($origin_post, $lang_code) as $key => $field) {
                 add_post_meta($job->ID, 'bbl_job_meta', $key, false);
             }
         }
         # @TODO else wp_die()?
     }
     # @TODO not implemented:
     if ($origin_term_nonce and wp_verify_nonce($origin_term_nonce, "bbl_translation_origin_term_{$job->ID}")) {
         if ($origin_term = get_term(absint($_POST['bbl_origin_term']), $_POST['bbl_origin_taxonomy'])) {
             add_post_meta($job->ID, 'bbl_job_term', "{$origin_term->taxonomy}|{$origin_term->term_id}", false);
         }
         # @TODO else wp_die()?
     }
     if ($edit_post_nonce and wp_verify_nonce($edit_post_nonce, "bbl_translation_edit_post_{$job->ID}")) {
         $post_data = stripslashes_deep($_POST['bbl_translation']['post']);
         if ($post_data['post_name']) {
             $post_data['post_name'] = sanitize_title($post_data['post_name']);
         }
         $post_info = get_post_meta($job->ID, 'bbl_job_post', true);
         list($post_type, $post_id) = explode('|', $post_info);
         $post = get_post($post_id);
         update_post_meta($job->ID, "bbl_post_{$post_id}", sanitize_post($post_data, 'db'));
         if ('pending' == $job->post_status) {
             # Nothing.
         }
         if ('complete' == $job->post_status) {
             # The ability to complete a translation of a post directly
             # maps to the ability to publish the origin post.
             if (current_user_can('publish_post', $job->ID)) {
                 if (!($trans = $bbl_post_public->get_post_in_lang($post, $lang_code, false))) {
                     $trans = $bbl_post_public->initialise_translation($post, $lang_code);
                 }
                 $post_data['ID'] = $trans->ID;
                 $post_data['post_status'] = $post->post_status;
                 $this->no_recursion = true;
                 wp_update_post($post_data, true);
                 $this->no_recursion = false;
             } else {
                 # Just in case. Switch the job back to in-progress status.
                 # It would be nice to be able to use the 'publish' status because then we get the built-in
                 # publish_post cap checks, but we can't control the post status label on a per-post-type basis yet.
                 $this->no_recursion = true;
                 wp_update_post(array('ID' => $job->ID, 'post_status' => 'in-progress'), true);
                 $this->no_recursion = false;
             }
         }
         if ($edit_meta_nonce and wp_verify_nonce($edit_meta_nonce, "bbl_translation_edit_meta_{$job->ID}")) {
             $meta_data = stripslashes_deep($_POST['bbl_translation']['meta']);
             if (true === is_array($meta_data)) {
                 array_walk_recursive($meta_data, array($this, 'wp_kses_post_by_reference'));
             } else {
                 $meta_data = sanitize_text_field($meta_data);
             }
             foreach ($objects['meta'] as $meta_key => $meta_field) {
                 $value = apply_filters('bbl_meta_before_save', $meta_data[$meta_key], $job, $meta_key, $meta_field, $meta_data);
                 update_post_meta($job->ID, "bbl_meta_{$meta_key}", $value);
                 if ('complete' == $job->post_status) {
                     if (current_user_can('publish_post', $job->ID)) {
                         update_post_meta($trans->ID, $meta_key, $value);
                     }
                 }
             }
         }
     }
     if ($edit_terms_nonce and wp_verify_nonce($edit_terms_nonce, "bbl_translation_edit_terms_{$job->ID}")) {
         $terms_data = stripslashes_deep($_POST['bbl_translation']['terms']);
//.........这里部分代码省略.........
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:101,代码来源:class-jobs.php

示例7: pmxi_insert_attachment

function pmxi_insert_attachment($object, $file = false, $parent = 0)
{
    global $wpdb;
    $user_id = get_current_user_id();
    $defaults = array('post_status' => 'inherit', 'post_type' => 'post', 'post_author' => $user_id, 'ping_status' => get_option('default_ping_status'), 'post_parent' => 0, 'post_title' => '', 'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_password' => '', 'post_content' => '', 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0, 'context' => '');
    $object = wp_parse_args($object, $defaults);
    if (!empty($parent)) {
        $object['post_parent'] = $parent;
    }
    unset($object['filter']);
    $object = sanitize_post($object, 'db');
    // export array as variables
    extract($object, EXTR_SKIP);
    if (empty($post_author)) {
        $post_author = $user_id;
    }
    $post_type = 'attachment';
    if (!in_array($post_status, array('inherit', 'private'))) {
        $post_status = 'inherit';
    }
    if (!empty($post_category)) {
        $post_category = array_filter($post_category);
    }
    // Filter out empty terms
    // Make sure we set a valid category.
    if (empty($post_category) || 0 == count($post_category) || !is_array($post_category)) {
        $post_category = array();
    }
    // Are we updating or creating?
    if (!empty($ID)) {
        $update = true;
        $post_ID = (int) $ID;
    } else {
        $update = false;
        $post_ID = 0;
    }
    // Create a valid post name.
    if (empty($post_name)) {
        $post_name = sanitize_title($post_title);
    } else {
        $post_name = sanitize_title($post_name);
    }
    // expected_slashed ($post_name)
    $post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent);
    if (empty($post_date)) {
        $post_date = current_time('mysql');
    }
    if (empty($post_date_gmt)) {
        $post_date_gmt = current_time('mysql', 1);
    }
    if (empty($post_modified)) {
        $post_modified = $post_date;
    }
    if (empty($post_modified_gmt)) {
        $post_modified_gmt = $post_date_gmt;
    }
    if (empty($comment_status)) {
        if ($update) {
            $comment_status = 'closed';
        } else {
            $comment_status = get_option('default_comment_status');
        }
    }
    if (empty($ping_status)) {
        $ping_status = get_option('default_ping_status');
    }
    if (isset($to_ping)) {
        $to_ping = preg_replace('|\\s+|', "\n", $to_ping);
    } else {
        $to_ping = '';
    }
    if (isset($post_parent)) {
        $post_parent = (int) $post_parent;
    } else {
        $post_parent = 0;
    }
    if (isset($menu_order)) {
        $menu_order = (int) $menu_order;
    } else {
        $menu_order = 0;
    }
    if (!isset($post_password)) {
        $post_password = '';
    }
    if (!isset($pinged)) {
        $pinged = '';
    }
    // expected_slashed (everything!)
    $data = compact(array('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'));
    $data = wp_unslash($data);
    if ($update) {
        $wpdb->update($wpdb->posts, $data, array('ID' => $post_ID));
    } else {
        // If there is a suggested ID, use it if not already present
        if (!empty($import_id)) {
            $import_id = (int) $import_id;
            if (!$wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE ID = %d", $import_id))) {
                $data['ID'] = $import_id;
            }
        }
//.........这里部分代码省略.........
开发者ID:thabofletcher,项目名称:tc-site,代码行数:101,代码来源:pmxi_insert_attachment.php

示例8: _set_preview

/**
 * Sets up the post object for preview based on the post autosave.
 *
 * @since 2.7.0
 * @access private
 *
 * @param WP_Post $post
 * @return WP_Post|false
 */
function _set_preview($post)
{
    if (!is_object($post)) {
        return $post;
    }
    $preview = wp_get_post_autosave($post->ID);
    if (!is_object($preview)) {
        return $post;
    }
    $preview = sanitize_post($preview);
    $post->post_content = $preview->post_content;
    $post->post_title = $preview->post_title;
    $post->post_excerpt = $preview->post_excerpt;
    add_filter('get_the_terms', '_wp_preview_terms_filter', 10, 3);
    return $post;
}
开发者ID:AndreyLanko,项目名称:perevorot-prozorro-wp,代码行数:25,代码来源:revision.php

示例9: the_posts

 function the_posts($posts)
 {
     if (!is_admin() && isset($this->settings['show_untranslated_blog_posts']) && $this->settings['show_untranslated_blog_posts'] && $this->get_current_language() != $this->get_default_language()) {
         // show untranslated posts
         global $wpdb, $wp_query;
         $default_language = $this->get_default_language();
         $current_language = $this->get_current_language();
         $debug_backtrace = $this->get_backtrace(4, true);
         //Limit to first 4 stack frames, since 3 is the highest index we use
         /** @var $custom_wp_query WP_Query */
         $custom_wp_query = isset($debug_backtrace[3]['object']) ? $debug_backtrace[3]['object'] : false;
         //exceptions
         if ($current_language == $default_language || $wp_query != $custom_wp_query || !$custom_wp_query->is_posts_page && !$custom_wp_query->is_home || $wp_query->is_singular || !empty($custom_wp_query->query_vars['category__not_in']) || !empty($custom_wp_query->query_vars['tag__not_in']) || !empty($custom_wp_query->query_vars['post__in']) || !empty($custom_wp_query->query_vars['post__not_in']) || !empty($custom_wp_query->query_vars['post_parent'])) {
             return $posts;
         }
         // get the posts in the default language instead
         $this_lang = $this->this_lang;
         $this->this_lang = $default_language;
         remove_filter('the_posts', array($this, 'the_posts'));
         $custom_wp_query->query_vars['suppress_filters'] = 0;
         if (isset($custom_wp_query->query_vars['pagename']) && !empty($custom_wp_query->query_vars['pagename'])) {
             if (isset($custom_wp_query->queried_object_id) && !empty($custom_wp_query->queried_object_id)) {
                 $page_id = $custom_wp_query->queried_object_id;
             } else {
                 // urlencode added for languages that have urlencoded post_name field value
                 $custom_wp_query->query_vars['pagename'] = urlencode($custom_wp_query->query_vars['pagename']);
                 $page_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_name='{$custom_wp_query->query_vars['pagename']}' AND post_type='page'");
             }
             if ($page_id) {
                 $tr_page_id = icl_object_id($page_id, 'page', false, $default_language);
                 if ($tr_page_id) {
                     $custom_wp_query->query_vars['pagename'] = $wpdb->get_var("SELECT post_name FROM {$wpdb->posts} WHERE ID={$tr_page_id}");
                 }
             }
         }
         // look for posts without translations
         if ($posts) {
             $pids = false;
             foreach ($posts as $p) {
                 $pids[] = $p->ID;
             }
             if ($pids) {
                 $trids = $wpdb->get_col("\r\n\t\t\t\t\t\tSELECT trid\r\n\t\t\t\t\t\tFROM {$wpdb->prefix}icl_translations\r\n\t\t\t\t\t\tWHERE element_type='post_post' AND element_id IN (" . join(',', $pids) . ") AND language_code = '" . $this_lang . "'");
                 if (!empty($trids)) {
                     $posts_not_translated = $wpdb->get_col("\r\n\t\t\t\t\t\t\tSELECT element_id, COUNT(language_code) AS c\r\n\t\t\t\t\t\t\tFROM {$wpdb->prefix}icl_translations\r\n\t\t\t\t\t\t\tWHERE trid IN (" . join(',', $trids) . ") GROUP BY trid HAVING c = 1\r\n\t\t\t\t\t\t");
                     if (!empty($posts_not_translated)) {
                         $GLOBALS['__icl_the_posts_posts_not_translated'] = $posts_not_translated;
                         add_filter('posts_where', array($this, '_posts_untranslated_extra_posts_where'), 99);
                     }
                 }
             }
         }
         //fix page for posts
         unset($custom_wp_query->query_vars['pagename']);
         unset($custom_wp_query->query_vars['page_id']);
         unset($custom_wp_query->query_vars['p']);
         $my_query = new WP_Query($custom_wp_query->query_vars);
         add_filter('the_posts', array($this, 'the_posts'));
         $this->this_lang = $this_lang;
         // create a map of the translated posts
         foreach ($posts as $post) {
             $trans_posts[$post->ID] = $post;
         }
         // loop original posts
         foreach ($my_query->posts as $k => $post) {
             // loop posts in the default language
             $trid = $this->get_element_trid($post->ID);
             $translations = $this->get_element_translations($trid);
             // get translations
             if (isset($translations[$current_language])) {
                 // if there is a translation in the current language
                 if (isset($trans_posts[$translations[$current_language]->element_id])) {
                     //check the map of translated posts
                     $my_query->posts[$k] = $trans_posts[$translations[$current_language]->element_id];
                 } else {
                     // check if the translated post exists in the database still
                     $_post = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE ID = %d AND post_status='publish' LIMIT 1", $translations[$current_language]->element_id));
                     if (!empty($_post)) {
                         $_post = sanitize_post($_post);
                         $my_query->posts[$k] = $_post;
                     } else {
                         $my_query->posts[$k]->original_language = true;
                     }
                 }
             } else {
                 $my_query->posts[$k]->original_language = true;
             }
         }
         if ($custom_wp_query == $wp_query) {
             $wp_query->max_num_pages = $my_query->max_num_pages;
         }
         $posts = $my_query->posts;
         unset($GLOBALS['__icl_the_posts_posts_not_translated']);
         remove_filter('posts_where', array($this, '_posts_untranslated_extra_posts_where'), 99);
     }
     // cache translated posts
     $this->cache_translations($posts);
     return $posts;
 }
开发者ID:pablomarsan,项目名称:iftheme-docs,代码行数:99,代码来源:sitepress.class.php

示例10: import_item

 /**
  * Create a post for an item (a class or a function).
  *
  * Anything that needs to be dealt identically for functions or methods should go in this function.
  * Anything more specific should go in either import_function() or import_class() as appropriate.
  *
  * @param array $data           Data.
  * @param int   $parent_post_id Optional; post ID of the parent (class or function) this item belongs to. Defaults to zero (no parent).
  * @param bool  $import_ignored Optional; defaults to false. If true, functions or classes marked `@ignore` will be imported.
  *                              Disabled, not remove to prevent PHP Warning
  * @param array $arg_overrides  Optional; array of parameters that override the defaults passed to wp_update_post().
  *
  * @return bool|int Post ID of this item, false if any failure.
  */
 public function import_item(array $data, $parent_post_id = 0, $import_ignored = false, array $arg_overrides = array())
 {
     /** @var \wpdb $wpdb */
     global $wpdb;
     $is_new_post = true;
     $slug = sanitize_title(str_replace('::', '-', $data['name']));
     $post_data = wp_parse_args($arg_overrides, array('post_content' => $data['doc']['long_description'], 'post_excerpt' => $data['doc']['description'], 'post_name' => $slug, 'post_parent' => (int) $parent_post_id, 'post_status' => 'publish', 'post_title' => $data['name'], 'post_type' => $this->post_type_function));
     $post_type_name_to_log = substr($post_data['post_type'], 10);
     // Don't import items marked @ignore
     if (wp_list_filter($data['doc']['tags'], array('name' => 'ignore'))) {
         $indent = $parent_post_id ? "\t\t" : "\t";
         global $wpdb;
         if ($ignore = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT ID FROM {$wpdb->posts} WHERE post_name = %s AND post_type = %s", $slug, $post_data['post_type']))) {
             $this->logger->info($indent . sprintf('Deleting @ignore-d %s "%s"', $post_type_name_to_log, $data['name']));
             foreach ($ignore as $ignore_post_id) {
                 if (wp_list_filter(get_post_meta($ignore_post_id, '_wp-parser_tags', true), array('name' => 'ignore'))) {
                     if (!wp_delete_post($ignore_post_id, true)) {
                         $this->errors[] = $indent . sprintf('Problem deleting @ignore-d post for %s "%s"', $post_type_name_to_log, $data['name']);
                     }
                 }
             }
         }
         return false;
     }
     /**
      * Filter whether to proceed with adding/updating a prospective import item.
      *
      * Returning a falsey value to the filter will short-circuit addition of the import item.
      *
      * @param bool  $display         Whether to proceed with adding/updating the import item. Default true.
      * @param array $data            Data
      * @param int   $parent_post_id  Optional; post ID of the parent (class or function) this item belongs to. Defaults to zero (no parent).
      * @param bool  $import_ignored  Optional; defaults to false. If true, functions or classes marked `@ignore` will be imported.
      * @param array $arg_overrides   Optional; array of parameters that override the defaults passed to wp_update_post().
      */
     if (!apply_filters('wp_parser_pre_import_item', true, $data, $parent_post_id, $import_ignored, $arg_overrides)) {
         return false;
     }
     // Look for an existing post for this item
     $existing_post_id = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT ID FROM {$wpdb->posts} WHERE post_name = %s AND post_type = %s ORDER BY post_date ASC", $slug, $post_data['post_type']));
     // If the file or this items is deprecated not import, if exists deleted
     if ($this->file_meta['deprecated'] || wp_list_filter($data['doc']['tags'], array('name' => 'deprecated'))) {
         if (!empty($existing_post_id)) {
             $indent = $parent_post_id ? "\t\t" : "\t";
             $this->logger->info($indent . sprintf('Deleting deprecated %s "%s"', $post_type_name_to_log, $data['name']));
             $deleted_with_error = array();
             foreach ($existing_post_id as $exists_post_id) {
                 if ($this->file_meta['deprecated'] || wp_list_filter(get_post_meta($exists_post_id, '_wp-parser_tags', true), array('name' => 'deprecated'))) {
                     if (!wp_delete_post($exists_post_id, true)) {
                         $deleted_with_error[] = $exists_post_id;
                     }
                 }
             }
             if ($deleted_with_error) {
                 $this->errors[] = $indent . sprintf('Problem deleting deprecated post for %s "%s"', $post_type_name_to_log, $data['name']);
             }
         }
         return false;
     }
     /**
      * Filter an import item's post data before it is updated or inserted.
      *
      * @param array   $post_data          Array of post data.
      * @param array   $existing_post_id   ID if the post already exists, empty otherwise.
      */
     $post_data = apply_filters('wp_parser_import_item_post_data', $post_data, $existing_post_id);
     // Insert/update the item post
     if (!empty($existing_post_id)) {
         $is_new_post = false;
         $post_id = $post_data['ID'] = (int) array_shift($existing_post_id);
         $post_needed_update = array_diff_assoc(sanitize_post($post_data, 'db'), get_post($post_id, ARRAY_A, 'db'));
         if ($existing_post_id) {
             $indent = $parent_post_id ? "\t\t" : "\t";
             $this->errors[] = $indent . sprintf('Possible Duplicate posts of the %s "%s"', $post_type_name_to_log, $data['name']);
         }
         if ($post_needed_update) {
             $post_id = wp_update_post(wp_slash($post_data), true);
         }
     } else {
         $post_id = wp_insert_post(wp_slash($post_data), true);
     }
     $anything_updated = array();
     if (!$post_id || is_wp_error($post_id)) {
         $indent = $parent_post_id ? "\t\t" : "\t";
         $this->errors[] = $indent . sprintf('Problem inserting/updating post for %s "%s"', $post_type_name_to_log, $data['name']);
         return false;
//.........这里部分代码省略.........
开发者ID:23r9i0,项目名称:sublime,代码行数:101,代码来源:class-importer.php

示例11: import_item

 /**
  * Create a post for an item (a class or a function).
  *
  * Anything that needs to be dealt identically for functions or methods should go in this function.
  * Anything more specific should go in either import_function() or import_class() as appropriate.
  *
  * @param array $data           Data.
  * @param int   $parent_post_id Optional; post ID of the parent (class or function) this item belongs to. Defaults to zero (no parent).
  * @param bool  $import_ignored Optional; defaults to false. If true, functions or classes marked `@ignore` will be imported.
  * @param array $arg_overrides  Optional; array of parameters that override the defaults passed to wp_update_post().
  *
  * @return bool|int Post ID of this item, false if any failure.
  */
 public function import_item(array $data, $parent_post_id = 0, $import_ignored = false, array $arg_overrides = array())
 {
     /** @var \wpdb $wpdb */
     global $wpdb;
     $is_new_post = true;
     $ns_name = empty($data['namespace']) || 'global' === $data['namespace'] ? $data['name'] : $data['namespace'] . '\\' . $data['name'];
     $slug = sanitize_title(str_replace('\\', '-', str_replace('::', '-', $ns_name)));
     $post_data = wp_parse_args($arg_overrides, array('post_content' => $data['doc']['long_description'], 'post_excerpt' => $data['doc']['description'], 'post_name' => $slug, 'post_parent' => (int) $parent_post_id, 'post_status' => 'publish', 'post_title' => $data['name'], 'post_type' => $this->post_type_function));
     // Don't import items marked `@ignore` unless explicitly requested. See https://github.com/WordPress/phpdoc-parser/issues/16
     if (!$import_ignored && wp_list_filter($data['doc']['tags'], array('name' => 'ignore'))) {
         switch ($post_data['post_type']) {
             case $this->post_type_class:
                 $this->logger->info("\t" . sprintf('Skipped importing @ignore-d class "%1$s"', $ns_name));
                 break;
             case $this->post_type_method:
                 $this->logger->info("\t\t" . sprintf('Skipped importing @ignore-d method "%1$s"', $ns_name));
                 break;
             case $this->post_type_hook:
                 $indent = $parent_post_id ? "\t\t" : "\t";
                 $this->logger->info($indent . sprintf('Skipped importing @ignore-d hook "%1$s"', $ns_name));
                 break;
             default:
                 $this->logger->info("\t" . sprintf('Skipped importing @ignore-d function "%1$s"', $ns_name));
         }
         return false;
     }
     if (wp_list_filter($data['doc']['tags'], array('name' => 'ignore'))) {
         return false;
     }
     /**
      * Filter whether to proceed with adding/updating a prospective import item.
      *
      * Returning a falsey value to the filter will short-circuit addition of the import item.
      *
      * @param bool  $display         Whether to proceed with adding/updating the import item. Default true.
      * @param array $data            Data
      * @param int   $parent_post_id  Optional; post ID of the parent (class or function) this item belongs to. Defaults to zero (no parent).
      * @param bool  $import_ignored Optional; defaults to false. If true, functions or classes marked `@ignore` will be imported.
      * @param array $arg_overrides   Optional; array of parameters that override the defaults passed to wp_update_post().
      */
     if (!apply_filters('wp_parser_pre_import_item', true, $data, $parent_post_id, $import_ignored, $arg_overrides)) {
         return false;
     }
     // Look for an existing post for this item
     $existing_post_id = $wpdb->get_var($q = $wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_name = %s AND post_type = %s AND post_parent = %d LIMIT 1", $slug, $post_data['post_type'], (int) $parent_post_id));
     /**
      * Filter an import item's post data before it is updated or inserted.
      *
      * @param array       $post_data        Array of post data.
      * @param string|null $existing_post_id ID if the post already exists, null otherwise.
      */
     $post_data = apply_filters('wp_parser_import_item_post_data', $post_data, $existing_post_id);
     // Insert/update the item post
     if (!empty($existing_post_id)) {
         $is_new_post = false;
         $post_id = $post_data['ID'] = (int) $existing_post_id;
         $post_needed_update = array_diff_assoc(sanitize_post($post_data, 'db'), get_post($existing_post_id, ARRAY_A, 'db'));
         if ($post_needed_update) {
             $post_id = wp_update_post(wp_slash($post_data), true);
         }
     } else {
         $post_id = wp_insert_post(wp_slash($post_data), true);
     }
     $anything_updated = array();
     if (!$post_id || is_wp_error($post_id)) {
         switch ($post_data['post_type']) {
             case $this->post_type_class:
                 $this->errors[] = "\t" . sprintf('Problem inserting/updating post for class "%1$s"', $ns_name, $post_id->get_error_message());
                 break;
             case $this->post_type_method:
                 $this->errors[] = "\t\t" . sprintf('Problem inserting/updating post for method "%1$s"', $ns_name, $post_id->get_error_message());
                 break;
             case $this->post_type_hook:
                 $indent = $parent_post_id ? "\t\t" : "\t";
                 $this->errors[] = $indent . sprintf('Problem inserting/updating post for hook "%1$s"', $ns_name, $post_id->get_error_message());
                 break;
             default:
                 $this->errors[] = "\t" . sprintf('Problem inserting/updating post for function "%1$s"', $ns_name, $post_id->get_error_message());
         }
         return false;
     }
     $namespaces = !empty($data['namespace']) ? explode('\\', $data['namespace']) : array();
     $this->_set_namespaces($post_id, $namespaces);
     // If the item has @since markup, assign the taxonomy
     $since_versions = wp_list_filter($data['doc']['tags'], array('name' => 'since'));
     if (!empty($since_versions)) {
         // Loop through all @since versions.
//.........这里部分代码省略.........
开发者ID:lkwdwrd,项目名称:phpdoc-parser,代码行数:101,代码来源:class-importer.php

示例12: get_recent_pages

 public static function get_recent_pages($orders, $pagination, $allow_autodrafts = false)
 {
     global $wpdb;
     if (!array_key_exists('date', $orders)) {
         $orders['date'] = 'DESC';
     }
     $sql_autodrafts = " AND post_status != 'auto-draft' ";
     if ($allow_autodrafts) {
         $sql_autodrafts = '';
     }
     $total_items = $wpdb->get_var("SELECT count(*) FROM {$wpdb->posts} WHERE post_type = 'page' {$sql_autodrafts}");
     $current_page = !empty($pagination['current_page']) ? $pagination['current_page'] : 1;
     $nb_per_page = !empty($pagination['nb_per_page']) ? $pagination['nb_per_page'] : 10;
     $total_pages = $nb_per_page > 0 ? ceil($total_items / $nb_per_page) : 0;
     if ($current_page > $total_pages) {
         $current_page = $total_pages;
     }
     $offset = $nb_per_page * ($current_page - 1);
     $orderby_data = self::get_sql_orderby_data($orders);
     $join = $orderby_data['join'];
     $order_by = $orderby_data['order_by'];
     //Retrieve Recent page, then cache retrieved data:
     //Cannot use get_pages() here because we want to filter/order by Templates,
     //marked page infos etc... but we're forgiven if we cache the data after, no?
     $sql = "SELECT * FROM {$wpdb->posts} AS p \r\n\t\t\t\t\t\t {$join}\r\n\t\t\t\t\t\t WHERE post_type = 'page' \r\n\t\t\t\t\t\t {$sql_autodrafts}\r\n\t\t\t\t\t\t {$order_by} \r\n\t\t\t\t\t\t LIMIT {$offset}, {$nb_per_page}\r\n\t\t\t\t\t\t ";
     $pages = $wpdb->get_results($sql);
     //Inspired from WP get_pages() :
     //Sanitize before caching so it'll only get done once
     $num_pages = count($pages);
     for ($i = 0; $i < $num_pages; $i++) {
         $pages[$i] = sanitize_post($pages[$i], 'raw');
     }
     // Update cache.
     update_post_cache($pages);
     return array('pages' => $pages, 'pagination' => compact('current_page', 'nb_per_page', 'total_items', 'total_pages'));
 }
开发者ID:erkmen,项目名称:wpstartersetup,代码行数:36,代码来源:tree_data.php

示例13: post


//.........这里部分代码省略.........
                                     $modifypost = true;
                                     $content .= "<p><a href=\"" . get_permalink($attachment_ID) . "\"><img src=\"{$thumburi}\" alt=\"" . $theirfiles[$i]['name'] . " (" . tdomf_filesize_format(filesize($newpath)) . ")\" /></a></p>";
                                 }
                                 // add thumbnail link directly to file
                                 if ($options['thumb-a']) {
                                     $modifypost = true;
                                     $content .= "<p><a href=\"{$uri}\"><img src=\"{$thumburi}\" alt=\"" . $theirfiles[$i]['name'] . " (" . tdomf_filesize_format(filesize($newpath)) . ")\" /></a></p>";
                                 }
                             } else {
                                 tdomf_log_message("Could not find thumbnail {$thumbpath}!", TDOMF_LOG_ERROR);
                             }
                         }
                     } else {
                         // In Wordpress 2.5 the attachment data structure is changed,
                         // it only generates a thumbnail if it needs to...
                         // Medium sized images can also sometimes be created, make a note of it
                         //
                         if (isset($attachment_metadata['sizes']['medium'])) {
                             $medpath = $postdir . DIRECTORY_SEPARATOR . $attachment_metadata['sizes']['medium']['file'];
                             if (file_exists($medpath)) {
                                 $this->addToFileList($post_ID, $postfix, $medpath);
                             }
                         }
                         if (isset($attachment_metadata['sizes']['thumbnail'])) {
                             $thumbpath = $postdir . DIRECTORY_SEPARATOR . $attachment_metadata['sizes']['thumbnail']['file'];
                             if (file_exists($thumbpath)) {
                                 add_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_THUMB . $j, $thumbpath, true);
                                 // add to list
                                 //
                                 $this->addToFileList($post_ID, $postfix, $thumbpath);
                                 // Use direct links *or* wrapper
                                 //
                                 if ($options['nohandler'] && trim($options['url']) != "") {
                                     $thumburi = $options['url'] . "/{$post_ID}/" . $attachment_metadata['sizes']['thumbnail']['file'];
                                 } else {
                                     $thumburi = get_bloginfo('wpurl') . '/?tdomf_download=' . $post_ID . '&id=' . $j . '&thumb';
                                 }
                                 // store a copy of the thumb uri
                                 add_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_THUMBURI . $j, $thumburi, true);
                                 // add thumbnail link to attachment page
                                 if ($options['attach-thumb-a']) {
                                     $modifypost = true;
                                     $content .= "<p><a href=\"" . get_permalink($attachment_ID) . "\"><img src=\"{$thumburi}\" alt=\"" . $theirfiles[$i]['name'] . " (" . tdomf_filesize_format(filesize($newpath)) . ")\" /></a></p>";
                                 }
                                 // add thumbnail link directly to file
                                 if ($options['thumb-a']) {
                                     $modifypost = true;
                                     $content .= "<p><a href=\"{$uri}\"><img src=\"{$thumburi}\" alt=\"" . $theirfiles[$i]['name'] . " (" . tdomf_filesize_format(filesize($newpath)) . ")\" /></a></p>";
                                 }
                             } else {
                                 tdomf_log_message("Could not find thumbnail {$thumbpath}!", TDOMF_LOG_ERROR);
                             }
                         } else {
                             if (wp_attachment_is_image($attachment_ID) && ($options['attach-thumb-a'] || $options['thumb-a'])) {
                                 // Thumbnail not generated automatically, this means that the image
                                 // is smaller than a thumbnail => use as thumbnail
                                 tdomf_log_message("No thumbnail created => image is too small. Use image as thumbnail.", TDOMF_LOG_ERROR);
                                 $modifypost = true;
                                 $sizeit = "";
                                 $h = get_option("thumbnail_size_h");
                                 $w = get_option("thumbnail_size_w");
                                 if ($attachment_metadata['height'] > $h || $attachment_metadata['width'] > $w) {
                                     if ($attachment_metadata['height'] > $attachment_metadata['width']) {
                                         $sizeit = " height=\"{$h}px\" ";
                                     } else {
                                         $sizeit = " height=\"{$w}px\" ";
                                     }
                                 }
                                 // store a the uri as a the thumburi
                                 add_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_THUMBURI . $j, $uri, true);
                                 // add thumbnail link to attachment page
                                 if ($options['attach-thumb-a']) {
                                     $content .= "<p><a href=\"" . get_permalink($attachment_ID) . "\"><img src=\"{$uri}\" {$sizeit} alt=\"" . $theirfiles[$i]['name'] . " (" . tdomf_filesize_format(filesize($newpath)) . ")\" /></a></p>";
                                 }
                                 // add just the image (no point linking to thumbnail)
                                 if ($options['thumb-a']) {
                                     $content .= "<p><img src=\"{$uri}\" {$sizeit} alt=\"" . $theirfiles[$i]['name'] . " (" . tdomf_filesize_format(filesize($newpath)) . ")\" /></p>";
                                 }
                             }
                         }
                     }
                     // Add meta data
                     //
                     wp_update_attachment_metadata($attachment_ID, $attachment_metadata);
                     tdomf_log_message("Added " . $theirfiles[$i]['name'] . " as attachment");
                 }
             } else {
                 tdomf_log_message("Failed to move " . $theirfiles[$i]['name'] . "!", TDOMF_LOG_ERROR);
                 return __("Failed to move uploaded file from temporary location!", "tdomf");
             }
         }
     }
     if ($modifypost) {
         tdomf_log_message("Attempting to update post with file upload info");
         $post = array("ID" => $post_ID, "post_content" => $content, "post_title" => $title, "post_name" => sanitize_title($title));
         sanitize_post($post, "db");
         wp_update_post($post);
     }
     return NULL;
 }
开发者ID:TheReaCompany,项目名称:pooplog,代码行数:101,代码来源:tdomf-upload-functions.php

示例14: ym_post

<?php

global $ym_formgen;
$email_id = ym_post('email_id');
$defaults = array('email_subject' => '', 'email_content' => '');
$postarr = wp_parse_args($_POST, $defaults);
$postarr = sanitize_post($postarr, 'db');
// export array as variables
extract($postarr, EXTR_SKIP);
$ym_month_email_date = ym_post('ym_month_email_date');
$ym_date_email_date = ym_post('ym_date_email_date');
$ym_year_email_date = ym_post('ym_year_email_date');
$ym_hour_email_date = ym_post('ym_hour_email_date');
$ym_min_email_date = ym_post('ym_min_email_date');
$recipient_list = ym_post('recipient_list');
do_action('mailmanager_broadcast_precontent');
if ($ym_month_email_date) {
    $time = array($ym_month_email_date, $ym_date_email_date, $ym_year_email_date, $ym_hour_email_date, $ym_min_email_date);
} else {
    $time = time();
}
if (!$email_id && (!$email_content || !$email_subject) && $_POST) {
    ym_box_top(__('Broadcast Error', 'ym_mailmanager'));
    echo '<p>' . __('You must provide a Email to send or fill in the a email content and subject', 'ym_mailmanager') . '</p>';
    ym_box_bottom();
} else {
    if (ym_post('submit')) {
        // swotch the time back to unix time
        if (is_array($time)) {
            $value = array();
            $value['month'] = array_shift($time);
开发者ID:AdultStack,项目名称:ap-members,代码行数:31,代码来源:broadcast.php

示例15: get_post

function get_post($post = null, $output = OBJECT, $filter = 'raw')
{
    if (empty($post) && isset($GLOBALS['post'])) {
        $post = $GLOBALS['post'];
    }
    // pr($post);die;
    if ($post instanceof WP_Post) {
        $_post = $post;
    } elseif (is_object($post)) {
        if (empty($post->filter)) {
            $_post = sanitize_post($post, 'raw');
            $_post = new WP_Post($_post);
        } elseif ('raw' == $post->filter) {
            $_post = new WP_Post($post);
        } else {
            $_post = WP_Post::get_instance($post->ID);
        }
    } else {
        $_post = WP_Post::get_instance($post);
    }
    // pr($_post);die;
    if (!$_post) {
        return null;
    }
    $_post = $_post->filter($filter);
    if ($output == ARRAY_A) {
        return $_post->to_array();
    } elseif ($output == ARRAY_N) {
        return array_values($_post->to_array());
    }
    return $_post;
}
开发者ID:AppItNetwork,项目名称:yii2-wordpress-themes,代码行数:32,代码来源:post.php


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