• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_insert_post函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: create

 /**
  * Create or edit a a project
  *
  * @param null|int $project_id
  * @return int
  */
 function create($project_id = 0, $posted = array())
 {
     $is_update = $project_id ? true : false;
     $data = array('post_title' => $posted['project_name'], 'post_content' => $posted['project_description'], 'post_type' => 'project', 'post_status' => 'publish');
     if ($is_update) {
         $data['ID'] = $project_id;
         $project_id = wp_update_post($data);
     } else {
         $project_id = wp_insert_post($data);
     }
     if ($project_id) {
         $this->insert_project_user_role($posted, $project_id);
         wp_set_post_terms($project_id, $posted['project_cat'], 'project_category', false);
         if ($is_update) {
             do_action('cpm_project_update', $project_id, $data);
         } else {
             update_post_meta($project_id, '_project_archive', 'no');
             update_post_meta($project_id, '_project_active', 'yes');
             $settings = $this->settings_user_permission();
             update_post_meta($project_id, '_settings', $settings);
             do_action('cpm_project_new', $project_id, $data);
         }
     }
     return $project_id;
 }
开发者ID:javalidigital,项目名称:multipla,代码行数:31,代码来源:project.php


示例2: affiliate_wp_install

function affiliate_wp_install()
{
    // Create affiliate caps
    $roles = new Affiliate_WP_Capabilities();
    $roles->add_caps();
    $affiliate_wp_install = new stdClass();
    $affiliate_wp_install->affiliates = new Affiliate_WP_DB_Affiliates();
    $affiliate_wp_install->affiliate_meta = new Affiliate_WP_Affiliate_Meta_DB();
    $affiliate_wp_install->referrals = new Affiliate_WP_Referrals_DB();
    $affiliate_wp_install->visits = new Affiliate_WP_Visits_DB();
    $affiliate_wp_install->creatives = new Affiliate_WP_Creatives_DB();
    $affiliate_wp_install->settings = new Affiliate_WP_Settings();
    $affiliate_wp_install->affiliates->create_table();
    $affiliate_wp_install->affiliate_meta->create_table();
    $affiliate_wp_install->referrals->create_table();
    $affiliate_wp_install->visits->create_table();
    $affiliate_wp_install->creatives->create_table();
    if (!get_option('affwp_is_installed')) {
        $affiliate_area = wp_insert_post(array('post_title' => __('Affiliate Area', 'affiliate-wp'), 'post_content' => '[affiliate_area]', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page', 'comment_status' => 'closed'));
        $options = $affiliate_wp_install->settings->get_all();
        $options['affiliates_page'] = $affiliate_area;
        update_option('affwp_settings', $options);
    }
    update_option('affwp_is_installed', '1');
    update_option('affwp_version', AFFILIATEWP_VERSION);
    // Clear rewrite rules
    flush_rewrite_rules();
    // Bail if activating from network, or bulk
    if (is_network_admin() || isset($_GET['activate-multi'])) {
        return;
    }
    // Add the transient to redirect
    set_transient('_affwp_activation_redirect', true, 30);
}
开发者ID:jwondrusch,项目名称:AffiliateWP,代码行数:34,代码来源:install.php


示例3: activate

 /**
  * Activates the module
  *
  * Callback for "tml_activate_themed-profiles/themed-profiles.php" hook in method Theme_My_Login_Modules_Admin::activate_module()
  *
  * @see Theme_My_Login_Modules_Admin::activate_module()
  * @since 6.0
  * @access public
  */
 public function activate()
 {
     if (!($page_id = Theme_My_Login::get_page_id('profile'))) {
         $page_id = wp_insert_post(array('post_title' => __('Your Profile'), 'post_status' => 'publish', 'post_type' => 'page', 'post_content' => '[theme-my-login]', 'comment_status' => 'closed', 'ping_status' => 'closed'));
         update_post_meta($page_id, '_tml_action', 'profile');
     }
 }
开发者ID:mostafiz93,项目名称:PrintfScanf,代码行数:16,代码来源:themed-profiles-admin.php


示例4: wc_create_page

/**
 * Create a page and store the ID in an option.
 *
 * @access public
 * @param mixed $slug Slug for the new page
 * @param mixed $option Option name to store the page's ID
 * @param string $page_title (default: '') Title for the new page
 * @param string $page_content (default: '') Content for the new page
 * @param int $post_parent (default: 0) Parent for the new page
 * @return int page ID
 */
function wc_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0)
{
    global $wpdb;
    $option_value = get_option($option);
    if ($option_value > 0 && get_post($option_value)) {
        return -1;
    }
    $page_found = null;
    if (strlen($page_content) > 0) {
        // Search for an existing page with the specified page content (typically a shortcode)
        $page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_type='page' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
    } else {
        // Search for an existing page with the specified page slug
        $page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_type='page' AND post_name = %s LIMIT 1;", $slug));
    }
    if ($page_found) {
        if (!$option_value) {
            update_option($option, $page_found);
        }
        return $page_found;
    }
    $page_data = array('post_status' => 'publish', 'post_type' => 'page', 'post_author' => 1, 'post_name' => $slug, 'post_title' => $page_title, 'post_content' => $page_content, 'post_parent' => $post_parent, 'comment_status' => 'closed');
    $page_id = wp_insert_post($page_data);
    if ($option) {
        update_option($option, $page_id);
    }
    return $page_id;
}
开发者ID:hoonio,项目名称:PhoneAfrika,代码行数:39,代码来源:wc-admin-functions.php


示例5: setUp

 function setUp()
 {
     parent::setUp();
     $this->post_date_ts = strtotime('+1 day');
     $this->post_data = array('post_type' => 'page', 'post_title' => rand_str(), 'post_content' => rand_str(2000), 'post_excerpt' => rand_str(100), 'post_author' => $this->make_user_by_role('author'), 'post_date' => strftime("%Y-%m-%d %H:%M:%S", $this->post_date_ts));
     $this->post_id = wp_insert_post($this->post_data);
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:7,代码来源:getPage.php


示例6: generatePayment

function generatePayment($data)
{
    if (empty($data['amount'])) {
        $data['amount'] = 10;
    }
    $return['result'] = true;
    $donationOptions = get_theme_mod('donation_options');
    $paypalEmail = $donationOptions['email'];
    $donor_data['post_title'] = $data['first_name'] . ' ' . $data['last_name'];
    $donor_data['post_type'] = 'donor';
    $donor_id = wp_insert_post($donor_data);
    update_post_meta($donor_id, 'donor_email', $data['email']);
    update_post_meta($donor_id, 'donor_phone', $data['phone']);
    update_post_meta($donor_id, 'donor_address', $data['address']);
    update_post_meta($donor_id, 'donor_note', $data['notes']);
    update_post_meta($donor_id, 'donor_amount', $data['amount']);
    if (!empty($data['sign_up'])) {
        update_post_meta($donor_id, 'donor_subscribe', $data['sign_up']);
    }
    if ($data['donation_id'] == 0) {
        update_post_meta($donor_id, 'donor_donation', '');
        $returnUrl = home_url();
        $items['item_name'] = __('Site Donation', STM_DOMAIN);
    } else {
        update_post_meta($donor_id, 'donor_donation', get_the_title($data['donation_id']));
        $returnUrl = get_permalink($data['donation_id']);
        $items['item_name'] = get_the_title($data['donation_id']);
    }
    $items['item_number'] = $data['donation_id'];
    $items['amount'] = $data['amount'];
    $items = http_build_query($items);
    $return = 'https://' . paypal_url() . '/cgi-bin/webscr?cmd=_xclick&business=' . $paypalEmail . '&' . $items . '&no_shipping=1&no_note=1&currency_code=' . $donationOptions['currency'] . '&bn=PP%2dBuyNowBF&charset=UTF%2d8&invoice=' . $donor_id . '&return=' . $returnUrl . '&rm=2&notify_url=' . $returnUrl;
    return $return;
}
开发者ID:bogdandobritoiu,项目名称:aripi,代码行数:34,代码来源:donation.php


示例7: wcs3_create_new_wcs3_static_data

/**
 * Converts the old WCS2 data to the new WCS3 format.
 * 
 * @param array $data: data array as returned from wcs3_get_static_wcs2_data
 */
function wcs3_create_new_wcs3_static_data($data)
{
    foreach ($data as $post_type => $content) {
        if ($post_type == 'classes') {
            foreach ($data['classes'] as $key => $class) {
                $new_post = array('post_content' => $class['class_description'], 'post_title' => $class['class_name'], 'post_type' => 'wcs3_class', 'post_status' => 'publish');
                $data['classes'][$key]['new_id'] = wp_insert_post($new_post);
            }
        } else {
            if ($post_type == 'instructors') {
                foreach ($data['instructors'] as $key => $inst) {
                    $new_post = array('post_content' => $inst['instructor_description'], 'post_title' => $inst['instructor_name'], 'post_type' => 'wcs3_instructor', 'post_status' => 'publish');
                    $data['instructors'][$key]['new_id'] = wp_insert_post($new_post);
                }
            } else {
                if ($post_type == 'classrooms') {
                    foreach ($data['classrooms'] as $key => $loc) {
                        $new_post = array('post_content' => $loc['classroom_description'], 'post_title' => $loc['classroom_name'], 'post_type' => 'wcs3_location', 'post_status' => 'publish');
                        $data['classrooms'][$key]['new_id'] = wp_insert_post($new_post);
                    }
                }
            }
        }
    }
    // Return data with new IDs.
    return $data;
}
开发者ID:visiblefrank,项目名称:Grainne-Repo,代码行数:32,代码来源:wcs3_db.php


示例8: make_up_room

 public function make_up_room()
 {
     //$post_arr=$arr;
     $post_arr->post_title = "Test123";
     $post_arr->post_slug = "Test123";
     $post_arr->post_status = "draft";
     $post_arr->post_type = "make_up_room";
     $post = wp_insert_post($post_arr, $wp_error);
     return array('post' => $post);
     /*     global $json_api;
         if (!current_user_can('edit_posts')) {
           $json_api->error("You need to login with a user that has 'edit_posts' capacity.");
         }
         if (!$json_api->query->nonce) {
           $json_api->error("You must include a 'nonce' value to create posts. Use the `get_nonce` Core API method.");
         }
         $nonce_id = $json_api->get_nonce_id('posts', 'create_post');
         if (!wp_verify_nonce($json_api->query->nonce, $nonce_id)) {
           $json_api->error("Your 'nonce' value was incorrect. Use the 'get_nonce' API method.");
         }
         nocache_headers();
         $post = new JSON_API_Post();
         $id = $post->create($_REQUEST);
         if (empty($id)) {
           $json_api->error("Could not create post.");
         }
         return array(
           'post' => $post
         );*/
 }
开发者ID:elangovanaspire,项目名称:bimini,代码行数:30,代码来源:posts.php


示例9: lp_duplicate_post_create_duplicate

function lp_duplicate_post_create_duplicate($post, $status = '', $parent_id = '', $blank = false)
{
    $prefix = "";
    $suffix = "";
    if (!is_object($post) && is_numeric($post)) {
        $post = get_post($post);
    }
    $status = $post->post_status;
    /* We don't want to clone revisions */
    if ($post->post_type == 'revision') {
        return;
    }
    if ($post->post_type != 'attachment') {
        $prefix = "Copy of ";
        $suffix = "";
        $status = 'pending';
    }
    $new_post_author = lp_duplicate_post_get_current_user();
    if ($blank == false) {
        $new_post = array('menu_order' => $post->menu_order, 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status, 'post_author' => $new_post_author->ID, 'post_content' => $post->post_content, 'post_excerpt' => $post->post_excerpt, 'post_mime_type' => $post->post_mime_type, 'post_parent' => $new_post_parent = empty($parent_id) ? $post->post_parent : $parent_id, 'post_password' => $post->post_password, 'post_status' => $status, 'post_title' => $prefix . $post->post_title . $suffix, 'post_type' => $post->post_type);
        $new_post['post_date'] = $new_post_date = $post->post_date;
        $new_post['post_date_gmt'] = get_gmt_from_date($new_post_date);
    } else {
        $new_post = array('menu_order' => $post->menu_order, 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status, 'post_author' => $new_post_author->ID, 'post_content' => "", 'post_excerpt' => "", 'post_mime_type' => $post->post_mime_type, 'post_status' => $status, 'post_title' => __("New Blank Landing Page", 'landing-pages'), 'post_type' => $post->post_type, 'post_date' => date('Y-m-d H:i:s'));
    }
    $new_post_id = wp_insert_post($new_post);
    $meta_data = lp_get_post_meta_all($post->ID);
    foreach ($meta_data as $key => $value) {
        update_post_meta($new_post_id, $key, $value);
    }
    return $new_post_id;
}
开发者ID:devilcranx,项目名称:landing-pages,代码行数:32,代码来源:module.clone.php


示例10: manager_admin_init

 function manager_admin_init()
 {
     if (isset($_POST['key']) && $_POST['key'] == "ioamediamanager") {
         $type = $_POST['type'];
         switch ($type) {
             case "create":
                 $slider_title = $_POST['value'];
                 $slider_post = array('post_title' => $slider_title, 'post_type' => 'slider');
                 $id = wp_insert_post($slider_post);
                 echo "\r\n\r\n\t\t\t\t\t\t<div class='slider-item clearfix'>\r\n\t\t\t\t\t\t\t     \t\t<a href='" . admin_url() . "admin.php?page=ioamed&edit_id={$id}' class='edit-icon pencil-3icon- ioa-front-icon'></a>\r\n\t\t\t\t\t\t\t     \t\t<h6>" . $slider_title . "</h6>\r\n\t\t\t\t\t\t\t     \t\t<span class='shortcode'> " . __('Shortcode', 'ioa') . " [slider id='{$id}'] </span>\r\n\t\t\t\t\t\t\t\t\t\t<a href='{$id}' class='close cancel-circled-2icon- ioa-front-icon'></a>\r\n\t\t\t\t\t\t</div> \r\n\t\t\t\t\t";
                 break;
             case "update":
                 $id = $_POST['id'];
                 $ioa_options = $slides = '';
                 if (isset($_POST['options'])) {
                     $ioa_options = $_POST['options'];
                 }
                 if (isset($_POST['slides'])) {
                     $slides = $_POST['slides'];
                 }
                 wp_publish_post($id);
                 update_post_meta($id, "options", $ioa_options);
                 update_post_meta($id, "slides", $slides);
                 break;
             case "delete":
                 $id = $_POST['id'];
                 wp_delete_post($id, true);
         }
         die;
     }
 }
开发者ID:severnrescue,项目名称:web,代码行数:31,代码来源:media_manager.php


示例11: maybe_import_post

 function maybe_import_post($guid, $post_arr)
 {
     $results = array();
     if ($this->post_exists($guid)) {
         $results[] = "<p>{$guid} already exists</p>";
     } else {
         $results[] = "<p>{$guid} does not alread exist</p>";
         $post_title = $post_arr['title'];
         $post_content = $post_arr['content'];
         $author_exists = $this->author_exists($post_arr['author']);
         if (!$author_exists) {
             $results[] = "<p>{$guid} author does not already exist</p>";
             $author_id = $this->import_author($post_arr['author']);
             if (!empty($author_id)) {
                 $results[] = "<p>{$guid} author added as author_id {$author_id}</p>";
             }
         } else {
             $results[] = "<p>{$guid} author already exists as id {$author_exists}</p>";
             $author_id = $author_exists;
             add_user_to_blog(get_current_blog_id(), $author_id, 'subscriber');
         }
         $post_excerpt = $post_arr['description'];
         $args = array('post_title' => $post_title, 'post_content' => $post_content, 'post_author' => $author_id, 'post_excerpt' => $post_excerpt);
         $new_post_id = wp_insert_post($args);
         if (!empty($new_post_id)) {
             $results[] = "<p>{$guid} was inserted as post ID {$new_post_id}</p>";
             add_post_meta($new_post_id, SJF_GF . "-guid", $guid, TRUE);
         } else {
             $results[] = "<p>{$guid} could not be inserted</p>";
         }
     }
     return $results;
 }
开发者ID:scofennell,项目名称:SJF-Get-Fed,代码行数:33,代码来源:import.php


示例12: get_new_id

 /**
  * Returns post ID of custom post type 'contesthopper' with 'auto-draft' status. If none exists, it creates new one.
  * @return int Contest ID
  */
 public static function get_new_id()
 {
     global $wpdb;
     $args = array('post_type' => CH_Manager::post_type, 'post_status' => 'auto-draft');
     $query = new WP_Query($args);
     if (count($query->posts) == 0) {
         $new_id = wp_insert_post($args);
         $datetimes = self::get_default_times();
         update_post_meta($new_id, 'ch_disclaimer_rules_type', 'none');
         update_post_meta($new_id, 'ch_media_description_layout', 'media-top');
         update_post_meta($new_id, 'ch_widget_size', '640');
         update_post_meta($new_id, 'ch_headline_color', '#ffffff');
         update_post_meta($new_id, 'ch_headline_font', 'arial');
         update_post_meta($new_id, 'ch_description_color', '#000000');
         update_post_meta($new_id, 'ch_description_font', 'arial');
         update_post_meta($new_id, 'ch_title_background_color', '#40b3df');
         update_post_meta($new_id, 'ch_background_color', '#ffffff');
         update_post_meta($new_id, 'ch_border_color', '#2a71a2');
         update_post_meta($new_id, 'ch_winners_num', '1');
         update_post_meta($new_id, 'ch_referral_entries', '1');
         update_post_meta($new_id, 'ch_timezone', $datetimes['timezone']);
         update_post_meta($new_id, 'ch_date_start', $datetimes['start']);
         update_post_meta($new_id, 'ch_date_end', $datetimes['end']);
         update_post_meta($new_id, 'ch_submit_text', __('Join sweepstakes', 'contesthopper'));
         update_post_meta($new_id, 'ch_from_email', '"Contesthopper" <' . get_option('admin_email') . '>');
         return $new_id;
     }
     return $query->posts[0]->ID;
     // return existing auto-draft ID
 }
开发者ID:EliasGoldberg,项目名称:troop-sim,代码行数:34,代码来源:model-contest.php


示例13: saveData

 function saveData($items, $thisPage, $pages)
 {
     $complete = true;
     foreach ($items as $item) {
         $cons = "SELECT * FROM wp_postmeta WHERE meta_key = 'fr-id' AND meta_value = '" . $item->id . "'";
         $result = mysql_query($cons) or die(mysql_error());
         if (mysql_num_rows($result)) {
             $complete = false;
             echo "<br> Aborting: photo already loaded " . $item->id;
             break;
         } else {
             echo "<br> Importing picture " . $item->id;
             $date = gmdate("Y-m-d H:i:s", $item->dateupload);
             $my_post_test = array('post_title' => $item->title, 'post_content' => $item->description->_content, 'post_status' => 'publish', 'post_author' => 1, 'post_type' => "fr-pic", 'post_date' => $date);
             $post_id = wp_insert_post($my_post_test, $wp_error);
             add_post_meta($post_id, 'fr-id', $item->id);
             add_post_meta($post_id, 'small-pic', $item->url_s);
             add_post_meta($post_id, 'big-pic', $item->url_l);
         }
     }
     if ($thisPage < $pages && $complete) {
         $this->fetchData($thisPage + 1);
     } else {
         echo "<br> FLICKR JOB COMPLETED";
     }
 }
开发者ID:maxijb,项目名称:social-fetcher,代码行数:26,代码来源:flickr-social-fetcher.php


示例14: clonePage

 /**
  * Clones provided page ID
  * @param  int $pageId
  * @return int
  */
 public function clonePage($pageId)
 {
     $oldPost = get_post($pageId);
     if (null === $oldPost) {
         return 0;
     }
     if ('revision' === $oldPost->post_type) {
         return 0;
     }
     $currentUser = wp_get_current_user();
     $newPost = array('menu_order' => $oldPost->menu_order, 'comment_status' => $oldPost->comment_status, 'ping_status' => $oldPost->ping_status, 'post_author' => $currentUser->ID, 'post_content' => $oldPost->post_content, 'post_excerpt' => $oldPost->post_excerpt, 'post_mime_type' => $oldPost->post_mime_type, 'post_parent' => $oldPost->post_parent, 'post_password' => $oldPost->post_password, 'post_status' => $oldPost->post_status, 'post_title' => '(dup) ' . $oldPost->post_title, 'post_type' => $oldPost->post_type, 'post_date' => $oldPost->post_date, 'post_date_gmt' => get_gmt_from_date($oldPost->post_date));
     $newId = wp_insert_post($newPost);
     /*
      * Generating unique slug
      */
     if ($newPost['post_status'] == 'publish' || $newPost['post_status'] == 'future') {
         $postName = wp_unique_post_slug($oldPost->post_name, $newId, $newPost['post_status'], $oldPost->post_type, $newPost['post_parent']);
         $newPost = array();
         $newPost['ID'] = $newId;
         $newPost['post_name'] = $postName;
         wp_update_post($newPost);
     }
     $this->cloneMeta($pageId, $newId);
     $this->cloneOpData($pageId, $newId);
     return $newId;
 }
开发者ID:kyscastellanos,项目名称:arepa,代码行数:31,代码来源:clone_page.php


示例15: create_idx_pages

 public function create_idx_pages()
 {
     $saved_links = $this->idx_api->idx_api_get_savedlinks();
     $system_links = $this->idx_api->idx_api_get_systemlinks();
     if (!is_array($system_links) || !is_array($saved_links)) {
         return;
     }
     $idx_links = array_merge($saved_links, $system_links);
     $existing_page_urls = $this->get_existing_idx_page_urls();
     foreach ($idx_links as $link) {
         if (!in_array($link->url, $existing_page_urls)) {
             if (!empty($link->name)) {
                 $name = $link->name;
             } else {
                 if ($link->linkTitle) {
                     $name = $link->linkTitle;
                 }
             }
             $post = array('comment_status' => 'closed', 'ping_status' => 'closed', 'post_name' => $link->url, 'post_content' => '', 'post_status' => 'publish', 'post_title' => $name, 'post_type' => 'idx_page');
             // filter sanitize_tite so it returns the raw title
             add_filter('sanitize_title', array($this, 'sanitize_title_filter'), 10, 2);
             wp_insert_post($post);
         }
     }
 }
开发者ID:jdelia,项目名称:wordpress-plugin,代码行数:25,代码来源:idx-pages.php


示例16: import

        /**
         * import function.
         *
         * @access public
         * @param array $array
         * @param array $columns
         * @return void
         */
        function import($array = array(), $columns = array('post_title'))
        {
            $this->imported = $this->skipped = 0;
            if (!is_array($array) || !sizeof($array)) {
                $this->footer();
                die;
            }
            $rows = array_chunk($array, sizeof($columns));
            foreach ($rows as $row) {
                $row = array_filter($row);
                if (empty($row)) {
                    continue;
                }
                $meta = array();
                foreach ($columns as $index => $key) {
                    $meta[$key] = sp_array_value($row, $index);
                }
                $name = sp_array_value($meta, 'post_title');
                if (!$name) {
                    $this->skipped++;
                    continue;
                }
                $args = array('post_type' => 'sp_sponsor', 'post_status' => 'publish', 'post_title' => $name);
                $id = wp_insert_post($args);
                // Update URL
                update_post_meta($id, 'sp_url', sp_array_value($meta, 'sp_url'));
                $this->imported++;
            }
            // Show Result
            echo '<div class="updated settings-error below-h2"><p>
				' . sprintf(__('Import complete - imported <strong>%s</strong> sponsors and skipped <strong>%s</strong>.', 'prosports'), $this->imported, $this->skipped) . '
			</p></div>';
            $this->import_end();
        }
开发者ID:kleitz,项目名称:ProSports,代码行数:42,代码来源:class-sp-sponsor-importer.php


示例17: spamlytics_user_logout

 /**
  * Log when a user is logged in
  *
  * @param $user_login
  * @param $user
  */
 public function spamlytics_user_logout($user_login, $user)
 {
     $post_id = wp_insert_post(array('post_title' => 'LOGOUT', 'post_content' => 'User ' . $user_login . ' logged out from ' . $_SERVER['REMOTE_ADDR'], 'post_status' => 'inherit', 'post_type' => 'spamlytics_log'));
     update_post_meta($post_id, 'ip_address', $_SERVER['REMOTE_ADDR']);
     update_post_meta($post_id, 'type', 'LOGOUT');
     update_post_meta($post_id, 'spam_type', 'User');
 }
开发者ID:SpamLytics,项目名称:Spam-Prevention-by-SpamLytics,代码行数:13,代码来源:class-init.php


示例18: wepn_save_user_city_group_category

 /**
  * Saves the term selected on the edit user/profile page in the admin. This function is triggered when the page
  * is updated.  We just grab the posted data and use wp_set_object_terms() to save it.
  *
  * @param int $user_id The ID of the user to save the terms for.
  */
 public function wepn_save_user_city_group_category($user_id)
 {
     if (!WEPN_Helper::check_user_role('vendor', $user_id)) {
         return;
     }
     global $wpdb;
     $company_name = esc_attr($_POST['company_name']);
     $company_id = get_user_meta($user_id, 'company', true);
     if ($company_id && is_numeric($company_id)) {
         wp_update_post(array('ID' => $company_id, 'post_title' => $company_name, 'post_author' => $user_id, 'post_type' => 'vendor', 'post_status' => 'publish'));
     } else {
         $company_id = $wpdb->get_var("SELECT ID FROM wp_posts WHERE post_title = '" . $company_name . "'");
         if (!empty($company_name) && !$company_id) {
             $company_id = wp_insert_post(array('post_title' => $company_name, 'post_author' => $user_id, 'post_type' => 'vendor', 'post_status' => 'publish'));
             update_user_meta($user_id, 'company', $company_id);
         }
     }
     // Update Post Meta
     update_post_meta($company_id, 'vendor', $user_id);
     //Only administrator can change this section
     if (current_user_can('manage_options')) {
         $city = $_POST['city'];
         $group = $_POST['group'];
         $category = $_POST['category'];
         $group_slug = sanitize_title($group);
         $category_slug = sanitize_title($category);
         $other_categories = (array) (!empty($_POST['categories']) ? $_POST['categories'] : array());
         // Remove existing post and term relatinships
         $old_tax = get_post_meta($company_id, 'city', true);
         wp_delete_object_term_relationships($company_id, $old_tax);
         if (!in_array($category, $other_categories)) {
             $other_categories = array_merge($other_categories, array($category));
         }
         if (count($other_categories) > 0) {
             $terms = array();
             foreach ($other_categories as $term_title) {
                 if (empty($term_title)) {
                     continue;
                 }
                 $term_slug = sanitize_title($term_title);
                 if (!($term = term_exists($term_title, $city))) {
                     $term = wp_insert_term($term_title, $city, array('slug' => $term_slug));
                 }
                 if (!is_wp_error($term)) {
                     $terms[] = $term['term_id'];
                 }
             }
             wp_set_post_terms($company_id, $terms, $city, false);
         }
         // Update custom permalink
         update_post_meta($company_id, 'custom_permalink', $city . '/' . $group_slug . '/' . $category_slug . '/' . sanitize_title($company_name));
         update_post_meta($company_id, 'region', $group_slug);
         update_post_meta($company_id, 'city', $city);
         update_post_meta($company_id, 'category', $category_slug);
         // Update user meta
         update_user_meta($user_id, 'city', $city);
         update_user_meta($user_id, 'group', $group_slug);
         update_user_meta($user_id, 'category', $category_slug);
     }
 }
开发者ID:jrald1291,项目名称:atu,代码行数:66,代码来源:class-wepn-admin-users.php


示例19: create

 /**
  * Create a submission.
  * 
  * @access public
  * @since 2.7
  * @return int $sub_id
  */
 public function create($form_id = '')
 {
     // Create Submission
     $post = array('post_status' => 'publish', 'post_type' => 'nf_sub');
     $sub_id = wp_insert_post($post);
     // Add our form ID to the submission
     Ninja_Forms()->sub($sub_id)->update_form_id($form_id);
     // Get the current sequential ID
     $form = ninja_forms_get_form_by_id($form_id);
     if (isset($form['data']['last_sub'])) {
         $seq_num = $form['data']['last_sub'] + 1;
     } else {
         // If we don't have a starting number, start at 1
         $seq_num = 1;
     }
     $seq_num = apply_filters('nf_sub_seq_num', $seq_num, $form_id);
     // Add the sequential ID to the post meta
     Ninja_Forms()->sub($sub_id)->update_seq_num($seq_num);
     // Update our form data with the new "last seq id."
     $form['data']['last_sub'] = $seq_num;
     $args = array('update_array' => array('data' => serialize($form['data'])), 'where' => array('id' => $form_id));
     ninja_forms_update_form($args);
     // Update our sub count
     Ninja_Forms()->form($form_id)->sub_count = $seq_num - 1;
     return $sub_id;
 }
开发者ID:Natedaug,项目名称:WordPressSites,代码行数:33,代码来源:subs.php


示例20: saveImport

 /**
  * Save the Import
  */
 private function saveImport()
 {
     $title = __('Import on ', 'wpsimplelocator') . date_i18n('Y-m-d H:m:s', time());
     $importpost = array('post_title' => $title, 'post_status' => 'publish', 'post_type' => 'wpslimport');
     $post_id = wp_insert_post($importpost);
     add_post_meta($post_id, 'wpsl_import_data', $this->transient);
 }
开发者ID:itto,项目名称:wp-simple-locator,代码行数:10,代码来源:FinishImport.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_insert_term函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_insert_link函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap