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


PHP get_post函数代码示例

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


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

示例1: wpcf7_special_mail_tag_for_post_data

function wpcf7_special_mail_tag_for_post_data($output, $name)
{
    if (!isset($_POST['_wpcf7_unit_tag']) || empty($_POST['_wpcf7_unit_tag'])) {
        return $output;
    }
    if (!preg_match('/^wpcf7-f(\\d+)-p(\\d+)-o(\\d+)$/', $_POST['_wpcf7_unit_tag'], $matches)) {
        return $output;
    }
    $post_id = (int) $matches[2];
    if (!($post = get_post($post_id))) {
        return $output;
    }
    $user = new WP_User($post->post_author);
    // For backwards compat.
    $name = preg_replace('/^wpcf7\\./', '_', $name);
    if ('_post_id' == $name) {
        $output = (string) $post->ID;
    } elseif ('_post_name' == $name) {
        $output = $post->post_name;
    } elseif ('_post_title' == $name) {
        $output = $post->post_title;
    } elseif ('_post_url' == $name) {
        $output = get_permalink($post->ID);
    } elseif ('_post_author' == $name) {
        $output = $user->display_name;
    } elseif ('_post_author_email' == $name) {
        $output = $user->user_email;
    }
    return $output;
}
开发者ID:KurtMakesWeb,项目名称:CandG,代码行数:30,代码来源:special-mail-tags.php

示例2: notification_email

 /**
  * Set the notification email when sending an email.
  *
  * @since WP Job Manager - Contact Listing 1.0.0
  *
  * @return string The email to notify.
  */
 public function notification_email($components, $cf7, $three = null)
 {
     $submission = WPCF7_Submission::get_instance();
     $unit_tag = $submission->get_meta('unit_tag');
     if (!preg_match('/^wpcf7-f(\\d+)-p(\\d+)-o(\\d+)$/', $unit_tag, $matches)) {
         return $components;
     }
     $post_id = (int) $matches[2];
     $object = get_post($post_id);
     // Prevent issues when the form is not submitted via a listing/resume page
     if (!isset($this->forms[$object->post_type])) {
         return $components;
     }
     if (!array_search($cf7->id(), $this->forms[$object->post_type])) {
         return $components;
     }
     // Bail if this is the second mail
     if (isset($three) && 'mail_2' == $three->name()) {
         return $components;
     }
     $recipient = $object->_application ? $object->_application : $object->_candidate_email;
     //if we couldn't find the email by now, get it from the listing owner/author
     if (empty($recipient)) {
         //just get the email of the listing author
         $owner_ID = $object->post_author;
         //retrieve the owner user data to get the email
         $owner_info = get_userdata($owner_ID);
         if (false !== $owner_info) {
             $recipient = $owner_info->user_email;
         }
     }
     $components['recipient'] = $recipient;
     return $components;
 }
开发者ID:durichitayat,项目名称:befolio-wp,代码行数:41,代码来源:cf7.php

示例3: init

 /**
  * Prevent caching on dynamic pages.
  *
  * @access public
  * @return void
  */
 public function init()
 {
     if (false === ($wc_page_uris = get_transient('woocommerce_cache_excluded_uris'))) {
         if (woocommerce_get_page_id('cart') < 1 || woocommerce_get_page_id('checkout') < 1 || woocommerce_get_page_id('myaccount') < 1) {
             return;
         }
         $wc_page_uris = array();
         $cart_page = get_post(woocommerce_get_page_id('cart'));
         $checkout_page = get_post(woocommerce_get_page_id('checkout'));
         $account_page = get_post(woocommerce_get_page_id('myaccount'));
         $wc_page_uris[] = '/' . $cart_page->post_name;
         $wc_page_uris[] = '/' . $checkout_page->post_name;
         $wc_page_uris[] = '/' . $account_page->post_name;
         $wc_page_uris[] = 'p=' . $cart_page->ID;
         $wc_page_uris[] = 'p=' . $checkout_page->ID;
         $wc_page_uris[] = 'p=' . $account_page->ID;
         set_transient('woocommerce_cache_excluded_uris', $wc_page_uris);
     }
     if (is_array($wc_page_uris)) {
         foreach ($wc_page_uris as $uri) {
             if (strstr($_SERVER['REQUEST_URI'], $uri)) {
                 $this->nocache();
                 break;
             }
         }
     }
 }
开发者ID:rongandat,项目名称:sallumeh,代码行数:33,代码来源:class-wc-cache-helper.php

示例4: dswoddil_post_nav

    /**
     * Display navigation to next/previous post when applicable.
     *
     * @since DSW oddil 1.0
     */
    function dswoddil_post_nav()
    {
        // Don't print empty markup if there's nowhere to navigate.
        $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
        $next = get_adjacent_post(false, '', false);
        if (!$next && !$previous) {
            return;
        }
        ?>
	<nav class="navigation post-navigation" role="navigation">
		<h1 class="screen-reader-text"><?php 
        _e('Post navigation', 'dswoddil');
        ?>
</h1>
		<div class="nav-links">
			<?php 
        if (is_attachment()) {
            previous_post_link('%link', __('<span class="meta-nav">Published In</span>%title', 'dswoddil'));
        } else {
            previous_post_link('%link', __('<span class="meta-nav">Previous Post</span>%title', 'dswoddil'));
            next_post_link('%link', __('<span class="meta-nav">Next Post</span>%title', 'dswoddil'));
        }
        ?>
		</div><!-- .nav-links -->
	</nav><!-- .navigation -->
	<?php 
    }
开发者ID:kalich5,项目名称:dsw-oddil,代码行数:32,代码来源:template-tags.php

示例5: variable_fields

/**
 * Create new fields for variations
 *
*/
function variable_fields($loop, $variation_data, $variation)
{
    global $post;
    if (!$post) {
        $post = get_post($variation->ID);
    }
    ?>
	<tr>
		<td>
		</br>
			<?php 
    //$_pg_field = $variation_data['_pg_field'][0]
    $variation_id = $variation->ID;
    $_pg_field = get_post_meta($variation_id, '_pg_field', true);
    /*
    echo "</br>"; 
    var_dump($variation_data); 
    echo "</br>";
    echo "</br>";
    var_dump($variation); 
    echo "</br>";
    echo "</br>";
    var_dump($_pg_field); 
    echo "</br>";
    echo "</br>"."_pg_field : ". $_pg_field ."</br>";
    echo "</br>";
    */
    woocommerce_wp_text_input(array('id' => '_pg_field[' . $loop . ']', 'label' => __('Product Generator Data', 'woocommerce'), 'placeholder' => 'angle="33" lux="100" luxD="100" minD="100" maxD="500"', 'desc_tip' => 'true', 'description' => __('Enter the Product Generator Data here.', 'woocommerce'), 'value' => $_pg_field));
    ?>
		</td>
	</tr>
    
    <?php 
}
开发者ID:TheDraguun,项目名称:julitewoo,代码行数:38,代码来源:functions.php

示例6: test_ajax

function test_ajax()
{
    header("content-type: applications/json");
    $posts_array = get_post();
    echo json_encode($posts_array);
    die;
}
开发者ID:adbijan,项目名称:my-awesome-bootstrap-theme,代码行数:7,代码来源:custom-from-the-video-but-doesnt-work.php

示例7: __construct

 public function __construct(Episode $episode)
 {
     $this->episode = $episode;
     $this->post = get_post($episode->post_id);
     $this->player_format_assignments = $this->get_player_format_assignments();
     $this->files = $this->get_files();
 }
开发者ID:johannes-mueller,项目名称:podlove-publisher,代码行数:7,代码来源:printer.php

示例8: __construct

 function __construct($id = '', $status = 'any', $output = 'OBJECT')
 {
     $continue = true;
     if ($status !== 'any') {
         if (get_post_status($id) == $status) {
             $continue = true;
         } else {
             $continue = false;
         }
     }
     if ($continue) {
         $this->id = $id;
         $this->output = $output;
         $this->details = get_post($this->id, $this->output);
         $tickets = new TC_Tickets();
         $fields = $tickets->get_ticket_fields();
         if (isset($this->details)) {
             if (!empty($fields)) {
                 foreach ($fields as $field) {
                     if (!isset($this->details->{$field['field_name']})) {
                         $this->details->{$field['field_name']} = get_post_meta($this->id, $field['field_name'], true);
                     }
                 }
             }
         }
     } else {
         $this->id = null;
     }
 }
开发者ID:walkthenight,项目名称:walkthenight-wordpress,代码行数:29,代码来源:class.ticket.php

示例9: admin_enqueue_scripts

/**
 * Enqueue the admin script to page post types only
 *
 * @uses get_post()
 * @uses wp_enqueue_script()
 *
 * @return void
 */
function admin_enqueue_scripts()
{
    $post = get_post();
    if ($post && 'page' === $post->post_type) {
        wp_enqueue_script('city-admin', TMP_CITIES_URL . 'assets/js/template-cities.js', array(), TMP_CITIES_VERSION, true);
    }
}
开发者ID:fuhton,项目名称:template-cities,代码行数:15,代码来源:setup.php

示例10: widget

 /**
  * widget function.
  *
  * @see WP_Widget
  * @access public
  * @param array $args
  * @param array $instance
  * @return void
  */
 function widget($args, $instance)
 {
     if ($this->get_cached_widget($args)) {
         return;
     }
     global $job_manager, $post;
     extract($args);
     $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     $icon = isset($instance['icon']) ? $instance['icon'] : null;
     $gallery = Listify_WP_Job_Manager_Gallery::get(get_post()->ID);
     $limit = isset($instance['limit']) ? $instance['limit'] : 8;
     $has_more = count($gallery) > $limit;
     if (empty($gallery) && !current_user_can('upload_files')) {
         return;
     }
     if ($icon) {
         $before_title = sprintf($before_title, 'ion-' . $icon);
     }
     ob_start();
     if ($has_more) {
         $before_widget = str_replace('widget-job_listing', 'widget-job_listing has-more', $before_widget);
     }
     echo $before_widget;
     if ($title) {
         echo $before_title . sprintf('<a href="%s" class="image-gallery-link">%s</a>', Listify_WP_Job_Manager_Gallery::url(), $title) . $after_title;
     }
     include locate_template(array('content-single-job_listing-gallery-overview.php'));
     if ($has_more) {
         printf('<a href="%s" class="go-to-gallery"><i class="ion-ios7-more"></i></a>', Listify_WP_Job_Manager_Gallery::url());
     }
     echo $after_widget;
     $content = ob_get_clean();
     echo apply_filters($this->widget_id, $content);
     $this->cache_widget($args, $content);
 }
开发者ID:GaryJones,项目名称:dockerfiles,代码行数:44,代码来源:class-widget-job_listing-gallery.php

示例11: test_autosave_post

	/**
	 * Test autosaving a post
	 * @return void
	 */
	public function test_autosave_post() {

		// Become an admin
		$this->_setRole( 'administrator' );

		// Set up the $_POST request
		$md5 = md5( uniqid() );
		$_POST = array(
		    'post_id'       => $this->_post->ID,
		    'autosavenonce' => wp_create_nonce( 'autosave' ),
		    'post_content'  => $this->_post->post_content . PHP_EOL . $md5,
			'post_type'     => 'post',
		    'autosave'      => 1,
		);

		// Make the request
		try {
			$this->_handleAjax( 'autosave' );
		} catch ( WPAjaxDieContinueException $e ) {
			unset( $e );
		}

		// Get the response
		$xml = simplexml_load_string( $this->_last_response, 'SimpleXMLElement', LIBXML_NOCDATA );

		// Ensure everything is correct
		$this->assertEquals( $this->_post->ID, (int) $xml->response[0]->autosave['id'] );
		$this->assertEquals( 'autosave_' . $this->_post->ID, (string) $xml->response['action']);

		// Check that the edit happened
		$post = get_post( $this->_post->ID) ;
		$this->assertGreaterThanOrEqual( 0, strpos( $post->post_content, $md5 ) );
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:37,代码来源:Autosave.php

示例12: zerif_post_nav

    /**
    * Display navigation to next/previous post when applicable.
    */
    function zerif_post_nav()
    {
        // Don't print empty markup if there's nowhere to navigate.
        $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
        $next = get_adjacent_post(false, '', false);
        if (!$next && !$previous) {
            return;
        }
        ?>

	<nav class="navigation post-navigation">

		<h2 class="screen-reader-text"><?php 
        _e('Post navigation', 'zerif-lite');
        ?>
</h2>

		<div class="nav-links">

			<?php 
        previous_post_link('<div class="nav-previous">%link</div>', _x('<span class="meta-nav">&larr;</span> %title', 'Previous post link', 'zerif-lite'));
        next_post_link('<div class="nav-next">%link</div>', _x('%title <span class="meta-nav">&rarr;</span>', 'Next post link', 'zerif-lite'));
        ?>

		</div><!-- .nav-links -->

	</nav><!-- .navigation -->

	<?php 
    }
开发者ID:JasonAJames,项目名称:jasonajamescom,代码行数:33,代码来源:template-tags.php

示例13: __construct

 public function __construct($bean = null)
 {
     $post = null;
     $this->capabilityType = 'post';
     $this->serializeDataStorage = true;
     // If your class name is Book. Your Post Type would be 'book'
     $this->getPostType();
     if (is_int($bean)) {
         $post = get_post($bean);
     } elseif ($bean instanceof \WP_Post && !empty($bean->ID)) {
         $post = $bean;
     }
     // Load Basic post data
     if (!empty($post)) {
         $this->post = $post;
         $this->ID = $post->ID;
         $this->title = $post->post_title;
         $this->content = $post->post_content;
         $this->excerpt = $post->post_excerpt;
     }
     // Setup Basic post data
     if (empty($this->nameLabel)) {
         $currentObjectName = $this->getClassName();
         $this->setNameLabel($currentObjectName);
         $this->setSingularNameLabel($currentObjectName);
     }
     //Metaboxes and Fields
     $this->metaBoxes = new MetaBoxCollection();
     $this->fields = new FieldCollection();
     $this->tableFields = array();
     $this->registerCustomPostType()->registerFilters();
 }
开发者ID:page-carbajal,项目名称:wpexpress,代码行数:32,代码来源:BaseModel.class.php

示例14: get_order

 /**
  * get_order function.
  *
  * @param bool $the_order (default: false)
  * @return WC_Order|bool
  */
 public function get_order($the_order = false)
 {
     global $post;
     if (false === $the_order) {
         $the_order = $post;
     } elseif (is_numeric($the_order)) {
         $the_order = get_post($the_order);
     }
     if (!$the_order || !is_object($the_order)) {
         return false;
     }
     $order_id = absint($the_order->ID);
     $post_type = $the_order->post_type;
     if ($order_type = wc_get_order_type($post_type)) {
         $classname = $order_type['class_name'];
     } else {
         $classname = false;
     }
     // Filter classname so that the class can be overridden if extended.
     $classname = apply_filters('woocommerce_order_class', $classname, $post_type, $order_id);
     if (!class_exists($classname)) {
         $classname = 'WC_Order';
     }
     return new $classname($the_order);
 }
开发者ID:abcode619,项目名称:wpstuff,代码行数:31,代码来源:class-wc-order-factory.php

示例15: start_el

 function start_el(&$output, $page, $depth = 0, $args = array(), $current_page = 0)
 {
     if ($depth) {
         $indent = str_repeat("\t", $depth);
     } else {
         $indent = '';
     }
     extract($args, EXTR_SKIP);
     $css_class = array('page_item', 'page-item-' . $page->ID);
     if (!empty($current_page)) {
         $_current_page = get_post($current_page);
         if (in_array($page->ID, $_current_page->ancestors)) {
             $css_class[] = 'current_page_ancestor';
         }
         if ($page->ID == $current_page) {
             $css_class[] = 'current_page_item';
         } elseif ($_current_page && $page->ID == $_current_page->post_parent) {
             $css_class[] = 'current_page_parent';
         }
     } elseif ($page->ID == get_option('page_for_posts')) {
         $css_class[] = 'current_page_parent';
     }
     $css_class = implode(' ', apply_filters('page_css_class', $css_class, $page, $depth, $args, $current_page));
     $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_permalink($page->ID) . '">' . $link_before . apply_filters('the_title', $page->post_title, $page->ID) . $link_after . '</a>';
     if (!empty($show_date)) {
         if ('modified' == $show_date) {
             $time = $page->post_modified;
         } else {
             $time = $page->post_date;
         }
         $output .= " " . mysql2date($date_format, $time);
     }
 }
开发者ID:jeremybradbury,项目名称:wp-ninja-kit,代码行数:33,代码来源:default_menu_walker.php


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