WordPress.org

Plugin Directory

Changeset 1467319


Ignore:
Timestamp:
08/04/16 03:15:34 (9 months ago)
Author:
aaronrutley
Message:

v1.1

Location:
acf-theme-code
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • acf-theme-code/trunk/acf_theme_code.php

    r1458037 r1467319  
    44Plugin URI: http://www.acfthemecode.com/ 
    55Description: Generates theme code for ACF field groups to speed up development. 
    6 Version: 1.0.0 
     6Version: 1.1.0 
    77Author: Aaron Rutley, Ben Pearson 
    88Author URI: http://www.acfthemecode.com/ 
     
    1111*/ 
    1212 
    13 // Exit if accessed directly  
    14 if ( ! defined( 'ABSPATH' ) ) exit;  
     13// Exit if accessed directly 
     14if ( ! defined( 'ABSPATH' ) ) exit; 
    1515 
    16 // Check for dashboard or admin panel  
     16// Check for dashboard or admin panel 
    1717if ( is_admin() ) { 
    1818 
     
    2525 
    2626    /** 
    27      * Extended functionality classes 
    28      */ 
    29     if ( file_exists( plugin_dir_path( __FILE__ ) . 'extend' ) ) { 
    30         include('extend/core/flexible-content-layout.php'); 
    31     } 
    32  
    33     /** 
    3427     * Single function for accessing plugin core instance 
    3528     * 
     
    4033        static $instance; 
    4134        if ( !$instance ) 
    42             $instance = new ACFTC_Core( plugin_dir_path( __FILE__ ), plugin_dir_url( __FILE__ ) ); 
     35            $instance = new ACFTC_Core( plugin_dir_path( __FILE__ ), plugin_dir_url( __FILE__ ), plugin_basename( __FILE__ ) ); 
    4336        return $instance; 
    4437    } 
  • acf-theme-code/trunk/assets/acf-theme-code.css

    r1458037 r1467319  
    2525    display: block; 
    2626    color:#999; 
    27     font-weight: bold; 
    2827    -webkit-user-select: none;  /* Chrome all / Safari all */ 
    2928    -moz-user-select: none;     /* Firefox all */ 
     
    105104   -moz-animation: zoomitbig 300ms ease-out 
    106105} 
     106 
     107a.acftc-contact-link { 
     108    display: block; 
     109    padding:10px; 
     110} 
  • acf-theme-code/trunk/assets/prism.css

    r1458037 r1467319  
    7070.token.cdata { 
    7171    color: slategray; 
     72    font-style: italic; 
    7273} 
    7374 
  • acf-theme-code/trunk/core/core.php

    r1458639 r1467319  
    77    public static $plugin_path = ''; 
    88    public static $plugin_url = ''; 
     9    public static $plugin_basename = ''; 
     10 
    911    public static $db_table = ''; 
    1012    public static $indent_repeater = 2; 
     
    2224    ); 
    2325 
    24     // Extended functionality types 
    25     public static $extended_types = array( 
     26    // Field types supported by TC Pro 
     27    public static $tc_pro_field_types = array( 
    2628        'flexible_content', 
    2729        'repeater', 
    2830        'gallery', 
     31        'clone', 
    2932        'font-awesome', 
    30         'google_font_selector' 
     33        'google_font_selector', 
     34        'rgba_color', 
     35        'image_crop', 
     36        'markdown', 
     37        'nav_menu', 
     38        'smart_button', 
     39        'sidebar_selector', 
     40        'tablepress_field', 
     41        'table' 
    3142    ); 
    3243 
     
    3445     * ACFTC_Core constructor 
    3546     */ 
    36     public function __construct( $plugin_path, $plugin_url ) { 
     47    public function __construct( $plugin_path, $plugin_url, $plugin_basename ) { 
    3748 
    3849        // Paths and URLs 
    3950        self::$plugin_path = $plugin_path; 
    4051        self::$plugin_url = $plugin_url; 
     52        self::$plugin_basename = $plugin_basename; 
    4153 
    4254        // Hooks 
     55        add_action( 'admin_init', array($this, 'acf_theme_code_pro_check') ); 
    4356        add_action( 'admin_init', array($this, 'set_db_table') ); 
    4457        add_action( 'add_meta_boxes', array($this, 'register_meta_boxes') ); 
     
    4659 
    4760    } 
     61 
     62    /** 
     63     * Check if ACF Theme Code Pro is activated 
     64     */ 
     65    public function acf_theme_code_pro_check() { 
     66 
     67        // If Theme Code Pro is activated, disable Theme Code (free) and display notice 
     68        if ( is_plugin_active( 'acf-theme-code-pro/acf_theme_code_pro.php' ) ) { 
     69            deactivate_plugins( self::$plugin_basename ); 
     70            add_action( 'admin_notices', array( $this, 'disabled_notice' ) ); 
     71            if ( isset( $_GET['activate'] ) ) { 
     72                unset( $_GET['activate'] ); 
     73            } 
     74        } 
     75 
     76    } 
     77 
     78    /** 
     79     * ACF Theme Code (free) disabled notice 
     80     */ 
     81    public function disabled_notice() { 
     82        echo '<div class="notice notice-success is-dismissible">'; 
     83            echo '<p>Plugin <strong>Advanced Custom Fields: Theme Code Pro</strong> is activated so plugin <strong>Advanced Custom Fields: Theme Code</strong> has been disabled.</p>'; 
     84        echo '</div>'; 
     85    } 
    4886 
    4987 
     
    71109         */ 
    72110 
    73         if ( is_plugin_active( 'advanced-custom-fields-pro/acf.php' ) ) { 
    74             self::$db_table = 'posts'; 
     111        if ( is_plugin_active( 'advanced-custom-fields-pro/acf.php' ) || // ACF Pro 
     112             is_plugin_active( 'advanced-custom-fields-pro-beta/acf.php') || // ACF Pro Beta 
     113             is_plugin_active( 'acf-pro-master/acf.php' ) ) { // ACF Pro Beta alt 
     114            self::$db_table = 'posts'; 
    75115        } elseif  ( is_plugin_active('advanced-custom-fields/acf.php' ) ) { 
    76116            self::$db_table = 'postmeta'; 
  • acf-theme-code/trunk/core/field.php

    r1458037 r1467319  
    136136        if ( !empty( $this->type ) ) { 
    137137 
    138             // if extended functionality 
    139             if ( file_exists( ACFTC_Core::$plugin_path . 'extend' ) && 
    140                  in_array( $this->type, ACFTC_Core::$extended_types ) ) { 
    141                 $render_partial = ACFTC_Core::$plugin_path . 'extend/render/' . $this->type . '.php'; 
    142             } 
    143             // else if one of the basic field types 
    144             elseif ( in_array( $this->type, ACFTC_Core::$basic_types ) ) { 
     138            // Basic types 
     139            if ( in_array( $this->type, ACFTC_Core::$basic_types ) ) { 
    145140                $render_partial = ACFTC_Core::$plugin_path . 'render/basic.php'; 
    146141            } 
    147             // else field type has it's own partial 
     142            // Field types with their own partial 
    148143            else { 
    149144                $render_partial = ACFTC_Core::$plugin_path . 'render/' . $this->type . '.php'; 
     
    163158 
    164159            // if the field is a tab or a message, bail early 
    165             if($this->type == 'tab' || $this->type == 'message') { 
     160            if ( $this->type == 'tab' || $this->type == 'message' ) { 
    166161                return; 
    167162            } 
     
    175170                //echo htmlspecialchars('<h2>'. $this->label .'</h2>'); 
    176171 
    177                 // dev - debug field partial  
     172                // dev - debug field partial 
    178173                //echo htmlspecialchars('<h2>'. $this->render_partial .'</h2>'); 
    179174 
     
    195190            } 
    196191 
    197             // include field type partial 
     192            // Field supported by TC (free) 
    198193            if ( file_exists( $this->render_partial ) ) { 
    199194                include( $this->render_partial ); 
    200             } else { 
    201                 echo $this->indent . "This field type is not supported.\n"; 
     195            } 
     196            // Field supported by TC Pro only 
     197            elseif ( in_array( $this->type, ACFTC_Core::$tc_pro_field_types ) ) { 
     198                echo $this->indent . htmlspecialchars( "<?php // Upgrade to ACF Theme Code Pro for " . $this->type . " field support. ?>" ) . "\n"; 
     199                echo $this->indent . htmlspecialchars( "<?php // Visit http://www.hookturn.io for more information. ?>" ) . "\n"; 
     200            } 
     201            // Field not supported at all (yet) 
     202            else { 
     203                echo $this->indent . htmlspecialchars( "<?php // The " . $this->type  . " field type is not supported in this verison of the plugin. ?>" ) . "\n"; 
     204                echo $this->indent . htmlspecialchars( "<?php // Contact http://www.hookturn.io to request support for this field type. ?>" ) . "\n"; 
    202205            } 
    203206 
  • acf-theme-code/trunk/readme.txt

    r1458077 r1467319  
    33Tags: acf,advanced custom fields,php,automation 
    44Requires at least: 4.5.3 
    5 Tested up to: 4.5.3 
     5Tested up to: 4.6 
    66Stable tag: 1.0.0 
    77License: GPL2+ 
     
    3131* Easily copy / paste the field code into your theme 
    3232* Great for offline documentation 
    33 * Code generated is based on examples the from official ACF documentation 
     33* Code generated is based on examples from the official ACF documentation 
     34 
     35> <strong>Upgrade to ACF Theme Code Pro</strong><br> 
     36> ALL ACF Pro field types are supported, including the popular Repeater, Flexible Content and Gallery field types. 
     37> 10+ ACF Add-on field types are also supported, including Font Awesome and Image Crop. 
     38> [Find out more about ACF Theme Code Pro](https://hookturn.io/downloads/acf-theme-code-pro/) 
    3439 
    3540= Support for the following fields: = 
     
    66714. Scroll down to see the ACF Theme code 
    6772 
     73== Frequently Asked Questions == 
     74 
     75= Does this plugin support ACF Pro ?  = 
     76 
     77This plugin has basic support for ACF Pro (we support all the fields found in the ACF free version). 
     78Our premium version - [ACF Theme Code Pro](https://hookturn.io/downloads/acf-theme-code-pro/) supports all the fields in ACF Pro and a range of other 3rd Party Fields. 
     79 
     80= Why is there so many PHP tags in the code that's generated ? = 
     81 
     82At the moment it's for developer convenience, so you can easily wrap our code in your own HTML markup. 
     83We're open to suggestions and keen to improve the code generated based on community discussion. 
     84 
    6885== Screenshots == 
    69861. When you publish, edit or update an ACF Field Group, the code required to implement each field is displayed for you in the Template Code section below. Use the clipboard icon to easily copy these code blocks and paste them into your theme. 
     
    7188== Changelog == 
    7289 
     90= 1.1.0 = 
     91* Various field formatting improvements inline with ACF Theme Code Pro 
     92 
    7393= 1.0.0 = 
    7494* First version 
  • acf-theme-code/trunk/render/basic.php

    r1458639 r1467319  
    66 
    77// This is used for multiple 'basic' fields that 'fail gracefully' 
    8 echo $this->indent . htmlspecialchars("<?php " . $this->the_field_method . "('" . $this->name ."'); ?>")."\n"; 
     8echo $this->indent . htmlspecialchars("<?php " . $this->the_field_method . "( '" . $this->name ."' ); ?>")."\n"; 
  • acf-theme-code/trunk/render/checkbox.php

    r1458037 r1467319  
    22// Checkbox field 
    33 
    4 // Exit if accessed directly  
    5 if ( ! defined( 'ABSPATH' ) ) exit;  
     4// Exit if accessed directly 
     5if ( ! defined( 'ABSPATH' ) ) exit; 
    66 
    7 // Loop over show multiple checkboxes 
    8 echo $this->indent . htmlspecialchars("<?php \$field = ". $this->get_field_object_method ."('" . $this->name . "'); ?>")."\n"; 
    9 echo $this->indent . htmlspecialchars("<?php \$value = \$field['value']; ?>")."\n"; 
    10 echo $this->indent . htmlspecialchars("<?php \$choices = \$field['choices']; ?>")."\n"; 
    11 echo $this->indent . htmlspecialchars("<?php if( \$value ): ?>")."\n"; 
    12 echo $this->indent . htmlspecialchars(" <?php foreach( \$value as \$v ): ?>")."\n"; 
    13 echo $this->indent . htmlspecialchars("     <?php echo \$choices[ \$v ]; ?>")."\n"; 
    14 echo $this->indent . htmlspecialchars(" <?php endforeach; ?>")."\n"; 
    15 echo $this->indent . htmlspecialchars("<?php endif; ?>")."\n"; 
     7$return_format = $this->settings['return_format']; 
     8// echo htmlspecialchars('<h3>'.$return_format.'</h3>')."\n"; 
    169 
     10// if return format is value or label (single array) 
     11if($return_format == 'value' || $return_format == 'label') { 
     12 
     13    // Return the code to ouput the vlaue from an array 
     14    echo $this->indent . htmlspecialchars("<?php // ".$this->name." ( ".$return_format." )")."\n"; 
     15    echo $this->indent . htmlspecialchars("\$".$this->name."_array = ". $this->get_field_method . "( '" . $this->name . "' );")."\n"; 
     16    echo $this->indent . htmlspecialchars("if ( \$".$this->name."_array ):")."\n"; 
     17    echo $this->indent . htmlspecialchars(" foreach ( \$".$this->name."_array as \$".$this->name."_item ):")."\n"; 
     18    echo $this->indent . htmlspecialchars("     echo \$".$this->name."_item;")."\n"; 
     19    echo $this->indent . htmlspecialchars(" endforeach;")."\n"; 
     20    echo $this->indent . htmlspecialchars("endif; ?>"."\n"); 
     21 
     22} elseif($return_format == 'array') { 
     23 
     24    // Return the code to output the value from a multi dimensional array 
     25    echo $this->indent . htmlspecialchars("<?php // ".$this->name." (".$return_format.")")."\n"; 
     26    echo $this->indent . htmlspecialchars("\$".$this->name."_array = ". $this->get_field_method . "( '" . $this->name . "' );")."\n"; 
     27    echo $this->indent . htmlspecialchars("if ( \$".$this->name."_array ):")."\n"; 
     28    echo $this->indent . htmlspecialchars(" foreach ( \$".$this->name."_array as \$".$this->name."_item ):")."\n"; 
     29    echo $this->indent . htmlspecialchars("     echo \$".$this->name."_item['value'];")."\n"; 
     30    echo $this->indent . htmlspecialchars(" endforeach;")."\n"; 
     31    echo $this->indent . htmlspecialchars("endif; ?>"."\n"); 
     32 
     33} else { 
     34 
     35    // Fallback to acf 5.3 style output 
     36    echo $this->indent . htmlspecialchars("<?php // ".$this->name)."\n"; 
     37    echo $this->indent . htmlspecialchars("\$field = ". $this->get_field_object_method ."( '" . $this->name . "' );")."\n"; 
     38    echo $this->indent . htmlspecialchars("\$value = \$field['value'];")."\n"; 
     39    echo $this->indent . htmlspecialchars("\$choices = \$field['choices'];")."\n"; 
     40    echo $this->indent . htmlspecialchars("if ( \$value ):")."\n"; 
     41    echo $this->indent . htmlspecialchars(" foreach ( \$value as \$v ):")."\n"; 
     42    echo $this->indent . htmlspecialchars("     echo \$choices[ \$v ];")."\n"; 
     43    echo $this->indent . htmlspecialchars(" endforeach;")."\n"; 
     44    echo $this->indent . htmlspecialchars("endif; ?>")."\n"; 
     45 
     46} 
  • acf-theme-code/trunk/render/date_picker.php

    r1458037 r1467319  
    22// Date picker 
    33 
    4 // Exit if accessed directly  
    5 if ( ! defined( 'ABSPATH' ) ) exit;  
     4// Exit if accessed directly 
     5if ( ! defined( 'ABSPATH' ) ) exit; 
    66 
    77// Date output is handled by ACF settings 
    8 echo $this->indent . htmlspecialchars("<?php " . $this->the_field_method . "('" . $this->name . "'); ?>")."\n"; 
     8echo $this->indent . htmlspecialchars("<?php " . $this->the_field_method . "( '" . $this->name . "' ); ?>")."\n"; 
  • acf-theme-code/trunk/render/date_time_picker.php

    r1458037 r1467319  
    66 
    77// Date and Time output is handled by ACF settings 
    8 echo $this->indent . htmlspecialchars("<?php " . $this->the_field_method . "('" . $this->name . "'); ?>")."\n"; 
     8echo $this->indent . htmlspecialchars("<?php " . $this->the_field_method . "( '" . $this->name . "' ); ?>")."\n"; 
  • acf-theme-code/trunk/render/file.php

    r1458037 r1467319  
    22// File field 
    33 
    4 // Exit if accessed directly  
    5 if ( ! defined( 'ABSPATH' ) ) exit;  
     4// Exit if accessed directly 
     5if ( ! defined( 'ABSPATH' ) ) exit; 
    66 
    77 
    8 if ( "postmeta" == ACFTC_Core::$db_table ) { // ACF 
     8if ( "postmeta" == ACFTCP_Core::$db_table ) { // ACF 
    99    $return_format = $this->settings['save_format']; 
    10 } elseif ( "posts" == ACFTC_Core::$db_table ) { // ACF PRO 
     10} elseif ( "posts" == ACFTCP_Core::$db_table ) { // ACF PRO 
    1111    $return_format = $this->settings['return_format']; 
    1212} 
     
    1414// If image is returned as an array 
    1515if ( $return_format == 'array' ) { 
    16     echo $this->indent . htmlspecialchars("<?php \$file = " . $this->get_field_method . "('".$this->name."'); ?>")."\n"; 
    17     echo $this->indent . htmlspecialchars("<?php if( \$file ) { ?>")."\n"; 
    18     echo $this->indent . htmlspecialchars(" <a href=\"<?php echo \$file['url']; ?>\" /><?php echo \$file['filename']; ?></a>"."\n"); 
     16    echo $this->indent . htmlspecialchars("<?php \$".$this->name." = " . $this->get_field_method . "( '".$this->name."' ); ?>")."\n"; 
     17    echo $this->indent . htmlspecialchars("<?php if ( \$".$this->name." ) { ?>")."\n"; 
     18    echo $this->indent . htmlspecialchars(" <a href=\"<?php echo \$".$this->name."['url']; ?>\" /><?php echo \$".$this->name."['filename']; ?></a>"."\n"); 
    1919    echo $this->indent . htmlspecialchars("<?php } ?>"."\n"); 
    2020} 
     
    2222// If image is returned as an object (v4) 
    2323if ( $return_format == 'object') { 
    24     echo $this->indent . htmlspecialchars("<?php \$file = " . $this->get_field_method . "('".$this->name."'); ?>")."\n"; 
    25     echo $this->indent . htmlspecialchars("<?php if( \$file ) { ?>")."\n"; 
    26     echo $this->indent . htmlspecialchars(" <a href=\"<?php echo \$file['url']; ?>\" /><?php echo \$file['title']; ?></a>"."\n"); 
     24    echo $this->indent . htmlspecialchars("<?php \$".$this->name." = " . $this->get_field_method . "( '".$this->name."' ); ?>")."\n"; 
     25    echo $this->indent . htmlspecialchars("<?php if ( \$".$this->name." ) { ?>")."\n"; 
     26    echo $this->indent . htmlspecialchars(" <a href=\"<?php echo \$".$this->name."['url']; ?>\" /><?php echo\$".$this->name."['title']; ?></a>"."\n"); 
    2727    echo $this->indent . htmlspecialchars("<?php } ?>"."\n"); 
    2828} 
     
    3131// If file is returned as a ID 
    3232if ( $return_format == 'id' ) { 
    33     echo $this->indent . htmlspecialchars("<?php \$file = " . $this->get_field_method . "('".$this->name."'); ?>")."\n"; 
    34     echo $this->indent . htmlspecialchars("<?php if( \$file ) { ?>")."\n"; 
    35     echo $this->indent . htmlspecialchars(" <?php \$url = wp_get_attachment_url( \$file ); ?>")."\n"; 
     33    echo $this->indent . htmlspecialchars("<?php \$".$this->name." = " . $this->get_field_method . "( '".$this->name."' ); ?>")."\n"; 
     34    echo $this->indent . htmlspecialchars("<?php if ( \$".$this->name.") { ?>")."\n"; 
     35    echo $this->indent . htmlspecialchars(" <?php \$url = wp_get_attachment_url( \$".$this->name." ); ?>")."\n"; 
    3636    echo $this->indent . htmlspecialchars(" <a href=\"<?php echo \$url; ?>\">Download File</a>")."\n"; 
    3737    echo $this->indent . htmlspecialchars("<?php } ?>"."\n"); 
     
    4040// If file is returned as a URL 
    4141if ( $return_format == 'url' ) { 
    42     echo $this->indent . htmlspecialchars("<?php if( ".$this->get_field_method . "('".$this->name."') ) { ?>")."\n"; 
    43     echo $this->indent . htmlspecialchars(" <a href=\"<?php the_field('".$this->name."'); ?>\">Download File</a>")."\n"; 
     42    echo $this->indent . htmlspecialchars("<?php if ( ".$this->get_field_method . "( '".$this->name."' ) ) { ?>")."\n"; 
     43    echo $this->indent . htmlspecialchars(" <a href=\"<?php the_field( '".$this->name."' ); ?>\">Download File</a>")."\n"; 
    4444    echo $this->indent . htmlspecialchars("<?php } ?>"."\n"); 
    4545} 
  • acf-theme-code/trunk/render/google_map.php

    r1458037 r1467319  
    22// Google map / location field 
    33 
    4 // Exit if accessed directly  
    5 if ( ! defined( 'ABSPATH' ) ) exit;  
     4// Exit if accessed directly 
     5if ( ! defined( 'ABSPATH' ) ) exit; 
    66 
    77 
    88// Location stored in array for now 
    9 echo $this->indent . htmlspecialchars("<?php \$location_array = " .  $this->get_field_method . "('" . $this->name . "');")."\n"; 
    10 echo $this->indent . htmlspecialchars("// var_dump(\$location_array); ?>")."\n"; 
     9echo $this->indent . htmlspecialchars("<?php \$location_array = " .  $this->get_field_method . "( '" . $this->name . "' );")."\n"; 
     10echo $this->indent . htmlspecialchars("// var_dump( \$location_array ); ?>")."\n"; 
  • acf-theme-code/trunk/render/image.php

    r1458037 r1467319  
    22// Image field 
    33 
    4 // Exit if accessed directly  
    5 if ( ! defined( 'ABSPATH' ) ) exit;  
     4// Exit if accessed directly 
     5if ( ! defined( 'ABSPATH' ) ) exit; 
    66 
    77 
    8 if ( "postmeta" == ACFTC_Core::$db_table ) { // ACF 
     8if ( "postmeta" == ACFTCP_Core::$db_table ) { // ACF 
    99    $return_format = $this->settings['save_format']; 
    10 } elseif ( "posts" == ACFTC_Core::$db_table ) { // ACF PRO 
     10} elseif ( "posts" == ACFTCP_Core::$db_table ) { // ACF PRO 
    1111    $return_format = $this->settings['return_format']; 
    1212} 
     
    1414// If image is returned as an array (postmeta / v5) or an object (posts / v4) 
    1515if ( $return_format == 'array' || $return_format == 'object'  ) { 
    16     echo $this->indent . htmlspecialchars("<?php \$image = " . $this->get_field_method . "( '".$this->name."' ); ?>")."\n"; 
    17     echo $this->indent . htmlspecialchars("<?php if ( \$image ) { ?>")."\n"; 
    18     echo $this->indent . htmlspecialchars(" <img src=\"<?php echo \$image['url']; ?>\" alt=\"<?php echo \$image['alt']; ?>\" />")."\n"; 
     16    echo $this->indent . htmlspecialchars("<?php \$".$this->name." = " . $this->get_field_method . "( '".$this->name."' ); ?>")."\n"; 
     17    echo $this->indent . htmlspecialchars("<?php if ( \$".$this->name." ) { ?>")."\n"; 
     18    echo $this->indent . htmlspecialchars(" <img src=\"<?php echo \$".$this->name."['url']; ?>\" alt=\"<?php echo \$".$this->name."['alt']; ?>\" />")."\n"; 
    1919    echo $this->indent . htmlspecialchars("<?php } ?>\n"); 
    2020} 
     
    2929// If image is returned as an ID 
    3030if ( $return_format == 'id' ) { 
    31     echo $this->indent . htmlspecialchars("<?php \$image = " . $this->get_field_method . "( '".$this->name."' ); ?>")."\n"; 
    32     echo $this->indent . htmlspecialchars("<?php if ( \$image ) { ?>")."\n"; 
    33     echo $this->indent . htmlspecialchars(" <?php echo wp_get_attachment_image( \$image, 'full' ); ?>")."\n"; 
     31    echo $this->indent . htmlspecialchars("<?php \$".$this->name." = " . $this->get_field_method . "( '".$this->name."' ); ?>")."\n"; 
     32    echo $this->indent . htmlspecialchars("<?php if ( \$".$this->name." ) { ?>")."\n"; 
     33    echo $this->indent . htmlspecialchars(" <?php echo wp_get_attachment_image( \$".$this->name.", 'full' ); ?>")."\n"; 
    3434    echo $this->indent . htmlspecialchars("<?php } ?>\n"); 
    3535} 
  • acf-theme-code/trunk/render/page_link.php

    r1458037 r1467319  
    22// Page link field 
    33 
    4 // Exit if accessed directly  
    5 if ( ! defined( 'ABSPATH' ) ) exit;  
     4// Exit if accessed directly 
     5if ( ! defined( 'ABSPATH' ) ) exit; 
    66 
    77 
     
    1111// If single 
    1212if($multiple_values == 0) { 
    13     echo $this->indent . htmlspecialchars("<?php " . $this->the_field_method . "('" . $this->name . "'); ?>")."\n"; 
     13    echo $this->indent . htmlspecialchars("<?php " . $this->the_field_method . "( '" . $this->name . "' ); ?>")."\n"; 
    1414} 
    1515 
    1616// If multiple 
    1717if($multiple_values == 1) { 
    18     echo $this->indent . htmlspecialchars("<?php \$page_link_array =  " . $this->get_field_method . "('" . $this->name . "'); ?>")."\n"; 
    19     echo $this->indent . htmlspecialchars("<?php foreach (\$page_link_array as \$page_link_value) { ?>")."\n"; 
    20     echo $this->indent . htmlspecialchars(" <?php echo \$page_link_value;?> ")."\n"; 
     18    echo $this->indent . htmlspecialchars("<?php \$".$this->name."_items =  " . $this->get_field_method . "( '" . $this->name . "' ); ?>")."\n"; 
     19    echo $this->indent . htmlspecialchars("<?php foreach ( \$".$this->name."_items as \$".$this->name."_item ) { ?>")."\n"; 
     20    echo $this->indent . htmlspecialchars(" <?php echo \$".$this->name."_item; ?> ")."\n"; 
    2121    echo $this->indent . htmlspecialchars("<?php } ?>")."\n"; 
    2222} 
  • acf-theme-code/trunk/render/post_object.php

    r1458037 r1467319  
    22// Post Object field 
    33 
    4 // Exit if accessed directly  
    5 if ( ! defined( 'ABSPATH' ) ) exit;  
     4// Exit if accessed directly 
     5if ( ! defined( 'ABSPATH' ) ) exit; 
    66 
    77// Check if single or multiple values can be stored 
    88$multiple_values = $this->settings['multiple']; 
     9$return_format = $this->settings['return_format']; 
    910 
    10 // If single 
    11 if($multiple_values == 0) { 
    12     echo $this->indent . htmlspecialchars("<?php \$post_object = " . $this->get_field_method . "('" . $this->name . "'); ?>")."\n"; 
    13     echo $this->indent . htmlspecialchars("<?php if( \$post_object ): ?>")."\n"; 
     11// If ID and single 
     12if( $return_format == 'id' && $multiple_values == 0 ) { 
     13 
     14    echo $this->indent . htmlspecialchars("<?php \$".$this->name. ' = ' . $this->get_field_method . "( '" . $this->name ."' ); ?>")."\n"; 
     15 
     16} 
     17 
     18// If ID and multiple 
     19if( $return_format == 'id' && $multiple_values == 1 ) { 
     20 
     21    echo $this->indent . htmlspecialchars("<?php \$".$this->name.' = ' . $this->get_field_method . "( '" . $this->name ."' ); ?>")."\n"; 
     22    echo $this->indent . htmlspecialchars("<?php // var_dump( \$".$this->name." ); ?>")."\n"; 
     23 
     24} 
     25 
     26// If object and single 
     27if( $return_format == 'object' && $multiple_values == 0 ) { 
     28    echo $this->indent . htmlspecialchars("<?php \$post_object = " . $this->get_field_method . "( '" . $this->name . "' ); ?>")."\n"; 
     29    echo $this->indent . htmlspecialchars("<?php if ( \$post_object ): ?>")."\n"; 
    1430    echo $this->indent . htmlspecialchars(" <?php \$post = \$post_object; ?>")."\n"; 
    1531    echo $this->indent . htmlspecialchars(" <?php setup_postdata( \$post ); ?> ")."\n"; 
     
    1935} 
    2036 
    21 // If multiple 
    22 if($multiple_values == 1) { 
    23     echo $this->indent . htmlspecialchars("<?php \$post_objects = " . $this->get_field_method . "('" . $this->name . "'); ?>")."\n"; 
    24     echo $this->indent . htmlspecialchars("<?php if( \$post_objects ): ?>")."\n"; 
    25     echo $this->indent . htmlspecialchars(" <?php foreach( \$post_objects as \$post):  ?>")."\n"; 
    26     echo $this->indent . htmlspecialchars("     <?php setup_postdata(\$post); ?>")."\n"; 
     37// If object and multiple 
     38if( $return_format == 'object' && $multiple_values == 1 ) { 
     39    echo $this->indent . htmlspecialchars("<?php \$post_objects = " . $this->get_field_method . "( '" . $this->name . "' ); ?>")."\n"; 
     40    echo $this->indent . htmlspecialchars("<?php if ( \$post_objects ): ?>")."\n"; 
     41    echo $this->indent . htmlspecialchars(" <?php foreach ( \$post_objects as \$post ):  ?>")."\n"; 
     42    echo $this->indent . htmlspecialchars("     <?php setup_postdata( \$post ); ?>")."\n"; 
    2743    echo $this->indent . htmlspecialchars("     <a href=\"<?php the_permalink(); ?>\"><?php the_title(); ?></a>")."\n"; 
    2844    echo $this->indent . htmlspecialchars(" <?php endforeach; ?>")."\n"; 
  • acf-theme-code/trunk/render/relationship.php

    r1458037 r1467319  
    22// Relationship field 
    33 
    4 // Exit if accessed directly  
    5 if ( ! defined( 'ABSPATH' ) ) exit;  
     4// Exit if accessed directly 
     5if ( ! defined( 'ABSPATH' ) ) exit; 
    66 
    7 // Get return format  
     7// Get return format 
    88$return_format = $this->settings['return_format']; 
    99 
    1010// If returned as object 
    1111if ( $return_format == 'object' ) { 
    12     echo $this->indent . htmlspecialchars("<?php \$post_objects = " . $this->get_field_method . "('" . $this->name . "'); ?>")."\n"; 
    13     echo $this->indent . htmlspecialchars("<?php if( \$post_objects ): ?>")."\n"; 
    14     echo $this->indent . htmlspecialchars(" <?php foreach( \$post_objects as \$post):  ?>")."\n"; 
    15     echo $this->indent . htmlspecialchars("     <?php setup_postdata(\$post); ?>")."\n"; 
     12    echo $this->indent . htmlspecialchars("<?php \$".$this->name." = " . $this->get_field_method . "( '" . $this->name . "' ); ?>")."\n"; 
     13    echo $this->indent . htmlspecialchars("<?php if ( \$".$this->name." ): ?>")."\n"; 
     14    echo $this->indent . htmlspecialchars(" <?php foreach ( \$".$this->name." as \$post ):  ?>")."\n"; 
     15    echo $this->indent . htmlspecialchars("     <?php setup_postdata (\$post); ?>")."\n"; 
    1616    echo $this->indent . htmlspecialchars("         <a href=\"<?php the_permalink(); ?>\"><?php the_title(); ?></a>")."\n"; 
    1717    echo $this->indent . htmlspecialchars(" <?php endforeach; ?>")."\n"; 
     
    2222// IF returned as ID 
    2323if ( $return_format == 'id' ) { 
    24     echo $this->indent . htmlspecialchars("<?php \$posts = " . $this->get_field_method . "('" . $this->name . "'); ?>")."\n"; 
    25     echo $this->indent . htmlspecialchars("<?php if( \$posts ): ?>")."\n"; 
    26     echo $this->indent . htmlspecialchars(" <?php foreach( \$posts as \$p ): ?>")."\n"; 
     24    echo $this->indent . htmlspecialchars("<?php \$".$this->name." = " . $this->get_field_method . "( '" . $this->name . "' ); ?>")."\n"; 
     25    echo $this->indent . htmlspecialchars("<?php if ( \$".$this->name." ): ?>")."\n"; 
     26    echo $this->indent . htmlspecialchars(" <?php foreach ( \$".$this->name." as \$p ): ?>")."\n"; 
    2727    echo $this->indent . htmlspecialchars("     <a href=\"<?php echo get_permalink( \$p ); ?>\"><?php echo get_the_title( \$p ); ?></a>")."\n"; 
    2828    echo $this->indent . htmlspecialchars(" <?php endforeach; ?>")."\n"; 
  • acf-theme-code/trunk/render/select.php

    r1458037 r1467319  
    1 <?php 
    2 // Select field 
     1<?php // Select field 
    32 
    4 // Exit if accessed directly  
    5 if ( ! defined( 'ABSPATH' ) ) exit;  
     3// Exit if accessed directly 
     4if ( ! defined( 'ABSPATH' ) ) exit; 
    65 
    76// Check if single or multiple values can be stored 
    87$multiple_values = $this->settings['multiple']; 
    98 
     9// Check for return format ACF 5.4 feature 
     10$return_format = $this->settings['return_format']; 
     11 
     12// Dev - uncomment to debug this field 
     13//echo htmlspecialchars('<h3>'.$multiple_values.$return_format.'</h3>')."\n"; 
     14 
    1015// If single 
    1116if($multiple_values == 0) { 
    12     echo $this->indent . htmlspecialchars("<?php " . $this->the_field_method . "('" . $this->name . "'); ?>")."\n"; 
     17 
     18    // if this a single option returned as an array 
     19    if($return_format == 'array') { 
     20 
     21        // return a get field with the var name 
     22        echo $this->indent . htmlspecialchars("<?php \$".$this->name."_array = ". $this->get_field_method . "( '" . $this->name . "' ); ?>")."\n"; 
     23        echo $this->indent . htmlspecialchars("<?php if ( \$".$this->name."_array ): ?>")."\n"; 
     24        echo $this->indent . htmlspecialchars(" <?php foreach ( \$".$this->name."_array as \$".$this->name."_item ): ?>")."\n"; 
     25        echo $this->indent . htmlspecialchars("     <?php echo \$".$this->name."_item; ?>")."\n"; 
     26        echo $this->indent . htmlspecialchars(" <?php endforeach; ?>")."\n"; 
     27        echo $this->indent . htmlspecialchars("<?php endif; ?>"."\n"); 
     28 
     29    } else { 
     30 
     31        // else retun the field 
     32        echo $this->indent . htmlspecialchars("<?php " . $this->the_field_method . "( '" . $this->name . "' ); ?>")."\n"; 
     33 
     34    } 
    1335} 
    1436 
    1537// If multiple 
    1638if($multiple_values == 1) { 
    17     echo $this->indent . htmlspecialchars("<?php \$select_object = " . $this->get_field_object_method . "('" . $this->name . "'); ?>")."\n"; 
    18     echo $this->indent . htmlspecialchars("<?php \$select_array = \$select_object[value]; ?>")."\n"; 
    19     echo $this->indent . htmlspecialchars("<?php foreach (\$select_array as \$select_value) { ?>")."\n"; 
    20     echo $this->indent . htmlspecialchars(" <?php echo \$select_value;?>")."\n"; 
    21     echo $this->indent . htmlspecialchars("<?php } ?>")."\n"; 
     39 
     40    if($return_format == 'array') { 
     41 
     42        // multi dimensional array 
     43        echo $this->indent . htmlspecialchars("<?php \$".$this->name."_array = ". $this->get_field_method . "( '" . $this->name . "' ); ?>")."\n"; 
     44        echo $this->indent . htmlspecialchars("<?php if ( \$".$this->name."_array ): ?>")."\n"; 
     45        echo $this->indent . htmlspecialchars(" <?php foreach ( \$".$this->name."_array as \$".$this->name."_sub_array ): ?>")."\n"; 
     46        echo $this->indent . htmlspecialchars("     <?php foreach ( \$".$this->name."_sub_array as \$".$this->name."_sub_array_item ): ?>")."\n"; 
     47        echo $this->indent . htmlspecialchars("         <?php echo \$".$this->name."_sub_array_item; ?>")."\n"; 
     48        echo $this->indent . htmlspecialchars("     <?php endforeach; ?>")."\n"; 
     49        echo $this->indent . htmlspecialchars(" <?php endforeach; ?>")."\n"; 
     50        echo $this->indent . htmlspecialchars("<?php endif; ?>"."\n"); 
     51 
     52    } else { 
     53 
     54        // loop over the array 
     55        echo $this->indent . htmlspecialchars("<?php \$".$this->name."_array = ". $this->get_field_method . "( '" . $this->name . "' ); ?>")."\n"; 
     56        echo $this->indent . htmlspecialchars("<?php if ( \$".$this->name."_array ): ?>")."\n"; 
     57        echo $this->indent . htmlspecialchars(" <?php foreach ( \$".$this->name."_array as \$".$this->name."_item ): ?>")."\n"; 
     58        echo $this->indent . htmlspecialchars("     <?php echo \$".$this->name."_item; ?>")."\n"; 
     59        echo $this->indent . htmlspecialchars(" <?php endforeach; ?>")."\n"; 
     60        echo $this->indent . htmlspecialchars("<?php endif; ?>"."\n"); 
     61 
     62    } 
     63 
    2264} 
  • acf-theme-code/trunk/render/taxonomy.php

    r1458037 r1467319  
    22// Taxonomy field 
    33 
    4 // Exit if accessed directly  
    5 if ( ! defined( 'ABSPATH' ) ) exit;  
     4// Exit if accessed directly 
     5if ( ! defined( 'ABSPATH' ) ) exit; 
    66 
    7 // Get return format and type  
     7// Get return format and type 
    88$return_format = $this->settings['return_format']; 
    99$taxonomy_field_type = $this->settings['field_type']; 
     
    1313    // If field type is a single type 
    1414    if($taxonomy_field_type == 'select' || $taxonomy_field_type == 'radio') { 
    15         echo $this->indent . htmlspecialchars("<?php \$term = " . $this->get_field_method . "('" . $this->name . "'); ?>")."\n"; 
    16         echo $this->indent . htmlspecialchars("<?php if( \$term ): ?>")."\n"; 
    17         echo $this->indent . htmlspecialchars(" <?php echo \$term->name; ?>")."\n"; 
     15        echo $this->indent . htmlspecialchars("<?php \$".$this->name."_term = " . $this->get_field_method . "( '" . $this->name . "' ); ?>")."\n"; 
     16        echo $this->indent . htmlspecialchars("<?php if ( \$".$this->name."_term ): ?>")."\n"; 
     17        echo $this->indent . htmlspecialchars(" <?php echo \$".$this->name."_term->name; ?>")."\n"; 
    1818        echo $this->indent . htmlspecialchars("<?php endif; ?>")."\n"; 
    1919 
     
    2222    // If field type is a multiple type 
    2323    if($taxonomy_field_type == 'multi_select' || $taxonomy_field_type == 'checkbox') { 
    24         echo $this->indent . htmlspecialchars("<?php \$terms = " . $this->get_field_method . "('" . $this->name . "'); ?>")."\n"; 
    25         echo $this->indent . htmlspecialchars("<?php if( \$terms ): ?>")."\n"; 
    26         echo $this->indent . htmlspecialchars(" <?php foreach( \$terms as \$term ): ?>")."\n"; 
    27         echo $this->indent . htmlspecialchars("     <?php echo \$term->name; ?>")."\n"; 
     24        echo $this->indent . htmlspecialchars("<?php \$".$this->name."_terms = " . $this->get_field_method . "( '" . $this->name . "' ); ?>" )."\n"; 
     25        echo $this->indent . htmlspecialchars("<?php if ( \$".$this->name."_terms ): ?>")."\n"; 
     26        echo $this->indent . htmlspecialchars(" <?php foreach ( \$".$this->name."_terms as \$".$this->name."_term ): ?>")."\n"; 
     27        echo $this->indent . htmlspecialchars("     <?php echo \$".$this->name."_term->name; ?>")."\n"; 
    2828        echo $this->indent . htmlspecialchars(" <?php endforeach; ?>")."\n"; 
    2929        echo $this->indent . htmlspecialchars("<?php endif; ?>")."\n"; 
     
    3434// if return format is an array of ids 
    3535if ( $return_format == 'id' ) { 
    36     echo $this->indent . htmlspecialchars("<?php \$term_ids = " . $this->get_field_method . "('" . $this->name . "'); ?>")."\n"; 
    37     echo $this->indent . htmlspecialchars("// var_dump(\$term_ids); ?>")."\n"; 
     36    echo $this->indent . htmlspecialchars("<?php \$".$this->name."_ids = " . $this->get_field_method . "( '" . $this->name . "' ); ?>")."\n"; 
     37    echo $this->indent . htmlspecialchars("<?php // var_dump( \$".$this->name."_ids ); ?>")."\n"; 
    3838} 
  • acf-theme-code/trunk/render/time_picker.php

    r1458037 r1467319  
    66 
    77// Time output is handled by ACF settings 
    8 echo $this->indent . htmlspecialchars("<?php " . $this->the_field_method . "('" . $this->name . "'); ?>")."\n"; 
     8echo $this->indent . htmlspecialchars("<?php " . $this->the_field_method . "( '" . $this->name . "' ); ?>")."\n"; 
  • acf-theme-code/trunk/render/true_false.php

    r1458037 r1467319  
    22// True False field 
    33 
    4 // Exit if accessed directly  
    5 if ( ! defined( 'ABSPATH' ) ) exit;  
     4// Exit if accessed directly 
     5if ( ! defined( 'ABSPATH' ) ) exit; 
    66 
    77 
    8 echo $this->indent . htmlspecialchars("<?php if( " . $this->get_field_method . "('" . $this->name . "') == 1 ) { ?>")."\n"; 
    9 echo $this->indent . htmlspecialchars(" <?php // true ?>")."\n"; 
    10 echo $this->indent . htmlspecialchars("<?php } else { ?>")."\n"; 
    11 echo $this->indent . htmlspecialchars(" <?php // false ?>")."\n"; 
    12 echo $this->indent . htmlspecialchars("<?php } ?>")."\n"; 
     8echo $this->indent . htmlspecialchars("<?php if ( " . $this->get_field_method . "( '" . $this->name . "' ) == 1 ) { ")."\n"; 
     9echo $this->indent . htmlspecialchars(" // echo 'true'; ")."\n"; 
     10echo $this->indent . htmlspecialchars("} else { ")."\n"; 
     11echo $this->indent . htmlspecialchars(" // echo 'false'; ")."\n"; 
     12echo $this->indent . htmlspecialchars("} ?>")."\n"; 
  • acf-theme-code/trunk/render/user.php

    r1458037 r1467319  
    22// User field 
    33 
    4 // Exit if accessed directly  
    5 if ( ! defined( 'ABSPATH' ) ) exit;  
     4// Exit if accessed directly 
     5if ( ! defined( 'ABSPATH' ) ) exit; 
    66 
    7 echo $this->indent . htmlspecialchars("<?php \$user_array = " . $this->get_field_method . "('".$this->name."'); "."\n"); 
    8 echo $this->indent . htmlspecialchars("// var_dump(\$user_array); ?>")."\n"; 
     7echo $this->indent . htmlspecialchars("<?php \$".$this->name."_array = " . $this->get_field_method . "( '".$this->name."' ); ?> "."\n"); 
     8echo $this->indent . htmlspecialchars("<?php // var_dump( \$".$this->name."_array ); ?>")."\n"; 
Note: See TracChangeset for help on using the changeset viewer.