Plugin Directory

Changeset 2936193


Ignore:
Timestamp:
07/09/2023 04:02:49 PM (3 years ago)
Author:
thewpcatalyst
Message:

version 1.1.0

Location:
plus-features-for-advanced-custom-fields
Files:
50 added
2 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • plus-features-for-advanced-custom-fields/trunk/README.txt

    r2928297 r2936193  
    55Requires at least: 5.0
    66Tested up to: 6.2
    7 Stable tag: 1.0.0
     7Stable tag: 1.1.0
    88Requires PHP: 7.0
    99License: GPLv2 or later
     
    8383[acfp field="dual_range_slider_field_name"  field_type="acfp_dual_range_slider"]
    8484
     85[acfp field="image_field_name"  field_type="image" alt="A simple image"]
     86
     87[acfp field="image_field_name"  field_type="image" alt="A simple image" media_sizes="(max-width: 600px) 480px, 800px" tag_id="my-img-id" tag_class="my-img-class" ]
     88
     89[acfp field="file_field_name"  field_type="file" ]
     90
     91[acfp field="wysiwyg_field_name"  field_type="wysiwyg" ]
     92
     93[acfp field="oembed_field_name"  field_type="oembed" ]
     94
    8595== Frequently Asked Questions ==
    8696
     
    118128== Changelog ==
    119129
     130= 1.1.0 =
     131Supports ACF shortcode security filters.
     132Added step settings to dual range slider.
     133Added shortcode support for ACF images, files, WYSIWYG, oEmbed.
     134Enhancement- Dual Range slider now has set settings.
     135
    120136= 1.0.0 =
    121137Beginning of ACF Plus.
     
    123139== Upgrade Notice ==
    124140
    125 = 1.0.0 =
    126 Beginning of ACF Plus.
     141= 1.1.0 =
     142Added shortcode support for ACF images, files, WYSIWYG, oEmbed.
  • plus-features-for-advanced-custom-fields/trunk/acfp.php

    r2928290 r2936193  
    11<?php
    2 
    32/**
    43 * The plugin bootstrap file
     
    1716 * Plugin URI:        https://wordpress.org/plugins/plus-features-for-advanced-custom-fields
    1817 * Description:       Adds extra features to Advanced Custom Fields plugin(ACF)
    19  * Version:           1.0.0
     18 * Version:           1.1.0
    2019 * Author:            the WP Catalyst
    2120 * Author URI:        https://profiles.wordpress.org/thewpcatalyst/
     
    3635 * Rename this for your plugin and update it as you release new versions.
    3736 */
    38 define( 'ACFP_VERSION', '1.0.0' );
     37define( 'ACFP_VERSION', '1.1.0' );
    3938
    4039/**
  • plus-features-for-advanced-custom-fields/trunk/admin/partials/acfp-admin-display.php

    r2928290 r2936193  
    11<?php
    2 
    32/**
    43 * Provide a admin area view for the plugin
     
    1211 * @subpackage Acfp/admin/partials
    1312 */
     13
    1414?>
    1515
  • plus-features-for-advanced-custom-fields/trunk/assets/build/js/acfp-field-dual-range-slider.js

    r2928290 r2936193  
    1212        fromSlider=sliderInputs[0];
    1313        toSlider=sliderInputs[1];
    14         console.log(toSlider);
    1514      }else if(j==2){//number_control
    1615         number_control_containers= child.children;
     
    2120        toInput=container_2.children[1]
    2221        valueTextInput=container_3.children[0]
    23         console.log(valueTextInput);
    2422      }
    2523    }
     
    119117
    120118getParsed(currentFrom, currentTo) {
    121   const from = parseInt(currentFrom.value, 10);
    122   const to = parseInt(currentTo.value, 10);
     119  const from = parseFloat(currentFrom.value, 10);
     120  const to = parseFloat(currentTo.value, 10);
    123121  return [from, to];
    124122}
    125123
    126124fillSlider(from, to, sliderColor, rangeColor, controlSlider,initial) {
    127   if(parseInt(initial!=true && controlSlider.offsetHeight)==0){
     125  if(parseFloat(initial!=true && controlSlider.offsetHeight)==0){
    128126    controlSlider=this.getFromSlider();
    129127  }
  • plus-features-for-advanced-custom-fields/trunk/assets/build/js/acfp-field-dual-range-slider.min.js

    r2928290 r2936193  
    1 document.addEventListener('DOMContentLoaded', acfpDocumentReadyDualRangeSlider, false);
    2 
    3 function acfpDocumentReadyDualRangeSlider () {
    4   const acfp_dual_range_slider_containers = document.getElementsByClassName("acfp_dual_range_slider_container");
    5   for(i=0; i<acfp_dual_range_slider_containers.length;i++){
    6     children=acfp_dual_range_slider_containers[i].children;
    7     j=0;
    8     for (const child of children) {
    9       j++;
    10       if(j==1){//sliders_control
    11         sliderInputs= child.children;
    12         fromSlider=sliderInputs[0];
    13         toSlider=sliderInputs[1];
    14         console.log(toSlider);
    15       }else if(j==2){//number_control
    16          number_control_containers= child.children;
    17         container_1=number_control_containers[0];
    18         container_2=number_control_containers[1];
    19         container_3=number_control_containers[2];
    20         fromInput=container_1.children[1];
    21         toInput=container_2.children[1]
    22         valueTextInput=container_3.children[0]
    23         console.log(valueTextInput);
    24       }
    25     }
    26     acfpInitDualRangeSlider(fromSlider, fromInput, toInput, toSlider, valueTextInput);
    27   }
    28 }
    29 
    30 function acfpInitDualRangeSlider(fromSlider, fromInput, toInput, toSlider, valueTextInput){
    31   acfpDualRangeSlider =new AcfpDualRangeSlider(fromSlider, fromInput, toInput, toSlider, valueTextInput);
    32 }
    33 
    34 class AcfpDualRangeSlider {
    35   fromSlider=null;
    36   toSlider=null;
    37  
    38   constructor(fromSlider, fromInput, toInput, toSlider, valueTextInput) {
    39     this.fromSlider=fromSlider;
    40     this.fromInput=fromInput;
    41     this.toInput=toInput;
    42     this.toSlider=toSlider;
    43     this.valueTextInput=valueTextInput;
    44     //event listeners
    45     this.toSliderInputListener = this.controlToSlider.bind(this);
    46     this.fromSliderInputListener = this.controlFromSlider.bind(this);
    47     this.init();
    48   }
    49 
    50   init(){
    51     this.fillSlider(this.getFromSlider(), this.getToSlider(), '#C6C6C6', '#25daa5', this.getToSlider(), true);
    52     this.getToSlider().addEventListener('input', this.toSliderInputListener);
    53     this.getFromSlider().addEventListener('input', this.fromSliderInputListener);
    54     this.getFromInput().oninput = () => this.controlFromInput(this.getFromSlider(), this.getFromInput(), this.getToInput());
    55     this.getToInput().oninput = () => this.controlToInput(this.getToSlider(), this.getFromInput(), this.getToInput());
    56   }
    57  
    58   controlFromInput(fromSlider, fromInput, toInput) {
    59     const [from, to] = this.getParsed(fromInput, toInput);
    60     if (from > to) {
    61         fromSlider.value = to;
    62         fromInput.value = to;
    63     } else {
    64         fromSlider.value = from;
    65     }
    66     //dispatch input event
    67     const inputEvent = new Event('input');
    68     fromSlider.dispatchEvent(inputEvent);
    69 }
    70    
    71 controlToInput(toSlider, fromInput, toInput) {
    72     const [from, to] = this.getParsed(fromInput, toInput);
    73     if (from <= to) {
    74         toSlider.value = to;
    75         toInput.value = to;
    76     } else {
    77         toInput.value = from;
    78     }
    79     //dispatch input event
    80     const inputEvent = new Event('input');
    81     toSlider.dispatchEvent(inputEvent);
    82 }
    83 
    84 controlFromSlider(){
    85   let from=parseFloat(this.getFromSlider().value);
    86   let to=parseFloat(this.getToSlider().value);
    87   if (from > to){
    88     let tmp=this.getToSlider();
    89     this.setToSlider(this.getFromSlider());
    90     this.setFromSlider(tmp);
    91   }
    92   this.updateNumberInputs();
    93   this.fillSlider(this.getFromSlider(), this.getToSlider(), '#C6C6C6', '#25daa5', this.getToSlider());
    94   this.controlValueInput(valueTextInput,fromSlider, toSlider);
    95 }
    96 
    97 controlToSlider(){
    98   let from=parseFloat(this.getFromSlider().value);
    99   let to=parseFloat(this.getToSlider().value);
    100   if (from > to){
    101     let tmp=this.getToSlider();
    102     this.setToSlider(this.getFromSlider());
    103     this.setFromSlider(tmp);
    104   }
    105   this.fillSlider(this.getFromSlider(), this.getToSlider(), '#C6C6C6', '#25daa5', this.getToSlider());
    106   this.controlValueInput(valueTextInput,fromSlider, toSlider);
    107   this.updateNumberInputs();
    108 }
    109 
    110 updateNumberInputs(){
    111   this.getFromInput().value=this.getFromSlider().value;
    112   this.getToInput().value=this.getToSlider().value;
    113 }
    114 
    115 
    116 controlValueInput(){
    117   this.getValueTextInput().value =this.getFromSlider().value+","+this.getToSlider().value;
    118 }
    119 
    120 getParsed(currentFrom, currentTo) {
    121   const from = parseInt(currentFrom.value, 10);
    122   const to = parseInt(currentTo.value, 10);
    123   return [from, to];
    124 }
    125 
    126 fillSlider(from, to, sliderColor, rangeColor, controlSlider,initial) {
    127   if(parseInt(initial!=true && controlSlider.offsetHeight)==0){
    128     controlSlider=this.getFromSlider();
    129   }
    130   const rangeDistance = to.max-to.min;
    131     const fromPosition = from.value - to.min;
    132     const toPosition = to.value - to.min;
    133     controlSlider.style.background = `linear-gradient(
     1function acfpDocumentReadyDualRangeSlider(){let t=document.getElementsByClassName("acfp_dual_range_slider_container");for(i=0;i<t.length;i++){for(let e of(children=t[i].children,j=0,children))1==++j?(fromSlider=(sliderInputs=e.children)[0],toSlider=sliderInputs[1]):2==j&&(container_1=(number_control_containers=e.children)[0],container_2=number_control_containers[1],container_3=number_control_containers[2],fromInput=container_1.children[1],toInput=container_2.children[1],valueTextInput=container_3.children[0]);acfpInitDualRangeSlider(fromSlider,fromInput,toInput,toSlider,valueTextInput)}}function acfpInitDualRangeSlider(t,e,l,r,n){acfpDualRangeSlider=new AcfpDualRangeSlider(t,e,l,r,n)}document.addEventListener("DOMContentLoaded",acfpDocumentReadyDualRangeSlider,!1);class AcfpDualRangeSlider{fromSlider=null;toSlider=null;constructor(t,e,l,r,n){this.fromSlider=t,this.fromInput=e,this.toInput=l,this.toSlider=r,this.valueTextInput=n,this.toSliderInputListener=this.controlToSlider.bind(this),this.fromSliderInputListener=this.controlFromSlider.bind(this),this.init()}init(){this.fillSlider(this.getFromSlider(),this.getToSlider(),"#C6C6C6","#25daa5",this.getToSlider(),!0),this.getToSlider().addEventListener("input",this.toSliderInputListener),this.getFromSlider().addEventListener("input",this.fromSliderInputListener),this.getFromInput().oninput=()=>this.controlFromInput(this.getFromSlider(),this.getFromInput(),this.getToInput()),this.getToInput().oninput=()=>this.controlToInput(this.getToSlider(),this.getFromInput(),this.getToInput())}controlFromInput(t,e,l){let[r,n]=this.getParsed(e,l);r>n?(t.value=n,e.value=n):t.value=r;let o=new Event("input");t.dispatchEvent(o)}controlToInput(t,e,l){let[r,n]=this.getParsed(e,l);r<=n?(t.value=n,l.value=n):l.value=r;let o=new Event("input");t.dispatchEvent(o)}controlFromSlider(){let t=parseFloat(this.getFromSlider().value),e=parseFloat(this.getToSlider().value);if(t>e){let l=this.getToSlider();this.setToSlider(this.getFromSlider()),this.setFromSlider(l)}this.updateNumberInputs(),this.fillSlider(this.getFromSlider(),this.getToSlider(),"#C6C6C6","#25daa5",this.getToSlider()),this.controlValueInput(valueTextInput,fromSlider,toSlider)}controlToSlider(){let t=parseFloat(this.getFromSlider().value),e=parseFloat(this.getToSlider().value);if(t>e){let l=this.getToSlider();this.setToSlider(this.getFromSlider()),this.setFromSlider(l)}this.fillSlider(this.getFromSlider(),this.getToSlider(),"#C6C6C6","#25daa5",this.getToSlider()),this.controlValueInput(valueTextInput,fromSlider,toSlider),this.updateNumberInputs()}updateNumberInputs(){this.getFromInput().value=this.getFromSlider().value,this.getToInput().value=this.getToSlider().value}controlValueInput(){this.getValueTextInput().value=this.getFromSlider().value+","+this.getToSlider().value}getParsed(t,e){let l=parseFloat(t.value,10),r=parseFloat(e.value,10);return[l,r]}fillSlider(t,e,l,r,n,o){0==parseFloat(!0!=o&&n.offsetHeight)&&(n=this.getFromSlider());let s=e.max-e.min,u=t.value-e.min,d=e.value-e.min;n.style.background=`linear-gradient(
    1342      to right,
    135       ${sliderColor} 0%,
    136       ${sliderColor} ${(fromPosition)/(rangeDistance)*100}%,
    137       ${rangeColor} ${((fromPosition)/(rangeDistance))*100}%,
    138       ${rangeColor} ${(toPosition)/(rangeDistance)*100}%,
    139       ${sliderColor} ${(toPosition)/(rangeDistance)*100}%,
    140       ${sliderColor} 100%)`;
    141 }
    142 
    143 setToggleAccessible(currentTarget,toSlider) {
    144   if (Number(currentTarget.value) <= 0 ) {
    145     toSlider.style.zIndex = 2;
    146   } else {
    147     toSlider.style.zIndex = 0;
    148   }
    149 }
    150   //Setters and getters
    151   setFromSlider(fromSlider) {
    152     this.fromSlider=fromSlider;
    153   }
    154 
    155   getFromSlider() {
    156     return this.fromSlider;
    157   }
    158 
    159   setToSlider(toSlider) {
    160     this.toSlider=toSlider;
    161   }
    162 
    163   getToSlider() {
    164     return this.toSlider;
    165   }
    166 
    167   setFromInput(fromInput) {
    168     this.fromInput=fromInput;
    169   }
    170 
    171   getFromInput() {
    172     return this.fromInput;
    173   }
    174 
    175   setToInput(toInput) {
    176     this.toInput=toInput;
    177   }
    178 
    179   getToInput() {
    180     return this.toInput;
    181   }
    182 
    183   setValueTextInput(valueTextInput) {
    184     this.valueTextInput=valueTextInput;
    185   }
    186 
    187   getValueTextInput() {
    188     return this.valueTextInput;
    189   }
    190 }
     3      ${l} 0%,
     4      ${l} ${u/s*100}%,
     5      ${r} ${u/s*100}%,
     6      ${r} ${d/s*100}%,
     7      ${l} ${d/s*100}%,
     8      ${l} 100%)`}setToggleAccessible(t,e){0>=Number(t.value)?e.style.zIndex=2:e.style.zIndex=0}setFromSlider(t){this.fromSlider=t}getFromSlider(){return this.fromSlider}setToSlider(t){this.toSlider=t}getToSlider(){return this.toSlider}setFromInput(t){this.fromInput=t}getFromInput(){return this.fromInput}setToInput(t){this.toInput=t}getToInput(){return this.toInput}setValueTextInput(t){this.valueTextInput=t}getValueTextInput(){return this.valueTextInput}}
  • plus-features-for-advanced-custom-fields/trunk/includes/acfp-utility.php

    r2928290 r2936193  
    11<?php
     2/**
     3 * The file that defines acfp global functions
     4 *
     5 * @link       https://profiles.wordpress.org/thewpcatalyst/
     6 * @since      1.0.0
     7 *
     8 * @package    Acfp
     9 * @subpackage Acfp/includes
     10 */
    211
    3 if(!function_exists('acfp_get_post_id')){
    4     /**
    5      * Returns post id and false incase of an error.
    6      *
    7      * @return int|false
    8      */
    9     function acfp_get_post_id(){
    10        return get_the_ID();
    11     }
    12 
     12if ( ! function_exists( 'acfp_get_post_id' ) ) {
     13    /**
     14     * Returns post id and false incase of an error.
     15     *
     16     * @since 1.0.0
     17     *
     18     * @return int|false
     19     */
     20    function acfp_get_post_id() {
     21        return get_the_ID();
     22    }
    1323}
    1424
    15 /**
    16  * Gets fields definition by field name or field key and post ID
    17  *
    18  * @param [type] $field_name_or_key
    19  * @param [type] $post_id
    20  * @return array|false
    21  */
    22 function acfp_get_field_definitions( $field_name_or_key, $post_id ) {
    23     $groups = acf_get_field_groups( array( 'post_id' => $post_id ) );
    24     foreach ( $groups as $group ) {
    25         $fields = acf_get_fields( $group['key'] );
    26         foreach ( $fields as $field ) {
    27             if($field['name']==$field_name_or_key||$field['name']==$field_name_or_key){
    28                 return $field;
    29             }
     25if ( ! function_exists( 'acfp_get_field_definitions' ) ) {
     26    /**
     27     * Gets fields definition by field name or field key and post ID
     28     *
     29     * @since 1.0.0
     30     *
     31     * @param string $field_name_or_key Field name or key.
     32     * @param mixed  $post_id post ID.
     33     * @return array|false
     34     */
     35    function acfp_get_field_definitions( $field_name_or_key, $post_id ) {
     36        $groups = acf_get_field_groups( array( 'post_id' => $post_id ) );
     37        foreach ( $groups as $group ) {
     38            $fields = acf_get_fields( $group['key'] );
     39            foreach ( $fields as $field ) {
     40                if ( $field['name'] === $field_name_or_key || $field['name'] === $field_name_or_key ) {
     41                    return $field;
     42                }
     43            }
    3044        }
     45        return false;
    3146    }
    32     return false;
    3347}
     48
     49
     50if ( ! function_exists( 'acfp_get_attachment' ) ) {
     51    /**
     52     * Function to get attachment details in array from ID
     53     *
     54     * @since 1.1.0
     55     *
     56     * @param integer $attachment_id attachment ID.
     57     * @return array|false
     58     */
     59    function acfp_get_attachment( int $attachment_id ) {
     60        if ( function_exists( 'acf_get_attachment' ) ) {
     61            return acf_get_attachment( $attachment_id );
     62        }
     63        return false;
     64    }
     65}
  • plus-features-for-advanced-custom-fields/trunk/includes/class-acfp-activator.php

    r2928290 r2936193  
    11<?php
    2 
    32/**
    43 * Fired during plugin activation
  • plus-features-for-advanced-custom-fields/trunk/includes/class-acfp-deactivator.php

    r2928290 r2936193  
    11<?php
    2 
    32/**
    43 * Fired during plugin deactivation
  • plus-features-for-advanced-custom-fields/trunk/includes/class-acfp-i18n.php

    r2928290 r2936193  
    11<?php
    2 
    32/**
    43 * Define the internationalization functionality
  • plus-features-for-advanced-custom-fields/trunk/includes/class-acfp-loader.php

    r2928290 r2936193  
    11<?php
    2 
    32/**
    43 * Register all actions and filters for the plugin
     
    5857     *
    5958     * @since    1.0.0
    60      * @param    string               $hook             The name of the WordPress action that is being registered.
    61      * @param    object               $component        A reference to the instance of the object on which the action is defined.
    62      * @param    string               $callback         The name of the function definition on the $component.
    63      * @param    int                  $priority         Optional. The priority at which the function should be fired. Default is 10.
    64      * @param    int                  $accepted_args    Optional. The number of arguments that should be passed to the $callback. Default is 1.
     59     * @param    string $hook             The name of the WordPress action that is being registered.
     60     * @param    object $component        A reference to the instance of the object on which the action is defined.
     61     * @param    string $callback         The name of the function definition on the $component.
     62     * @param    int    $priority         Optional. The priority at which the function should be fired. Default is 10.
     63     * @param    int    $accepted_args    Optional. The number of arguments that should be passed to the $callback. Default is 1.
    6564     */
    6665    public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
     
    7271     *
    7372     * @since    1.0.0
    74      * @param    string               $hook             The name of the WordPress filter that is being registered.
    75      * @param    object               $component        A reference to the instance of the object on which the filter is defined.
    76      * @param    string               $callback         The name of the function definition on the $component.
    77      * @param    int                  $priority         Optional. The priority at which the function should be fired. Default is 10.
    78      * @param    int                  $accepted_args    Optional. The number of arguments that should be passed to the $callback. Default is 1
     73     * @param    string $hook             The name of the WordPress filter that is being registered.
     74     * @param    object $component        A reference to the instance of the object on which the filter is defined.
     75     * @param    string $callback         The name of the function definition on the $component.
     76     * @param    int    $priority         Optional. The priority at which the function should be fired. Default is 10.
     77     * @param    int    $accepted_args    Optional. The number of arguments that should be passed to the $callback. Default is 1.
    7978     */
    8079    public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
     
    8887     * @since    1.0.0
    8988     * @access   private
    90      * @param    array                $hooks            The collection of hooks that is being registered (that is, actions or filters).
    91      * @param    string               $hook             The name of the WordPress filter that is being registered.
    92      * @param    object               $component        A reference to the instance of the object on which the filter is defined.
    93      * @param    string               $callback         The name of the function definition on the $component.
    94      * @param    int                  $priority         The priority at which the function should be fired.
    95      * @param    int                  $accepted_args    The number of arguments that should be passed to the $callback.
     89     * @param    array  $hooks            The collection of hooks that is being registered (that is, actions or filters).
     90     * @param    string $hook             The name of the WordPress filter that is being registered.
     91     * @param    object $component        A reference to the instance of the object on which the filter is defined.
     92     * @param    string $callback         The name of the function definition on the $component.
     93     * @param    int    $priority         The priority at which the function should be fired.
     94     * @param    int    $accepted_args    The number of arguments that should be passed to the $callback.
    9695     * @return   array                                  The collection of actions and filters registered with WordPress.
    9796     */
     
    103102            'callback'      => $callback,
    104103            'priority'      => $priority,
    105             'accepted_args' => $accepted_args
     104            'accepted_args' => $accepted_args,
    106105        );
    107106
  • plus-features-for-advanced-custom-fields/trunk/includes/class-acfp.php

    r2928290 r2936193  
    8686            $this->version = ACFP_VERSION;
    8787        } else {
    88             $this->version = '1.0.0';
     88            $this->version = '1.1.0';
    8989        }
    9090        $this->plugin_name                     = 'acfp';
  • plus-features-for-advanced-custom-fields/trunk/includes/fields/class-acfp-acf-field-dual-range-slider.php

    r2928290 r2936193  
    5959        */
    6060        $this->defaults = array(
     61            'step'              => '1',
    6162            'min_value'         => '0',
    6263            'default_min_value' => '0',
     
    107108     */
    108109    function render_field_settings( $field ) {
    109         /*
    110         *  acf_render_field_setting
    111         *
    112         *  This function will create a setting for your field. Simply pass the $field parameter and an array of field settings.
    113         *  The array of settings does not require a `value` or `prefix`; These settings are found from the $field array.
    114         *
    115         *  More than one setting can be added by copy/paste the above code.
    116         *  Please note that you must also have a matching $defaults value for the field name (font_size)
    117         */
     110        acf_render_field_setting(
     111            $field,
     112            array(
     113                'label'        => __( 'Step', 'acfp' ),
     114                'instructions' => __( 'Slider step value', 'acfp' ),
     115                'type'         => 'number',
     116                'name'         => 'step',
     117                'required'     => 1,
     118            )
     119        );
    118120        acf_render_field_setting(
    119121            $field,
     
    183185            $to_slider_value   = intval( $field['default_max_value'] );
    184186        }
     187        $step = floatval( $field['step'] );
    185188
    186189        ?>
     
    188191        <div class="acfp_dual_range_slider_container">
    189192            <div class="sliders_control">
    190                 <input class="fromSlider" id="fromSlider-<?php echo esc_attr( $field['name'] . $field_id ); ?>" type="range" value="<?php echo esc_attr( $from_slider_value ); ?>" min="<?php echo esc_attr( $min ); ?>" max="<?php echo esc_attr( $max ); ?>"/>
    191                 <input class="toSlider" id="toSlider-<?php echo esc_attr( $field['name'] . $field_id ); ?>" type="range" value="<?php echo esc_attr( $to_slider_value ); ?>" min="<?php echo esc_attr( $min ); ?>" max="<?php echo esc_attr( $max ); ?>"/>
     193                <input class="fromSlider" id="fromSlider-<?php echo esc_attr( $field['name'] . $field_id ); ?>" type="range" value="<?php echo esc_attr( $from_slider_value ); ?>" min="<?php echo esc_attr( $min ); ?>" max="<?php echo esc_attr( $max ); ?>" step="<?php echo esc_attr( $step ); ?>"/>
     194                <input class="toSlider" id="toSlider-<?php echo esc_attr( $field['name'] . $field_id ); ?>" type="range" value="<?php echo esc_attr( $to_slider_value ); ?>" min="<?php echo esc_attr( $min ); ?>" max="<?php echo esc_attr( $max ); ?>" step="<?php echo esc_attr( $step ); ?>"/>
    192195            </div>
    193196            <div class="number_control">
    194197                <div class="number_control_container">
    195198                    <div class="number_text_min">Min</div>
    196                     <input class="number_input_from" type="number" id="fromInput-<?php echo esc_attr( $field['name'] . $field_id ); ?>" value="<?php echo esc_attr( $from_slider_value ); ?>"  min="<?php echo esc_attr( $min ); ?>" max="<?php echo esc_attr( $max ); ?>"/>
     199                    <input class="number_input_from" type="number" id="fromInput-<?php echo esc_attr( $field['name'] . $field_id ); ?>" value="<?php echo esc_attr( $from_slider_value ); ?>"  min="<?php echo esc_attr( $min ); ?>" max="<?php echo esc_attr( $max ); ?>" step="<?php echo esc_attr( $step ); ?>"/>
    197200                </div>
    198201                <div class="number_control_container">
    199202                    <div class="number_text_max">Max</div>
    200                     <input class="number_input_to" type="number" id="toInput-<?php echo esc_attr( $field['name'] . $field_id ); ?>" value="<?php echo esc_attr( $to_slider_value ); ?>" min="<?php echo esc_attr( $min ); ?>" min="<?php echo esc_attr( $min ); ?>" max="<?php echo esc_attr( $max ); ?>"/>
     203                    <input class="number_input_to" type="number" id="toInput-<?php echo esc_attr( $field['name'] . $field_id ); ?>" value="<?php echo esc_attr( $to_slider_value ); ?>" min="<?php echo esc_attr( $min ); ?>" min="<?php echo esc_attr( $min ); ?>" max="<?php echo esc_attr( $max ); ?>" step="<?php echo esc_attr( $step ); ?>"/>
    201204                </div>
    202205                <div class="number_control_container">
     
    229232            "{$url_to_plugin_base}assets/build/js/acfp-field-dual-range-slider.min.js",
    230233            array( 'acf-input' ),
    231             $version
     234            $version,
     235            false
    232236        );
    233237
     
    299303     * @return array|false
    300304     */
    301     function get_desired_value( $value ) {
     305    public function get_desired_value( $value ) {
    302306        if ( is_string( $value ) ) {
    303307            $input_array   = explode( ',', $value );
  • plus-features-for-advanced-custom-fields/trunk/includes/index.php

    r2928290 r2936193  
    1 <?php // Silence is golden
     1<?php
     2/**
     3 * Silence is golden.
     4 *
     5 * @link              https://profiles.wordpress.org/thewpcatalyst/
     6 * @since             1.0.0
     7 * @package           Acfp/includes
     8 */
  • plus-features-for-advanced-custom-fields/trunk/includes/shortcodes/class-acfp-shortcode.php

    r2928290 r2936193  
    6666     */
    6767    public function acfp_shortcode( $atts ) {
     68        // Return if the ACF shortcode is disabled.
     69        if ( ! acf_get_setting( 'enable_shortcode' ) ) {
     70            return;
     71        }
     72
     73        if ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) {
     74            // Prevent the ACF shortcode in FSE block template parts by default.
     75            // phpcs:ignore WordPress.NamingConventions.ValidHookName
     76            if ( ! doing_filter( 'the_content' ) && ! apply_filters( 'acf/shortcode/allow_in_block_themes_outside_content', false ) ) {
     77                return;
     78            }
     79        }
     80
     81        // Limit previews of ACF shortcode data for users without publish_posts permissions.
     82        // phpcs:ignore WordPress.NamingConventions.ValidHookName
     83        $preview_capability = apply_filters( 'acf/shortcode/preview_capability', 'publish_posts' );
     84        if ( is_preview() && ! current_user_can( $preview_capability ) ) {
     85            // phpcs:ignore WordPress.NamingConventions.ValidHookName
     86            return apply_filters( 'acf/shortcode/preview_capability_message', __( '[ACF shortcode value disabled for preview]', 'acfp' ) );
     87        }
     88
     89        // Mitigate issue where some AJAX requests can return ACF field data.
     90        // phpcs:ignore WordPress.NamingConventions.ValidHookName
     91        $ajax_capability = apply_filters( 'acf/ajax/shortcode_capability', 'edit_posts' );
     92        if ( wp_doing_ajax() && ( false !== $ajax_capability ) && ! current_user_can( $ajax_capability ) ) {
     93            return;
     94        }
    6895        $a                   = shortcode_atts(
    6996            array(
     
    78105                'decimal_separator'   => '.', // used in number.
    79106                'thousands_separator' => ',', // used in number.
     107                'alt'                 => '', // used in image.
     108                'width'               => '100px', // used in image.
     109                'height'              => '100px', // used in image.
     110                'style'               => '', // used in image.
     111                'size'                => '', // used in image.
     112                'media_sizes'         => '', // used in image.
     113                'tag_id'              => '', // used in image.
     114                'tag_class'           => '', // used in image.
    80115            ),
    81116            $atts
     
    87122        $field_type          = $a['field_type'];
    88123        $link_text           = $a['link_text'];// Used in email,urls.
    89         $format              = $a['format'];// Used in email,url: link. Used in number: separators_decimals.
     124        $format              = $a['format'];// Used in email,url: link. Number: separators_decimals. File: to be added.
    90125        $decimals            = $a['decimals'];// Used in number.
    91126        $decimal_separator   = $a['decimal_separator'];// Used in number.
    92127        $thousands_separator = $a['thousands_separator'];// Used in number.
     128        $alt                 = $a['alt'];// Used in image.
     129        $width               = $a['width'];// Used in image.
     130        $height              = $a['height'];// Used in image.
     131        $style               = $a['style'];// Used in image.
     132        $size                = $a['size'];// Used in image.
     133        $media_sizes         = $a['media_sizes'];// Used in image.
     134        $tag_id              = $a['tag_id'];// Used in email,url,image.
     135        $tag_class           = $a['tag_class'];// Used in email,url,image.
     136
    93137        if ( 'current_post' === $object ) {
    94138            $post_id = acfp_get_post_id();
     
    96140                if ( '' !== $field ) {
    97141                    if ( function_exists( 'get_field' ) ) {
     142                        // phpcs:ignore WordPress.NamingConventions.ValidHookName
     143                        $access_already_prevented = apply_filters( 'acf/prevent_access_to_unknown_fields', false );
     144                        $filter_applied           = false;
     145
     146                        if ( ! $access_already_prevented ) {
     147                            $filter_applied = true;
     148                            add_filter( 'acf/prevent_access_to_unknown_fields', '__return_true' );
     149                        }
    98150
    99151                        $field_value = get_field( $field, $post_id );
     152
     153                        if ( $filter_applied ) {
     154                            remove_filter( 'acf/prevent_access_to_unknown_fields', '__return_true' );
     155                        }
     156
    100157                        if ( $field_value ) {
    101158                            if ( ! $field_type || ! in_array( $field_type, $this->acfp->get_shortcode_supported_field_types(), true ) ) {
     
    107164                                $content = $field_value;
    108165                            } elseif ( 'number' === $field_type ) {
    109                                 if ( 'separators_decimals' === $format ) {
    110                                     $content = number_format( $field_value, $decimals, $decimal_separator, $thousands_separator );
    111                                 } else {
    112                                     $content = $field_value;
    113                                 }
     166                                $content = $this->get_number_render_content( $format, $field_value, $decimals, $decimal_separator, $thousands_separator );
    114167                            } elseif ( 'email' === $field_type ) {
    115                                 if ( 'link' === $format ) {
    116                                     if ( ! $link_text ) {
    117                                         $link_text = $field_value;
    118                                     }
    119                                     $content = '<a href="mailto:' . esc_attr( $field_value ) . '">' . esc_html( $link_text ) . '</a>';
    120                                 } else {
    121                                     $content = $field_value;
    122                                 }
     168                                $content = $this->get_email_render_content( $format, $field_value, $link_text, $tag_class, $tag_id, $style );
    123169                            } elseif ( 'url' === $field_type ) {
    124                                 if ( 'link' === $format ) {
    125                                     if ( ! $link_text ) {
    126                                         $link_text = $field_value;
    127                                     }
    128                                     $content = '<a href="' . esc_url( $field_value ) . '">' . esc_html( $link_text ) . '</a>';
    129                                 } else {
    130                                     $content = $field_value;
    131                                 }
     170                                $content = $this->get_url_render_content( $format, $field_value, $link_text, $tag_class, $tag_id, $style );
    132171                            } elseif ( 'acfp_dual_range_slider' === $field_type ) {
    133                                 if ( 'min' === $format ) {
    134                                     if ( array_key_exists( 'min', $field_value ) ) {
    135                                         $content = esc_html( $field_value['min'] );
    136                                     } else {
    137                                         $content = '';
    138                                     }
    139                                 } elseif ( 'max' === $format ) {
    140                                     if ( array_key_exists( 'max', $field_value ) ) {
    141                                         $content = esc_html( $field_value['max'] );
    142                                     } else {
    143                                         $content = '';
    144                                     }
    145                                 } else {
    146                                     $content = implode( ', ', $field_value );
    147                                 }
     172                                $content = $this->get_acfp_dual_range_slider_render_content( $format, $field_value );
     173                            } elseif ( 'image' === $field_type ) {
     174                                $content = $this->get_image_render_content( $field_value, $tag_class, $tag_id, $alt, $width, $height, $style, $size, $media_sizes );
     175                            } elseif ( 'file' === $field_type ) {
     176                                $content = $this->get_file_render_content( $field_value, $format, $link_text, $tag_class, $tag_id, $style );
     177                            } elseif ( 'wysiwyg' === $field_type ) {
     178                                $content = $this->get_wysiwyg_render_content( $field_value );
     179                            } elseif ( 'oembed' === $field_type ) {
     180                                $content = $this->get_oembed_render_content( $field_value );
    148181                            }
    149182                        } else {
     
    156189        return $content;
    157190    }
     191
     192    /**
     193     * Renders number content
     194     *
     195     * @param string $format format to be displayed.
     196     * @param mixed  $field_value field value.
     197     * @param string $decimals number of decimals.
     198     * @param string $decimal_separator character to be used as decimal separator.
     199     * @param string $thousands_separator character to be used as thousand separator.
     200     * @return string
     201     */
     202    public function get_number_render_content( $format, $field_value, $decimals, $decimal_separator, $thousands_separator ) {
     203        if ( 'separators_decimals' === $format ) {
     204            $content = number_format( $field_value, $decimals, $decimal_separator, $thousands_separator );
     205        } else {
     206            $content = $field_value;
     207        }
     208        return $content;
     209    }
     210
     211    /**
     212     * Function to get email render content
     213     *
     214     * @since 1.0.0
     215     * @since 1.1.0
     216     * Added  $tag_class,$tag_id,$style
     217     *
     218     * @param string $format format to be displayed.
     219     * @param string $field_value field value.
     220     * @param string $link_text text to be rendered on the page instead of the actual link.
     221     * @param string $tag_class tag class.
     222     * @param string $tag_id tag id.
     223     * @param string $style tag style.
     224     * @return string
     225     */
     226    public function get_email_render_content( $format, $field_value, $link_text, $tag_class, $tag_id, $style ) {
     227        if ( 'link' === $format ) {
     228            if ( ! $link_text ) {
     229                $link_text = $field_value;
     230            }
     231            $content = $this->get_link_tag_html( $field_value, $link_text, $tag_class, $tag_id, $style );
     232        } else {
     233            $content = $field_value;
     234        }
     235        return $content;
     236    }
     237
     238    /**
     239     * Function to get url render content
     240     *
     241     * @since 1.0.0
     242     * @since 1.1.0
     243     * Added  $tag_class,$tag_id,$style
     244     *
     245     * @param string $format format to be displayed.
     246     * @param string $field_value field value.
     247     * @param string $link_text text to be rendered on the page instead of the actual link.
     248     * @param string $tag_class tag class.
     249     * @param string $tag_id tag id.
     250     * @param string $style tag style.
     251     * @return string
     252     */
     253    public function get_url_render_content( $format, $field_value, $link_text, $tag_class, $tag_id, $style ) {
     254        if ( 'link' === $format ) {
     255            if ( ! $link_text ) {
     256                $link_text = $field_value;
     257            }
     258            $content = $this->get_link_tag_html( $field_value, $link_text, $tag_class, $tag_id, $style );
     259        } else {
     260            $content = $field_value;
     261        }
     262        return $content;
     263    }
     264
     265    /**
     266     * Function to get dual range slider render content
     267     *
     268     * @since 1.0.0
     269     *
     270     * @param string $format format to be displayed.
     271     * @param string $field_value field value.
     272     * @return string
     273     */
     274    public function get_acfp_dual_range_slider_render_content( $format, $field_value ) {
     275        if ( 'min' === $format ) {
     276            if ( array_key_exists( 'min', $field_value ) ) {
     277                $content = esc_html( $field_value['min'] );
     278            } else {
     279                $content = '';
     280            }
     281        } elseif ( 'max' === $format ) {
     282            if ( array_key_exists( 'max', $field_value ) ) {
     283                $content = esc_html( $field_value['max'] );
     284            } else {
     285                $content = '';
     286            }
     287        } else {
     288            $content = implode( ', ', $field_value );
     289        }
     290        return $content;
     291    }
     292
     293    /**
     294     * Function to get image render content
     295     *
     296     * @since 1.1.0
     297     *
     298     * @param string $field_value field value.
     299     * @param string $tag_class tag class.
     300     * @param string $tag_id tag id.
     301     * @param string $alt alternative text incase image fails to load.
     302     * @param int    $width image width.
     303     * @param int    $height image height.
     304     * @param string $style tag style.
     305     * @param string $size WordPress thumbnail size to be rendered.
     306     * @param string $media_sizes media sizes https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images.
     307     * @return string
     308     */
     309    public function get_image_render_content( $field_value, $tag_class, $tag_id, $alt, $width, $height, $style, $size, $media_sizes ) {
     310        $content     = '';
     311        $image_width = $width;
     312        if ( is_int( $field_value ) ) {
     313            // image set to return Image ID.
     314            $field_value = acfp_get_attachment( $field_value );
     315        }
     316
     317        if ( is_array( $field_value ) ) {
     318            $url = $field_value['url'];
     319            if ( '' === $alt ) {
     320                $alt = $field_value['alt'];
     321            }
     322
     323            $sizes               = $field_value['sizes'];
     324            $sizes               = $this->group_wordpress_image_sizes_with_their_sizes( $sizes );
     325            $srcset              = '';
     326            $srcset_added_widths = array();// init array of added widths to srcset.
     327            foreach ( $sizes as $size_array ) {
     328                $src_url       = $size_array['value'];
     329                $size_from_url = $this->extract_image_size_from_url( $src_url );// size extracted from URL.
     330                $w             = '';
     331                if ( $size_from_url ) {// size from url is given priority.
     332                    $w = $size_from_url['width'] . 'w';
     333                } else {
     334                    $w = $size_array['width_value'] . 'w';
     335                }
     336                if ( ! in_array( array( $src_url => $w ), $srcset_added_widths, true ) ) {
     337                    array_push( $srcset_added_widths, array( $src_url => $w ) );
     338                }
     339            }
     340            $sizes_count = count( $srcset_added_widths );
     341
     342            for ( $i = 0;$i < $sizes_count;$i++ ) {
     343
     344                if ( 0 === $i ) {
     345                    // first item.
     346                    foreach ( $srcset_added_widths[ $i ] as $thumb_url => $width ) {
     347                        $srcset .= $thumb_url . ' ' . $width;
     348                    }
     349                } else {
     350                    foreach ( $srcset_added_widths[ $i ] as $thumb_url => $width ) {
     351                        $srcset .= ', ' . $thumb_url . ' ' . $width;
     352                    }
     353                }
     354            }
     355            $content = '<img
     356            ' . $this->get_tag_class_render_content( $tag_class ) . '
     357            ' . $this->get_tag_id_render_content( $tag_id ) . '
     358            srcset="' . esc_attr( $srcset ) . '"
     359            src="' . esc_url( $url ) . '"
     360            alt="' . esc_attr( $alt ) . '"
     361            ' . $this->get_width_render_content( $image_width ) . '
     362            ' . $this->get_height_render_content( $height ) . '   
     363            ' . $this->get_media_sizes_render_content( $media_sizes ) . '
     364            ' . $this->get_style_render_content( $style ) . '
     365            "/>';
     366        } elseif ( is_string( $field_value ) ) {
     367            $content = '<img
     368            ' . $this->get_tag_class_render_content( $tag_class ) . '
     369            ' . $this->get_tag_id_render_content( $tag_id ) . '
     370            src="' . esc_attr( $field_value ) . '"
     371            alt="' . esc_attr( $alt ) . '"
     372            ' . $this->get_width_render_content( $image_width ) . '
     373            ' . $this->get_height_render_content( $height ) . '
     374            ' . $this->get_style_render_content( $style ) . '/>';
     375        }
     376
     377        return $content;
     378
     379    }
     380
     381    /**
     382     * Gets file html content to be rendered on front end.
     383     *
     384     * @since 1.1.0
     385     *
     386     * @param mixed  $field_value field value.
     387     * @param string $format format.
     388     * @param string $link_text link text.
     389     * @param string $tag_class class.
     390     * @param string $tag_id tag id.
     391     * @param string $style tag style.
     392     * @return string
     393     */
     394    public function get_file_render_content( $field_value, string $format, string $link_text, string $tag_class, string $tag_id, string $style ) {
     395        if ( is_int( $field_value ) ) {
     396            // image set to return Image ID.
     397            $field_value = acfp_get_attachment( $field_value );
     398        }
     399        if ( is_array( $field_value ) ) {
     400            if ( ! $link_text ) {
     401                $link_text = $field_value['filename'];
     402            }
     403            ob_start();
     404            ?>
     405            <div class="acfp-file-container">
     406                <div class="file-icon">
     407                    <img data-name="icon" src="<?php echo esc_url( $field_value['icon'] ); ?>" alt=""/>
     408                </div>
     409                <div class="file-info">
     410                    <p>
     411                        <strong data-name="title"><?php echo esc_html( $field_value['title'] ); ?></strong>
     412                    </p>
     413                    <p>
     414                        <strong><?php esc_html_e( 'File name', 'acfp' ); ?>:</strong>
     415                        <a data-name="filename" href="<?php echo esc_url( $field_value['url'] ); ?>" target="_blank"><?php echo esc_html( $link_text ); ?></a>
     416                    </p>
     417                    <p>
     418                        <strong><?php esc_html_e( 'File size', 'acfp' ); ?>:</strong>
     419                        <span data-name="filesize"><?php echo esc_html( size_format( $field_value['filesize'] ) ); ?></span>
     420                    </p>
     421                </div>
     422            </div>
     423            <?php
     424            $content = ob_get_clean();
     425
     426        } elseif ( is_string( $field_value ) ) {
     427            if ( ! $link_text ) {
     428                $link_text = $field_value;
     429            }
     430            $content = $this->get_link_tag_html( $field_value, $link_text, $tag_class, $tag_id, $style );
     431        }
     432        return $content;
     433
     434    }
     435
     436    /**
     437     * Gets render content for wysiwyg
     438     *
     439     * @param string $field_value field value.
     440     * @return string
     441     */
     442    public function get_wysiwyg_render_content( $field_value ) {
     443        return $field_value;
     444    }
     445
     446    /**
     447     * Returns oembed render content.
     448     *
     449     * @since 1.1.0
     450     *
     451     * @param string $field_value field value.
     452     * @return string
     453     */
     454    public function get_oembed_render_content( $field_value ) {
     455        return $field_value;
     456    }
     457
     458
     459    /**
     460     * Groups returned images urls with their sizes.
     461     *
     462     * @since 1.1.0
     463     *
     464     * @param array $sizes sizes to be grouped.
     465     * @return array
     466     */
     467    public function group_wordpress_image_sizes_with_their_sizes( $sizes ) {
     468        $result = array();
     469        $keys   = array_keys( $sizes );
     470        $count  = count( $keys );
     471
     472        for ( $i = 0; $i < $count; $i += 3 ) {
     473            $key          = $keys[ $i ];
     474            $value        = $sizes[ $key ];
     475            $width_key    = $keys[ $i + 1 ];
     476            $width_value  = $sizes[ $width_key ];
     477            $height_key   = $keys[ $i + 2 ];
     478            $height_value = $sizes[ $height_key ];
     479
     480            $result[] = array(
     481                'key'          => $key,
     482                'value'        => $value,
     483                'width_key'    => $width_key,
     484                'width_value'  => $width_value,
     485                'height_key'   => $height_key,
     486                'height_value' => $height_value,
     487            );
     488        }
     489
     490        return $result;
     491    }
     492
     493
     494    /**
     495     * Extracts image size from url.
     496     *
     497     * @since 1.1.0
     498     *
     499     * @param string $url WordPress image url.
     500     * @return array|false
     501     */
     502    public function extract_image_size_from_url( $url ) {
     503        $parsed_url = wp_parse_url( $url );
     504
     505        // Check if the URL is valid and contains a path.
     506        if ( ! $parsed_url || empty( $parsed_url['path'] ) ) {
     507            return false;
     508        }
     509
     510        // Extract the filename from the path.
     511        $filename = basename( $parsed_url['path'] );
     512
     513        // Use regular expressions to extract the image size.
     514        if ( preg_match( '/-(\d+)x(\d+)\./i', $filename, $matches ) ) {
     515            $width  = $matches[1];
     516            $height = $matches[2];
     517            return array(
     518                'width'  => $width,
     519                'height' => $height,
     520            );
     521        } else {
     522            return false;
     523        }
     524    }
     525
     526    /**
     527     * Function to return media size render content where possible.
     528     *
     529     * @since 1.1.0
     530     *
     531     * @param string $media_sizes media sizes.
     532     * @return string
     533     */
     534    public function get_media_sizes_render_content( string $media_sizes ) {
     535        if ( '' !== $media_sizes && false !== $media_sizes ) {
     536            $media_sizes = 'sizes="' . esc_attr( $media_sizes ) . '" ';
     537        }
     538        return $media_sizes;
     539    }
     540
     541    /**
     542     * Function to return tag id render content where possible.
     543     *
     544     * @since 1.1.0
     545     *
     546     * @param string $tag_id tag id.
     547     * @return string
     548     */
     549    public function get_tag_id_render_content( string $tag_id ) {
     550        if ( '' !== $tag_id && false !== $tag_id ) {
     551            $tag_id = 'id="' . esc_attr( $tag_id ) . '" ';
     552        }
     553        return $tag_id;
     554    }
     555
     556    /**
     557     * Function to return tag class render content where possible.
     558     *
     559     * @since 1.1.0
     560     *
     561     * @param string $tag_class tag class.
     562     * @return string
     563     */
     564    public function get_tag_class_render_content( string $tag_class ) {
     565        if ( '' !== $tag_class && false !== $tag_class ) {
     566            $tag_class = 'class="' . esc_attr( $tag_class ) . '" ';
     567        }
     568        return $tag_class;
     569    }
     570
     571    /**
     572     * Function to return style render content where possible.
     573     *
     574     * @since 1.1.0
     575     *
     576     * @param string $style tag class.
     577     * @return string
     578     */
     579    public function get_style_render_content( string $style ) {
     580        if ( '' !== $style && false !== $style ) {
     581            $style = 'style="' . esc_attr( $style ) . '" ';
     582        }
     583        return $style;
     584    }
     585
     586    /**
     587     * Function to return width render content where possible.
     588     *
     589     * @since 1.1.0
     590     *
     591     * @param string $width tag class.
     592     * @return string
     593     */
     594    public function get_width_render_content( string $width ) {
     595        if ( '' !== $width && false !== $width ) {
     596            $width = 'width="' . esc_attr( $width ) . '" ';
     597        }
     598        return $width;
     599    }
     600
     601    /**
     602     * Function to return height render content where possible.
     603     *
     604     * @since 1.1.0
     605     *
     606     * @param string $height tag class.
     607     * @return string
     608     */
     609    public function get_height_render_content( string $height ) {
     610        if ( '' !== $height && false !== $height ) {
     611            $height = 'height="' . esc_attr( $height ) . '" ';
     612        }
     613        return $height;
     614    }
     615
     616    /**
     617     * Generates link tag html
     618     *
     619     * @since 1.1.0
     620     *
     621     * @param string $field_value Field value.
     622     * @param string $link_text Link text.
     623     * @param string $tag_class class to be added on the tag.
     624     * @param string $tag_id id to be added on the tag.
     625     * @param string $style style to be associated with tag.
     626     * @return string
     627     */
     628    public function get_link_tag_html( string $field_value, string $link_text, string $tag_class, string $tag_id, string $style ) {
     629        return '<a ' . $this->get_tag_class_render_content( $tag_class ) . $this->get_tag_id_render_content( $tag_id ) . $this->get_style_render_content( $style ) . ' href="' . esc_url( $field_value ) . '">' . esc_html( $link_text ) . '</a>';
     630    }
    158631}
     632
  • plus-features-for-advanced-custom-fields/trunk/index.php

    r2928290 r2936193  
    1 <?php // Silence is golden
     1<?php
     2/**
     3 * Silence is golden.
     4 *
     5 * @link              https://profiles.wordpress.org/thewpcatalyst/
     6 * @since             1.0.0
     7 * @package           Acfp
     8 */
  • plus-features-for-advanced-custom-fields/trunk/public/class-acfp-public.php

    r2928290 r2936193  
    11<?php
    2 
    32/**
    43 * The public-facing functionality of the plugin.
     
    4544     *
    4645     * @since    1.0.0
    47      * @param      string    $plugin_name       The name of the plugin.
    48      * @param      string    $version    The version of this plugin.
     46     * @param      string $plugin_name       The name of the plugin.
     47     * @param      string $version    The version of this plugin.
    4948     */
    5049    public function __construct( $plugin_name, $version ) {
    5150
    5251        $this->plugin_name = $plugin_name;
    53         $this->version = $version;
     52        $this->version     = $version;
    5453
    5554    }
  • plus-features-for-advanced-custom-fields/trunk/public/index.php

    r2928290 r2936193  
    1 <?php // Silence is golden
     1<?php
     2/**
     3 * Silence is golden.
     4 *
     5 * @link              https://profiles.wordpress.org/thewpcatalyst/
     6 * @since             1.0.0
     7 * @package           Acfp/public
     8 */
Note: See TracChangeset for help on using the changeset viewer.