Ejemplo n.º 1
0
function prez($args = 'nope')
{
    $argType = gettype($args);
    if ($argType == 'string') {
        $prez = get_fields();
    } elseif ($argType == 'array') {
        $prez = $args;
    } elseif ($argType == 'integer') {
        $prez = get_fields($args);
    }
    echo '<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.2/highlight.min.js"></script>';
    echo '<script type="text/javascript">hljs.initHighlightingOnLoad();</script>';
    echo '<style>.hljs{display:block;overflow-x:auto;padding:.5em;background:#f0f0f0;-webkit-text-size-adjust:none}.apache .hljs-cbracket,.apache .hljs-tag,.asciidoc .hljs-header,.bash .hljs-variable,.coffeescript .hljs-attribute,.django .hljs-variable,.erlang_repl .hljs-function_or_atom,.haml .hljs-symbol,.hljs-addition,.hljs-constant,.hljs-flow,.hljs-parent,.hljs-pragma,.hljs-preprocessor,.hljs-rules .hljs-value,.hljs-stream,.hljs-string,.hljs-tag .hljs-value,.hljs-template_tag,.hljs-title,.markdown .hljs-header,.ruby .hljs-symbol,.ruby .hljs-symbol .hljs-string,.smalltalk .hljs-class,.tex .hljs-command,.tex .hljs-special{color:#800}.asciidoc .hljs-blockquote,.diff .hljs-header,.hljs-annotation,.hljs-chunk,.hljs-comment,.hljs-template_comment,.markdown .hljs-blockquote,.smartquote{color:#888}.asciidoc .hljs-bullet,.asciidoc .hljs-link_url,.go .hljs-constant,.hljs-change,.hljs-date,.hljs-hexcolor,.hljs-literal,.hljs-number,.hljs-regexp,.lasso .hljs-variable,.makefile .hljs-variable,.markdown .hljs-bullet,.markdown .hljs-link_url,.smalltalk .hljs-char,.smalltalk .hljs-symbol{color:#080}.apache .hljs-sqbracket,.asciidoc .hljs-attribute,.asciidoc .hljs-link_label,.clojure .hljs-attribute,.coffeescript .hljs-property,.erlang_repl .hljs-reserved,.haml .hljs-bullet,.hljs-array,.hljs-attr_selector,.hljs-decorator,.hljs-deletion,.hljs-doctype,.hljs-envvar,.hljs-filter .hljs-argument,.hljs-important,.hljs-javadoc,.hljs-label,.hljs-localvars,.hljs-phony,.hljs-pi,.hljs-prompt,.hljs-pseudo,.hljs-shebang,.lasso .hljs-attribute,.markdown .hljs-link_label,.nginx .hljs-built_in,.ruby .hljs-string,.tex .hljs-formula,.vhdl .hljs-attribute{color:#88f}.apache .hljs-tag,.asciidoc .hljs-strong,.bash .hljs-variable,.css .hljs-tag,.hljs-built_in,.hljs-dartdoc,.hljs-id,.hljs-javadoctag,.hljs-keyword,.hljs-phpdoc,.hljs-request,.hljs-status,.hljs-title,.hljs-type,.hljs-typename,.hljs-winutils,.hljs-yardoctag,.markdown .hljs-strong,.smalltalk .hljs-class,.tex .hljs-command{font-weight:400}.asciidoc .hljs-emphasis,.markdown .hljs-emphasis{font-style:italic}.nginx .hljs-built_in{font-weight:400}.coffeescript .javascript,.javascript .xml,.lasso .markup,.tex .hljs-formula,.xml .css,.xml .hljs-cdata,.xml .javascript,.xml .vbscript{opacity:.5}.hljs,.hljs-change,.hljs-flow,.hljs-keyword,.hljs-literal,.hljs-strong,.hljs-tag,.hljs-tag .hljs-title,.hljs-winutils,.nginx .hljs-title,.tex .hljs-special{color:#fff}.hljs .hljs-constant,.hljs-code{color:#66d9ef}.hljs-class .hljs-title,.hljs-code,.hljs-header{color:#fff}.hljs-attribute,.hljs-link_label,.hljs-regexp,.hljs-symbol,.hljs-symbol .hljs-string,.hljs-value{color:#bf79db}.apache .hljs-cbracket,.apache .hljs-tag,.django .hljs-filter .hljs-argument,.django .hljs-template_tag,.django .hljs-variable,.hljs-addition,.hljs-attr_selector,.hljs-built_in,.hljs-bullet,.hljs-emphasis,.hljs-envvar,.hljs-javadoc,.hljs-link_url,.hljs-pragma,.hljs-preprocessor,.hljs-prompt,.hljs-pseudo,.hljs-stream,.hljs-string,.hljs-subst,.hljs-tag .hljs-value,.hljs-title,.hljs-type,.ruby .hljs-class .hljs-parent,.smalltalk .hljs-array,.smalltalk .hljs-class,.smalltalk .hljs-localvars,.tex .hljs-command{color:#1E824C}.apache .hljs-sqbracket,.hljs-annotation,.hljs-blockquote,.hljs-comment,.hljs-decorator,.hljs-deletion,.hljs-doctype,.hljs-horizontal_rule,.hljs-pi,.hljs-shebang,.hljs-template_comment,.smartquote,.tex .hljs-formula{color:#75715e}.apache .hljs-tag,.bash .hljs-variable,.css .hljs-id,.diff .hljs-header,.hljs-chunk,.hljs-dartdoc,.hljs-header,.hljs-keyword,.hljs-literal,.hljs-phpdoc,.hljs-request,.hljs-status,.hljs-title,.hljs-type,.hljs-winutils,.rsl .hljs-built_in,.smalltalk .hljs-class,.tex .hljs-special,.vbscript .hljs-built_in{font-weight:700}.coffeescript .javascript,.javascript .xml,.tex .hljs-formula,.xml .css,.xml .hljs-cdata,.xml .javascript,.xml .vbscript{opacity:.5}body{height:100%}.hljs{color:#C8F7C5}#pre-z{width:100%;position:fixed;top:0;height:100%;overflow-y:scroll;left:-100%;z-index:999999;-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;transition:all .2s ease-in-out}input.pre-z-check{display:none}label.pre-z-lbl{color:#FFF;background-color:rgba(46,204,113,.95);padding:10px 30px;position:fixed;top:10px;left:0;z-index:999999;text-align:center;cursor:pointer;-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;transition:all .2s ease-in-out}label.pre-z-lbl-x{color:#FFF;background-color:rgba(46,204,113,.95);padding:10px 30px;position:fixed;top:10px;left:0;z-index:9999999;-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;transition:all .2s ease-in-out;cursor:pointer;opacity:0;border:3px solid #fff;border-left:0}#pre-z pre{margin:0;font-size:12px;font-family:"Lucida Sans Unicode","Lucida Grande",sans-serif;background-color:rgba(46,204,113,.95);color:#FFF;border:none;border-radius:0;padding-top:5px;height:100%}#pre-z code{background-color:transparent;height:100%}input.pre-z-check:checked~#pre-z{left:0}input.pre-z-check:checked~label.pre-z-lbl{opacity:0}input.pre-z-check:checked~label.pre-z-lbl-x{opacity:1}#pre-z p{padding:50px;text-align:center;word-break:break-all;word-wrap:break-word;line-height:1.4;font-size:14px}#pre-z p span{font-size:150%}#pre-z h1{font-size:50px;text-align:center}</style>
	<input id="pre-z-check" type="checkbox" class="pre-z-check">
	<label class="pre-z-lbl" for="pre-z-check">PRE-Z</label>
	<label class="pre-z-lbl-x" for="pre-z-check">CLOSE</label>
	<div id="pre-z">
	<pre><code class="css"><h1>PRE-Z</h1>';
    if ($prez) {
        print_r($prez);
    } else {
        echo '<p>SOMETHING WENT WRONG</p>';
    }
    echo '</code></pre></div>';
}
Ejemplo n.º 2
0
 /**
  * Get all of the custom fields of this object from ACF and Wordpress
  *
  * @param  bool $run Whether or not to get the custom fields
  * @param  string[] $keys Only get specific keys
  * @return $this
  */
 public function getCustomFields(bool $run = false, array $keys = null) : User
 {
     if (!$run) {
         return $this;
     }
     // If keys is set and ACF is enabled, just get the specific keys from WP
     if (!empty($keys) && function_exists('get_field')) {
         foreach ($keys as $key) {
             $this->data[$key] = get_field($key, 'user_' . $this->data['ID']);
         }
     } else {
         // Check the Wordpress-set custom fields and if they're single item arrays
         // convert them to strings
         $wordpressMeta = (array) ((array) get_userdata($this->data['ID']))['data'];
         foreach ($wordpressMeta as &$value) {
             if (is_array($value) && count($value) === 1) {
                 $value = current($value);
             }
         }
         // Get the custom fields from ACF, if ACF is enabled
         $acfMeta = [];
         if (function_exists('get_fields')) {
             $acfMeta = get_fields('user_' . $this->data['ID']);
             if (!$acfMeta) {
                 $acfMeta = [];
             }
         }
         // Merge the data together for all of the custom fields
         $this->data = array_merge($this->data, $wordpressMeta, $acfMeta);
     }
     return $this;
 }
Ejemplo n.º 3
0
function create_xml($table, $conn)
{
    //получаем названия столбцов
    $fields = get_fields($table, $conn);
    //получаем данные
    $data_from_table = get_data($table, $conn);
    //создаем объект документа
    $dom = new DOMDocument('1.0', 'UTF-8');
    //создаем корневой элемент по имени таблицы
    $catalog = $dom->createElement("catalog");
    $dom->appendChild($catalog);
    //создаем контейнер для обектов
    $entities = $dom->createElement("entities");
    $catalog->appendChild($entities);
    //создаем и добавляем объекты
    foreach ($data_from_table as $value) {
        $entity = $dom->createElement("entity");
        $attribute_id = $dom->createAttribute('id');
        $attribute_id->value = $value[0];
        $entity->appendChild($attribute_id);
        for ($k = 0, $i = count($fields); $k < $i; $k++) {
            $name_tag = $dom->createElement($fields[$k], $value[$k]);
            $entity->appendChild($name_tag);
        }
        $entities->appendChild($entity);
    }
    //сохраняем документ
    $dom->save("files/xml/" . $table . ".xml");
}
function getCompany($id)
{
    $post = get_post($id);
    $acfs = get_fields($post->ID);
    $post = array_merge((array) $post, (array) $acfs);
    return $post;
}
Ejemplo n.º 5
0
function sponsor_box_tag($atts)
{
    global $post;
    $align = $atts['align'];
    $option = get_fields('option');
    return Timber::compile('partials/content-box-sponsor.twig', array('post' => $post, 'align' => $align, 'option' => $option));
}
Ejemplo n.º 6
0
 /**
  * Make sure that all custom fields get attached to wp-api json output
  *
  * @since    1.0.0
  */
 function wp_api_encode_acf($data, $post, $context)
 {
     if (get_fields($post['ID'])) {
         $data['meta'] = array_merge($data['meta'], get_fields($post['ID']));
     }
     return $data;
 }
Ejemplo n.º 7
0
 function add_to_context($context)
 {
     $context['main_menu'] = new TimberMenu('primary_navigation');
     $context['site'] = $this;
     $context['options'] = get_fields('option');
     return $context;
 }
Ejemplo n.º 8
0
 public static function ACF_featured_content($post_id)
 {
     $fields = get_fields($post_id);
     $fields = self::parsed_ACF($fields);
     $content = array('image' => null, 'standfirst' => null);
     if (!isset($fields['left'])) {
         return $content;
     }
     $fields = $fields['left'];
     if (empty($fields)) {
         return $content;
     }
     foreach ($fields as $field) {
         if (empty($field)) {
             continue;
         }
         foreach ($field as $subfields) {
             foreach ($subfields as $name => $subfield) {
                 if ($name == 'vac_block_image_slider') {
                     $image = $subfield[0];
                     $content['image'] = array('id' => $image['id'], 'caption' => $image['caption'], 'alt' => $image['alt']);
                 }
                 if ($name == 'vac_block_standfirst') {
                     $content['standfirst'] = $subfield;
                 }
             }
         }
     }
     return $content;
 }
 public function get_fields($data = NULL, $object = NULL, $context = NULL)
 {
     $this->format_id($object);
     if (!($data['acf'] = get_fields($this->id))) {
         $data['acf'] = array();
     }
     return apply_filters("acf_to_wp_rest_api_{$this->type}_data", $data, $object, $context);
 }
 static function display($brick_id)
 {
     $BrickClass = get_post_meta($brick_id, SlidesPostType::$brick_type_key, true);
     $BrickClass::display(get_fields($brick_id));
     // echo "<pre>";
     // print_r(get_fields($brick_id));
     // echo "</pre>";
 }
Ejemplo n.º 11
0
function option($key = null)
{
    static $options;
    if (!isset($options)) {
        $options = get_fields('option');
    }
    return $key == null ? $options : (isset($options[$key]) ? $options[$key] : null);
}
Ejemplo n.º 12
0
/**
 * Makes custom fields created with Advanced Custom Fields available in the
 * WP Rest API
 * 
 * @package d7
 * @subpackage boilerplate-plugin_filters+hooks
 * 
 * @link http://wp-api.org WP JSON API documentation
 * @link http://codex.wordpress.org/Function_Reference/is_plugin_active is_plugin_active
 * @link http://www.advancedcustomfields.com/resources ACF Resources
 * @link https://wordpress.org/support/topic/custom-meta-data-2 Source for this technique
 * @internal only used as `json_prepare_post` filter
 * 
 */
function d7_add_acf_to_json_api($postaray, $postdata, $context)
{
    if (function_exists('get_fields')) {
        $custom_fields = $postdata['ID'];
        $postaray['meta']['custom_fields'] = get_fields($custom_fields);
    }
    return $postaray;
}
Ejemplo n.º 13
0
/**
 * Theme Options
 */
function get_options()
{
    static $options;
    if (!isset($options)) {
        $options = function_exists('get_field') ? get_fields('options') : false;
    }
    return $options;
}
Ejemplo n.º 14
0
function json_api_encode_acf($post)
{
    $acf = get_fields($post['ID']);
    if (isset($post)) {
        $post['acf'] = $acf;
    }
    return $post;
}
Ejemplo n.º 15
0
 function add_to_context($context)
 {
     $context['main_menu'] = new TimberMenu('primary_navigation');
     $context['site'] = $this;
     $context['display_sidebar'] = Setup\display_sidebar();
     $context['sidebar_primary'] = Timber::get_widgets('sidebar-primary');
     $context['options'] = get_fields('option');
     return $context;
 }
Ejemplo n.º 16
0
function theme_timber_context($context)
{
    // Enable ACF options everywhere
    $context['option'] = get_fields('option');
    // Enable menu
    $context['menu'] = new TimberMenu('main_menu');
    $context['footer_menu'] = new TimberMenu('footer_menu');
    return $context;
}
Ejemplo n.º 17
0
function wp_api_encode_acf_user($data, $post)
{
    if (!function_exists('get_fields')) {
        return $data;
    }
    $customMeta = (array) get_fields("user_" . $data['ID']);
    $data['meta'] = array_merge($data['meta'], $customMeta);
    return $data;
}
/**
 * Print classes depending on images that might be in a post
 *
 * @package pp
 * @subpackage boilerplate-theme
 *
 * @param array $classes The classes array
 * @return array The updated classes array
 *
 */
function pp_post_image_classes($classes)
{
    // Has feature image
    if (has_post_thumbnail()) {
        // Using a dash instead of underscore because WP turns it
        // into that anyway and I want to be more transparent
        $classes[] = 'has-post-thumbnail';
    }
    // ACF images
    if (function_exists('get_fields')) {
        $fields = get_fields();
        if ($fields) {
            foreach ($fields as $field => $field_content) {
                // Only work with arrays
                if (is_array($field_content)) {
                    // For normal ACF images
                    if (isset($field_content['sizes']) && count($field_content['sizes'])) {
                        if (!in_array('has-image', $classes)) {
                            $classes[] = 'has-image';
                        }
                        $classes[] = 'has-image--' . $field;
                    } elseif (is_array($field_content)) {
                        // Loop through the nested fields
                        foreach ($field_content as $nested_field => $nested_field_content) {
                            // Each repeater field
                            if (is_array($nested_field_content)) {
                                foreach ($nested_field_content as $repeater_field => $repeater_field_content) {
                                    // If the nested field is an image, add that class too
                                    if (is_array($repeater_field_content) && isset($repeater_field_content['sizes']) && count($repeater_field_content['sizes'])) {
                                        if (!in_array('has-iamge', $classes)) {
                                            $classes[] = 'has-image';
                                        }
                                        // !in_array
                                        if (!in_array($repeater_field, $classes)) {
                                            $classes[] = 'has-image--' . $repeater_field;
                                        }
                                        // !in_array
                                    }
                                    // if it's an image field
                                }
                                // each repeater field
                            }
                        }
                        // foreach nested fields
                    }
                    // elseif
                }
                // field content is array
            }
            // foreach
        }
        // if $fields
    }
    // if get_fields
    // Return the classes array
    return $classes;
}
Ejemplo n.º 19
0
function array_filter_rekey($vars, $defaults, $transforms = array())
{
    if (empty($transforms)) {
        return get_fields($vars, $defaults);
    }
    $defaults = array_combine(array_flip($defaults), $defaults);
    $key_name_mapping = get_fields(array_merge($defaults, $transform), $defaults);
    return array_combine(array_keys($key_name_mapping), get_fields_ordered_numeric($vars, $key_name_mapping));
}
Ejemplo n.º 20
0
 protected function _getData($count, $startIndex)
 {
     global $post;
     $tmpPost = $post;
     list($orderBy, $order) = N2Parse::parse($this->data->get('postscategoryorder', 'post_date|*|desc'));
     $postsFilter = array('include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'post_mime_type' => '', 'post_parent' => '', 'post_status' => 'publish', 'suppress_filters' => false, 'offset' => $startIndex, 'posts_per_page' => $count, 'orderby' => $orderBy, 'order' => $order);
     $categories = (array) N2Parse::parse($this->data->get('postscategory'));
     if (!in_array(0, $categories)) {
         $postsFilter['category'] = implode(',', $categories);
     }
     $posts = get_posts($postsFilter);
     $data = array();
     for ($i = 0; $i < count($posts); $i++) {
         $record = array();
         $post = $posts[$i];
         setup_postdata($post);
         $record['id'] = $post->ID;
         $record['url'] = get_permalink();
         $record['title'] = apply_filters('the_title', get_the_title());
         $record['description'] = $record['content'] = get_the_content();
         $record['author_name'] = $record['author'] = get_the_author();
         $record['author_url'] = get_the_author_meta('url');
         $record['date'] = get_the_date();
         $record['excerpt'] = get_the_excerpt();
         $record['modified'] = get_the_modified_date();
         $category = get_the_category($post->ID);
         if (isset($category[0])) {
             $record['category_name'] = $category[0]->name;
             $record['category_link'] = get_category_link($category[0]->cat_ID);
         } else {
             $record['category_name'] = '';
             $record['category_link'] = '';
         }
         $record['featured_image'] = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
         if (!$record['featured_image']) {
             $record['featured_image'] = '';
         }
         $record['thumbnail'] = $record['image'] = $record['featured_image'];
         $record['url_label'] = 'View post';
         if (class_exists('acf')) {
             $fields = get_fields($post->ID);
             if (count($fields)) {
                 foreach ($fields as $k => $v) {
                     $record[$k] = $v;
                 }
             }
         }
         $data[$i] =& $record;
         unset($record);
     }
     wp_reset_postdata();
     $post = $tmpPost;
     if ($post) {
         setup_postdata($post);
     }
     return $data;
 }
Ejemplo n.º 21
0
 function getData($number)
 {
     global $post;
     $tmpPost = $post;
     $data = array();
     $order = NextendParse::parse($this->_data->get('postsorder', 'post_date|*|desc'));
     $args = array('posts_per_page' => $number, 'offset' => 0, 'orderby' => $order[0], 'order' => $order[1], 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => $this->posttype, 'post_mime_type' => '', 'post_parent' => '', 'post_status' => 'publish', 'suppress_filters' => false);
     $posts_array = get_posts($args);
     $i = 0;
     foreach ($posts_array as $mypost) {
         $post = $mypost;
         setup_postdata($mypost);
         $data[$i] = array();
         $data[$i]['id'] = $mypost->ID;
         $data[$i]['url'] = get_permalink();
         $data[$i]['title'] = apply_filters('the_title', get_the_title());
         $data[$i]['description'] = $data[$i]['content'] = apply_filters('the_content', get_the_content());
         $data[$i]['author_name'] = $data[$i]['author'] = get_the_author();
         $data[$i]['author_url'] = get_the_author_meta('url');
         $data[$i]['featured_image'] = wp_get_attachment_url(get_post_thumbnail_id($mypost->ID));
         if (!$data[$i]['featured_image']) {
             $data[$i]['featured_image'] = '';
         }
         $data[$i]['thumbnail'] = $data[$i]['image'] = $data[$i]['featured_image'];
         $data[$i]['url_label'] = 'View';
         $customs = get_post_custom($mypost->ID);
         if ($customs && count($customs)) {
             foreach ($customs as $k => $v) {
                 if (is_array($v)) {
                     if (isset($v[0])) {
                         $v = $v[0];
                     } else {
                         continue;
                     }
                 }
                 $data[$i][$k] = $v;
             }
         }
         if (class_exists('acf')) {
             $fields = get_fields($mypost->ID);
             if (count($fields) && $fields) {
                 foreach ($fields as $k => $v) {
                     $data[$i][$k] = $v;
                 }
             }
         }
         $i++;
     }
     wp_reset_postdata();
     $post = $tmpPost;
     if ($post) {
         setup_postdata($post);
     }
     return $data;
 }
/**
 * Latest Edition Page Template JSON API Response Modifications
 *
 * @param $response     The JSON API Response Object
 *
 * @return $response    Update JSON API Response Object
 */
function tls_latest_edition_page_json_api_encode($response)
{
    if (isset($response['page_template_slug']) && $response['page_template_slug'] == "template-latest-edition.php" || isset($response['post']) && $response['post']->type == 'tls_editions') {
        if (isset($response['page_template_slug']) && $response['page_template_slug'] == "template-latest-edition.php") {
            $latest_edition = new WP_Query(array('post_type' => 'tls_editions', 'post_status' => 'publish', 'posts_per_page' => 1, 'orderby ' => 'date'));
            wp_reset_query();
        } else {
            if (isset($response['post']) && $response['post']->type == 'tls_editions') {
                $latest_edition = new WP_Query(array('p' => $response['post']->id, 'post_type' => 'tls_editions', 'post_status' => 'publish', 'posts_per_page' => 1, 'orderby ' => 'date'));
                wp_reset_query();
            }
        }
        $latest_edition = $latest_edition->posts[0];
        global $post;
        $oldGlobal = $post;
        $post = get_post($latest_edition->ID);
        $response['latest_edition'] = array('id' => $latest_edition->ID, 'title' => get_the_title($latest_edition->ID), 'url' => get_permalink($latest_edition->ID));
        if (get_previous_post()) {
            $previousPost = get_previous_post();
            $response['latest_edition']['previous_post_info'] = array('previous' => $previousPost, 'id' => $previousPost->ID, 'title' => get_the_title($previousPost->ID), 'url' => get_permalink($previousPost->ID));
        }
        if (get_next_post()) {
            $nextPost = get_next_post();
            $response['latest_edition']['next_post_info'] = array('next' => $nextPost, 'id' => $nextPost->ID, 'title' => get_the_title($nextPost->ID), 'url' => get_permalink($nextPost->ID));
        }
        $latest_edition_articles = get_fields($latest_edition->ID);
        $response['latest_edition']['content']['featured'] = array('issue_no' => $latest_edition_articles['edition_number'], 'image_url' => $latest_edition_articles['feautured_image']['url']);
        $response['latest_edition']['content']['public']['title'] = __('Public content', 'tls');
        $public_articles = get_field('public_articles', $latest_edition->ID);
        foreach ($public_articles as $public_article) {
            $section = wp_get_post_terms($public_article->ID, 'article_section');
            $postAuthor = get_field('field_54e4d3b1b0094', $public_article->ID);
            $response['latest_edition']['content']['public']['articles'][$public_article->post_name] = array('id' => $public_article->ID, 'author' => $postAuthor, 'title' => get_the_title($public_article->ID), 'section' => array('name' => $section[0]->name, 'link' => get_term_link($section[0]->term_id, $section[0]->taxonomy)), 'url' => get_permalink($public_article->ID));
        }
        $response['latest_edition']['content']['regulars']['title'] = __('Regular Features', 'tls');
        $regular_articles = get_field('edition_regular_articles', $latest_edition->ID);
        foreach ($regular_articles as $regular_article) {
            $postAuthor = get_field('field_54e4d3b1b0094', $regular_article->ID);
            $section = wp_get_post_terms($regular_article->ID, 'article_section');
            $article_section = wp_get_post_terms($regular_article->ID, 'article_visibility');
            $response['latest_edition']['content']['regulars']['articles'][$regular_article->post_name] = array('type' => 'article', 'id' => $regular_article->ID, 'author' => $postAuthor, 'title' => get_the_title($regular_article->ID), 'section' => array('name' => $section[0]->name, 'link' => get_term_link($section[0]->term_id, $section[0]->taxonomy)), 'taxonomy_article_visibility' => $article_section, 'url' => get_permalink($regular_article->ID));
        }
        $response['latest_edition']['content']['subscribers']['title'] = __('Subscriber Exclusive');
        $subscriber_only_articles = get_field('subscriber_only_articles', $latest_edition->ID);
        foreach ($subscriber_only_articles as $subscriber_only_article) {
            $section = wp_get_post_terms($subscriber_only_article->ID, 'article_section');
            $postAuthor = get_field('field_54e4d3b1b0094', $subscriber_only_article->ID);
            $response['latest_edition']['content']['subscribers']['articles'][$section[0]->name]['section']->name = $section[0]->name;
            $response['latest_edition']['content']['subscribers']['articles'][$section[0]->name]['section']->link = get_term_link($section[0]->term_id, $section[0]->taxonomy);
            $response['latest_edition']['content']['subscribers']['articles'][$section[0]->name]['posts'][$subscriber_only_article->post_name] = array('id' => $subscriber_only_article->ID, 'author' => $postAuthor, 'title' => get_the_title($subscriber_only_article->ID), 'section' => array('name' => $section[0]->name, 'link' => get_term_link($section[0]->term_id, $section[0]->taxonomy)), 'url' => get_permalink($subscriber_only_article->ID));
        }
    }
    return $response;
}
 public static function display($brick_info)
 {
     echo "<pre>";
     print_r($brick_info);
     print_r(get_fields(12040));
     echo "</pre>";
     echo '<div class="slide">';
     echo '<div class="interactive-grid-wrapper container">';
     echo '<div class=" interactive-grid">';
     echo '<div class="row">';
     foreach ($brick_info["resources"] as $key => $grid_item) {
         // echo "<pre>";
         // print_r($grid_item);
         // echo "</pre>";
         $more_info = get_fields($grid_item['resource']->ID);
         // print_r($more_info);
         if ($grid_item['resources_or_html'] == "resources" && $more_info['content_type'] != "video") {
             echo '<a target="_blank" href="' . $more_info['resource_url'] . '">';
         }
         echo '<div class=" ';
         echo $more_info['content_type'] == "video" ? ' active-video ' : ' active-md ';
         echo self::$width[$grid_item['width']] . ' interact grid-item-wrapper" >';
         echo '<div class="grid-item option ' . $grid_item['height'];
         echo $more_info['content_type'] == "video" ? ' embed-responsive embed-responsive-16by9 ' : '';
         echo ' ">';
         if ($grid_item['icon']) {
             echo '<div class="expand hide-on-expand"><i class="' . $grid_item['icon'] . '"></i></div>';
         }
         echo '<div class="background-image" style="background-image:url(\'' . self::$domain . self::$backgroundImageDir . self::$backgroundOptions[$grid_item['background_options']] . '\');"></div>';
         echo '<div class="close"><i class="fa fa-times"></i></div>';
         if ($more_info['content_type'] == "video") {
             echo '<i class="video-play dr-player x15"></i>';
             echo '<iframe class="video embed-responsive-item" style="width: 100%; height: 100%;" id="' . $grid_item['video_pretty_id'] . '" src="https://player.vimeo.com/video/' . $grid_item['video_id'] . '?api=1&amp;player_id=' . $grid_item['video_pretty_id'] . '" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';
         } else {
             echo "<div class='headline-wrapper'>";
             echo "<div class='headline'>";
             echo $grid_item['headline'];
             echo "</div>";
             echo "</div>";
             echo "<div class='description'>";
             echo $grid_item['description'];
             echo "</div>";
         }
         echo '</div>';
         echo '</div>';
         if ($grid_item['resources_or_html'] == "resources" && $more_info['content_type'] != "video") {
             echo '</a>';
         }
     }
     echo '</div>';
     echo '</div>';
     echo '</div>';
     echo '</div>';
 }
Ejemplo n.º 24
0
function foodrush_timber_context($context)
{
    // Enable ACF options everywhere
    $context['option'] = get_fields('option');
    // Enable menu
    $context['menu'] = new TimberMenu('main_menu');
    $context['footer_menu'] = new TimberMenu('footer_menu');
    $context['current_prize'] = get_the_title(get_ID_by_slug('prize-draw'));
    $context['current_url'] = home_url() . $_SERVER['REQUEST_URI'];
    return $context;
}
Ejemplo n.º 25
0
function timber_post_get_meta($customs, $pid, $post)
{
    if ($post instanceof \WPSW\Core\Model\Globals) {
        $pid = 'options';
    }
    $customs = array();
    foreach ((array) get_fields($pid) as $key => $value) {
        array_tree_push($customs, $key, $value);
    }
    return $customs;
}
Ejemplo n.º 26
0
 function add_to_context($context)
 {
     $context['foo'] = 'bar';
     $context['stuff'] = 'I am a value set in your functions.php file';
     $context['notes'] = 'These values are available everytime you call Timber::get_context();';
     $context['menu'] = new TimberMenu();
     $context['primaryNav'] = new TimberMenu('primary');
     $context['site'] = $this;
     $context['options'] = get_fields('options');
     return $context;
 }
Ejemplo n.º 27
0
 protected function _getData($count, $startIndex)
 {
     global $post;
     $tmpPost = $post;
     $i = 0;
     $data = array();
     foreach ($this->getIDs() as $id) {
         $record = array();
         $post = get_post($id);
         setup_postdata($post);
         $record['id'] = $post->ID;
         $record['url'] = get_permalink();
         $record['title'] = apply_filters('the_title', get_the_title());
         $record['description'] = $record['content'] = get_the_content();
         $record['author_name'] = $record['author'] = get_the_author();
         $record['author_url'] = get_the_author_meta('url');
         $record['date'] = get_the_date();
         $record['excerpt'] = get_the_excerpt();
         $record['modified'] = get_the_modified_date();
         $category = get_the_category($post->ID);
         if (isset($category[0])) {
             $record['category_name'] = $category[0]->name;
             $record['category_link'] = get_category_link($category[0]->cat_ID);
         } else {
             $record['category_name'] = '';
             $record['category_link'] = '';
         }
         $record['featured_image'] = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
         if (!$record['featured_image']) {
             $record['featured_image'] = '';
         }
         $record['thumbnail'] = $record['image'] = $record['featured_image'];
         $record['url_label'] = 'View post';
         if (class_exists('acf')) {
             $fields = get_fields($post->ID);
             if (count($fields)) {
                 foreach ($fields as $k => $v) {
                     $record[$k] = $v;
                 }
             }
         }
         $data[$i] =& $record;
         unset($record);
         $i++;
     }
     wp_reset_postdata();
     $post = $tmpPost;
     if ($post) {
         setup_postdata($post);
     }
     return $data;
 }
Ejemplo n.º 28
0
/**
 * Expand post classes.
 *
 * @package d7
 * @subpackage boilerplate-theme_filters+hooks
 *
 * @internal called by `post_class` filter
 *
 */
function d7_add_post_classes($classes)
{
    // Full post or listing item
    if (is_single() || is_page()) {
        $classes[] = 'post--full';
    } else {
        $classes[] = 'listing__item';
    }
    // Has feature image
    if (has_post_thumbnail()) {
        // Using a dash instead of underscore because WP turns it
        // into that anyway and I want to be more transparent
        $classes[] = 'has-post-thumbnail';
    }
    // Has other acf images, add classes for those
    $fields = get_fields();
    if ($fields) {
        foreach ($fields as $field => $field_content) {
            if (is_array($field_content) && isset($field_content['sizes']) && count($field_content['sizes'])) {
                $classes[] = 'has-image';
                $classes[] = 'has-image-' . $field;
            }
        }
    }
    // Has comments or not
    if (comments_open() && get_comments_number()) {
        $classes[] = 'has-comments';
    } else {
        $classes[] = 'no-comments';
    }
    // Comments open/closed
    if (comments_open()) {
        $classes[] = 'can-comment';
    }
    // If it's a link post
    $link = get_field('post_link');
    if ($link) {
        $classes[] = 'post--link';
    } else {
        $classes[] = 'post--normal';
    }
    // Remove listing
    if (in_array('not-listing', $classes)) {
        unset($classes[array_search('not-listing', $classes)]);
        unset($classes[array_search('listing__item', $classes)]);
    }
    // Focus mode class
    if (is_single() && get_post_type() == 'post') {
        $classes[] = 'js-focus-content';
    }
    return $classes;
}
Ejemplo n.º 29
0
function prt($name)
{
    setcookie('tbname', $name);
    $field = get_fields($name);
    echo "<p> 表 {$name} 添加一条数据  </p>";
    echo "<form method='post' action='?tbname={$name}' >";
    echo "<table border='1'>";
    echo "<tr>";
    foreach ($field as $v) {
        echo "<td>{$v}</td>";
    }
    echo "<td></td>";
    echo "</tr>";
    echo "<tr>";
    foreach ($field as $v) {
        echo "<td><input type='text' name={$v}> </td>";
    }
    echo "<td> <input type='submit' value='添加一条数据'> </td>";
    echo "</tr>";
    echo "</table>";
    echo "</form>";
    echo "<P>表 {$name} 的信息</p>";
    $result = mysql_query("select * from {$name}");
    if ($result) {
        while ($ans = mysql_fetch_assoc($result)) {
            $info[] = $ans;
        }
    }
    echo "<table border='1'>";
    echo "<tr>";
    echo "</tr>";
    echo "<tr>";
    foreach ($field as $v) {
        echo "<td>{$v}</td>";
    }
    echo "<td>删除(del) </td>";
    echo "</tr>";
    if (!isset($info)) {
        echo "目前表 {$name} 是空表";
    } else {
        foreach ($info as $v) {
            echo "<tr>";
            foreach ($v as $d) {
                echo "<td> {$d} </td>";
            }
            echo "<td style='text-align: center; min-width:100px '><a  href='?del={$v['id']}&tbname={$name}' data='{$v['id']}' >{$v['id']}</td>";
            echo '</tr>';
        }
    }
    echo "</table>";
    echo "<script>\n        \$(function () {\n            \$('table input:first').remove();        \n\n        })\n\n     </script>";
}
Ejemplo n.º 30
0
 protected function import()
 {
     if (!$this->object->raw) {
         return;
     }
     //$this->field_objects = get_field_objects($this->object);
     $fields = get_fields($this->object->raw);
     if (!is_array($fields)) {
         return;
     }
     foreach ($fields as $key => $value) {
         array_set($this->cache, $key, $value);
     }
 }