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


PHP get_field函数代码示例

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


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

示例1: get_Relationships_by_Tag

 public function get_Relationships_by_Tag($tag, $_method, $_route, $_path, $_headers)
 {
     if (empty($tag) || !is_string($tag)) {
         return new WP_Error('json_options_invalid_tag', __("Invalid options tag"), ['status' => 404]);
     }
     $site = $_headers['REMOTE'];
     $tags = explode(',', $tag);
     if ($tags) {
         $tags_query['relation'] = 'OR';
         foreach ($tags as $tag) {
             $tags_query[] = array('key' => 'related_tags', 'value' => $tag, 'compare' => 'LIKE');
         }
     }
     $args = array('post_type' => 'relationship', 'meta_query' => array('relation' => 'AND', array('key' => 'site_address', 'value' => $site), $tags_query));
     $relationships = new WP_Query($args);
     if ($relationships->have_posts()) {
         // Get the Target Categories
         $targets = [];
         while ($relationships->have_posts()) {
             $relationships->the_post();
             $targets[] = get_field('target_category');
         }
         $targets = dedupe($targets);
         $related_categories = implode(', ', $targets);
         // Find Matching Relationships
         $args = array('post_type' => 'relationship', 'tax_query' => array(array('taxonomy' => 'related_categories', 'terms' => $related_categories)));
         $relationships = new WP_Query($args);
         // Build Relationships JSON Reponse
         include 'related-json-response.php';
     }
     wp_reset_query();
     return $sites;
 }
开发者ID:fullsteamlabs,项目名称:root-around,代码行数:33,代码来源:class-root-around-relationships.php

示例2: rd_after_container

 function rd_after_container()
 {
     $post_sidebar = '';
     if (is_product()) {
         if (get_field('product_sidebar')) {
             $post_sidebar = get_field('product_sidebar');
         }
         if ($post_sidebar == 'sidebar_default' || empty($post_sidebar)) {
             $post_sidebar = rd_options('reedwan_woo_product_sidebar_position');
         }
     } elseif (is_shop()) {
         $pageID = get_option('woocommerce_shop_page_id');
         if (get_field('page_sidebar', $pageID)) {
             $post_sidebar = get_field('page_sidebar', $pageID);
         }
         if ($post_sidebar == 'sidebar_default' || empty($post_sidebar)) {
             $post_sidebar = rd_options('reedwan_woo_archive_sidebar_position');
         }
     } elseif (is_product_category() || is_product_tag()) {
         $post_sidebar = rd_options('reedwan_woo_archive_sidebar_position');
     } else {
         $post_sidebar = 'sidebar_none';
     }
     echo '</div>';
     if ($post_sidebar != 'sidebar_none') {
         echo '<div class="sidebar grid_3">';
         if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('woo-sidebar')) {
         }
         echo '</div>';
     }
     echo '</div></div></div>';
 }
开发者ID:devmoonshine,项目名称:development,代码行数:32,代码来源:woo_config.php

示例3: setup_read_touch_easy_seo_caps

function setup_read_touch_easy_seo_caps()
{
    $roles = touch_easy_seo_touch_get_lower_roles();
    $allowed_roles = get_field('allowed_roles_for_touch_seo', 'options');
    // Do not allow rights modification of administrator and current role
    if (isset($roles["administrator"])) {
        unset($roles["administrator"]);
    }
    // ALWAYS ALLOW ADMINISTRATORS TO VIEW THE PLUGIN
    $adminRole = get_role("administrator");
    if (current_user_can("administrator") && !current_user_can("read_touch-easy-seo")) {
        $adminRole->add_cap("read_touch-easy-seo");
    }
    if (current_user_can("administrator") && !current_user_can("read_touch-easy-seo-settings")) {
        $adminRole->add_cap("read_touch-easy-seo-settings");
    }
    foreach ($roles as $role_name => $role_info) {
        $role = get_role($role_name);
        if ($allowed_roles != '' && in_array($role_name, $allowed_roles) && !$role->has_cap("read_touch-easy-seo")) {
            $role->add_cap("read_touch-easy-seo");
        } elseif ($allowed_roles != '' && $role->has_cap("read_touch-easy-seo") && !in_array($role_name, $allowed_roles)) {
            $role->remove_cap("read_touch-easy-seo");
        } elseif ($allowed_roles == '' && $role->has_cap("read_touch-easy-seo")) {
            $role->remove_cap("read_touch-easy-seo");
        }
    }
}
开发者ID:tofubuddha,项目名称:example,代码行数:27,代码来源:touch-meta-tags.php

示例4: display_add_field

 function display_add_field($recordid = 0)
 {
     if ($recordid) {
         $content = get_field('data_content', 'content', 'fieldid', $this->field->id, 'recordid', $recordid);
         $content = explode('##', $content);
     } else {
         $content = array();
     }
     $str = '<div title="' . s($this->field->description) . '">';
     $str .= '<select name="field_' . $this->field->id . '[]" id="field_' . $this->field->id . '" multiple="multiple">';
     foreach (explode("\n", $this->field->param1) as $option) {
         $option = trim($option);
         $str .= '<option value="' . s($option) . '"';
         if (array_search($option, $content) !== false) {
             // Selected by user.
             $str .= ' selected >';
         } else {
             $str .= '>';
         }
         $str .= $option . '</option>';
     }
     $str .= '</select>';
     $str .= '</div>';
     return $str;
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:25,代码来源:field.class.php

示例5: constantcontact_submit

function constantcontact_submit()
{
    $form_email = $_REQUEST['constantcontact_email'];
    if ($form_email) {
        $cc_user = get_field('constant_contact_username', 'option');
        $cc_pass = get_field('constant_contact_password', 'option');
        $cc_group = get_field('constant_contact_group_name', 'option');
        if (empty($cc_user) || empty($cc_pass) || empty($cc_group)) {
            $message = 'Plugin Settings incomplete';
        } else {
            if (empty($form_email)) {
                $message = 'Email address is required.';
            } else {
                $cc_url = 'https://api.constantcontact.com/0.1/API_AddSiteVisitor.jsp?' . 'loginName=' . rawurlencode($cc_user) . '&loginPassword=' . rawurlencode($cc_pass) . '&ea=' . rawurlencode($form_email) . '&ic=' . rawurlencode($cc_group);
                $response = wp_remote_get($cc_url);
                if (is_wp_error($response)) {
                    $message = 'Could not connect to Constant Contact';
                } else {
                    $rsp = explode("\n", $response['body']);
                    if (intval($rsp[0])) {
                        $message = !empty($rsp[1]) ? $rsp[1] : (intval($rsp[0]) == 400 ? __('Constant Contact username/password not accepted') : __('Constant Contact error'));
                    } else {
                        $message = get_field('constant_contact_success_message', 'option');
                        $message = $message ? $message : "Thank you, you've been added to the list!";
                        $message_type = 'success';
                    }
                }
            }
        }
        if ($message) {
            $tabby_cc_param = array('message' => $message, 'message_type' => $message_type ? $message_type : 'error');
            wp_localize_script('jquery', 'tabby_cc_param', $tabby_cc_param);
        }
    }
}
开发者ID:slavic18,项目名称:cats,代码行数:35,代码来源:tabbysplace-constant-contact.php

示例6: get_widget_meta

 public static function get_widget_meta($widget_id, $meta_key)
 {
     if (!self::exists() || !$meta_key || !$widget_id) {
         return;
     }
     return get_field($meta_key, 'widget_' . $widget_id);
 }
开发者ID:pkostadinov-2create,项目名称:acf-widgets-example,代码行数:7,代码来源:acf-widgets.php

示例7: insert_fb_in_head

function insert_fb_in_head()
{
    global $post;
    if (!is_single()) {
        echo '<meta property="fb:app_id" content="964610463630306">';
        echo '<meta property="og:title" content="SMS Brandname"/>';
        echo '<meta property="og:type" content="website">';
        echo '<meta property="og:url" content="' . home_url() . '"/>';
        echo '<meta property="og:site_name" content="SMS Brandname"/>';
        echo '<meta property="og:description" content="Cam kết giá dịch vụ, Tính năng hữu ích, Khác biệt và tươi mới, Tốc độ và niềm tin, Hổ trợ tuyệt vời">';
        echo "";
        return;
    }
    //
    $current_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    echo '<meta property="fb:app_id" content="964610463630306">';
    echo '<meta property="og:title" content="' . get_the_title() . '"/>';
    echo '<meta property="og:type" content="website">';
    echo '<meta property="og:url" content="' . $current_url . '"/>';
    echo '<meta property="og:site_name" content="SMS Brandname"/>';
    echo '<meta property="og:description" content="Cam kết giá dịch vụ, Tính năng hữu ích, Khác biệt và tươi mới, Tốc độ và niềm tin, Hổ trợ tuyệt vời">';
    echo "";
    if (is_single()) {
        $image = get_field('image');
        echo '<meta property="og:image" content="' . $image['sizes']['large'] . '"/>';
    } else {
        $default_image = "http://sms.viet-digital.com/wp-content/uploads/2016/03/logo-top.png";
        echo '<meta property="og:image" content="' . $default_image . '"/>';
    }
    echo "";
}
开发者ID:localymine,项目名称:sms-brandname,代码行数:31,代码来源:my_facebook_share.php

示例8: vc_gitem_template_attribute_acf

/**
 * Get ACF data
 *
 * @param $value
 * @param $data
 *
 * @return string
 */
function vc_gitem_template_attribute_acf($value, $data)
{
    $label = '';
    /**
     * @var null|Wp_Post $post ;
     * @var string $data ;
     */
    extract(array_merge(array('post' => null, 'data' => ''), $data));
    if (strstr($data, 'field_from_group_')) {
        $group_id = preg_replace('/(^field_from_group_|_labeled$)/', '', $data);
        $fields = function_exists('acf_get_fields') ? acf_get_fields($group_id) : apply_filters('acf/field_group/get_fields', array(), $group_id);
        $field = is_array($fields) && isset($fields[0]) ? $fields[0] : false;
        if (is_array($field) && isset($field['key'])) {
            $data = $field['key'] . (strstr($data, '_labeled') ? str_replace($data, '', '_labeled') : '');
        }
    }
    if (preg_match('/_labeled$/', $data)) {
        $data = preg_replace('/_labeled$/', '', $data);
        $field = apply_filters('acf/load_field', array(), $data);
        $label = is_array($field) ? '<span class="vc_gite-acf-label">' . $field['label'] . ':</span> ' : '';
    }
    if (get_field($data)) {
        $value = apply_filters('vc_gitem_template_attribute_acf_value', get_field($data, $post->ID));
    }
    return strlen($value) > 0 ? $label . $value : '';
}
开发者ID:hikaram,项目名称:wee,代码行数:34,代码来源:grid-item-attributes.php

示例9: get_all_feature_meta

	function get_all_feature_meta($posts) {
		$meta_fetch_list = array (
			"feature_name",
			"feature_usage",
			"feature_action_cost",
			"flavor_text",
			"feature_requirement",
			"feature_text",
			"trigger",
			"atk_block"
			);

		$abilities = array();

		$i = 0;

		foreach ($posts as $post) {
			$abilities[$i]["title"] = $post->post_title;
			$abilities[$i]["id"] = $post->ID;
			$abilities[$i]["data"] = array();

			foreach ($meta_fetch_list as $field) {
				$abilities[$i]['data'][$field] = get_field($field, $post->ID);
			}

			$i++;
		}

		return $abilities;
	}
开发者ID:supahseppe,项目名称:path-of-gaming,代码行数:30,代码来源:create_monster_json.php

示例10: ecs_newpatient_module_content_filter

    function ecs_newpatient_module_content_filter($content)
    {
        $page = get_field('option_newpatient_page', 'option');
        if (is_page($page->ID)) {
            ob_start();
            if (get_field('option_vacation_notice', 'option')) {
                ?>
					
				<div class="info">
					
					<?php 
                the_field('option_vacation_notice_text', 'option');
                ?>

				</div>

				<?php 
            }
            gravity_form_enqueue_scripts(3, true);
            gravity_form(3, false, false, false, '', true, 1);
            return ob_get_clean();
        } else {
            return $content;
        }
    }
开发者ID:Johnystardust,项目名称:ecs-247-bereikbaar,代码行数:25,代码来源:newpatient.php

示例11: andclose

function andclose($PID, $order_id)
{
    // NEED TO ADD ORDER ARCHIVE FILTER
    $archive = get_field('order_archive', $PID);
    __update_post_meta($PID, 'order_archive', $value = '');
    __update_post_meta($PID, 'order_count', $value = $archive);
}
开发者ID:avijitdeb,项目名称:flatterbox.com,代码行数:7,代码来源:flatterbox_action.php

示例12: __construct

 function __construct()
 {
     $this->sitemap_url = get_field('catfish_website_url', 'option') . "sitemap-index.xml";
     $this->sitemap_xml = file_get_contents($this->sitemap_url);
     $this->service = new \Sabre\Xml\Service();
     $this->do_mapping();
 }
开发者ID:shortlist-digital,项目名称:agreable-catfish-importer-plugin,代码行数:7,代码来源:SitemapParser.php

示例13: aps_scholarship_article_month

function aps_scholarship_article_month()
{
    $state = get_field('scholarship_article_journal_publication_month');
    if ($state) {
        echo $state . ' ';
    }
}
开发者ID:gato-gordo,项目名称:association-print-scholars,代码行数:7,代码来源:scholarship_functions.php

示例14: pp_get_acf_image

/**
 * Returns html for an ACF image
 *
 * ### Usage:
 * ```php
 * $image = pp_get_acf_image($image, $size, $classes);
 * if ( $image ) {
 *	echo $image;
 * }
 * ```
 *
 * @package pp
 * @subpackage boilerplate-theme
 *
 * @param array|string  $image 			Image array as returned by ACF, or field name as a string
 * @param string $size 					Image size
 * @param string $classes 				Classes to be added
 * @link http://www.advancedcustomfields.com/resources/image/
 * @return string 						HTML output
 *
 */
function pp_get_acf_image($image, $size = 'thumbnail', $classes = '')
{
    // Bail early if there's no image
    if (!is_array($image)) {
        // Maybe it's a string with a field name?
        $field = get_field($image);
        if ($field) {
            $image = $field;
        } else {
            return false;
        }
    }
    $img = '<img src="' . $image['sizes'][$size] . '"';
    // Alt
    if (!empty($image['alt'])) {
        $img .= ' alt="' . $image['alt'] . '"';
    }
    // Title
    if (!empty($image['title'])) {
        $img .= ' title="' . $image['title'] . '"';
    }
    // Classes
    if ($classes) {
        $img .= ' class="' . $classes . '"';
    }
    // width/height
    $img .= ' width="' . $image['sizes'][$size . '-width'] . '"';
    $img .= ' height="' . $image['sizes'][$size . '-height'] . '" />';
    return $img;
}
开发者ID:nathansh,项目名称:penguinpress-theme,代码行数:51,代码来源:images.php

示例15: testimonialssingle

function testimonialssingle($att)
{
    //echo '<pre>';
    $posts = get_post($att['id']);
    //print_r($posts);
    return '<div class="testmlist"><p><i class="fa-left-quote"></i><span>' . $posts->post_content . '</span><i class="fa-right-quote"></i></p> <div class="test-details">' . get_the_post_thumbnail($posts->ID) . '</div><div class="test-name"><strong>' . $posts->post_title . '</strong> ' . get_field('position', $posts->ID) . '</div></div>';
}
开发者ID:femgineer,项目名称:website,代码行数:7,代码来源:CustomShortCode.php


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