本文整理汇总了PHP中Essential_Grid_Base::convert_post_date方法的典型用法代码示例。如果您正苦于以下问题:PHP Essential_Grid_Base::convert_post_date方法的具体用法?PHP Essential_Grid_Base::convert_post_date怎么用?PHP Essential_Grid_Base::convert_post_date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Essential_Grid_Base
的用法示例。
在下文中一共展示了Essential_Grid_Base::convert_post_date方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replace_all_meta_in_text
/**
* replace all metas with corresponding text
*/
public function replace_all_meta_in_text($post_id, $text)
{
if (trim($text) === '' || intval($post_id) === 0) {
return '';
}
$base = new Essential_Grid_Base();
$meta_link = new Essential_Grid_Meta_Linking();
$cmeta = $this->get_all_meta();
//process meta tags:
$arr_matches = array();
preg_match_all("/%[^%]*%/", $text, $arr_matches);
if (!empty($arr_matches)) {
$my_post = get_post($post_id, ARRAY_A);
foreach ($arr_matches as $matches) {
if (is_array($matches)) {
foreach ($matches as $match) {
$meta = trim(str_replace('%', '', $match));
$meta_value = get_post_meta($post_id, $meta, true);
if (!empty($cmeta)) {
foreach ($cmeta as $me) {
if ('eg-' . $me['handle'] == $meta) {
if ($me['type'] == 'image') {
if (intval($meta_value) > 0) {
//get URL to Image
$img = wp_get_attachment_image_src($meta_value, 'full');
if ($img !== false) {
$meta_value = $img[0];
} else {
$meta_value = '';
}
} else {
$meta_value = '';
}
}
if ($meta_value == '' && isset($me['default'])) {
$meta_value = $me['default'];
}
break;
}
}
}
//check woocommerce
if (Essential_Grid_Woocommerce::is_woo_exists()) {
$wc_text = Essential_Grid_Woocommerce::get_value_by_meta($post_id, $meta);
if ($wc_text !== '') {
$meta_value = $wc_text;
}
}
if (empty($meta_value) && !empty($my_post)) {
//try to get from post
switch ($meta) {
//Post elements
case 'post_url':
$post_id = $base->getVar($my_post, 'ID', '');
$meta_value = get_permalink($post_id);
break;
case 'post_id':
$meta_value = $base->getVar($my_post, 'ID', '');
break;
case 'title':
$meta_value = $base->getVar($my_post, 'post_title', '');
break;
case 'excerpt':
$meta_value = trim($base->getVar($my_post, 'post_excerpt'));
if (empty($meta_value)) {
$meta_value = trim($base->getVar($my_post, 'post_content'));
}
$meta_value = strip_tags($meta_value);
//,"<b><br><br/><i><strong><small>"
break;
case 'meta':
$m = new Essential_Grid_Meta();
$meta_value = $m->get_meta_value_by_handle($my_post['ID'], $meta);
break;
case 'alias':
$meta_value = $base->getVar($my_post, 'post_name');
break;
case 'content':
$meta_value = $base->getVar($my_post, 'post_content');
break;
case 'link':
$meta_value = get_permalink($my_post['ID']);
break;
case 'date':
$postDate = $base->getVar($my_post, "post_date_gmt");
$meta_value = $base->convert_post_date($postDate);
break;
case 'date_modified':
$dateModified = $base->getVar($my_post, "post_modified");
$meta_value = $base->convert_post_date($dateModified);
break;
case 'author_name':
$authorID = $base->getVar($my_post, 'post_author');
$meta_value = get_the_author_meta('display_name', $authorID);
break;
case 'num_comments':
$meta_value = $base->getVar($my_post, 'comment_count');
//.........这里部分代码省略.........
示例2: get_post_value
/**
* Retrieve the value of post elements
*/
public function get_post_value($handle, $separator, $function, $meta)
{
$base = new Essential_Grid_Base();
$text = '';
switch ($handle) {
//Post elements
case 'post_id':
$text = $base->getVar($this->post, 'ID', '');
break;
case 'post_url':
$post_id = $base->getVar($this->post, 'ID', '');
$text = get_permalink($post_id);
break;
case 'title':
$text = $base->getVar($this->post, 'post_title', '');
break;
case 'excerpt':
$text = trim($base->getVar($this->post, 'post_excerpt'));
if (empty($text)) {
//strip essential grid shortcode here
$text = do_shortcode($base->strip_essential_shortcode($base->getVar($this->post, 'post_content')));
$text = preg_replace("/<style\\b[^>]*>(.*?)<\\/style>/s", "", $text);
$text = preg_replace("/<script\\b[^>]*>(.*?)<\\/script>/s", "", $text);
}
$text = strip_tags($text);
//,"<b><br><br/><i><strong><small>"
break;
case 'meta':
$m = new Essential_Grid_Meta();
$text = $m->get_meta_value_by_handle($this->post['ID'], $meta);
break;
case 'alias':
$text = $base->getVar($this->post, 'post_name');
break;
case 'content':
$text = apply_filters('the_content', $base->getVar($this->post, 'post_content'));
break;
case 'link':
$text = get_permalink($this->post['ID']);
break;
case 'date':
$postDate = $base->getVar($this->post, "post_date_gmt");
$text = $base->convert_post_date($postDate);
break;
case 'date_modified':
$dateModified = $base->getVar($this->post, "post_modified");
$text = $base->convert_post_date($dateModified);
break;
case 'author_name':
$authorID = $base->getVar($this->post, 'post_author');
$text = get_the_author_meta('display_name', $authorID);
break;
case 'num_comments':
$text = $base->getVar($this->post, 'comment_count');
break;
case 'cat_list':
$use_taxonomies = false;
$postCatsIDs = $base->getVar($this->post, 'post_category');
if (empty($postCatsIDs) && isset($this->post['post_type'])) {
$postCatsIDs = array();
$obj = get_object_taxonomies($this->post['post_type']);
if (!empty($obj) && is_array($obj)) {
foreach ($obj as $tax) {
$use_taxonomies[] = $tax;
$new_terms = get_the_terms($this->post['ID'], $tax);
if (is_array($new_terms) && !empty($new_terms)) {
foreach ($new_terms as $term) {
$postCatsIDs[$term->term_id] = $term->term_id;
}
}
}
}
}
$text = $base->get_categories_html_list($postCatsIDs, $function, $separator, $use_taxonomies);
break;
case 'tag_list':
$text = $base->get_tags_html_list($this->post['ID'], $separator, $function);
break;
}
return $text;
}