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


PHP wp_set_post_tags函数代码示例

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


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

示例1: tweetimport_import_twitter_feed

function tweetimport_import_twitter_feed($twitter_account)
{
  require_once (ABSPATH . WPINC . '/class-feed.php');

  $feed = new SimplePie();

  $account_parts = explode ('/', $twitter_account['twitter_name'], 2);



  if ($twitter_account['account_type'] == 1): //Account is Favorites
    $feed->set_feed_url(str_replace('#=#USER#=#', $account_parts[0], TWEETIMPORT_API_FAVORITES_URL));
  elseif ($twitter_account['account_type'] == 0 && count($account_parts) == 1): //User timeline
      $feed->set_feed_url(str_replace('#=#USER#=#', $account_parts[0], TWEETIMPORT_API_USER_TIMELINE_URL));
  elseif ($twitter_account['account_type'] == 2 && count($account_parts) == 2): //Account is list
      $feed_url = str_replace('#=#USER#=#', $account_parts[0], TWEETIMPORT_API_LIST_URL);
      $feed_url = str_replace('#=#LIST#=#', $account_parts[1], $feed_url);
      $feed->set_feed_url($feed_url);
  else :
      return '<strong>ERROR: Account information not correct. Account type wrong?</strong>';
  endif;

  $feed->set_useragent('Tweet Import http://skinju.com/wordpress/tweetimport');
  $feed->set_cache_class('WP_Feed_Cache');
  $feed->set_file_class('WP_SimplePie_File');
  $feed->enable_cache(true);
  $feed->set_cache_duration (apply_filters('tweetimport_cache_duration', 880));
  $feed->enable_order_by_date(false);
  $feed->init();
  $feed->handle_content_type();

  if ($feed->error()):
   return '<strong>ERROR: Feed Reading Error.</strong>';
  endif;

  $rss_items = $feed->get_items();

  $imported_count = 0;
  foreach ($rss_items as $item)
  {
    $item = apply_filters ('tweetimport_tweet_before_new_post', $item); //return false to stop processing an item.
    if (!$item) continue;

    $processed_description = $item->get_description();

    //Get the twitter author from the beginning of the tweet text
    $twitter_author = trim(preg_replace("~^(\w+):(.*?)$~", "\\1", $processed_description));

    if ($twitter_account['strip_name'] == 1):
      $processed_description = preg_replace("~^(\w+):(.*?)~i", "\\2", $processed_description);
    endif;

    if ($twitter_account['names_clickable'] == 1):
      $processed_description = preg_replace("~@(\w+)~", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $processed_description);
      $processed_description = preg_replace("~^(\w+):~", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>:", $processed_description);
    endif;

    if ($twitter_account['hashtags_clickable'] == 1):
      if ($twitter_account['hashtags_clickable_twitter'] == 1):
          $processed_description = preg_replace("/#(\w+)/", "<a href=\"http://search.twitter.com/search?q=\\1\" target=\"_blank\">#\\1</a>", $processed_description);
      else:
        $processed_description = preg_replace("/#(\w+)/", "<a href=\"" . skinju_get_tag_link("\\1") . "\">#\\1</a>", $processed_description);
      endif;
    endif;

  $processed_description = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $processed_description);
  $processed_description = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $processed_description);

    $new_post = array('post_title' => trim (substr (preg_replace("~{$account_parts[0]}: ~i", "", $item->get_title()), 0, 25) . '...'),
                      'post_content' => trim ($processed_description),
                      'post_date' => $item->get_date('Y-m-d H:i:s'),
                      'post_author' => $twitter_account['author'],
                      'post_category' => array($twitter_account['category']),
                      'post_status' => 'publish');

    $new_post = apply_filters('tweetimport_new_post_before_create', $new_post); // Offer the chance to manipulate new post data. return false to skip
    if (!$new_post) continue;
    $new_post_id = wp_insert_post($new_post);

    $imported_count++;

    add_post_meta ($new_post_id, 'tweetimport_twitter_author', $twitter_author, true); 
    add_post_meta ($new_post_id, 'tweetimport_date_imported', date ('Y-m-d H:i:s'), true);
    add_post_meta ($new_post_id, 'tweetimport_twitter_id', $item->get_id(), true);
    add_post_meta ($new_post_id, 'tweetimport_twitter_id', $item->get_id(), true);
    add_post_meta ($new_post_id, '_tweetimport_twitter_id_hash', $item->get_id(true), true);
    add_post_meta ($new_post_id, 'tweetimport_twitter_post_uri', $item->get_link(0));
    add_post_meta ($new_post_id, 'tweetimport_author_avatar', $item->get_link(0, 'image'));

    preg_match_all ('~#([A-Za-z0-9_]+)(?=\s|\Z)~', $item->get_description(), $out);
    if ($twitter_account['add_tag']) $out[0][] = $twitter_account['add_tag'];
    wp_set_post_tags($new_post_id, implode (',', $out[0]));
  }

  return $imported_count;
}
开发者ID:robotconscience,项目名称:Robotconscience.com,代码行数:96,代码来源:tweet-import.php

示例2: custom_bulk_action


//.........这里部分代码省略.........
                         $content_post = get_post($post_id);
                         $content = strip_tags($content_post->post_content);
                         $arraytags = array();
                         if ($idioma1 === 'English') {
                             $engine = "https://api.monkeylearn.com/v2/extractors/ex_isnnZRbS/extract/";
                             $keywords = "https://api.monkeylearn.com/v2/extractors/ex_y7BPYzNG/extract/";
                             $location = "LOCATION";
                             $organization = "ORGANIZATION";
                             $person = "PERSON";
                             $other = "OTRO";
                         } elseif ($idioma1 === 'Español') {
                             $engine = "https://api.monkeylearn.com/v2/extractors/ex_Kc8uzhSi/extract/";
                             $keywords = "https://api.monkeylearn.com/v2/extractors/ex_eV2dppYE/extract/";
                             $location = "LUG";
                             $organization = "ORG";
                             $person = "PERS";
                             $other = "OTROS";
                         }
                         //ENTITIES ANALYSIS
                         if ($peopleopt || $organizationsopt || $otheropt || $placesopt) {
                             $url = $engine;
                             $result = wp_autoTAG_remoteApiCall($content, $url, $valuetoken);
                             $jsonIterator = new RecursiveIteratorIterator(new RecursiveArrayIterator(json_decode($result, true)), RecursiveIteratorIterator::SELF_FIRST);
                             $push = false;
                             foreach ($jsonIterator as $key => $val) {
                                 if (is_array($val)) {
                                     // Nothing to do here?
                                 } else {
                                     if ($peopleopt) {
                                         if ($key === 'tag' && $val === $person) {
                                             $push = true;
                                         }
                                     }
                                     if ($placesopt) {
                                         if ($key === 'tag' && $val === $location) {
                                             $push = true;
                                         }
                                     }
                                     if ($organizationsopt) {
                                         if ($key === 'tag' && $val === $organization) {
                                             $push = true;
                                         }
                                     }
                                     if ($otheropt) {
                                         if ($key === 'tag' && $val === $other) {
                                             $push = true;
                                         }
                                     }
                                     if ($key === 'entity' && $push == true) {
                                         $entity = $val;
                                         array_push($arraytags, $entity);
                                         $push = false;
                                     }
                                 }
                             }
                         }
                         // RELEVANT KEYWORDS ANALYSIS
                         if ($keywordsopt) {
                             $limite = $relevanceopt;
                             $url = $keywords;
                             $result2 = wp_autoTAG_remoteApiCall($content, $url, $valuetoken);
                             $jsonIterator = new RecursiveIteratorIterator(new RecursiveArrayIterator(json_decode($result2, TRUE)), RecursiveIteratorIterator::SELF_FIRST);
                             foreach ($jsonIterator as $key => $val) {
                                 if (is_array($val)) {
                                     // Nothing to do here?
                                 } else {
                                     // CHECK RELEVANCE
                                     if ($key === 'relevance') {
                                         if (floatval($val) > floatval($limite)) {
                                             $push = true;
                                         } else {
                                             $push = false;
                                         }
                                     }
                                     // ADD KEYWORDS TO ARRAY
                                     if ($key === 'keyword') {
                                         if ($push == true) {
                                             array_push($arraytags, $val);
                                         }
                                     }
                                 }
                             }
                         }
                         wp_set_post_tags($post_id, $arraytags);
                     }
                     if (!$this->perform_export($post_id)) {
                         wp_die(__('Error adding tags.'));
                     }
                     $tags_added++;
                 }
                 $sendback = add_query_arg(array('exported' => $tags_added, 'ids' => join(',', $post_ids)), $sendback);
                 break;
             default:
                 return;
         }
         $sendback = remove_query_arg(array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback);
         wp_redirect($sendback);
         exit;
     }
 }
开发者ID:8mikelx8,项目名称:wp_autotag,代码行数:101,代码来源:WP_autotag.php

示例3: ct_update_tags

 public function ct_update_tags($tags, $object, $field_name)
 {
     if (empty($tags) || !tags) {
         return;
     }
     return wp_set_post_tags($object->ID, $tags);
 }
开发者ID:judahnator,项目名称:WP-API-Categories-Tags,代码行数:7,代码来源:posts.class.php

示例4: wp_aatags_alts

function wp_aatags_alts($post_ID, $post_title, $post_content)
{
    $tags = get_tags(array('hide_empty' => false));
    $tagx = get_option('wp_aatags_opts');
    $number = get_option('wp_aatags_aadnumber');
    switch ($tagx) {
        case 3:
            $d = strtolower($post_title . ' ' . wp_trim_words($post_content, 333, ''));
            break;
        case 2:
            $d = strtolower($post_title . ' ' . wp_trim_words($post_content, 999, ''));
            break;
        default:
            $d = strtolower($post_title);
            break;
    }
    if ($tags) {
        $i = 0;
        foreach ($tags as $tag) {
            if (strpos($d, strtolower($tag->name)) !== false) {
                wp_set_post_tags($post_ID, $tag->name, true);
                $i++;
            }
            if ($i == $number) {
                break;
            }
        }
    }
}
开发者ID:yszar,项目名称:linuxwp,代码行数:29,代码来源:wp-autotags.php

示例5: set_tags

 /**
  * Set tags to the post.
  *
  * @param  int   $post_id Post ID.
  * @param  array $post	Post object.
  * @return none
  * @since  0.1.0
  */
 public static function set_tags($post_id, $post)
 {
     if (!is_wp_error($post_id)) {
         if (isset($post['tags_input'])) {
             wp_set_post_tags($post_id, $post['tags_input'], true);
         }
     }
 }
开发者ID:adaminfinitum,项目名称:advanced-csv-importer,代码行数:16,代码来源:Actions.php

示例6: image_keyword_tagger_add_keywords

function image_keyword_tagger_add_keywords($mid, $object_id, $meta_key, $_meta_value)
{
    if ('_wp_attachment_metadata' == $meta_key) {
        $attachment_meta = wp_get_attachment_metadata($object_id);
        if (!empty($attachment_meta['image_meta']['keywords'])) {
            wp_set_post_tags($object_id, implode(',', $attachment_meta['image_meta']['keywords']), true);
        }
    }
}
开发者ID:2ndkauboy,项目名称:image-keyword-tagger,代码行数:9,代码来源:image-keyword-tagger.php

示例7: set_tags

 public function set_tags($value, $object, $field_name)
 {
     $tags = [];
     foreach ($value as $k => $v) {
         error_log("Setting tag: {$k}");
         $tags[] = $k;
     }
     return wp_set_post_tags($object->ID, $tags);
 }
开发者ID:nabsul,项目名称:wp-linkoscope-plugin,代码行数:9,代码来源:class-linkoscope-post-meta.php

示例8: test_get_the_taxonomies

 function test_get_the_taxonomies()
 {
     $post_id = $this->factory->post->create();
     $taxes = get_the_taxonomies($post_id);
     $this->assertNotEmpty($taxes);
     $this->assertEquals(array('category'), array_keys($taxes));
     $id = $this->factory->tag->create();
     wp_set_post_tags($post_id, array($id));
     $taxes = get_the_taxonomies($post_id);
     $this->assertNotEmpty($taxes);
     $this->assertCount(2, $taxes);
     $this->assertEquals(array('category', 'post_tag'), array_keys($taxes));
 }
开发者ID:Benrajalu,项目名称:philRaj,代码行数:13,代码来源:taxonomy.php

示例9: tdomf_widget_tags_post

 function tdomf_widget_tags_post($args)
 {
     extract($args);
     $options = tdomf_widget_tags_options($tdomf_form_id);
     $tagslist = '';
     if ($options['default']) {
         $tagslist = strip_tags($options['default']);
     }
     if (isset($tags) && !empty($tags)) {
         if (!empty($tagslist)) {
             $tagslist .= ',';
         }
         $tagslist .= strip_tags($tags);
     }
     if (!empty($tagslist)) {
         # set last var to true to just append
         wp_set_post_tags($post_ID, strip_tags($tagslist), false);
     }
     return NULL;
 }
开发者ID:TheReaCompany,项目名称:pooplog,代码行数:20,代码来源:tdomf-tags-widget.php

示例10: test_empty_category__in

 /**
  * @ticket 28099
  * @group taxonomy
  */
 function test_empty_category__in()
 {
     $cat_id = $this->factory->category->create();
     $post_id = $this->factory->post->create();
     wp_set_post_categories($post_id, $cat_id);
     $q1 = get_posts(array('category__in' => array($cat_id)));
     $this->assertNotEmpty($q1);
     $q2 = get_posts(array('category__in' => array()));
     $this->assertNotEmpty($q2);
     $tag = wp_insert_term('woo', 'post_tag');
     $tag_id = $tag['term_id'];
     $slug = get_tag($tag_id)->slug;
     wp_set_post_tags($post_id, $slug);
     $q3 = get_posts(array('tag__in' => array($tag_id)));
     $this->assertNotEmpty($q3);
     $q4 = get_posts(array('tag__in' => array()));
     $this->assertNotEmpty($q4);
     $q5 = get_posts(array('tag_slug__in' => array($slug)));
     $this->assertNotEmpty($q5);
     $q6 = get_posts(array('tag_slug__in' => array()));
     $this->assertNotEmpty($q6);
 }
开发者ID:Benrajalu,项目名称:philRaj,代码行数:26,代码来源:query.php

示例11: ipin_edit

function ipin_edit()
{
    $nonce = $_POST['nonce'];
    if (!wp_verify_nonce($nonce, 'ajax-nonce')) {
        die;
    }
    do_action('ipin_before_edit_pin', $_POST);
    global $user_ID;
    $postinfo = get_post(intval($_POST['postdata_pid']), ARRAY_A);
    $user_id = $postinfo['post_author'];
    if (!(current_user_can('administrator') || current_user_can('editor') || $user_id == $user_ID)) {
        die;
    }
    //Get board info
    $board_add_new = sanitize_text_field($_POST['postdata_board_add_new']);
    $board_add_new_category = $_POST['postdata_board_add_new_category'];
    $board_parent_id = get_user_meta($user_id, '_Board Parent ID', true);
    if ($board_add_new !== '') {
        $board_children = get_term_children($board_parent_id, 'board');
        $found = '0';
        foreach ($board_children as $board_child) {
            $board_child_term = get_term_by('id', $board_child, 'board');
            if (stripslashes(htmlspecialchars($board_add_new, ENT_NOQUOTES, 'UTF-8')) == $board_child_term->name) {
                $found = '1';
                $found_board_id = $board_child_term->term_id;
                break;
            }
        }
        if ($found == '0') {
            $slug = wp_unique_term_slug($board_add_new . '__ipinboard', 'board');
            //append __ipinboard to solve slug conflict with category and 0 in title
            if ($board_add_new_category == '-1') {
                $board_add_new_category = '1';
            }
            $new_board_id = wp_insert_term($board_add_new, 'board', array('description' => $board_add_new_category, 'parent' => $board_parent_id, 'slug' => $slug));
            $postdata_board = $new_board_id['term_id'];
        } else {
            $postdata_board = $found_board_id;
        }
    } else {
        $postdata_board = $_POST['postdata_board'];
    }
    //category ID is stored in the board description field
    $category_id = get_term_by('id', $postdata_board, 'board');
    $post_id = intval($_POST['postdata_pid']);
    $edit_post = array();
    $edit_post['ID'] = $post_id;
    $edit_post['post_category'] = array($category_id->description);
    $edit_post['post_name'] = '';
    $allowed_html = array('a' => array('href' => true), 'em' => array(), 'blockquote' => array(), 'p' => array(), 'li' => array(), 'ol' => array(), 'strong' => array(), 'ul' => array());
    if (of_get_option('htmltags') != 'enable') {
        unset($allowed_html);
        $allowed_html = array();
    }
    if (of_get_option('form_title_desc') != 'separate') {
        $edit_post['post_title'] = balanceTags(wp_kses($_POST['postdata_title'], $allowed_html), true);
    } else {
        $edit_post['post_title'] = sanitize_text_field($_POST['postdata_title']);
    }
    $edit_post['post_content'] = balanceTags(wp_kses($_POST['postdata_content'], $allowed_html), true);
    remove_action('save_post', 'ipin_save_post', 50, 2);
    wp_update_post($edit_post);
    wp_set_post_terms($post_id, array($postdata_board), 'board');
    //update postmeta for new post
    if ($_POST['postdata_source'] != '') {
        update_post_meta($post_id, '_Photo Source', esc_url($_POST['postdata_source']));
        update_post_meta($post_id, '_Photo Source Domain', parse_url(esc_url($_POST['postdata_source']), PHP_URL_HOST));
    } else {
        delete_post_meta($post_id, '_Photo Source');
        delete_post_meta($post_id, '_Photo Source Domain');
    }
    //add tags
    wp_set_post_tags($post_id, sanitize_text_field($_POST['postdata_tags']));
    //add price
    if ($_POST['postdata_price']) {
        if (strpos($_POST['postdata_price'], '.') !== false) {
            $_POST['postdata_price'] = number_format($_POST['postdata_price'], 2);
        }
        update_post_meta($post_id, '_Price', sanitize_text_field($_POST['postdata_price']));
    } else {
        if (get_post_meta($post_id, '_Price', true) !== '') {
            delete_post_meta($post_id, '_Price');
        }
    }
    //add new board to followers who fully follow user
    if ($new_board_id && !is_wp_error($new_board_id)) {
        $usermeta_followers_id_allboards = get_user_meta($user_id, '_Followers User ID All Boards');
        $followers_id_allboards = $usermeta_followers_id_allboards[0];
        if (!empty($followers_id_allboards)) {
            foreach ($followers_id_allboards as $followers_id_allboard) {
                $usermeta_following_board_id = get_user_meta($followers_id_allboard, '_Following Board ID');
                $following_board_id = $usermeta_following_board_id[0];
                array_unshift($following_board_id, $new_board_id['term_id']);
                update_user_meta($followers_id_allboard, '_Following Board ID', $following_board_id);
            }
        }
    }
    do_action('ipin_after_edit_pin', $post_id);
    echo get_permalink($post_id);
    exit;
//.........这里部分代码省略.........
开发者ID:leshuis,项目名称:testwp,代码行数:101,代码来源:functions.php

示例12: mass_photo_posting

function mass_photo_posting()
{
    global $box;
    // check user permission to use bulk photo posting
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.', MAX_SHORTNAME));
    }
    // get the current user object
    $current_user = wp_get_current_user();
    if (!empty($_POST) && !empty($_POST['post'])) {
        ksort($_POST['post']);
        foreach ($_POST['post'] as $key => $value) {
            $imageID = $key;
            $photos[$imageID]['id_photo'] = $imageID;
            $photos[$imageID]['post_name'] = $_POST['post_name'][$imageID];
            foreach (@$_POST['galleries'] as $key => $value) {
                if ($key == $imageID) {
                    foreach ($value as $key2 => $value2) {
                        $photos[$imageID]['gal'] .= $key2 . ",";
                    }
                }
            }
            $photos[$imageID]['photo_copyright_information_value'] = $_POST['photo_copyright_information_value'][$imageID];
            $photos[$imageID]['photo_copyright_link_value'] = $_POST['photo_copyright_link_value'][$imageID];
            $photos[$imageID]['photo_location_value'] = $_POST['photo_location_value'][$imageID];
            $photos[$imageID]['photo_date_value'] = strtotime($_POST['photo_date_value'][$imageID]);
            $photos[$imageID]['photo_item_type_value'] = $_POST['photo_item_type_value'][$imageID];
            $photos[$imageID]['photo_cropping_direction_value'] = $_POST['photo_cropping_direction_value'][$imageID];
            $photos[$imageID]['photo_lightbox_type_value'] = "Photo";
            // Get fullsize background
            if ($_POST['fullsize_background'][$imageID] == 'nofullsize') {
                $photos[$imageID]['show_post_fullsize_value'] = 'false';
            } else {
                $photos[$imageID]['show_post_fullsize_value'] = 'true';
            }
            if ($_POST['fullsize_background'][$imageID] == 'random') {
                $photos[$imageID]['show_random_fullsize_value'] = 'true';
            } else {
                if ($_POST['fullsize_background'][$imageID] == 'featured') {
                    $photos[$imageID]['show_random_fullsize_value'] = 'false';
                } else {
                    $photos[$imageID]['show_random_fullsize_value'] = 'false';
                }
            }
            if ($_POST['fullsize_background_url'][$imageID] != '') {
                $photos[$imageID]['show_page_fullsize_url_value'] = $_POST['fullsize_background_url'][$imageID];
            }
            // get the tags array
            $photos[$imageID]['post_tags'] = explode(",", trim($_POST['post_tags'][$imageID]));
        }
        if (!empty($photos)) {
            foreach ($photos as $photo) {
                $cat_array = explode(',', substr($photo['gal'], 0, -1));
                // prepare the photo post values
                $post = array('post_title' => $photo['post_name'], 'post_content' => '', 'post_status' => 'publish', 'post_author' => $current_user->ID, 'post_type' => POST_TYPE_GALLERY, 'tax_input' => array(GALLERY_TAXONOMY => $cat_array));
                // add the new post
                $post_id = wp_insert_post($post);
                // add the tags to the new post
                if (!empty($photo['post_tags'])) {
                    wp_set_post_tags($post_id, $photo['post_tags']);
                    unset($GLOBALS['tag_cache']);
                }
                // add the meta fields from $_POST values to the new post
                foreach ($photo as $index => $value) {
                    add_post_meta($post_id, MAX_SHORTNAME . '_' . $index, $photo[$index]);
                }
                // Set featured post from media attachment
                set_post_thumbnail($post_id, $photo['id_photo']);
                $image_post = array();
                $image_post['ID'] = $photo['id_photo'];
                $image_post['post_parent'] = $post_id;
                // update the post
                wp_update_post($image_post);
                // show update message
                $_saved = true;
            }
        }
    } else {
        $_saved = false;
    }
    // Get unassigned attachments
    $images_args = array('numberposts' => 99999, 'orderby' => 'post_date', 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => 0, 'post_status' => 'inherit');
    $images = get_posts($images_args);
    // Get Gallery Categories
    $gallery_args = array('type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 0, 'hierarchical' => 1, 'taxonomy' => GALLERY_TAXONOMY, 'pad_counts' => false);
    $galleries = get_categories($gallery_args);
    // get the custom post type for further use
    $post_types = max_get_custom_post_type();
    // get galleries in hirachical order
    $taxonomy_names = get_object_taxonomies('gallery');
    $hierarchical_taxonomies = array();
    $flat_taxonomies = array();
    foreach ($taxonomy_names as $taxonomy_name) {
        $taxonomy = get_taxonomy($taxonomy_name);
        if (!$taxonomy->show_ui) {
            continue;
        }
        if ($taxonomy->hierarchical) {
            $hierarchical_taxonomies[] = $taxonomy;
        } else {
//.........这里部分代码省略.........
开发者ID:erdidoqan,项目名称:fishcom,代码行数:101,代码来源:max_mass_upload.php

示例13: usp_createPublicSubmission

function usp_createPublicSubmission($title, $content, $authorName, $authorID, $authorUrl, $tags, $category, $fileData)
{
    global $usp_options, $usp_post_meta_IsSubmission, $usp_post_meta_SubmitterIp, $usp_post_meta_Submitter, $usp_post_meta_SubmitterUrl, $usp_post_meta_Image;
    $authorName = strip_tags($authorName);
    $authorUrl = strip_tags($authorUrl);
    if (isset($_SERVER['REMOTE_ADDR'])) {
        $authorIp = stripslashes(trim($_SERVER['REMOTE_ADDR']));
    }
    if (isset($_POST['user-submitted-captcha'])) {
        $captcha = stripslashes(trim($_POST['user-submitted-captcha']));
    }
    if (isset($_POST['user-submitted-verify'])) {
        $verify = stripslashes(trim($_POST['user-submitted-verify']));
    }
    if (!usp_validateTitle($title)) {
        return false;
    }
    if (!usp_validateTags($tags)) {
        return false;
    }
    if (!empty($verify)) {
        return false;
    }
    if ($usp_options['usp_captcha'] == 'show') {
        if (!usp_spam_question($captcha)) {
            return false;
        }
    }
    $postData = array();
    $postData['post_title'] = $title;
    $postData['post_content'] = $content;
    $postData['post_status'] = 'pending';
    $postData['post_author'] = $authorID;
    $numberApproved = $usp_options['number-approved'];
    if ($numberApproved < 0) {
    } elseif ($numberApproved == 0) {
        $postData['post_status'] = 'publish';
    } else {
        $posts = get_posts(array('post_status' => 'publish', 'meta_key' => $usp_post_meta_Submitter, 'meta_value' => $authorName));
        $counter = 0;
        foreach ($posts as $post) {
            $submitterUrl = get_post_meta($post->ID, $usp_post_meta_SubmitterUrl, true);
            $submitterIp = get_post_meta($post->ID, $usp_post_meta_SubmitterIp, true);
            if ($submitterUrl == $authorUrl && $submitterIp == $authorIp) {
                $counter++;
            }
        }
        if ($counter >= $numberApproved) {
            $postData['post_status'] = 'publish';
        }
    }
    $newPost = wp_insert_post($postData);
    if ($newPost) {
        wp_set_post_tags($newPost, $tags);
        wp_set_post_categories($newPost, array($category));
        if ($usp_options['usp_email_alerts'] == true) {
            $to = $usp_options['usp_email_address'];
            if ($to !== '') {
                $subject = 'New user-submitted post!';
                $message = 'Hey, there is a new user-submitted post waiting for you.';
                wp_mail($to, $subject, $message);
            }
        }
        if (!function_exists('media_handle_upload')) {
            require_once ABSPATH . '/wp-admin/includes/media.php';
            require_once ABSPATH . '/wp-admin/includes/file.php';
            require_once ABSPATH . '/wp-admin/includes/image.php';
        }
        $attachmentIds = array();
        $imageCounter = 0;
        if ($fileData !== '') {
            for ($i = 0; $i < count($fileData['name']); $i++) {
                $imageInfo = @getimagesize($fileData['tmp_name'][$i]);
                if (false === $imageInfo || !usp_imageIsRightSize($imageInfo[0], $imageInfo[1])) {
                    continue;
                }
                $key = "public-submission-attachment-{$i}";
                $_FILES[$key] = array();
                $_FILES[$key]['name'] = $fileData['name'][$i];
                $_FILES[$key]['tmp_name'] = $fileData['tmp_name'][$i];
                $_FILES[$key]['type'] = $fileData['type'][$i];
                $_FILES[$key]['error'] = $fileData['error'][$i];
                $_FILES[$key]['size'] = $fileData['size'][$i];
                $attachmentId = media_handle_upload($key, $newPost);
                if (!is_wp_error($attachmentId) && wp_attachment_is_image($attachmentId)) {
                    $attachmentIds[] = $attachmentId;
                    add_post_meta($newPost, $usp_post_meta_Image, wp_get_attachment_url($attachmentId));
                    $imageCounter++;
                } else {
                    wp_delete_attachment($attachmentId);
                }
                if ($imageCounter == $usp_options['max-images']) {
                    break;
                }
            }
        }
        if (count($attachmentIds) < $usp_options['min-images']) {
            foreach ($attachmentIds as $idToDelete) {
                wp_delete_attachment($idToDelete);
            }
//.........这里部分代码省略.........
开发者ID:klebercarvalho,项目名称:demo,代码行数:101,代码来源:user-submitted-posts-bkp.php

示例14: tag_post_image_luminance

function tag_post_image_luminance($post_id)
{
    $threshold = 128;
    $tags = array();
    // Get the image data
    $image_src = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'small');
    $image_url = $image_src[0];
    if (empty($image_url)) {
        return $post_id;
    }
    // detect luminence value
    $luminance = calculate_image_luminance($image_url);
    $tags = wp_get_post_tags($post_id, array('fields' => 'names'));
    if ($luminance < $threshold) {
        $tags[] = 'dark';
    } elseif (false !== ($key = array_search('dark', $messages))) {
        unset($tags[$key]);
    }
    // Set a tag class
    if (!empty($tags)) {
        wp_set_post_tags($post_id, $tags, true);
    }
    return $post_id;
}
开发者ID:emutavchi,项目名称:WebKitForWayland,代码行数:24,代码来源:functions.php

示例15: test_get_objects_in_term_should_return_objects_ids

 public function test_get_objects_in_term_should_return_objects_ids()
 {
     $tag_id = $this->factory->tag->create();
     $cat_id = $this->factory->category->create();
     $posts_with_tag = array();
     $posts_with_category = array();
     for ($i = 0; $i < 3; $i++) {
         $post_id = $this->factory->post->create();
         wp_set_post_tags($post_id, array($tag_id));
         $posts_with_tag[] = $post_id;
     }
     for ($i = 0; $i < 3; $i++) {
         $post_id = $this->factory->post->create();
         wp_set_post_categories($post_id, array($cat_id));
         $posts_with_category[] = $post_id;
     }
     for ($i = 0; $i < 3; $i++) {
         $this->factory->post->create();
     }
     $posts_with_terms = array_merge($posts_with_tag, $posts_with_category);
     $this->assertEquals($posts_with_tag, get_objects_in_term($tag_id, 'post_tag'));
     $this->assertEquals($posts_with_category, get_objects_in_term($cat_id, 'category'));
     $this->assertEquals($posts_with_terms, get_objects_in_term(array($tag_id, $cat_id), array('post_tag', 'category')));
     $this->assertEquals(array_reverse($posts_with_tag), get_objects_in_term($tag_id, 'post_tag', array('order' => 'desc')));
 }
开发者ID:plis197715,项目名称:wordpress-develop,代码行数:25,代码来源:taxonomy.php


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