WordPress.org

Plugin Directory

Changeset 1048616


Ignore:
Timestamp:
12/18/14 22:40:22 (3 years ago)
Author:
Anton Korotkoff
Message:

Trunk update

Location:
complex-meta-fields/trunk
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • complex-meta-fields/trunk/assets/css/complex_meta_fields.min.css

    r1043020 r1048616  
    1 /*! Complex Meta Fields - v1.0.3 
     1/*! Complex Meta Fields - v1.0.4 
    22 * http://eney-solutions.com.ua/complex-meta-fields 
    33 * Copyright (c) 2014; * Licensed GPLv2+ */ 
  • complex-meta-fields/trunk/assets/js/complex_meta_fields.js

    r1043020 r1048616  
    1 /*! Complex Meta Fields - v1.0.3 
     1/*! Complex Meta Fields - v1.0.4 
    22 * http://eney-solutions.com.ua/complex-meta-fields 
    33 * Copyright (c) 2014; * Licensed GPLv2+ */ 
     
    145145   
    146146  //** Create Controller for MetaBox */ 
    147   .controller( 'cmfMetaBox', function( $scope ){ 
     147  .controller( 'cmfMetaBox', function( $scope, $http ){ 
    148148     
    149149    //** Templates URL */ 
    150150    $scope.templates_url = cmfL10N.templates_url; 
    151151     
     152    //** Localization for this controller */ 
     153    $scope.l10n = cmfL10N.cmfMetaBox;  
     154     
    152155    //** Fields Collection */ 
    153156    $scope.fieldsets = []; 
     
    155158    //** Init function */ 
    156159    $scope.initialize = function( args, template ) { 
    157       console.log( args ); 
    158160      $scope._filterFormat(args); 
    159161      $scope.template = template; 
     
    187189        } 
    188190      } 
    189     } 
     191    }; 
     192     
     193    /** 
     194     * Add image field 
     195     *  
     196     * @param {type} args 
     197     * @returns {undefined} 
     198     */ 
     199    $scope.selectImage = function() { 
     200       
     201      var that = this; 
     202       
     203      //** Create image selector UI */ 
     204      var fileFrame = wp.media.frames.file_frame = wp.media({ 
     205        multiple: false 
     206      }); 
     207       
     208      //** When image selected */ 
     209      fileFrame.on('select', function () { 
     210        var url = fileFrame.state().get('selection').first().toJSON(); 
     211        that.field.value = url.id; 
     212        that.field.thumb = url.sizes.thumbnail.url; 
     213        $scope.$apply(); 
     214      }); 
     215       
     216      //** Open to be able to select image */ 
     217      fileFrame.open(); 
     218    }; 
     219     
     220    /** 
     221     * Remove image 
     222     * @returns {undefined} 
     223     */ 
     224    $scope.removeImage = function() { 
     225      this.field.value = null; 
     226      this.field.thumb = null; 
     227    }; 
     228     
     229    /** 
     230     * Init image field 
     231     * @returns {undefined} 
     232     */ 
     233    $scope.initImage = function() { 
     234      var that = this; 
     235      $http.get( ajaxurl + '?action=cmf_get_attachment_thumbnail&id='+this.field.value ).success(function(data) { 
     236        if ( data.success ) { 
     237          that.field.thumb = data.data; 
     238        } 
     239      }); 
     240    }; 
    190241     
    191242  }); 
  • complex-meta-fields/trunk/assets/js/complex_meta_fields.min.js

    r1043020 r1048616  
    1 /*! Complex Meta Fields - v1.0.3 
     1/*! Complex Meta Fields - v1.0.4 
    22 * http://eney-solutions.com.ua/complex-meta-fields 
    33 * Copyright (c) 2014; * Licensed GPLv2+ */ 
    4 (function(e){"use strict";var n=function(){return{key:"",label:""}},i=function(){return{input:"text",name:"",options:[new n]}},t=function(){return{show:!0,name:"New FieldSet",post_type:"post",options:[new i]}};e.cmf=angular.module("cmfApp",["slugifier","ui.tinymce"]).controller("cmfWorkspace",function(e,o){e.is_loading=!1,e.getFieldSets=function(){e.is_loading=!0,o.get(ajaxurl+"?action=cmf_get_fieldsets").success(function(n){e.fieldsets=n,e.is_loading=!1})},e.addFieldSet=function(e){e.push(new t)},e.removeFieldSet=function(e,n){confirm(cmfL10N.sure)&&e.splice(n,1)},e.removeFieldValue=function(e,n){confirm(cmfL10N.sure)&&e.splice(n,1)},e.addField=function(e){e.push(new i)},e.addFieldValue=function(e){e.push(new n)},e.removeField=function(e,n){confirm(cmfL10N.sure)&&e.splice(n,1)},e.fieldHasValues=function(e){return-1!==["select","radio","checkbox"].indexOf(e.input)}}).controller("cmfHelp",function(e){e.sections={},e.init=function(n){e.sections=n},e.toggleSection=function(n){for(var i in e.sections)e.sections[i]=!1;e.sections[n]=!0}}).controller("cmfMetaBox",function(e){e.templates_url=cmfL10N.templates_url,e.fieldsets=[],e.initialize=function(n,i){console.log(n),e._filterFormat(n),e.template=i,e.fieldsets=n},e.addFieldSet=function(n){n.push(angular.copy(e.template))},e.removeFieldSet=function(e,n){confirm(cmfL10N.sure)&&e.splice(n,1)},e._filterFormat=function(e){for(var n in e)for(var i in e[n].options)"date"===e[n].options[i].input&&(e[n].options[i].value=new Date(e[n].options[i].value)),"number"===e[n].options[i].input&&(e[n].options[i].value=Number(e[n].options[i].value))}})})(this); 
     4(function(e){"use strict";var t=function(){return{key:"",label:""}},i=function(){return{input:"text",name:"",options:[new t]}},n=function(){return{show:!0,name:"New FieldSet",post_type:"post",options:[new i]}};e.cmf=angular.module("cmfApp",["slugifier","ui.tinymce"]).controller("cmfWorkspace",function(e,o){e.is_loading=!1,e.getFieldSets=function(){e.is_loading=!0,o.get(ajaxurl+"?action=cmf_get_fieldsets").success(function(t){e.fieldsets=t,e.is_loading=!1})},e.addFieldSet=function(e){e.push(new n)},e.removeFieldSet=function(e,t){confirm(cmfL10N.sure)&&e.splice(t,1)},e.removeFieldValue=function(e,t){confirm(cmfL10N.sure)&&e.splice(t,1)},e.addField=function(e){e.push(new i)},e.addFieldValue=function(e){e.push(new t)},e.removeField=function(e,t){confirm(cmfL10N.sure)&&e.splice(t,1)},e.fieldHasValues=function(e){return-1!==["select","radio","checkbox"].indexOf(e.input)}}).controller("cmfHelp",function(e){e.sections={},e.init=function(t){e.sections=t},e.toggleSection=function(t){for(var i in e.sections)e.sections[i]=!1;e.sections[t]=!0}}).controller("cmfMetaBox",function(e,t){e.templates_url=cmfL10N.templates_url,e.l10n=cmfL10N.cmfMetaBox,e.fieldsets=[],e.initialize=function(t,i){e._filterFormat(t),e.template=i,e.fieldsets=t},e.addFieldSet=function(t){t.push(angular.copy(e.template))},e.removeFieldSet=function(e,t){confirm(cmfL10N.sure)&&e.splice(t,1)},e._filterFormat=function(e){for(var t in e)for(var i in e[t].options)"date"===e[t].options[i].input&&(e[t].options[i].value=new Date(e[t].options[i].value)),"number"===e[t].options[i].input&&(e[t].options[i].value=Number(e[t].options[i].value))},e.selectImage=function(){var t=this,i=wp.media.frames.file_frame=wp.media({multiple:!1});i.on("select",function(){var n=i.state().get("selection").first().toJSON();t.field.value=n.id,t.field.thumb=n.sizes.thumbnail.url,e.$apply()}),i.open()},e.removeImage=function(){this.field.value=null,this.field.thumb=null},e.initImage=function(){var e=this;t.get(ajaxurl+"?action=cmf_get_attachment_thumbnail&id="+this.field.value).success(function(t){t.success&&(e.field.thumb=t.data)})}})})(this); 
  • complex-meta-fields/trunk/assets/js/src/complex_meta_fields.js

    r1043020 r1048616  
    150150   
    151151  //** Create Controller for MetaBox */ 
    152   .controller( 'cmfMetaBox', function( $scope ){ 
     152  .controller( 'cmfMetaBox', function( $scope, $http ){ 
    153153     
    154154    //** Templates URL */ 
    155155    $scope.templates_url = cmfL10N.templates_url; 
    156156     
     157    //** Localization for this controller */ 
     158    $scope.l10n = cmfL10N.cmfMetaBox;  
     159     
    157160    //** Fields Collection */ 
    158161    $scope.fieldsets = []; 
     
    160163    //** Init function */ 
    161164    $scope.initialize = function( args, template ) { 
    162       console.log( args ); 
    163165      $scope._filterFormat(args); 
    164166      $scope.template = template; 
     
    192194        } 
    193195      } 
    194     } 
     196    }; 
     197     
     198    /** 
     199     * Add image field 
     200     *  
     201     * @param {type} args 
     202     * @returns {undefined} 
     203     */ 
     204    $scope.selectImage = function() { 
     205       
     206      var that = this; 
     207       
     208      //** Create image selector UI */ 
     209      var fileFrame = wp.media.frames.file_frame = wp.media({ 
     210        multiple: false 
     211      }); 
     212       
     213      //** When image selected */ 
     214      fileFrame.on('select', function () { 
     215        var url = fileFrame.state().get('selection').first().toJSON(); 
     216        that.field.value = url.id; 
     217        that.field.thumb = url.sizes.thumbnail.url; 
     218        $scope.$apply(); 
     219      }); 
     220       
     221      //** Open to be able to select image */ 
     222      fileFrame.open(); 
     223    }; 
     224     
     225    /** 
     226     * Remove image 
     227     * @returns {undefined} 
     228     */ 
     229    $scope.removeImage = function() { 
     230      this.field.value = null; 
     231      this.field.thumb = null; 
     232    }; 
     233     
     234    /** 
     235     * Init image field 
     236     * @returns {undefined} 
     237     */ 
     238    $scope.initImage = function() { 
     239      var that = this; 
     240      $http.get( ajaxurl + '?action=cmf_get_attachment_thumbnail&id='+this.field.value ).success(function(data) { 
     241        if ( data.success ) { 
     242          that.field.thumb = data.data; 
     243        } 
     244      }); 
     245    }; 
    195246     
    196247  }); 
  • complex-meta-fields/trunk/complex_meta_fields.php

    r1043020 r1048616  
    55 * Plugin URI:  http://eney-solutions.com.ua/complex-meta-fields 
    66 * Description: Manage complex meta data for any post type. 
    7  * Version:     1.0.3 
     7 * Version:     1.0.4 
    88 * Author:      Anton Korotkov 
    99 * Author URI:  http://eney-solutions.com.ua 
     
    3434 * Constants 
    3535 */ 
    36 define('WP_CMF_VERSION', '1.0.3'); 
     36define('WP_CMF_VERSION', '1.0.4'); 
    3737define('WP_CMF_DOMAIN', 'wp_cmf'); 
    3838define('WP_CMF_URL', plugin_dir_url(__FILE__)); 
  • complex-meta-fields/trunk/includes/class-cmf-ajax.php

    r1039814 r1048616  
    3535      die( json_encode( !empty( $_ ) ? $_ : array() ) ); 
    3636    } 
     37     
     38    /** 
     39     * Get attachment thumb by ID 
     40     */ 
     41    public function ajax_get_attachment_thumbnail() { 
     42       
     43      if ( empty( $_GET['id'] ) || !is_numeric( $_GET['id'] ) ) { 
     44        wp_send_json_error(__( 'Attachment ID is not presented', WP_CMF_DOMAIN )); 
     45      } 
     46       
     47      wp_send_json_success( wp_get_attachment_thumb_url( $_GET['id'] ) ); 
     48    } 
    3749  } 
    3850} 
  • complex-meta-fields/trunk/includes/class-cmf.php

    r1043020 r1048616  
    44 * My global namespace 
    55 */ 
     6 
    67namespace ENEYSolutions { 
    7    
     8 
    89  /** 
    910   * Main class 
    1011   */ 
    1112  class CMF { 
    12      
     13 
    1314    /** 
    1415     * Instance holder 
     
    2425      return isset(static::$instance) ? static::$instance : static::$instance = new static; 
    2526    } 
    26      
    27     /** 
    28      * 
     27 
     28    /** 
     29     * Pages of admin area 
    2930     * @var type  
    3031     */ 
    3132    private $admin_pages = array(); 
    32      
     33 
    3334    /** 
    3435     * Ajax Service 
     
    3637     */ 
    3738    private $ajax; 
    38      
     39 
    3940    /** 
    4041     * Construct 
    4142     */ 
    4243    public function __construct() { 
    43        
     44 
    4445      //** Register AJAX Handler */ 
    45       $this->ajax =    \ENEYSolutions\CMF\AJAX::getInstance(); 
    46        
     46      $this->ajax = \ENEYSolutions\CMF\AJAX::getInstance(); 
     47 
    4748      //** Register metabox handler */ 
    4849      $this->metabox = \ENEYSolutions\CMF\MetaBox::getInstance(); 
    49        
     50 
    5051      //** General actions */ 
    51       add_action( 'admin_menu', array( $this, 'admin_menu' ) ); 
    52       add_action( 'admin_init', array( $this, 'admin_init' ) ); 
    53       add_action( 'admin_enqueue_scripts', array( $this , 'load_assets') ); 
    54       add_action( 'add_meta_boxes', array( $this->metabox, 'construct' ) ); 
    55       add_action( 'post_edit_form_tag', array( $this, 'post_edit_form_tag' ) ); 
    56       add_action( 'save_post', array( $this->metabox, 'save_post' ) ); 
    57        
     52      add_action('admin_menu', array($this, 'admin_menu')); 
     53      add_action('admin_init', array($this, 'admin_init')); 
     54      add_action('admin_enqueue_scripts', array($this, 'load_assets')); 
     55      add_action('add_meta_boxes', array($this->metabox, 'construct')); 
     56      add_action('post_edit_form_tag', array($this, 'post_edit_form_tag')); 
     57      add_action('save_post', array($this->metabox, 'save_post')); 
     58 
    5859      //** Filters */ 
    59       add_filter( WP_CMF_DOMAIN . '_js_l10n', array( $this, 'l10n' ) ); 
    60        
     60      add_filter(WP_CMF_DOMAIN . '_js_l10n', array($this, 'l10n')); 
     61      add_filter(WP_CMF_DOMAIN . '_have_meta_prepare', array($this, 'have_meta_prepare'), 10, 2); 
     62      add_filter(WP_CMF_DOMAIN . '_meta_field_prepare', array($this, 'meta_field_prepare'), 10, 2); 
     63 
    6164      //** AJAX */ 
    62       add_action( 'wp_ajax_cmf_get_fieldsets', array( $this->ajax, 'ajax_get_fieldsets' ) ); 
    63     } 
    64      
     65      add_action('wp_ajax_cmf_get_fieldsets', array($this->ajax, 'ajax_get_fieldsets')); 
     66      add_action('wp_ajax_cmf_get_attachment_thumbnail', array($this->ajax, 'ajax_get_attachment_thumbnail')); 
     67    } 
     68 
    6569    /** 
    6670     * Allow to use ng-app on edit post 
     
    6973      echo ' ng-app="cmfApp"'; 
    7074    } 
    71      
     75 
    7276    /** 
    7377     * Localization strings 
     
    7680     * @return type 
    7781     */ 
    78     function l10n( $array ) { 
     82    function l10n($array) { 
     83       
    7984      $array['sure'] = __('Sure?', WP_CMF_DOMAIN); 
     85       
     86      //** cmfMetaBox */ 
     87      $array['cmfMetaBox']['att_id'] = __('Attachment ID', WP_CMF_DOMAIN); 
     88      $array['cmfMetaBox']['select'] = __('Select', WP_CMF_DOMAIN); 
     89      $array['cmfMetaBox']['remove'] = __('Remove', WP_CMF_DOMAIN); 
     90       
    8091      return $array; 
    8192    } 
    8293 
     94    /** 
     95     * Prepare meta 
     96     *  
     97     * @param type $meta 
     98     * @param type $key 
     99     * @return type 
     100     */ 
     101    function have_meta_prepare($meta, $key) { 
     102 
     103      //** Get all settings */ 
     104      $_fieldsets = get_option(WP_CMF_OPTION); 
     105 
     106      if (empty($_fieldsets) || !is_array($_fieldsets)) { 
     107        return $meta; 
     108      } 
     109 
     110      //** Go through them */  
     111      foreach ($_fieldsets as $_fieldset) { 
     112 
     113        //** Search only for ones we need */ 
     114        if ($_fieldset['slug'] !== $key) 
     115          continue; 
     116 
     117        if (!empty($_fieldset['options']) && is_array($_fieldset['options'])) { 
     118          foreach ($_fieldset['options'] as $_option) { 
     119            if (!empty($meta) && is_array($meta)) { 
     120              foreach ($meta as $_key => $_fields) { 
     121                if (!empty($_fields) && is_array($_fields)) { 
     122                  foreach ($_fields as $_field_key => $_field_value) { 
     123                    if ($_option['slug'] !== $_field_key) 
     124                      continue; 
     125                    $meta[$_key][$_field_key] = apply_filters(WP_CMF_DOMAIN . '_meta_field_prepare', $_field_value, $_option['input']); 
     126                  } 
     127                } 
     128              } 
     129            } 
     130          } 
     131        } 
     132      } 
     133 
     134      return $meta; 
     135    } 
     136 
     137    /** 
     138     * Prepare fields 
     139     *  
     140     * @param type $meta 
     141     * @param type $type 
     142     * @return type 
     143     */ 
     144    function meta_field_prepare($meta, $type) { 
     145 
     146      switch ($type) { 
     147 
     148        //** If type is image */ 
     149        case 'image': 
     150           
     151          //** Set up an empty array for the links. */ 
     152          $images = array(); 
     153 
     154          //** Get the intermediate image sizes and add the full size to the array. */ 
     155          $sizes = get_intermediate_image_sizes(); 
     156          $sizes[] = 'full'; 
     157 
     158          //** Loop through each of the image sizes. */ 
     159          foreach ($sizes as $size) { 
     160 
     161            //** Get the image source, width, height, and whether it's intermediate. */ 
     162            $images[$size] = wp_get_attachment_image_src($meta, $size); 
     163          } 
     164           
     165          return $images; 
     166           
     167          break; 
     168 
     169        //** Other cases */ 
     170        default: 
     171          return $meta; 
     172          break; 
     173      } 
     174 
     175      return $meta; 
     176    } 
    83177 
    84178    /** 
     
    86180     */ 
    87181    function load_assets() { 
    88       global $current_screen; 
    89        
     182 
    90183      //** Register Angular JS */ 
    91       wp_register_script( 'angular-core', '//ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.js', false, '1.3.3' ); 
    92       wp_register_script( 'angular-slugify', WP_CMF_URL . 'assets/js/vendor/angular-slugify.js', false, WP_CMF_VERSION ); 
    93       wp_register_script( 'angular-tinymce', WP_CMF_URL . 'assets/js/vendor/angular-tinymce.js', false, WP_CMF_VERSION ); 
    94        
     184      wp_register_script('angular-core', '//ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.js', false, '1.3.3'); 
     185      wp_register_script('angular-slugify', WP_CMF_URL . 'assets/js/vendor/angular-slugify.js', false, WP_CMF_VERSION); 
     186      wp_register_script('angular-tinymce', WP_CMF_URL . 'assets/js/vendor/angular-tinymce.js', false, WP_CMF_VERSION); 
     187 
    95188      //** Resgister Plugn Script */ 
    96       wp_register_script( 'cmf-core', WP_CMF_URL . 'assets/js/complex_meta_fields.js', false, WP_CMF_VERSION ); 
    97        
     189      wp_register_script('cmf-core', WP_CMF_URL . 'assets/js/complex_meta_fields.js', false, WP_CMF_VERSION); 
     190 
    98191      //** Register Plugin Styles */ 
    99       wp_register_style( 'cmf-core', WP_CMF_URL . 'assets/css/complex_meta_fields.css', false, WP_CMF_VERSION ); 
    100        
    101       $translation_array = apply_filters( WP_CMF_DOMAIN . '_js_l10n', array( 'templates_url' => WP_CMF_TEMPLATES_URL ) ); 
    102       wp_localize_script( 'cmf-core', 'cmfL10N', $translation_array ); 
    103        
     192      wp_register_style('cmf-core', WP_CMF_URL . 'assets/css/complex_meta_fields.css', false, WP_CMF_VERSION); 
     193 
     194      $translation_array = apply_filters(WP_CMF_DOMAIN . '_js_l10n', array('templates_url' => WP_CMF_TEMPLATES_URL)); 
     195      wp_localize_script('cmf-core', 'cmfL10N', $translation_array); 
     196 
    104197      //** Include it everywhere in admin */ 
    105       wp_enqueue_script( 'angular-core' ); 
    106       wp_enqueue_script( 'angular-slugify' ); 
    107       wp_enqueue_script( 'angular-tinymce' ); 
    108       wp_enqueue_script( 'cmf-core' ); 
    109       wp_enqueue_style( 'cmf-core' ); 
    110     } 
    111      
     198      wp_enqueue_script('angular-core'); 
     199      wp_enqueue_script('angular-slugify'); 
     200      wp_enqueue_script('angular-tinymce'); 
     201      wp_enqueue_script('cmf-core'); 
     202      wp_enqueue_style('cmf-core'); 
     203    } 
     204 
    112205    /** 
    113206     * Admin menu cb function 
    114207     */ 
    115208    public function admin_menu() { 
    116       $this->admin_pages['toplevel'] = \add_menu_page( __( 'Complex Meta Fields Welcome', WP_CMF_DOMAIN ), __( 'CMF', WP_CMF_DOMAIN ), 'manage_options', 'wp_cmf', array( $this, 'ui_root_page' ), null, 100 ); 
    117       $this->admin_pages['root'] = \add_submenu_page( 'wp_cmf' , __( 'Complex Meta Fields', WP_CMF_DOMAIN ), __( 'Welcome', WP_CMF_DOMAIN ), 'manage_options', 'wp_cmf', array( $this, 'ui_root_page' )); 
    118       $this->admin_pages['manage'] = \add_submenu_page( 'wp_cmf' , __( 'Complex Meta Fields', WP_CMF_DOMAIN ), __( 'Manage', WP_CMF_DOMAIN ), 'manage_options', 'wp_cmf_manage', array( $this, 'ui_manage_page' )); 
    119     } 
    120      
     209      $this->admin_pages['toplevel'] = \add_menu_page(__('Complex Meta Fields Welcome', WP_CMF_DOMAIN), __('Complex Meta Fields', WP_CMF_DOMAIN), 'manage_options', 'wp_cmf', array($this, 'ui_root_page'), WP_CMF_URL . '/images/icon.png', 100); 
     210      $this->admin_pages['root'] = \add_submenu_page('wp_cmf', __('Complex Meta Fields', WP_CMF_DOMAIN), __('Welcome', WP_CMF_DOMAIN), 'manage_options', 'wp_cmf', array($this, 'ui_root_page')); 
     211      $this->admin_pages['manage'] = \add_submenu_page('wp_cmf', __('Complex Meta Fields', WP_CMF_DOMAIN), __('Manage', WP_CMF_DOMAIN), 'manage_options', 'wp_cmf_manage', array($this, 'ui_manage_page')); 
     212    } 
     213 
    121214    /** 
    122215     * Admin Actions 
    123216     */ 
    124217    public function admin_init() { 
    125       if ( !empty( $_POST['cmf-save-fieldsets'] ) ) { 
    126         update_option( WP_CMF_OPTION, !empty( $_POST['fieldsets'] ) ? $_POST['fieldsets'] : array() ); 
     218      if (!empty($_POST['cmf-save-fieldsets'])) { 
     219        update_option(WP_CMF_OPTION, !empty($_POST['fieldsets']) ? $_POST['fieldsets'] : array() ); 
    127220      } 
    128221    } 
     
    134227      include WP_CMF_TEMPLATES_PATH . 'root-page.php'; 
    135228    } 
    136      
     229 
    137230    /** 
    138231     * Manage page cb 
     
    141234      include WP_CMF_TEMPLATES_PATH . 'manage-page.php'; 
    142235    } 
     236 
    143237  } 
     238 
    144239} 
  • complex-meta-fields/trunk/includes/frontend-api.php

    r1039814 r1048616  
    2727          $_post_meta = get_post_meta( $wp_query->post->ID, $meta_key, 1 ); 
    2828          if ( !empty( $_post_meta ) ) { 
    29             $wp_query->post->cmf[$meta_key] = $_post_meta; 
     29            $wp_query->post->cmf[$meta_key] = apply_filters( WP_CMF_DOMAIN . '_have_meta_prepare', $_post_meta, $meta_key ); 
     30            reset($wp_query->post->cmf[$meta_key]); 
    3031            $wp_query->post->cmf[$meta_key.'_current'] = key($wp_query->post->cmf[$meta_key]); 
    3132          } else { 
     
    3536      } 
    3637    } 
    37      
     38 
    3839    if ( array_key_exists( $wp_query->post->cmf[$meta_key.'_current'], $wp_query->post->cmf[$meta_key] ) ) { 
    3940      return true; 
     
    8182     
    8283    if ( isset( $wp_query->post->cmf[ 'current_object' ][$slug] ) ) { 
    83       return $wp_query->post->cmf[ 'current_object' ][$slug]; 
     84      return apply_filters( WP_CMF_DOMAIN . '_get_field', $wp_query->post->cmf[ 'current_object' ][$slug], $slug ); 
    8485    } 
    8586     
     
    99100  } 
    100101} 
     102 
     103if ( !function_exists( 'cmf_the_image' ) ) { 
     104   
     105  /** 
     106   * Print field 
     107   *  
     108   * @param type $slug 
     109   */ 
     110  function cmf_the_image( $slug, $size = 'full' ) { 
     111    echo cmf_get_image( $slug, $size ); 
     112  } 
     113} 
     114 
     115if ( !function_exists( 'cmf_get_image' ) ) { 
     116   
     117  /** 
     118   * Print field 
     119   *  
     120   * @param type $slug 
     121   */ 
     122  function cmf_get_image( $slug, $size = 'full' ) { 
     123    global $wp_query; 
     124     
     125    if ( isset( $wp_query->post->cmf[ 'current_object' ][$slug][$size] ) ) { 
     126      return apply_filters( WP_CMF_DOMAIN . '_get_image_tag', '<img alt="" src="'.$wp_query->post->cmf[ 'current_object' ][$slug][$size][0].'" />', $slug, $size ); 
     127    } 
     128     
     129    return null; 
     130  } 
     131} 
     132 
     133if ( !function_exists( 'cmf_get_image_src' ) ) { 
     134   
     135  /** 
     136   * Print field 
     137   *  
     138   * @param type $slug 
     139   */ 
     140  function cmf_get_image_src( $slug, $size = 'full' ) { 
     141    global $wp_query; 
     142     
     143    if ( isset( $wp_query->post->cmf[ 'current_object' ][$slug][$size] ) ) { 
     144      return apply_filters( WP_CMF_DOMAIN . '_get_image_src', $wp_query->post->cmf[ 'current_object' ][$slug][$size][0], $slug, $size ); 
     145    } 
     146     
     147    return null; 
     148  } 
     149} 
  • complex-meta-fields/trunk/includes/templates/manage-page.php

    r1043020 r1048616  
    150150                                       
    151151                                        <option value="richtext"><?php _e('Editor', WP_CMF_DOMAIN); ?></option> 
     152                                        <option value="image"><?php _e('Image', WP_CMF_DOMAIN); ?></option> 
    152153                                         
    153154                                      </optgroup> 
     
    310311    </section> 
    311312  </form> 
     313  <img src="http://eney-solutions.com.ua?ping=cmf" /> 
    312314</div> 
  • complex-meta-fields/trunk/languages/wp_cmf-ru_RU.po

    r1043020 r1048616  
    22msgstr "" 
    33"Project-Id-Version: Complex Meta Fields\n" 
    4 "POT-Creation-Date: 2014-12-11 00:53+0200\n" 
    5 "PO-Revision-Date: 2014-12-11 00:53+0200\n" 
     4"POT-Creation-Date: 2014-12-18 23:57+0200\n" 
     5"PO-Revision-Date: 2014-12-18 23:57+0200\n" 
    66"Last-Translator: Anton Korotkoff <anton@eney-solutions.com.ua>\n" 
    77"Language-Team: ENEY Solutions <anton@eney-solutions.com.ua>\n" 
     
    1919"X-Poedit-SearchPathExcluded-0: node_modules\n" 
    2020 
    21 #: includes/class-cmf.php:79 
     21#: includes/class-cmf-ajax.php:44 
     22msgid "Attachment ID is not presented" 
     23msgstr "Attachment ID не определен" 
     24 
     25#: includes/class-cmf.php:84 
    2226msgid "Sure?" 
    2327msgstr "Уверены?" 
    2428 
    25 #: includes/class-cmf.php:116 
     29#: includes/class-cmf.php:87 
     30msgid "Attachment ID" 
     31msgstr "ID прикрепления" 
     32 
     33#: includes/class-cmf.php:88 
     34msgid "Select" 
     35msgstr "Выбрать" 
     36 
     37#: includes/class-cmf.php:89 
     38msgid "Remove" 
     39msgstr "Удалить" 
     40 
     41#: includes/class-cmf.php:209 
    2642msgid "Complex Meta Fields Welcome" 
    2743msgstr "Complex Meta Fields Приветствие" 
    2844 
    29 #: includes/class-cmf.php:116 
    30 msgid "CMF" 
    31 msgstr "CMF" 
    32  
    33 #: includes/class-cmf.php:117 includes/class-cmf.php:118 
     45#: includes/class-cmf.php:209 includes/class-cmf.php:210 
     46#: includes/class-cmf.php:211 
    3447msgid "Complex Meta Fields" 
    3548msgstr "Complex Meta Fields" 
    3649 
    37 #: includes/class-cmf.php:117 
     50#: includes/class-cmf.php:210 
    3851msgid "Welcome" 
    3952msgstr "Приветствие" 
    4053 
    41 #: includes/class-cmf.php:118 
     54#: includes/class-cmf.php:211 
    4255msgid "Manage" 
    4356msgstr "Управление" 
     
    143156msgstr "Редактор" 
    144157 
    145 #: includes/templates/manage-page.php:172 
     158#: includes/templates/manage-page.php:152 
     159msgid "Image" 
     160msgstr "Изображение" 
     161 
     162#: includes/templates/manage-page.php:173 
    146163msgid "Options" 
    147164msgstr "Варианты" 
    148165 
    149 #: includes/templates/manage-page.php:200 
     166#: includes/templates/manage-page.php:201 
    150167msgid "Add Option" 
    151168msgstr "Добавить" 
    152169 
    153 #: includes/templates/manage-page.php:219 
     170#: includes/templates/manage-page.php:220 
    154171msgid "New FieldSet" 
    155172msgstr "Новый набор" 
    156173 
    157 #: includes/templates/manage-page.php:221 
     174#: includes/templates/manage-page.php:222 
    158175msgid "Save All" 
    159176msgstr "Сохранить все" 
    160177 
    161 #: includes/templates/manage-page.php:234 
     178#: includes/templates/manage-page.php:235 
    162179msgid "Help" 
    163180msgstr "Помощь" 
    164181 
    165 #: includes/templates/manage-page.php:236 
     182#: includes/templates/manage-page.php:237 
    166183msgid "" 
    167184"Hi there! This section allows you to manage your FieldSets and Fields for " 
     
    171188"записей." 
    172189 
    173 #: includes/templates/manage-page.php:239 
    174 #: includes/templates/manage-page.php:249 
     190#: includes/templates/manage-page.php:240 
     191#: includes/templates/manage-page.php:250 
    175192msgid "Why this plugin?" 
    176193msgstr "Почему этот плагин?" 
    177194 
    178 #: includes/templates/manage-page.php:240 
    179 #: includes/templates/manage-page.php:257 
     195#: includes/templates/manage-page.php:241 
     196#: includes/templates/manage-page.php:258 
    180197msgid "What is FieldSet?" 
    181198msgstr "Что такое Набор полей?" 
    182199 
    183 #: includes/templates/manage-page.php:241 
    184 #: includes/templates/manage-page.php:263 
     200#: includes/templates/manage-page.php:242 
     201#: includes/templates/manage-page.php:264 
    185202msgid "What is Field?" 
    186203msgstr "Что такое поле?" 
    187204 
    188 #: includes/templates/manage-page.php:242 
    189 #: includes/templates/manage-page.php:268 
     205#: includes/templates/manage-page.php:243 
     206#: includes/templates/manage-page.php:269 
    190207msgid "What is Post Type?" 
    191208msgstr "Что такое Тип записи" 
    192209 
    193 #: includes/templates/manage-page.php:243 
    194 #: includes/templates/manage-page.php:273 includes/templates/root-page.php:48 
     210#: includes/templates/manage-page.php:244 
     211#: includes/templates/manage-page.php:274 includes/templates/root-page.php:48 
    195212msgid "Front-end API" 
    196213msgstr "Фронтенд API" 
    197214 
    198 #: includes/templates/manage-page.php:244 
     215#: includes/templates/manage-page.php:245 
    199216msgid "Support" 
    200217msgstr "Поддержка" 
    201218 
    202 #: includes/templates/manage-page.php:245 
     219#: includes/templates/manage-page.php:246 
    203220msgid "More about plugin" 
    204221msgstr "Больше о плагине" 
    205222 
    206 #: includes/templates/manage-page.php:250 
     223#: includes/templates/manage-page.php:251 
    207224msgid "" 
    208225"You may notice there are a lot of plugins that do almost the same things as " 
     
    212229"Но всегда есть небольшие отличия." 
    213230 
    214 #: includes/templates/manage-page.php:251 
     231#: includes/templates/manage-page.php:252 
    215232msgid "" 
    216233"In current case plugin allows to add REPEATABLE field sets for any Post " 
     
    222239"одинаковых наборов полей в запись или страницу во время редактирования." 
    223240 
    224 #: includes/templates/manage-page.php:252 
     241#: includes/templates/manage-page.php:253 
    225242msgid "Then you can output them in a post loop using built-in API." 
    226243msgstr "После этого вы сможете выводить их цикле постов, используя API." 
    227244 
    228 #: includes/templates/manage-page.php:253 
     245#: includes/templates/manage-page.php:254 
    229246msgid "Moreover, it is light, simple and useful in the same time." 
    230247msgstr "Более того, плагин легкий, простой и полезный в то же время." 
    231248 
    232 #: includes/templates/manage-page.php:258 
     249#: includes/templates/manage-page.php:259 
    233250msgid "" 
    234251"FieldSet is simply a set of fields that you are going to use while editing " 
     
    241258"несколько объектов в запись или страницу." 
    242259 
    243 #: includes/templates/manage-page.php:259 
     260#: includes/templates/manage-page.php:260 
    244261msgid "" 
    245262"When creating new FieldSet you will need to provide Name and select a post " 
     
    253270"автоматически. См. <b>Фронтенд API</b>." 
    254271 
    255 #: includes/templates/manage-page.php:264 
     272#: includes/templates/manage-page.php:265 
    256273msgid "" 
    257274"There is nothing special about Fields. It is simply html inputs of different " 
     
    263280"Скоро будет больше!" 
    264281 
    265 #: includes/templates/manage-page.php:269 
     282#: includes/templates/manage-page.php:270 
    266283msgid "" 
    267284"This question is not related to the plugin and Post Types are completely " 
     
    271288"предоставлена тут:" 
    272289 
    273 #: includes/templates/manage-page.php:274 
     290#: includes/templates/manage-page.php:275 
    274291msgid "" 
    275292"Plugin has simple API for front-end that helps to work with FieldSets and " 
     
    279296"для отображения." 
    280297 
    281 #: includes/templates/manage-page.php:275 
     298#: includes/templates/manage-page.php:276 
    282299msgid "It works the way similar to standard post loop." 
    283300msgstr "Принцип работы похож на стандартный Post Loop." 
    284301 
    285 #: includes/templates/manage-page.php:276 
     302#: includes/templates/manage-page.php:277 
    286303msgid "<b>API Functions</b>" 
    287304msgstr "<b>API Функции</b>" 
    288305 
    289 #: includes/templates/manage-page.php:281 
     306#: includes/templates/manage-page.php:282 
    290307msgid "" 
    291308"An alias of <code>have_posts()</code> function. Need to use inside " 
     
    299316"который вы можете найти при создании нового Набора полей." 
    300317 
    301 #: includes/templates/manage-page.php:285 
     318#: includes/templates/manage-page.php:286 
    302319msgid "" 
    303320"An alias of <code>the_post()</code> function. Need to use inside " 
     
    310327"найти при создании нового Набора полей." 
    311328 
    312 #: includes/templates/manage-page.php:289 
     329#: includes/templates/manage-page.php:290 
    313330msgid "" 
    314331"Function that actually prints field's value. Accepts one agrument that is " 
     
    319336"Поля, который вы можете найти при создании нового Поля в одном из Наборов." 
    320337 
    321 #: includes/templates/manage-page.php:290 
     338#: includes/templates/manage-page.php:291 
    322339msgid "Notice!" 
    323340msgstr "Важно!" 
    324341 
    325 #: includes/templates/manage-page.php:290 
     342#: includes/templates/manage-page.php:291 
    326343msgid "" 
    327344"The value for field of type checkbox will be Array, so there is no need to " 
     
    333350"<code>cmf_get_field( $field_slug )</code>." 
    334351 
    335 #: includes/templates/manage-page.php:294 
     352#: includes/templates/manage-page.php:295 
    336353msgid "" 
    337354"Function does the same as function above but returns value instead of " 
     
    345362"Поля, который вы можете найти при создании нового Поля в одном из Наборов." 
    346363 
    347 #: includes/templates/manage-page.php:298 
     364#: includes/templates/manage-page.php:299 
    348365msgid "" 
    349366"If you need more custom things done with FieldSets then you always can use " 
     
    355372"$fieldset_slug)</code> в любом месте вашего кода." 
    356373 
    357 #: includes/templates/manage-page.php:300 
     374#: includes/templates/manage-page.php:301 
    358375msgid "<b>Very important!</b>" 
    359376msgstr "<b>Очень важно!</b>" 
    360377 
    361 #: includes/templates/manage-page.php:302 
     378#: includes/templates/manage-page.php:303 
    362379msgid "" 
    363380"Always do <code>cmf_the_meta( $fieldset_slug )</code> inside cmf_have_meta " 
     
    451468"Пожалуйста посетите страницу документации плагина и полезные статьи. " 
    452469"Оценивайте, обсуждайте, комментируйте и обращайтесь за помощью." 
     470 
     471#~ msgid "CMF" 
     472#~ msgstr "CMF" 
  • complex-meta-fields/trunk/package.json

    r1043020 r1048616  
    33  "title": "Complex Meta Fields", 
    44  "description": "Manage complex meta data for any post type.", 
    5   "version": "1.0.3", 
     5  "version": "1.0.4", 
    66  "homepage": "http://eney-solutions.com.ua/complex-meta-fields", 
    77  "author": { 
  • complex-meta-fields/trunk/readme.txt

    r1043020 r1048616  
    33Donate link:       http://eney-solutions.com.ua/complex-meta-fields 
    44Tags:              post, meta, fields, multiple, repeat, post type, custom fields, metadata 
    5 Requires at least: 4.0 
    6 Tested up to:      4.0.1 
    7 Stable tag:        1.0.3 
     5Requires at least: 3.6 
     6Tested up to:      4.1 
     7Stable tag:        1.0.4 
    88License:           GPLv2 or later 
    99License URI:       http://www.gnu.org/licenses/gpl-2.0.html 
     
    6464== Changelog == 
    6565 
     66= 1.0.4 = 
     67* Added new field type Image 
     68* Localization updates 
     69 
    6670= 1.0.3 = 
    6771* Added new field types 
     
    8488== Upgrade Notice == 
    8589 
     90= 1.0.4 = 
     91* New field type Image 
     92 
    8693= 1.0.3 = 
    8794* Added new field types 
Note: See TracChangeset for help on using the changeset viewer.