本文整理汇总了PHP中sf_get_post_meta函数的典型用法代码示例。如果您正苦于以下问题:PHP sf_get_post_meta函数的具体用法?PHP sf_get_post_meta怎么用?PHP sf_get_post_meta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sf_get_post_meta函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle_upload
/**
* Upload
* Ajax callback function
*
* @return string Error or (XML-)response
*/
static function handle_upload()
{
global $wpdb;
$post_id = is_numeric($_REQUEST['post_id']) ? $_REQUEST['post_id'] : 0;
$field_id = isset($_REQUEST['field_id']) ? $_REQUEST['field_id'] : '';
check_ajax_referer("rwmb-upload-images_{$field_id}");
// You can use WP's wp_handle_upload() function:
$file = $_FILES['async-upload'];
$file_attr = wp_handle_upload($file, array('test_form' => false));
//Get next menu_order
$meta = sf_get_post_meta($post_id, $field_id, false);
if (empty($meta)) {
$next = 0;
} else {
$meta = implode(',', (array) $meta);
$max = $wpdb->get_var("\n\t\t\t\t\tSELECT MAX(menu_order) FROM {$wpdb->posts}\n\t\t\t\t\tWHERE post_type = 'attachment'\n\t\t\t\t\tAND ID in ({$meta})\n\t\t\t\t");
$next = is_numeric($max) ? (int) $max + 1 : 0;
}
$attachment = array('guid' => $file_attr['url'], 'post_mime_type' => $file_attr['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename($file['name'])), 'post_content' => '', 'post_status' => 'inherit', 'menu_order' => $next);
// Adds file as attachment to WordPress
$id = wp_insert_attachment($attachment, $file_attr['file'], $post_id);
if (!is_wp_error($id)) {
wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $file_attr['file']));
// Save file ID in meta field
add_post_meta($post_id, $field_id, $id, false);
wp_send_json_success(self::img_html($id));
}
exit;
}
示例2: content
public function content($atts, $content = null)
{
$title = $el_class = $title_heading_class = $width = $el_position = '';
extract(shortcode_atts(array('title' => '', 'alt_background' => 'none', 'el_class' => '', 'el_position' => '', 'width' => '1/1'), $atts));
$output = '';
$el_class = $this->getExtraClass($el_class);
$width = spb_translateColumnWidthToSpan($width);
$el_class .= ' spb_text_column';
$sidebar_config = sf_get_post_meta(get_the_ID(), 'sf_sidebar_config', true);
$sidebars = '';
if ($sidebar_config == "left-sidebar" || $sidebar_config == "right-sidebar") {
$sidebars = 'one-sidebar';
} else {
if ($sidebar_config == "both-sidebars") {
$sidebars = 'both-sidebars';
} else {
$sidebars = 'no-sidebars';
}
}
if ($alt_background == "none" || $sidebars != "no-sidebars") {
$output .= "\n\t" . '<div class="full-width-text spb_content_element ' . $width . $el_class . '">';
$title_heading_class = "spb-text-heading";
} else {
$output .= "\n\t" . '<div class="full-width-text spb_content_element alt-bg ' . $alt_background . ' ' . $width . $el_class . '">';
$title_heading_class = "spb-center-heading";
}
$output .= "\n\t\t" . '<div class="spb_wrapper clearfix">';
$output .= $title != '' ? "\n\t\t\t" . '<div class="heading-wrap"><h3 class="spb-heading ' . $title_heading_class . '"><span>' . $title . '</span></h3></div>' : '';
$output .= "\n\t\t\t" . do_shortcode($content);
$output .= "\n\t\t" . '</div> ' . $this->endBlockComment('.spb_wrapper');
$output .= "\n\t" . '</div> ' . $this->endBlockComment($width);
$output = $this->startRow($el_position) . $output . $this->endRow($el_position);
return $output;
}
示例3: meta
/**
* Get meta value
* If field is cloneable, value is saved as a single entry in DB
* Otherwise value is saved as multiple entries (for backward compatibility)
*
* @see "save" method for better understanding
*
* TODO: A good way to ALWAYS save values in single entry in DB, while maintaining backward compatibility
*
* @param $post_id
* @param $saved
* @param $field
*
* @return array
*/
static function meta($post_id, $saved, $field)
{
$meta = sf_get_post_meta($post_id, $field['id'], $field['clone']);
$meta = !$saved && '' === $meta || array() === $meta ? $field['std'] : $meta;
$meta = array_map('esc_attr', (array) $meta);
return $meta;
}
示例4: lip_get_love_count
function lip_get_love_count($post_id)
{
$love_count = sf_get_post_meta($post_id, '_li_love_count', true);
if ($love_count) {
return $love_count;
}
return 0;
}
示例5: meta
/**
* Get meta value
*
* @param $post_id
* @param $saved
* @param $field
*
* @return array
*/
static function meta($post_id, $saved, $field)
{
$meta = sf_get_post_meta($post_id, $field['id']);
if (is_array($meta) && !empty($meta)) {
$meta = $meta[0];
}
return $meta;
}
示例6: content
protected function content($atts, $content = null)
{
$btn_color = $btn_text = $display_type = $target = $href = $promo_bar_text = $fullwidth = $inline_style = $inline_style_alt = $width = $position = $el_class = '';
extract(shortcode_atts(array('btn_color' => 'accent', 'btn_text' => '', 'btn_type' => 'dropshadow', 'target' => '', 'display_type' => '', 'href' => '', 'shadow' => 'yes', 'promo_bar_text' => '', 'content' => '', 'promo_bar_text_size' => '', 'width' => '1/1', 'bg_color' => '', 'text_color' => '', 'fullwidth' => 'no', 'el_class' => '', 'el_position' => ''), $atts));
$output = '';
$width = spb_translateColumnWidthToSpan($width);
$el_class = $this->getExtraClass($el_class);
$sidebar_config = sf_get_post_meta(get_the_ID(), 'sf_sidebar_config', true);
$sidebars = '';
if ($sidebar_config == "left-sidebar" || $sidebar_config == "right-sidebar") {
$sidebars = 'one-sidebar';
} else {
if ($sidebar_config == "both-sidebars") {
$sidebars = 'both-sidebars';
} else {
$sidebars = 'no-sidebars';
}
}
if ($bg_color != "") {
$inline_style .= 'background-color:' . $bg_color . ';';
}
if ($text_color != "") {
$inline_style_alt .= 'color:' . $text_color . ';';
}
// Button type
$btn_type = str_replace("_", " ", $btn_type);
if ($target == 'same' || $target == '_self') {
$target = '_self';
}
if ($target != '') {
$target = $target;
}
$next_icon = apply_filters('sf_next_icon', '<i class="ss-navigateright"></i>');
$output .= '<div class="spb-promo-wrap spb_content_element clearfix ' . $width . ' ' . $position . $el_class . '">' . "\n";
$output .= '<div class="sf-promo-bar ' . $display_type . '" style="' . $inline_style . '">';
if ($display_type == "promo-button") {
$output .= '<p class="' . $promo_bar_text_size . '" style="' . $inline_style_alt . '">' . $promo_bar_text . '</p>';
$output .= '<a href="' . $href . '" target="' . $target . '" class="sf-button ' . $btn_type . ' ' . $btn_color . '">' . $btn_text . '</a>';
} else {
if ($display_type == "promo-arrow") {
$output .= '<a href="' . $href . '" target="' . $target . '" style="' . $inline_style_alt . '"><p>' . $promo_bar_text . '</p>' . $next_icon . '</a>';
} else {
if ($display_type == "promo-text") {
$output .= '<a href="' . $href . '" target="' . $target . '" class="' . $promo_bar_text_size . '" style="' . $inline_style_alt . '"><p>' . do_shortcode($promo_bar_text) . '</p></a>';
} else {
$output .= '<p>' . do_shortcode($content) . '</p>';
}
}
}
$output .= '</div>';
$output .= '</div> ' . $this->endBlockComment('.spb-promo-wrap') . "\n";
if ($fullwidth == "yes" && $sidebars == "no-sidebars") {
$output = $this->startRow($el_position, '', true) . $output . $this->endRow($el_position, '', true);
} else {
$output = $this->startRow($el_position) . $output . $this->endRow($el_position);
}
return $output;
}
示例7: sf_add_desc_tab
/**
* Filter tabs and allow third parties to add their own
*
* Each tab is an array containing title, callback and priority.
* @see woocommerce_default_product_tabs()
*/
function sf_add_desc_tab($tabs = array())
{
global $post;
$product_description = sf_get_post_meta($post->ID, 'sf_product_description', true);
if ($product_description != "") {
$tabs['description'] = array('title' => __('Description', 'woocommerce'), 'priority' => 10, 'callback' => 'woocommerce_product_description_tab');
}
return $tabs;
}
示例8: widget
/** @see WP_Widget::widget */
function widget($args, $instance)
{
extract($args);
$title = apply_filters('widget_title', $instance['title']);
$number = strip_tags($instance['number']);
$loved_icon = apply_filters('sf_loved_icon', '<i class="ss-heart"></i>');
echo $before_widget;
if ($title) {
echo $before_title . $title . $after_title;
}
?>
<ul class="most-loved">
<?php
$args = array('post_type' => 'any', 'numberposts' => $number, 'meta_key' => '_li_love_count', 'orderby' => 'meta_value_num', 'order' => 'DESC');
$most_loved = get_posts($args);
foreach ($most_loved as $loved) {
?>
<?php
global $post;
$post_id = $loved->ID;
if (function_exists('icl_object_id')) {
$post_id = icl_object_id($post_id, 'post', true);
}
$author_id = get_post_field('post_author', $post_id);
$author_name = get_the_author_meta('user_nicename', $author_id);
?>
<li class="loved-item">
<a href="<?php
echo get_permalink($post_id);
?>
"></a>
<h5><?php
echo get_the_title($post_id);
?>
</h5>
<span><?php
echo sprintf(__('By %1$s', 'swiftframework'), $author_name);
?>
</span>
<div class="loved-count"><?php
echo $loved_icon;
?>
<span><?php
echo sf_get_post_meta($post_id, '_li_love_count', true);
?>
</span>
</div>
</li>
<?php
}
?>
</ul>
<?php
echo $after_widget;
}
示例9: sf_newsletter_bar
function sf_newsletter_bar()
{
global $sf_options, $post;
$enable_newsletter_sub_bar = $enable_newsletter_bar_page = false;
if (isset($sf_options['enable_newsletter_sub_bar'])) {
$enable_newsletter_sub_bar = $sf_options['enable_newsletter_sub_bar'];
}
if (is_page() && $post) {
$enable_newsletter_bar_page = sf_get_post_meta($post->ID, 'sf_enable_newsletter_bar', true);
}
if (isset($sf_options['enable_newsletter_sub_bar_globally'])) {
$enable_newsletter_bar_page = $sf_options['enable_newsletter_sub_bar_globally'];
}
if ($enable_newsletter_sub_bar && (is_home() || is_front_page()) || $enable_newsletter_bar_page) {
$sub_bar_text = __($sf_options['sub_bar_text'], "swiftframework");
$sub_bar_code = __($sf_options['sub_bar_code'], "swiftframework");
$fullwidth_header = $sf_options['fullwidth_header'];
$page_layout = $sf_options['page_layout'];
if (isset($_GET['layout'])) {
$page_layout = $_GET['layout'];
}
?>
<!--// OPEN #sf-newsletter-bar //-->
<div id="sf-newsletter-bar">
<?php
if (!$fullwidth_header || $page_layout == "boxed") {
?>
<div class="container">
<?php
}
?>
<h3 class="sub-text"><?php
echo esc_attr($sub_bar_text);
?>
</h3>
<div class="sub-code"><?php
echo do_shortcode($sub_bar_code);
?>
</div>
<a href="#" class="sub-close"><i class="sf-icon-close"></i></a>
<?php
if (!$fullwidth_header || $page_layout == "boxed") {
?>
</div>
<?php
}
?>
<!--// CLOSE #sf-newsletter-bar //-->
</div>
<?php
}
}
示例10: content
protected function content($atts, $content = null)
{
$title = $width = $el_class = $filter_output = $exclude_categories = $output = $tax_terms = $items = $el_position = '';
extract(shortcode_atts(array('title' => '', 'display_type' => 'standard', 'columns' => '4', 'show_title' => 'yes', 'show_subtitle' => 'yes', 'show_excerpt' => 'no', 'hover_show_excerpt' => 'no', "excerpt_length" => '20', 'item_count' => '-1', 'category' => '', 'portfolio_filter' => 'yes', 'pagination' => 'no', 'el_position' => '', 'width' => '1/1', 'el_class' => ''), $atts));
/* for PRO users! - SIDEBAR CONFIG
================================================== */
$sidebar_config = sf_get_post_meta(get_the_ID(), 'sf_sidebar_config', true);
$sidebars = '';
if ($sidebar_config == "left-sidebar" || $sidebar_config == "right-sidebar") {
$sidebars = 'one-sidebar';
} else {
if ($sidebar_config == "both-sidebars") {
$sidebars = 'both-sidebars';
} else {
$sidebars = 'no-sidebars';
}
}
/* for PRO users! - PORTFOLIO FILTER
================================================== */
if ($portfolio_filter == "yes" && $sidebars == "no-sidebars") {
if ($display_type == "masonry-fw" || $display_type == "masonry-gallery-fw") {
$filter_output = sf_portfolio_filter('full-width', $category);
} else {
$filter_output = sf_portfolio_filter('', $category);
}
}
/* for PRO users! - PORTFOLIO ITEMS
================================================== */
$items = sf_portfolio_items($display_type, $columns, $show_title, $show_subtitle, $show_excerpt, $hover_show_excerpt, $excerpt_length, $item_count, $category, $exclude_categories, $pagination, $sidebars);
/* for PRO users! - PAGE BUILDER OUTPUT
================================================== */
$width = spb_translateColumnWidthToSpan($width);
$el_class = $this->getExtraClass($el_class);
$output .= "\n\t" . '<div class="spb_portfolio_widget spb_content_element ' . $width . $el_class . '">';
$output .= "\n\t\t" . '<div class="spb_wrapper portfolio-wrap">';
$output .= $title != '' ? "\n\t\t\t" . '<h3 class="spb-heading"><span>' . $title . '</span></h3>' : '';
if ($filter_output != "") {
$output .= "\n\t\t\t" . $filter_output;
}
$output .= "\n\t\t\t" . $items;
$output .= "\n\t\t" . '</div> ' . $this->endBlockComment('.spb_wrapper');
$output .= "\n\t" . '</div> ' . $this->endBlockComment($width);
if ($display_type == "masonry-fw" || $display_type == "masonry-gallery-fw") {
$output = $this->startRow($el_position, '', true, "full-width") . $output . $this->endRow($el_position, '', true);
} else {
$output = $this->startRow($el_position) . $output . $this->endRow($el_position);
}
global $sf_include_isotope;
$sf_include_isotope = true;
global $sf_has_portfolio;
$sf_has_portfolio = true;
return $output;
}
示例11: sf_excerpt
function sf_excerpt($limit)
{
global $post;
$excerpt = "";
$custom_excerpt = sf_get_post_meta($post->ID, 'sf_custom_excerpt', true);
if ($custom_excerpt != "") {
$excerpt = wp_trim_words($custom_excerpt, $limit);
} else {
$excerpt = wp_trim_words(get_the_excerpt(), $limit);
}
$excerpt = preg_replace('`\\[[^\\]]*\\]`', '', $excerpt);
return '<p>' . $excerpt . '</p>';
}
示例12: sf_mega_menu_add_custom_nav_fields
/**
* Add custom fields to $item nav object
* in order to be used in custom Walker
*
* @access public
* @since 1.0
* @return void
*/
function sf_mega_menu_add_custom_nav_fields($menu_item)
{
$menu_item->subtitle = sf_get_post_meta($menu_item->ID, '_menu_item_subtitle', true);
$menu_item->htmlcontent = sf_get_post_meta($menu_item->ID, '_menu_item_htmlcontent', true);
$menu_item->nocolumnspacing = sf_get_post_meta($menu_item->ID, '_menu_nocolumnspacing', true);
$menu_item->ismegamenu = sf_get_post_meta($menu_item->ID, '_menu_is_megamenu', true);
$menu_item->isnaturalwidth = sf_get_post_meta($menu_item->ID, '_menu_is_naturalwidth', true);
$menu_item->altstyle = sf_get_post_meta($menu_item->ID, '_menu_is_altstyle', true);
$menu_item->hideheadings = sf_get_post_meta($menu_item->ID, '_menu_hideheadings', true);
$menu_item->megatitle = sf_get_post_meta($menu_item->ID, '_menu_megatitle', true);
$menu_item->menuicon = sf_get_post_meta($menu_item->ID, '_menu_item_icon', true);
$menu_item->menuwidth = sf_get_post_meta($menu_item->ID, '_menu_item_width', true);
return $menu_item;
}
示例13: sf_add_desc_tab
/**
* Filter tabs and allow third parties to add their own
*
* Each tab is an array containing title, callback and priority.
* @see woocommerce_default_product_tabs()
*/
function sf_add_desc_tab($tabs = array())
{
global $post;
$pb_active = sf_get_post_meta($post->ID, '_spb_js_status', true);
$product_description = "";
if ($pb_active == "true") {
$product_description = sf_get_post_meta($post->ID, 'sf_product_description', true);
} else {
$product_description = get_the_content();
}
if ($product_description != "") {
$tabs['description'] = array('title' => __('Description', 'swiftframework'), 'priority' => 10, 'callback' => 'woocommerce_product_description_tab');
}
return $tabs;
}
示例14: content
protected function content($atts, $content = null)
{
$title = $width = $el_class = $output = $show_blog_aux = $exclude_categories = $blog_aux = $show_read_more = $offset = $posts_order = $content_output = $items = $item_figure = $el_position = '';
extract(shortcode_atts(array('title' => '', 'show_blog_aux' => 'yes', "blog_type" => "standard", "masonry_effect_type" => "effect-1", 'show_title' => 'yes', 'show_excerpt' => 'yes', "show_details" => 'yes', "offset" => '0', "posts_order" => 'DESC', "excerpt_length" => '20', 'show_read_more' => 'yes', "item_count" => '5', "category" => '', "exclude_categories" => '', "pagination" => "no", "content_output" => 'excerpt', 'el_position' => '', 'width' => '1/1', 'el_class' => ''), $atts));
$width = spb_translateColumnWidthToSpan($width);
/* for PRO users! - SIDEBAR CONFIG
================================================== */
$sidebar_config = sf_get_post_meta(get_the_ID(), 'sf_sidebar_config', true);
$sidebars = '';
if ($sidebar_config == "left-sidebar" || $sidebar_config == "right-sidebar") {
$sidebars = 'one-sidebar';
} else {
if ($sidebar_config == "both-sidebars") {
$sidebars = 'both-sidebars';
} else {
$sidebars = 'no-sidebars';
}
}
/* for PRO users! - BLOG AUX
================================================== */
if ($show_blog_aux == "yes" && $sidebars == "no-sidebars") {
$blog_aux = sf_blog_aux($width);
}
/* for PRO users! - BLOG ITEMS
================================================== */
$items = sf_blog_items($blog_type, $masonry_effect_type, $show_title, $show_excerpt, $show_details, $excerpt_length, $content_output, $show_read_more, $item_count, $category, $exclude_categories, $pagination, $sidebars, $width, $offset, $posts_order);
/* for PRO users! - FINAL OUTPUT
================================================== */
$el_class = $this->getExtraClass($el_class);
$output .= "\n\t" . '<div class="spb_blog_widget spb_content_element ' . $width . $el_class . '">';
$output .= "\n\t\t" . '<div class="spb_wrapper blog-wrap">';
$output .= $title != '' ? "\n\t\t\t" . '<h3 class="spb-heading"><span>' . $title . '</span></h3>' : '';
if ($blog_aux != "") {
$output .= "\n\t\t\t" . $blog_aux;
}
$output .= "\n\t\t\t" . $items;
$output .= "\n\t\t" . '</div> ' . $this->endBlockComment('.spb_wrapper');
$output .= "\n\t" . '</div> ' . $this->endBlockComment($width);
if ($blog_type == "masonry-fw") {
$output = $this->startRow($el_position, '', true, "full-width") . $output . $this->endRow($el_position, '', true);
} else {
$output = $this->startRow($el_position) . $output . $this->endRow($el_position);
}
global $sf_has_blog, $sf_include_imagesLoaded;
$sf_include_imagesLoaded = true;
$sf_has_blog = true;
return $output;
}
示例15: content
public function content($atts, $content = null)
{
$title = $order = $items = $el_class = $width = $el_position = '';
extract(shortcode_atts(array('title' => '', 'twitter_username' => '', 'tweets_count' => '6', 'animation' => 'fade', 'autoplay' => 'yes', 'el_class' => '', 'el_position' => '', 'width' => '1/1'), $atts));
$output = '';
if ($autoplay == "yes") {
$items .= '<div class="flexslider tweets-slider content-slider" data-animation="' . $animation . '" data-autoplay="yes"><ul class="slides cS-hidden">';
} else {
$items .= '<div class="flexslider tweets-slider content-slider" data-animation="' . $animation . '" data-autoplay="no"><ul class="slides cS-hidden">';
}
$items .= sf_get_tweets($twitter_username, $tweets_count);
$items .= '</ul></div>';
$sidebar_config = sf_get_post_meta(get_the_ID(), 'sf_sidebar_config', true);
$sidebars = '';
if ($sidebar_config == "left-sidebar" || $sidebar_config == "right-sidebar") {
$sidebars = 'one-sidebar';
} else {
if ($sidebar_config == "both-sidebars") {
$sidebars = 'both-sidebars';
} else {
$sidebars = 'no-sidebars';
}
}
$el_class = $this->getExtraClass($el_class);
$width = spb_translateColumnWidthToSpan($width);
$el_class .= ' testimonial';
$output .= "\n\t" . '<div class="spb_tweets_slider_widget ' . $width . $el_class . '">';
$output .= "\n\t" . '<div class="spb-bg-color-wrap">';
$output .= "\n\t\t" . '<div class="spb-asset-content spb_wrapper slider-wrap">';
$output .= $title != '' ? "\n\t\t\t" . '<div class="heading-wrap"><h3 class="spb-heading spb-center-heading">' . $title . '</h3></div>' : '';
if ($title == "") {
$output .= "\n\t\t\t" . '<div class="tweet-icon"><i class="fa-twitter"></i></div>';
}
$output .= "\n\t\t\t" . $items;
$output .= "\n\t\t" . '</div>';
$output .= "\n\t\t" . '</div> ' . $this->endBlockComment('.spb_wrapper');
$output .= "\n\t" . '</div> ' . $this->endBlockComment($width);
if ($sidebars == "no-sidebars") {
$output = $this->startRow($el_position, '', true) . $output . $this->endRow($el_position, '', true);
} else {
$output = $this->startRow($el_position) . $output . $this->endRow($el_position);
}
global $sf_include_carousel;
$sf_include_carousel = true;
return $output;
}