WordPress.org

Plugin Directory

Changeset 1657343


Ignore:
Timestamp:
05/15/17 01:41:22 (3 months ago)
Author:
aaronrutley
Message:

version 1.3.0

Location:
acf-theme-code/trunk
Files:
6 edited

Legend:

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

    r1517648 r1657343  
    22/* 
    33Plugin Name: Advanced Custom Fields: Theme Code 
    4 Plugin URI: http://www.acfthemecode.com/ 
     4Plugin URI: http://www.hookturn.io 
    55Description: Generates theme code for ACF field groups to speed up development. 
    6 Version: 1.2.0 
     6Version: 1.3.0 
    77Author: Aaron Rutley, Ben Pearson 
    8 Author URI: http://www.acfthemecode.com/ 
     8Author URI: http://www.hookturn.io 
    99License: GPLv2 or later 
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    1313// Exit if accessed directly 
    1414if ( ! defined( 'ABSPATH' ) ) exit; 
     15 
     16// Define the version number 
     17define( 'ACFTC_VERSION', '1.3.0' ); 
    1518 
    1619// Check for dashboard or admin panel 
     
    3336        static $instance; 
    3437        if ( !$instance ) 
    35             $instance = new ACFTC_Core( plugin_dir_path( __FILE__ ), plugin_dir_url( __FILE__ ), plugin_basename( __FILE__ ) ); 
     38            $instance = new ACFTC_Core( plugin_dir_path( __FILE__ ), plugin_dir_url( __FILE__ ), plugin_basename( __FILE__ ), ACFTC_VERSION ); 
    3639        return $instance; 
    3740    } 
  • acf-theme-code/trunk/assets/acf-theme-code.css

    r1517648 r1657343  
    116116} 
    117117 
     118.acftc-pro-notice--top { 
     119    margin-top:0px; 
     120} 
     121 
    118122a.acftc-pro-notice__link { 
    119123    padding:10px 20px; 
     
    136140} 
    137141 
     142/* quick links */ 
     143 
    138144.li-field-label { 
    139145    width: 31% !important; 
  • acf-theme-code/trunk/assets/acf-theme-code.js

    r1517648 r1657343  
    1313            var data_type = $(this).attr("data-type"); 
    1414            if ( ( data_type != 'tab' ) && ( data_type != 'message') ) { 
    15                 $(this).find('.row_options').append( '<span>| <a class="acftc-scroll__link" href="#acftc-' + field_key + '">Code</a></span>' ); 
     15                  $(this).find('.row_options').append( '<span>| <a class="acftc-scroll__link" href="#acftc-' + field_key + '">Code</a></span>' ); 
    1616            } 
    1717        }); 
     
    2222            // exclude nested fields 
    2323            .filter( function() { 
    24                 return $(this).parentsUntil('#acf-field-group-fields', '.acf-field-object').length === 0; 
     24                return $(this).parentsUntil('#acf-field-group-fields', '.acf-field-object').length === 0; 
    2525            }); 
    2626 
     
    4040 
    4141        // smooth scroll - with offset for title and WP admin bar 
    42         $('a[href*=#]:not([href=#])').click(function() { 
     42        $("a[href*=\\#]:not([href=\\#])").click(function() { 
    4343            if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { 
    4444              var target = $(this.hash); 
     
    5454 
    5555              if (target.length) { 
    56                 $('html,body').animate({ 
    57                   scrollTop: target_offset - customoffset 
    58                 }, 1000); 
    59                 return false; 
     56                $('html,body').animate({ 
     57                  scrollTop: target_offset - customoffset 
     58                }, 1000); 
     59                return false; 
    6060              } 
    6161            } 
  • acf-theme-code/trunk/core/core.php

    r1517648 r1657343  
    88    public static $plugin_url = ''; 
    99    public static $plugin_basename = ''; 
    10  
     10    public static $plugin_version = ''; 
    1111    public static $db_table = ''; 
    1212    public static $indent_repeater = 2; 
     
    4545     * ACFTC_Core constructor 
    4646     */ 
    47     public function __construct( $plugin_path, $plugin_url, $plugin_basename ) { 
     47    public function __construct( $plugin_path, $plugin_url, $plugin_basename, $plugin_version ) { 
    4848 
    4949        // Paths and URLs 
     
    5151        self::$plugin_url = $plugin_url; 
    5252        self::$plugin_basename = $plugin_basename; 
     53        self::$plugin_version = $plugin_version; 
    5354 
    5455        // Hooks 
     
    8182    public function disabled_notice() { 
    8283        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 '<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>'; 
    8485        echo '</div>'; 
    85     } 
     86    } 
    8687 
    8788 
     
    9192    public function set_db_table() { 
    9293 
    93         /** 
    94          * If fields are created with ACF and then ACF PRO is installed and 
    95          * activated, the ACF fields are moved to the ACF PRO database structure. 
    96          * If ACF PRO is then deactivated and ACF is reactivated the fields 
    97          * won't appear in the admin. 
    98          * 
    99          * If fields are created with ACF PRO and then ACF is activated 
    100          * as well, only the fields created in ACF PRO will be visible 
    101          * in the the admin. 
    102          * 
    103          * If fields are created with ACF after activating and 
    104          * deactivating ACF PRO, they will only appear while ACF is 
    105          * activated and ACF PRO is deactivated. ACF PRO doesn't appear to 
    106          * convert fields to the new database structure more than once. 
    107          * 
    108          * Hence the following logic order is used: 
    109          */ 
    110  
    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'; 
    115         } elseif  ( is_plugin_active('advanced-custom-fields/acf.php' ) ) { 
     94        // If we can't detect ACF 
     95        if ( ! class_exists( 'acf' )  ) { 
     96 
     97            // bail early 
     98            return; 
     99 
     100         } 
     101 
     102        // Check for the function acf_get_setting - this came in version 5 
     103        if ( function_exists( 'acf_get_setting' ) ) { 
     104 
     105            // Get the version to be sure 
     106            // This will return a srting of the version eg '5.0.0' 
     107            $version = acf_get_setting( 'version' ); 
     108 
     109        } else { 
     110 
     111            // Use the version 4 logic to get the version 
     112            // This will return a string if the plugin is active eg '4.4.11' 
     113            // This will retrn the string 'version' if the plugin is not active 
     114            $version = apply_filters( 'acf/get_info', 'version' ); 
     115 
     116        } 
     117 
     118        // Get only the major version from the version string (the first character) 
     119        $major_version = substr( $version, 0 , 1 ); 
     120 
     121        // If the major version is 5 
     122        if( $major_version == '5' ) { 
     123 
     124            // Set the db table to posts 
     125            self::$db_table = 'posts'; 
     126 
     127        // If the major version is 4 
     128        } elseif( $major_version == '4' ) { 
     129 
     130            // Set the db table to postmeta 
    116131            self::$db_table = 'postmeta'; 
     132 
    117133        } 
    118134 
     
    144160        if ( self::$db_table == 'postmeta') { 
    145161 
     162            // Quick check for locations 
     163 
     164            // setup the location rules 
     165            $location_rules = []; 
     166 
     167            global $wpdb; 
     168 
     169            // Prepend table prefix 
     170            $table = $wpdb->prefix . 'postmeta'; 
     171 
     172            // Query postmeta table for location rules associated with this field group 
     173            $query_results = $wpdb->get_results( "SELECT * FROM " . $table . " WHERE post_id = " . $post->ID . " AND meta_key LIKE 'rule'" ); 
     174 
     175            foreach ( $query_results as $query_result ) { 
     176 
     177                // Unserialize location rule data 
     178                $location_rule = unserialize( $query_result->meta_value ); 
     179 
     180                // add the location to the array 
     181                $location_rules[] = $location_rule; 
     182 
     183            } 
     184 
     185            // count the location rules 
     186            $location_rules_count = count( $location_rules ); 
     187 
     188            // if we have more than 1 location show the notice 
     189            if( $location_rules_count >= 2 ) { 
     190                echo '<div class="acftc-pro-notice acftc-pro-notice--top"><a class="acftc-pro-notice__link" href="https://hookturn.io/downloads/acf-theme-code-pro/?utm_source=acftclocation" target="_blank">Generate code for each of your Location rules with <strong>ACF Theme Code Pro</strong></a></div>'; 
     191            } 
     192 
     193            // render the field group 
    146194            $parent_field_group = new ACFTC_Group( $post->ID ); 
    147195 
     196 
    148197        } elseif ( self::$db_table == 'posts') { 
    149198 
    150             $field_group_location = $this->get_field_group_locations( $post ); 
    151             $parent_field_group = new ACFTC_Group( $post->ID, 0 , 0 , $field_group_location); 
     199            // get an array of the locations 
     200            $field_group_location_array = $this->get_field_group_locations( $post ); 
     201 
     202            // count them 
     203            $field_group_location_array_count = count( $field_group_location_array ); 
     204 
     205            // if we have more than 1 location show the notice 
     206            if( $field_group_location_array_count >= 2 ) { 
     207                echo '<div class="acftc-pro-notice acftc-pro-notice--top"><a class="acftc-pro-notice__link" href="https://hookturn.io/downloads/acf-theme-code-pro/?utm_source=acftclocation" target="_blank">Generate code for each of your Location rules with <strong>ACF Theme Code Pro</strong></a></div>'; 
     208            } 
     209 
     210            // render the field group 
     211            $parent_field_group = new ACFTC_Group( $post->ID, 0 , 0 , ''); 
    152212 
    153213        } 
     
    174234     * @param WP_Post $post Current post object. 
    175235     */ 
     236 
    176237    private function get_field_group_locations( $post ) { 
     238 
     239        // define a locations array 
     240        $location_array = []; 
    177241 
    178242        // get field group locations from field group post content 
     
    183247            foreach ( $field_group_location_content['location']  as $location_condition_group ) { 
    184248 
     249 
    185250                foreach ( $location_condition_group as $location_condition ) { 
    186251 
    187                     // TODO: currently this function only supports "options_page". 
    188  
    189                     if ( "options_page" == $location_condition['param'] && 
    190                          "==" == $location_condition['operator'] ) { 
    191  
    192                         return "options_page"; 
    193  
    194                     } 
     252                    $location_array[] = $location_condition['param']; 
    195253 
    196254                } 
     
    198256            } 
    199257 
    200         } 
    201  
     258            return $location_array; 
     259 
     260        } 
    202261    } 
    203262 
     
    213272 
    214273            // Plugin styles 
    215             wp_enqueue_style( 'acftc_css', self::$plugin_url . 'assets/acf-theme-code.css'); 
     274            wp_enqueue_style( 'acftc_css', self::$plugin_url . 'assets/acf-theme-code.css', '' , self::$plugin_version); 
    216275 
    217276            // Prism (code formatting) 
    218             wp_enqueue_style( 'acftc_prism_css', self::$plugin_url . 'assets/prism.css'); 
    219             wp_enqueue_script( 'acftc_prism_js', self::$plugin_url . 'assets/prism.js' ); 
     277            wp_enqueue_style( 'acftc_prism_css', self::$plugin_url . 'assets/prism.css', '' , self::$plugin_version); 
     278            wp_enqueue_script( 'acftc_prism_js', self::$plugin_url . 'assets/prism.js', '' , self::$plugin_version); 
    220279 
    221280            // Clipboard 
    222             wp_enqueue_script( 'acftc_clipboard_js', self::$plugin_url . 'assets/clipboard.js' ); 
     281            wp_enqueue_script( 'acftc_clipboard_js', self::$plugin_url . 'assets/clipboard.js', '' , self::$plugin_version); 
    223282 
    224283            // Plugin js 
    225             wp_enqueue_script( 'acftc_js', self::$plugin_url . 'assets/acf-theme-code.js', array( 'acftc_clipboard_js' ), '', true ); 
     284            wp_enqueue_script( 'acftc_js', self::$plugin_url . 'assets/acf-theme-code.js', array( 'acftc_clipboard_js' ), self::$plugin_version ); 
    226285 
    227286        } 
  • acf-theme-code/trunk/readme.txt

    r1517652 r1657343  
    22Contributors: aaronrutley, benpearson 
    33Tags: acf,advanced custom fields,php,automation 
    4 Requires at least: 4.5.3 
    5 Tested up to: 4.6 
    6 Stable tag: 1.2.0 
     4Requires at least: 4.7 
     5Tested up to: 4.8.0 
     6Stable tag: 1.3.0 
    77License: GPL2+ 
    88 
     
    4949> <strong>Upgrade to ACF Theme Code Pro</strong><br> 
    5050> ACF Theme Code Pro generates code for all ACF Pro field types including the Clone, Repeater, Gallery and Flexible Content field.<br> 
    51 > ACF Theme Code Pro generates code for a range of popular 3rd party fields including the Font Awesome field and Image Crop Field.<br> 
     51> Our Pro version also generates code for a range of popular 3rd party fields and we generate code for location rules including Options Pages! 
    5252> [Find out more about ACF Theme Code Pro](https://hookturn.io/downloads/acf-theme-code-pro/) 
    5353 
     
    7171 
    7272This plugin has basic support for ACF Pro (we support all the fields found in the ACF free version). 
    73 Our 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. 
     73Our premium version - [ACF Theme Code Pro](https://hookturn.io/downloads/acf-theme-code-pro/) supports all the fields in ACF Pro, a range of other 3rd Party Fields & locations rules (like options). 
    7474 
    7575= Why is there so many PHP tags in the code that's generated ? = 
     
    8282 
    8383== Changelog == 
     84= 1.3.0 = 
     85* Core : Support for ACF Pro when bundled in a Theme 
     86* Fix : HTML output by the File field is now valid 
     87* Core : Notice for location rule support (now in ACF Theme Code Pro) 
    8488 
    8589= 1.2.0 = 
  • acf-theme-code/trunk/render/file.php

    r1517648 r1657343  
    1515    echo $this->indent . htmlspecialchars("<?php \$".$this->name." = " . $this->get_field_method . "( '".$this->name."' ); ?>")."\n"; 
    1616    echo $this->indent . htmlspecialchars("<?php if ( \$".$this->name." ) { ?>")."\n"; 
    17     echo $this->indent . htmlspecialchars(" <a href=\"<?php echo \$".$this->name."['url']; ?>\" /><?php echo \$".$this->name."['filename']; ?></a>"."\n"); 
     17    echo $this->indent . htmlspecialchars(" <a href=\"<?php echo \$".$this->name."['url']; ?>\"><?php echo \$".$this->name."['filename']; ?></a>"."\n"); 
    1818    echo $this->indent . htmlspecialchars("<?php } ?>"."\n"); 
    1919} 
     
    2323    echo $this->indent . htmlspecialchars("<?php \$".$this->name." = " . $this->get_field_method . "( '".$this->name."' ); ?>")."\n"; 
    2424    echo $this->indent . htmlspecialchars("<?php if ( \$".$this->name." ) { ?>")."\n"; 
    25     echo $this->indent . htmlspecialchars(" <a href=\"<?php echo \$".$this->name."['url']; ?>\" /><?php echo\$".$this->name."['title']; ?></a>"."\n"); 
     25    echo $this->indent . htmlspecialchars(" <a href=\"<?php echo \$".$this->name."['url']; ?>\"><?php echo \$".$this->name."['title']; ?></a>"."\n"); 
    2626    echo $this->indent . htmlspecialchars("<?php } ?>"."\n"); 
    2727} 
Note: See TracChangeset for help on using the changeset viewer.