WordPress.org

Plugin Directory

Changeset 1142114


Ignore:
Timestamp:
04/22/15 12:49:14 (3 years ago)
Author:
gyrus
Message:

Version 1.1 release

Location:
developers-custom-fields
Files:
90 added
6 edited

Legend:

Unmodified
Added
Removed
  • developers-custom-fields/trunk/css/slt-cf-admin.css

    r916775 r1142114  
    216216  margin-bottom: .6em; 
    217217} 
     218/* Image previews */ 
     219.slt-fs-preview img { 
     220  max-width: 100%; 
     221  height: auto; 
     222} 
  • developers-custom-fields/trunk/css/slt-cf-admin.less

    r916775 r1142114  
    237237    } 
    238238} 
     239 
     240/* Image previews */ 
     241.slt-fs-preview { 
     242    img { 
     243        max-width: 100%; 
     244        height: auto; 
     245    } 
     246} 
  • developers-custom-fields/trunk/readme.txt

    r1046187 r1142114  
    44Tags: admin, administration, custom, meta, page, pages, post, posts, attachments, custom fields, form, user, profile 
    55Requires at least: 3.5 
    6 Tested up to: 4.1 
    7 Stable tag: 1.0.1 
     6Tested up to: 4.2 
     7Stable tag: 1.1 
    88 
    99Provides developers with powerful and flexible tools for managing post and user custom fields. 
     
    9292 
    9393== Changelog == 
     94= 1.1 = 
     95* Added `slt_cf_file_select_button_enqueue()`, for using file select button outside this plugin 
     96* Added ability to automatically manage query string vars for custom queries, with the `make_query_var` field parameter, and the `dcf_use_query_string` and `dcf_custom_field_query_vars_only` flags for `WP_Query`. Includes integration with Simple Events date field. 
     97* Added `esc_url()` around uses of `add_query_arg()` 
     98* Added management of 'term splitting' for WordPress 4.2 - not activated by default, please read [the release notes](http://sltaylor.co.uk/blog/developers-custom-fields-1-1/) 
     99* Added version-specific update warnings functionality 
     100 
    94101= 1.0.1 = 
    95102* Made plugin translatable 
  • developers-custom-fields/trunk/slt-cf-admin.php

    r1025328 r1142114  
    2828 
    2929} 
     30 
     31add_action( 'in_plugin_update_message-' . SLT_CF_PRIMARY_FILE_PATH, 'slt_cf_upgrade_warnings' ); 
     32/** 
     33 * Check for any plugin update warning notices 
     34 * 
     35 * @since   1.1 
     36 */ 
     37function slt_cf_upgrade_warnings() { 
     38 
     39    // Get the warnings JSON file and the readme from SVN trunk 
     40    $svn_root_url = 'http://plugins.svn.wordpress.org/developers-custom-fields/trunk/'; 
     41    $version_warnings_json = file_get_contents( $svn_root_url . 'slt-cf-version-warnings.json' ); 
     42    $readme = file_get_contents( $svn_root_url . 'readme.txt' ); 
     43    if ( $version_warnings_json && $readme ) { 
     44 
     45        // Parse the current stable tag from readme 
     46        if ( preg_match( '/^Stable tag: ([0-9\.]+)$/m', $readme, $readme_matches ) === 1 ) { 
     47            $stable_version = $readme_matches[1]; 
     48 
     49            // Loop through the warnings 
     50            $current_warnings = array(); 
     51            foreach ( json_decode( $version_warnings_json ) as $warning_version => $warning ) { 
     52 
     53                // Add warning if it's for higher than current version, but lower than or equal to stable release version 
     54                if ( version_compare( $warning_version, SLT_CF_VERSION, '>' ) && version_compare( $warning_version, $stable_version, '<=' ) ) { 
     55 
     56                    // Add the warning 
     57                    $current_warnings[] = '<dt style="color:#d54e21;font-size:1.1em;font-weight:bold">Version '. $warning_version .'</dt><dd style="margin-left: 0;">' . $warning . '</dd>'; 
     58 
     59                } 
     60 
     61            } 
     62 
     63            // Warnings to output? 
     64            if ( $current_warnings ) { 
     65                echo '<dl>' . implode( "\n", $current_warnings ) . '</dl>'; 
     66            } 
     67 
     68        } 
     69 
     70    } 
     71 
     72} 
     73 
    3074 
    3175/* Database tools 
     
    161205} 
    162206 
     207 
     208/** 
     209 * Manage 4.2+ term splitting 
     210 * 
     211 * @since   1.1 
     212 */ 
     213function slt_cf_split_shared_term( $old_term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) { 
     214    global $slt_custom_fields, $slt_custom_fields_all_boxes, $wpdb; 
     215 
     216    // Has this request initialised the fields already? 
     217    // If so, we need to grab the copy made of all the box data 
     218    if ( isset( $slt_custom_fields_all_boxes ) && is_array( $slt_custom_fields_all_boxes ) && count( $slt_custom_fields_all_boxes ) ) { 
     219        $boxes = $slt_custom_fields_all_boxes; 
     220    } else { 
     221        $boxes = $slt_custom_fields['boxes']; 
     222    } 
     223 
     224    // Find fields that use options_type 'terms' 
     225    foreach ( $boxes as $box_key => $box ) { 
     226        foreach ( $box['fields'] as $field_key => $field ) { 
     227            // For multiple checkboxes and select fields which have options_type 'terms', using the same taxonomy 
     228            if ( ( $field['type'] == 'checkboxes' || ( $field['type'] == 'select' && $field['multiple'] ) ) && $field['options_type'] == 'terms' && ( $taxonomy == $field['options_query']['taxonomies'] || ( is_array( $field['options_query']['taxonomies'] ) && in_array( $taxonomy, $field['options_query']['taxonomies'] ) ) ) ) { 
     229 
     230                // Which meta table to look in? 
     231                $meta_table = $box['type'] == 'user' ? 'usermeta' : 'postmeta'; 
     232                $meta_type = $box['type'] == 'user' ? 'user' : 'post'; 
     233                $meta_key = slt_cf_field_key( $field['name'], $box['type'] ); 
     234                $object_id_column = $meta_type . '_id'; 
     235 
     236                // Get all records for this field 
     237                $field_records = $wpdb->get_results(" 
     238                    SELECT      * 
     239                    FROM        " . $wpdb->prefix . $meta_table . " 
     240                    WHERE       meta_key    = '" . $meta_key . "' 
     241                "); 
     242 
     243                // Check if any contain the old term ID 
     244                foreach ( $field_records as $field_record ) { 
     245                    $new_field_value = null; 
     246 
     247                    // Check for a serialise single entry 
     248                    if ( $field['single'] ) { 
     249 
     250                        // Cater for serialized arrays 
     251                        $field_values = maybe_unserialize( $field_record->meta_value ); 
     252                        if ( ! is_array( $field_values ) ) { 
     253                            // Just in case 
     254                            $field_values = (array) $field_values; 
     255                        } 
     256 
     257                        // If there are instance of the old term ID... 
     258                        if ( in_array( $old_term_id, $field_values ) ) { 
     259 
     260                            // Update them 
     261                            foreach ( $field_values as &$field_value ) { 
     262                                if ( $field_value == $old_term_id ) { 
     263                                    $field_value = $new_term_id; 
     264                                } 
     265                            } 
     266 
     267                            // Pass them through to update the DB 
     268                            $new_field_value = $field_values; 
     269 
     270                        } 
     271 
     272                        if ( ! is_null( $new_field_value ) ) { 
     273                            update_metadata( $meta_type, $field_record->{$object_id_column}, $meta_key, $new_field_value ); 
     274                        } 
     275 
     276                    } else { 
     277 
     278                        // Just a single value record, pass through to update the DB 
     279                        if ( $field_record->meta_value == $old_term_id ) { 
     280                            $new_field_value = $new_term_id; 
     281                        } 
     282 
     283                        if ( ! is_null( $new_field_value ) ) { 
     284                            // Multiple fields, need to pass old value to make sure the right entry is replaced 
     285                            update_metadata( $meta_type, $field_record->{$object_id_column}, $meta_key, $new_field_value, $old_term_id ); 
     286                        } 
     287 
     288                    } 
     289 
     290                } 
     291 
     292            } 
     293        } 
     294    } 
     295 
     296} 
  • developers-custom-fields/trunk/slt-cf-init.php

    r1025328 r1142114  
    3131    $gmaps_api_url = SLT_CF_REQUEST_PROTOCOL . 'maps.google.com/maps/api/js'; 
    3232    if ( defined( 'SLT_CF_GMAPS_API_KEY' ) && SLT_CF_GMAPS_API_KEY ) { 
    33         $gmaps_api_url = add_query_arg( 'key', SLT_CF_GMAPS_API_KEY, $gmaps_api_url ); 
     33        $gmaps_api_url = esc_url( add_query_arg( 'key', SLT_CF_GMAPS_API_KEY, $gmaps_api_url ) ); 
    3434    } 
    3535    wp_register_script( 'google-maps-api', $gmaps_api_url, array(), false, true ); 
     
    174174            // If an edit screen, only bother if there are file upload fields 
    175175            if ( SLT_CF_USE_FILE_SELECT && ( ! $edit_screen || $file_upload_fields ) ) { 
    176  
    177                 // Enqueue core API 
    178                 wp_enqueue_media(); 
    179  
    180                 // Localization / custom JS vars 
    181                 $media_localization = array( 
    182                     'ajaxurl'           => admin_url( 'admin-ajax.php', SLT_CF_REQUEST_PROTOCOL ), 
    183                     'button_text'       => __( 'Select', SLT_CF_TEXT_DOMAIN ), 
    184                 ); 
    185                 if ( $edit_screen ) { 
    186  
    187                     // Pass through values for all registered buttons 
    188                     foreach ( $file_upload_fields as $file_upload_field ) { 
    189                         $field_name = slt_cf_prefix( 'post' ) . $file_upload_field['name']; 
    190                         $media_localization['dialog_title__' . $field_name ] = $file_upload_field['file_dialog_title']; 
    191                         $media_localization['restrict_to_type__' . $field_name ] = $file_upload_field['file_restrict_to_type']; 
    192                         $media_localization['attach_to_post__' . $field_name ] = $file_upload_field['file_attach_to_post'] ? 'yes' : 'no'; 
    193                     } 
    194  
    195                 } 
    196                 wp_localize_script( 'slt-cf-media', 'slt_cf_media', $media_localization ); 
    197  
    198                 // Enqueue media script 
    199                 wp_enqueue_script( 'slt-cf-media' ); 
    200  
     176                slt_cf_file_select_button_enqueue( $file_upload_fields ); 
    201177            } 
    202178 
     
    204180 
    205181    } 
     182 
     183} 
     184 
     185/** 
     186 * Helper function to enqueue script for media select button 
     187 * 
     188 * If using the media select button outside this plugin, call this in your 
     189 * admin_enqueue_scripts hook function 
     190 * 
     191 * @since   1.1 
     192 * @param   array   $file_upload_fields 
     193 * @return  void 
     194 */ 
     195function slt_cf_file_select_button_enqueue( $file_upload_fields = array() ) { 
     196 
     197    // Enqueue core API 
     198    wp_enqueue_media(); 
     199 
     200    // Localization / custom JS vars 
     201    $media_localization = array( 
     202        'ajaxurl'           => admin_url( 'admin-ajax.php', SLT_CF_REQUEST_PROTOCOL ), 
     203        'button_text'       => __( 'Select', SLT_CF_TEXT_DOMAIN ), 
     204    ); 
     205    if ( $file_upload_fields ) { 
     206 
     207        // Pass through values for all registered buttons 
     208        foreach ( $file_upload_fields as $file_upload_field ) { 
     209            $field_name = slt_cf_prefix( 'post' ) . $file_upload_field['name']; 
     210            $media_localization['dialog_title__' . $field_name ] = $file_upload_field['file_dialog_title']; 
     211            $media_localization['restrict_to_type__' . $field_name ] = $file_upload_field['file_restrict_to_type']; 
     212            $media_localization['attach_to_post__' . $field_name ] = $file_upload_field['file_attach_to_post'] ? 'yes' : 'no'; 
     213        } 
     214 
     215    } 
     216    wp_localize_script( 'slt-cf-media', 'slt_cf_media', $media_localization ); 
     217 
     218    // Enqueue media script 
     219    wp_enqueue_script( 'slt-cf-media' ); 
    206220 
    207221} 
     
    233247 */ 
    234248function slt_cf_init_fields( $request_type, $scope, $object_id ) { 
    235     global $slt_custom_fields, $wp_roles, $post, $user_id; 
     249    global $slt_custom_fields, $slt_custom_fields_all_boxes, $wp_roles, $post, $user_id; 
     250 
     251    // Store a copy of all boxes before paring down the main boxes var for this request 
     252    // This is mainly so 4.2+ shared term splitting can be managed 
     253    // Only done if requested 
     254    $slt_custom_fields_all_boxes = null; 
     255    if ( defined( 'SLT_CF_HANDLE_TERM_SPLITTING' ) && SLT_CF_HANDLE_TERM_SPLITTING ) { 
     256        $slt_custom_fields_all_boxes = $slt_custom_fields['boxes']; 
     257    } 
    236258 
    237259    // Only run once per request 
     
    388410                'edit_on_profile'           => false, 
    389411                'attachments_list_options'  => array(), 
     412                'make_query_var'            => false, 
    390413            ); 
    391414            // Defaults dependent on request type 
  • developers-custom-fields/trunk/slt-custom-fields.php

    r1025328 r1142114  
    1010Description: Provides theme developers with tools for managing custom fields. 
    1111Author: Steve Taylor 
    12 Version: 1.0.1 
     12Version: 1.1 
    1313Author URI: http://sltaylor.co.uk 
    1414License: GPLv2 
     
    5151define( 'SLT_CF_NO_OPTIONS', __( 'No options to choose from', SLT_CF_TEXT_DOMAIN ) ); 
    5252define( 'SLT_CF_REQUEST_PROTOCOL', isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://' ); 
    53 define( 'SLT_CF_VERSION', '1.0.1' ); 
     53define( 'SLT_CF_VERSION', '1.1' ); 
     54define( 'SLT_CF_PRIMARY_FILE_PATH', plugin_basename( __FILE__ ) ); 
    5455$slt_custom_fields = array(); 
    5556$slt_custom_fields['prefix'] = '_slt_'; 
     
    5960$slt_custom_fields['timepicker_default_ampm'] = false; 
    6061$slt_custom_fields['boxes'] = array(); 
     62$slt_custom_fields['query_vars'] = array(); 
    6163 
    6264// Constants that can be overridden in wp-config.php 
    63 if ( ! defined( 'SLT_CF_USE_GMAPS' ) ) 
     65if ( ! defined( 'SLT_CF_USE_GMAPS' ) ) { 
    6466    define( 'SLT_CF_USE_GMAPS', true ); 
    65 if ( ! defined( 'SLT_CF_USE_FILE_SELECT' ) ) 
     67} 
     68if ( ! defined( 'SLT_CF_USE_FILE_SELECT' ) ) { 
    6669    define( 'SLT_CF_USE_FILE_SELECT', true ); 
     70} 
     71if ( ! defined( 'SLT_CF_HANDLE_TERM_SPLITTING' ) ) { 
     72    define( 'SLT_CF_HANDLE_TERM_SPLITTING', false ); 
     73} 
     74 
    6775 
    6876/* Options stored in database 
     
    110118} 
    111119 
     120 
    112121/* Initialize 
    113122***************************************************************************************/ 
     
    123132    add_action( 'admin_menu', 'slt_cf_admin_menus' ); 
    124133    add_action( 'admin_notices', 'slt_cf_admin_notices' ); 
     134    if ( defined( 'SLT_CF_HANDLE_TERM_SPLITTING' ) && SLT_CF_HANDLE_TERM_SPLITTING ) { 
     135        add_action( 'split_shared_term', 'slt_cf_split_shared_term', 10, 4 ); 
     136    } 
    125137 
    126138    // Login / register styles 
     
    234246require_once( 'slt-cf-init.php' ); 
    235247require_once( 'slt-cf-lib.php' ); 
    236  
     248require_once( 'slt-cf-query-vars.php' ); 
Note: See TracChangeset for help on using the changeset viewer.