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


PHP get_post_custom函数代码示例

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


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

示例1: display_media

 public function display_media($location, $fallback = true, $fallbackhome = false)
 {
     global $post;
     ob_start();
     $media = $this->query_attachments($post->ID, $location);
     if (!$media->have_posts() && $fallback == true) {
         $media = $this->query_attachments($post->post_parent, $location);
     }
     if (!$media->have_posts() && $fallbackhome == true) {
         $frontpage_id = get_option('page_on_front');
         $media = $this->query_attachments($frontpage_id, $location);
     }
     if ($media->have_posts()) {
         while ($media->have_posts()) {
             $media->the_post();
             $media_info = get_post_custom(get_the_ID());
             if (isset($media_info['image_link']) && $media_info['image_link'][0]) {
                 echo '<a href="' . $media_info['image_link'][0] . '">';
             }
             echo wp_get_attachment_image(get_the_ID(), 'full');
             if (isset($media_info['image_link']) && $media_info['image_link'][0]) {
                 echo '</a>';
             }
         }
         wp_reset_postdata();
     } else {
         return false;
     }
     return ob_get_clean();
 }
开发者ID:jemjabella,项目名称:media-locations,代码行数:30,代码来源:class.frontend.php

示例2: custom_sidebar_callback

function custom_sidebar_callback($post)
{
    global $wp_registered_sidebars;
    $template_name = get_post_meta($post->ID, '_wp_page_template', true);
    $custom = get_post_custom($post->ID);
    if (isset($custom['custom_sidebar'])) {
        $val = $custom['custom_sidebar'][0];
    } elseif ($template_name == "template-contact.php") {
        $val = "Contact Page Sidebar";
    } else {
        $val = "0";
    }
    // Use nonce for verification
    wp_nonce_field(plugin_basename(__FILE__), 'custom_sidebar_nonce');
    // The actual fields for data entry
    $output = '<p><label for="myplugin_new_field">' . __("Choose a sidebar to display", 'kingsize') . '</label></p>';
    $output .= "<select name='custom_sidebar'>";
    // Add a default option
    $output .= "<option";
    if ($val == "0") {
        $output .= " selected='selected'";
    }
    $output .= " value='0'>" . __('Default', $themename) . "</option>";
    // Fill the select element with all registered sidebars
    foreach ($wp_registered_sidebars as $sidebar_id => $sidebar) {
        //
        $output .= "<option";
        if ($sidebar['name'] == $val) {
            $output .= " selected='selected'";
        }
        $output .= " value='" . $sidebar['name'] . "'>" . $sidebar['name'] . "</option>";
    }
    $output .= "</select>";
    echo $output;
}
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:35,代码来源:sidebar_generator.php

示例3: do_shortcode

 public function do_shortcode($args)
 {
     $content_type = get_post_type();
     $ct_settings = get_option(RAPHAEL_SETTINGS . '_' . $content_type);
     $settings = get_option(RAPHAEL_SETTINGS);
     $custom = get_post_custom();
     //dpr(get_defined_vars());
     $values = $colors = $labels = array();
     foreach ($ct_settings['active_custom_fields'] as $field) {
         $values[] = $custom[$field][0];
         $colors[] = $ct_settings['custom_field_colors'][$field];
         if ($ct_settings[$content_type . '_showlabels']) {
             $labels[] = str_replace("%v%", $custom[$field][0], $ct_settings['custom_field_label'][$field]);
         }
     }
     //dpr(get_defined_vars());dpr($ct_settings[$content_type.'_dohover']);
     $js = self::script_bar_chart($values, $colors, $labels, $ct_settings[$content_type . '_barendtype'], 'chart-wrapper', $ct_settings[$content_type . '_dohover']);
     //$func = function() use ($js) { print $js; };
     //$code = "print '$js';";
     //$func = create_function('', $code);
     //dpr(get_defined_vars());
     //add_action('wp_footer', $func );
     self::$footer_js .= $js;
     return '<div id="chart-wrapper" style="width:' . $ct_settings[$content_type . '_chartwidth'] . 'px; height:' . $ct_settings[$content_type . '_chartheight'] . 'px;"></div>';
 }
开发者ID:nullvariable,项目名称:Raphael-Charts-for-WordPress,代码行数:25,代码来源:raphael_charts_display.class.php

示例4: credits_meta

 public static function credits_meta()
 {
     global $post;
     $data = array();
     $custom = get_post_custom($post->ID);
     $data['portfolio_date'] = @$custom["portfolio_date"][0];
     $data['portfolio_clients'] = @$custom["portfolio_clients"][0];
     $data['portfolio_tools'] = @$custom["portfolio_tools"][0];
     $data['tmm_portfolio'] = unserialize(@$custom["tmm_portfolio"][0]);
     //***
     $data['portfolio_camera'] = @$custom["portfolio_camera"][0];
     $data['portfolio_camera_label'] = @$custom["portfolio_camera_label"][0];
     $data['portfolio_lens'] = @$custom["portfolio_lens"][0];
     $data['portfolio_lens'] = @$custom["portfolio_lens_label"][0];
     $data['portfolio_tripod_or_handheld'] = @$custom["portfolio_tripod_or_handheld"][0];
     $data['portfolio_tripod_or_handheld_label'] = @$custom["portfolio_tripod_or_handheld_label"][0];
     $data['portfolio_fl'] = @$custom["portfolio_fl"][0];
     $data['portfolio_fl_label'] = @$custom["portfolio_fl_label"][0];
     $data['portfolio_exposure'] = @$custom["portfolio_exposure"][0];
     $data['portfolio_exposure_label'] = @$custom["portfolio_exposure_label"][0];
     $data['portfolio_brackets'] = @$custom["portfolio_brackets"][0];
     $data['portfolio_brackets_label'] = @$custom["portfolio_brackets_label"][0];
     $data['portfolio_processed'] = @$custom["portfolio_processed"][0];
     $data['portfolio_processed_label'] = @$custom["portfolio_processed_label"][0];
     $data['portfolio_etc'] = @$custom["portfolio_etc"][0];
     $data['portfolio_etc_label'] = @$custom["portfolio_etc_label"][0];
     //***
     echo TMM::draw_html('portfolio/credits_meta', $data);
 }
开发者ID:mattmcgiv,项目名称:etp-almera-theme,代码行数:29,代码来源:portfolio.php

示例5: job_title

function job_title($post)
{
    $values = get_post_custom($post->ID);
    $job_title = isset($values['job_title']) ? esc_attr($values['job_title'][0]) : '';
    wp_nonce_field('my_meta_box_nonce', 'meta_box_nonce');
    ?>
	<style type="text/css" media="screen">
	  #job_title_box{}
	  #job_title_box label,
	  #job_title_box input,
	  #job_title_box small{}
	  #job_title_box label{
	    padding:0 2px;
	  }
    #job_title{
      width:100%;
    }
    #job_title_box small{
      padding:0 3px;
      color:#999;
    }
	</style>
	<div id="job_title_box">
  	<p>
  		<label for="job_title">Job title</label><br />
  		<input type="text" name="job_title" id="job_title" value="<?php 
    echo $job_title;
    ?>
" /><br />
  		<small>e.g. Director of Operations</small>
  	</p>

	</div><!-- #job_title_box -->
	<?php 
}
开发者ID:panopticist,项目名称:oats,代码行数:35,代码来源:team-meta.php

示例6: handle

 /**
  * Handles shortcode
  * @param $atts
  * @param null $content
  * @return string
  */
 public function handle($atts, $content = null)
 {
     $attributes = shortcode_atts($this->extractShortcodeAttributes($atts), $atts);
     extract($attributes);
     $products = $this->getCollection($attributes, array('post_type' => 'product'));
     $counter = 0;
     $categories = get_term_by('slug', $cat_name, 'product_category');
     if (!$categories) {
         return __('Product category slug not found: ', 'ct_theme') . $cat_name;
     }
     $categoryName = $categories->name;
     $category_description = $categories->description;
     $icons = $this->getDefaultIcons();
     if (isset($icons[$category_image])) {
         $category_image = $icons[$category_image];
     }
     $menuBoxHtml = '[menu_box style="' . $style . '" title="' . $categoryName . '" image="' . $category_image . '" description="' . $category_description . '"]';
     foreach ($products as $p) {
         $custom = get_post_custom($p->ID);
         $counter++;
         $imageSrc = $images == "yes" ? ct_get_feature_image_src($p->ID, 'full') : '';
         $thumb = $images == 'yes' ? ct_product_featured_image2_src($p->ID, 'product_thumb') : '';
         $price = str_replace('.', ',', $custom['price'][0]);
         $productPrice = explode(",", $price);
         $menuBoxHtml .= $this->embedShortcode('menu_box_item', array('thumb' => $thumb, 'image' => $imageSrc, 'separator' => $counter == count($products) ? 'no' : 'yes', 'title' => $p->post_title, 'price' => $productPrice[0], 'subprice' => isset($productPrice[1]) ? $productPrice[1] : ''), $p->post_content) . "\n";
     }
     $menuBoxHtml .= '[/menu_box]';
     return do_shortcode($menuBoxHtml);
 }
开发者ID:clevervaughn,项目名称:dottiesbiscuitbarn,代码行数:35,代码来源:ctMenuShortcode.class.php

示例7: edd_wl_is_users_list

/**
 * Check if the list belongs to the current user.
 *
 * @return  boolean true if list belongs to current user, false otherwise
 * @since 1.0
*/
function edd_wl_is_users_list($list_id)
{
    $list = get_post($list_id);
    $current_user_id = get_current_user_id();
    // should only be on view or edit page
    if (!(get_query_var('wl_edit') || get_query_var('wl_view'))) {
        return;
    }
    // logged in users
    if (is_user_logged_in() && (int) $list->post_author === $current_user_id) {
        return true;
    } elseif (!is_user_logged_in()) {
        // get token
        $token = edd_wl_get_list_token();
        $token = isset($token) ? $token : '';
        if ($token) {
            // get custom meta of post
            $current_list_meta = get_post_custom($list_id);
            $current_list_token = isset($current_list_meta['edd_wl_token'][0]) ? $current_list_meta['edd_wl_token'][0] : '';
            // if token matches the edd_wl_token then this list belongs to user
            if ($token === $current_list_token) {
                return true;
            }
        }
    }
    return false;
}
开发者ID:SelaInc,项目名称:eassignment,代码行数:33,代码来源:user-functions.php

示例8: wp_stripe_send_api

function wp_stripe_send_api($amount, $created, $post_id)
{
    //set POST variables
    $url = 'http://domain.com/get-post.php';
    $transaction_post = get_post_custom($post_id);
    $project_id = $transaction_post["wp-stripe-projectid"][0];
    if ($project_id) {
        $project = 1;
        $project_post = get_post_custom($post_id);
        $project_size = $project_post["wp-stripe-project-size"][0];
        $project_raised = $project_post["wp-stripe-project-raised"][0];
    } else {
        $project = 0;
        $project_size = 0;
        $project_raised = 0;
    }
    $fields = array('amount' => urlencode($amount), 'date' => urlencode($created), 'p' => urlencode($project), 'ps' => urlencode($project_size), 'pr' => urlencode($project_raised), 'country' => urlencode($country), 'type' => urlencode($type));
    //url-ify the data for the POST
    $fields_string = '';
    foreach ($fields as $key => $value) {
        $fields_string .= $key . '=' . $value . '&amp;';
    }
    rtrim($fields_string, '&amp;');
    //open connection
    $ch = curl_init();
    //set the url, number of POST vars, POST data
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, count($fields));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
    //execute post
    $result = curl_exec($ch);
    //close connection
    curl_close($ch);
}
开发者ID:ukrosoft,项目名称:virtuals,代码行数:34,代码来源:stripe-api.php

示例9: do_request

 public function do_request()
 {
     global $wc_software, $wpdb;
     $this->check_required(array('product_id', 'secret_key', 'email'));
     $input = $this->check_input(array('product_id', 'secret_key', 'email', 'order_id', 'version', 'key_prefix', 'activations'));
     if ($wc_software->check_product_secret($input['product_id'], $input['secret_key'])) {
         $key_prefix = $input['key_prefix'];
         $key = $wc_software->generate_licence_key();
         $version = $input['version'];
         $activations = $input['activations'];
         // Get product details
         $product_id = $wpdb->get_var($wpdb->prepare("\n\t\t\t\tSELECT post_id FROM {$wpdb->postmeta} \n\t\t\t\tWHERE meta_key = '_software_product_id' \n\t\t\t\tAND meta_value = %s LIMIT 1\n\t\t\t", $input['product_id']));
         if ($product_id) {
             $meta = get_post_custom($product_id);
             if (!$key_prefix) {
                 $key_prefix = $meta['_software_license_key_prefix'][0];
             }
             if (!$version) {
                 $version = $meta['_software_version'][0];
             }
             if (!$activations) {
                 $activations = $meta['_software_activations'][0];
             }
         }
         $data = array('order_id' => $input['order_id'], 'activation_email' => $input['email'], 'prefix' => $key_prefix, 'licence_key' => $key, 'software_product_id' => $input['product_id'], 'software_version' => $version, 'activations_limit' => $activations);
         $key_id = $wc_software->save_licence_key($data);
         $json = array('key' => $key_prefix . $key, 'key_id' => $key_id);
         return $json;
     } else {
         $this->wc_software_api->error('105', __('Non matching product_id and secret_key provided', 'wc_software'), null, array('activated' => false));
     }
 }
开发者ID:edelkevis,项目名称:git-plus-wordpress,代码行数:32,代码来源:class-wc-generate-key-request.php

示例10: cptbc_image_url

function cptbc_image_url()
{
    global $post;
    $custom = get_post_custom($post->ID);
    $cptbc_image_url = isset($custom['cptbc_image_url']) ? $custom['cptbc_image_url'][0] : '';
    $cptbc_image_url_openblank = isset($custom['cptbc_image_url_openblank']) ? $custom['cptbc_image_url_openblank'][0] : '0';
    ?>
  <label><?php 
    _e('Image URL', 'cpt-bootstrap-carousel');
    ?>
:</label>
  <input name="cptbc_image_url" value="<?php 
    echo $cptbc_image_url;
    ?>
" /> <br />
  <small><em><?php 
    _e('(optional - leave blank for no link)', 'cpt-bootstrap-carousel');
    ?>
</em></small><br /><br />
  <label><input type="checkbox" name="cptbc_image_url_openblank" <?php 
    if ($cptbc_image_url_openblank == 1) {
        echo ' checked="checked"';
    }
    ?>
 value="1" /> <?php 
    _e('Open link in new window?', 'cpt-bootstrap-carousel');
    ?>
</label>
  <?php 
}
开发者ID:warruda,项目名称:portalsaudecrianca,代码行数:30,代码来源:cpt-bootstrap-carousel.php

示例11: google_maps_shortcode

 /**
  * Google Maps Builder Shortcode
  *
  * Google Maps output relies on the shortcode to display
  *
  * @param $atts
  *
  * @return string
  */
 public function google_maps_shortcode($atts)
 {
     $atts = shortcode_atts(array('title' => '', 'id' => '', 'reference' => ''), $atts, 'google_maps');
     //gather data for this shortcode
     $post = get_post($atts['id']);
     $all_meta = get_post_custom($atts['id']);
     $visual_info = maybe_unserialize($all_meta['gmb_width_height'][0]);
     $lat_lng = maybe_unserialize($all_meta['gmb_lat_lng'][0]);
     //Put markers into an array for JS usage
     $map_marker_array = array();
     $markers_repeatable = isset($all_meta['gmb_markers_group'][0]) ? maybe_unserialize($all_meta['gmb_markers_group'][0]) : '';
     if (is_array($markers_repeatable)) {
         foreach ($markers_repeatable as $marker) {
             array_push($map_marker_array, $marker);
         }
     }
     //Send data for AJAX usage
     //Add params to AJAX for Shortcode Usage
     //@see: http://benjaminrojas.net/using-wp_localize_script-dynamically/
     $localized_data = apply_filters('gmb_localized_data', array($post->ID => array('id' => $atts['id'], 'map_params' => array('title' => $post->post_title, 'width' => $visual_info['width'], 'height' => $visual_info['height'], 'latitude' => $lat_lng['latitude'], 'longitude' => $lat_lng['longitude'], 'zoom' => !empty($all_meta['gmb_zoom'][0]) ? $all_meta['gmb_zoom'][0] : '15', 'default_marker' => apply_filters('gmb_default_marker', GMB_PLUGIN_URL . 'assets/img/spotlight-poi.png')), 'map_controls' => array('zoom_control' => !empty($all_meta['gmb_zoom_control'][0]) ? strtoupper($all_meta['gmb_zoom_control'][0]) : 'STANDARD', 'pan_control' => !empty($all_meta['gmb_pan'][0]) ? $all_meta['gmb_pan'][0] : 'none', 'map_type_control' => !empty($all_meta['gmb_map_type_control'][0]) ? $all_meta['gmb_map_type_control'][0] : 'none', 'draggable' => !empty($all_meta['gmb_draggable'][0]) ? $all_meta['gmb_draggable'][0] : 'none', 'double_click_zoom' => !empty($all_meta['gmb_double_click'][0]) ? $all_meta['gmb_double_click'][0] : 'none', 'wheel_zoom' => !empty($all_meta['gmb_wheel_zoom'][0]) ? $all_meta['gmb_wheel_zoom'][0] : 'none', 'street_view' => !empty($all_meta['gmb_street_view'][0]) ? $all_meta['gmb_street_view'][0] : 'none'), 'map_theme' => array('map_type' => !empty($all_meta['gmb_type'][0]) ? $all_meta['gmb_type'][0] : 'RoadMap', 'map_theme_json' => !empty($all_meta['gmb_theme_json'][0]) ? $all_meta['gmb_theme_json'][0] : 'none'), 'map_markers' => $map_marker_array, 'places_api' => array('show_places' => !empty($all_meta['gmb_show_places'][0]) ? $all_meta['gmb_show_places'][0] : 'no', 'search_radius' => !empty($all_meta['gmb_search_radius'][0]) ? $all_meta['gmb_search_radius'][0] : '3000', 'search_places' => !empty($all_meta['gmb_places_search_multicheckbox'][0]) ? maybe_unserialize($all_meta['gmb_places_search_multicheckbox'][0]) : ''), 'map_markers_icon' => !empty($all_meta['gmb_map_marker']) ? $all_meta['gmb_map_marker'][0] : 'none')));
     $this->array_push_localized_script($localized_data);
     ob_start();
     include $this->get_google_maps_template('public.php');
     return apply_filters('gmb_shortcode_output', ob_get_clean());
 }
开发者ID:Makenrro,项目名称:repos,代码行数:34,代码来源:class-gmb-engine.php

示例12: portfolio_meta_options

function portfolio_meta_options()
{
    global $post;
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return $post_id;
    }
    $custom = get_post_custom($post->ID);
    if (isset($custom["projLink"][0])) {
        $link = $custom["projLink"][0];
    }
    if (isset($custom["client"][0])) {
        $client = $custom["client"][0];
    }
    ?>
  
	<label>Link:</label><input name="projLink" value="<?php 
    if (isset($link)) {
        echo $link;
    }
    ?>
" /><br />
	<label>Client:</label><input name="client" value="<?php 
    if (isset($client)) {
        echo $client;
    }
    ?>
" />  
	<?php 
}
开发者ID:annbransom,项目名称:techishowl-wp,代码行数:29,代码来源:posttype-portfolio.php

示例13: getPurchases

 function getPurchases($id, $type)
 {
     $data = array();
     if ($this->options['show_purchases'] == 'on') {
         switch ($type) {
             case 'woo':
                 $results = $this->wpdb->get_results($this->wpdb->prepare('select post_id from ' . $this->wpdb->postmeta . ' where meta_key = %s and meta_value = %d', '_customer_user', $id));
                 if ($results) {
                     foreach ($results as $row) {
                         $meta = get_post_custom($row->post_id);
                         if (in_array('_completed_date', array_keys($meta))) {
                             $date = date(get_option('date_format'), strtotime($meta['_completed_date'][0]));
                             foreach ($meta['_order_items'] as $item) {
                                 $itemData = unserialize($item);
                                 foreach ($itemData as $i) {
                                     $v .= '<a href="' . get_permalink($i['id']) . '">' . $i['name'] . '</a> - <span class="loginx_em"> ' . $date . '</span><br />';
                                 }
                             }
                             $data[] = substr($v, 0, -6);
                         }
                     }
                 }
                 break;
         }
     }
     return $data;
 }
开发者ID:laiello,项目名称:suitex,代码行数:27,代码来源:loginx_profile_obj.php

示例14: __construct

 public function __construct($post)
 {
     // Get associated post
     if (is_object($post) && $post instanceof WP_Post) {
         $this->post = $post;
     } else {
         if (is_numeric($post)) {
             $this->post = get_post($post);
         } else {
             throw new InvalidArgumentException('Recipes can only be instantiated with a Post object or Post ID.');
         }
     }
     // Add custom fields to recipe fields if there are any
     $custom_fields_addon = WPUltimateRecipe::addon('custom-fields');
     if ($custom_fields_addon) {
         $fields = $this->fields;
         $custom_fields = $custom_fields_addon->get_custom_fields();
         foreach ($custom_fields as $key => $custom_field) {
             $fields[] = $key;
         }
         $this->fields = $fields;
     }
     // Get metadata
     $this->meta = get_post_custom($this->post->ID);
 }
开发者ID:mehshan,项目名称:wp-ultimate-recipe,代码行数:25,代码来源:recipe.php

示例15: getWordpressData

    static function getWordpressData() {
        /**
         * Get all global page data
         */
        $blogDataParams = array(
            'url', 'wpurl', 'description', 'rdf_url' , 'rss_url', 'rss2_url'
            , 'atom_url', 'comments_atom_url', 'comments_rss2_url', 'pingback_url'
            , 'stylesheet_url', 'stylesheet_directory', 'template_directory'
            , 'template_url', 'admin_email', 'charset', 'html_type', 'version'
            , 'language', 'text_direction', 'name'
        );

        $blogData = array();

        foreach($blogDataParams as $blogDataParam) {
            $blogData[self::toCamelCase($blogDataParam)] = get_bloginfo($blogDataParam);
        }

        $blogData = array_merge($blogData, array(
            'title'            => wp_title(' | ', false, 'right') . get_bloginfo('name'),
            'archiveLinksHTML' => wp_get_archives('type=monthly&limit=5&format=link&echo=0'),
            'bodyClasses'      => self::getEchoFunctionContents('body_class'),
            'posts'            => array()
        ));

        /**
         * Get posts data
         */
        while (have_posts()) {
            the_post();
            
            $postId     = get_the_ID();

            // Get category data
            $categories = get_the_category();
            $categoryNames = array();
            foreach($categories as $category) {
                array_push($categoryNames, $category->cat_name);
            }

            // Add all relevant post data to the posts array
            array_push(
                $blogData['posts'],
                array_merge(
                    get_object_vars(get_post($postId)),
                    array(
                        'classes'       => get_post_class(),
                        'comments'      => get_comments(array('post_id' => $postId)),
                        'custom'        => get_post_custom(),
                        'permalink'     => get_permalink(),
                        'categories'    => $categories,
                        'categoryNames' => $categoryNames,
                        'categoriesStr' => implode(',', $categoryNames)
                    )
                )
            );
        }

        return $blogData;
    }
开发者ID:nottrobin,项目名称:rw-theme,代码行数:60,代码来源:SitesUtil.php


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