WordPress.org

Plugin Directory

Changeset 1142388


Ignore:
Timestamp:
04/22/15 17:00:22 (3 years ago)
Author:
jensnilsson
Message:

Added support for ACF4 (v0.0.2)

Location:
advanced-custom-fields-mapbox-geojson-field
Files:
13 added
5 edited

Legend:

Unmodified
Added
Removed
  • advanced-custom-fields-mapbox-geojson-field/trunk/acf-mapbox_geojson-v4.php

    r1141672 r1142388  
    2424        $this->category = __("Basic",'acf'); // Basic, Content, Choice, etc 
    2525        $this->defaults = array( 
    26             // add default here to merge into your field. 
    27             // This makes life easy when creating the field options as you don't need to use any if( isset('') ) logic. eg: 
    28             //'preview_size' => 'thumbnail' 
     26            'mapbox_access_token'   => '', 
     27            'mapbox_map_id'         => '', 
     28            'height'                => 400, 
    2929        ); 
    3030 
     
    3838            'path' => apply_filters('acf/helpers/get_path', __FILE__), 
    3939            'dir' => apply_filters('acf/helpers/get_dir', __FILE__), 
    40             'version' => '0.0.1' 
     40            'version' => '0.0.2' 
    4141        ); 
    4242 
     
    7272<tr class="field_option field_option_<?php echo $this->name; ?>"> 
    7373    <td class="label"> 
    74         <label><?php _e("Preview Size",'acf'); ?></label> 
    75         <p class="description"><?php _e("Thumbnail is advised",'acf'); ?></p> 
     74        <label><?php _e("API access token",'acf'); ?></label> 
     75        <p class="description"><?php _e("You can find it at <a href='https://www.mapbox.com/projects/' target='_blank'>https://www.mapbox.com/projects/</a>",'acf'); ?></p> 
    7676    </td> 
    7777    <td> 
     
    7979 
    8080        do_action('acf/create_field', array( 
    81             'type'      =>  'radio', 
    82             'name'      =>  'fields['.$key.'][preview_size]', 
    83             'value'     =>  $field['preview_size'], 
    84             'layout'    =>  'horizontal', 
    85             'choices'   =>  array( 
    86                 'thumbnail' => __('Thumbnail'), 
    87                 'something_else' => __('Something Else'), 
    88             ) 
     81            'type'      =>  'text', 
     82            'name'      =>  'fields['.$key.'][mapbox_access_token]', 
     83            'value'     =>  $field['mapbox_access_token'], 
     84        )); 
     85 
     86        ?> 
     87    </td> 
     88</tr> 
     89 
     90<tr class="field_option field_option_<?php echo $this->name; ?>"> 
     91    <td class="label"> 
     92        <label><?php _e("Map ID",'acf'); ?></label> 
     93        <p class="description"><?php _e("ID of you map project, you can find it at <a href='https://www.mapbox.com/projects/' target='_blank'>https://www.mapbox.com/projects/</a>",'acf'); ?></p> 
     94    </td> 
     95    <td> 
     96        <?php 
     97 
     98        do_action('acf/create_field', array( 
     99            'type'      =>  'text', 
     100            'name'      =>  'fields['.$key.'][mapbox_map_id]', 
     101            'value'     =>  $field['mapbox_map_id'], 
     102        )); 
     103 
     104        ?> 
     105    </td> 
     106</tr> 
     107 
     108<tr class="field_option field_option_<?php echo $this->name; ?>"> 
     109    <td class="label"> 
     110        <label><?php _e("Height (px)",'acf'); ?></label> 
     111        <p class="description"><?php _e("Height of the map",'acf'); ?></p> 
     112    </td> 
     113    <td> 
     114        <?php 
     115 
     116        do_action('acf/create_field', array( 
     117            'type'      =>  'number', 
     118            'name'      =>  'fields['.$key.'][height]', 
     119            'value'     =>  $field['height'], 
    89120        )); 
    90121 
     
    122153        ?> 
    123154        <div> 
    124  
     155            <input class="mapbox-geojson-field" type="hidden" name="<?php echo esc_attr($field['name']) ?>" value='<?php echo $field['value'] ?>' /> 
     156            <div class="mapbox-geojson-map" data-access-token="<?php echo esc_attr($field['mapbox_access_token']) ?>" data-map-id="<?php echo esc_attr($field['mapbox_map_id']) ?>" style="height:<?php echo $field['height'] ?>px;"></div> 
    125157        </div> 
    126158        <?php 
     
    144176        // Note: This function can be removed if not used 
    145177 
    146  
    147         // register ACF scripts 
    148         wp_register_script( 'acf-input-mapbox_geojson', $this->settings['dir'] . 'js/input.js', array('acf-input'), $this->settings['version'] ); 
    149         wp_register_style( 'acf-input-mapbox_geojson', $this->settings['dir'] . 'css/input.css', array('acf-input'), $this->settings['version'] ); 
    150  
    151  
    152         // scripts 
    153         wp_enqueue_script(array( 
    154             'acf-input-mapbox_geojson', 
    155         )); 
    156  
    157         // styles 
    158         wp_enqueue_style(array( 
    159             'acf-input-mapbox_geojson', 
    160         )); 
    161  
     178        // register & include JS 
     179        wp_register_script( 'acf-input-mapbox_geojson_mapbox_js', 'https://api.tiles.mapbox.com/mapbox.js/v2.1.8/mapbox.js' ); 
     180        wp_enqueue_script( 'acf-input-mapbox_geojson_mapbox_js' ); 
     181 
     182        wp_register_script( 'acf-input-mapbox_geojson_leaflet_draw_js', 'https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-draw/v0.2.2/leaflet.draw.js', array('acf-input-mapbox_geojson_mapbox_js') ); 
     183        wp_enqueue_script( 'acf-input-mapbox_geojson_leaflet_draw_js' ); 
     184 
     185        wp_register_script( 'acf-input-mapbox_geojson', $this->settings['dir'] . "js/input.js", array('acf-input-mapbox_geojson_mapbox_js', 'acf-input-mapbox_geojson_leaflet_draw_js'), $this->settings['version'], true ); 
     186        wp_enqueue_script( 'acf-input-mapbox_geojson' ); 
     187 
     188 
     189        // register & include CSS 
     190        wp_register_style( 'acf-input-mapbox_geojson_mapbox_css', 'https://api.tiles.mapbox.com/mapbox.js/v2.1.8/mapbox.css' ); 
     191        wp_enqueue_style( 'acf-input-mapbox_geojson_mapbox_css' ); 
     192 
     193        wp_register_style( 'acf-input-mapbox_geojson_leaflet_draw_css', 'https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-draw/v0.2.2/leaflet.draw.css' ); 
     194        wp_enqueue_style( 'acf-input-mapbox_geojson_leaflet_draw_css' ); 
    162195 
    163196    } 
  • advanced-custom-fields-mapbox-geojson-field/trunk/acf-mapbox_geojson-v5.php

    r1141672 r1142388  
    186186        wp_enqueue_script( 'acf-input-mapbox_geojson_leaflet_draw_js' ); 
    187187 
    188         wp_register_script( 'acf-input-mapbox_geojson', "{$dir}js/input.js", array('acf-input-mapbox_geojson_mapbox_js', 'acf-input-mapbox_geojson_leaflet_draw_js'), '0.0.1', true ); 
     188        wp_register_script( 'acf-input-mapbox_geojson', "{$dir}js/input.js", array('acf-input-mapbox_geojson_mapbox_js', 'acf-input-mapbox_geojson_leaflet_draw_js'), '0.0.2', true ); 
    189189        wp_enqueue_script( 'acf-input-mapbox_geojson' ); 
    190190 
  • advanced-custom-fields-mapbox-geojson-field/trunk/acf-mapbox_geojson.php

    r1141672 r1142388  
    55Plugin URI: https://github.com/jensjns/acf-mapbox-geojson-field 
    66Description: Adds a map field that lets you edit geoJSON-content. 
    7 Version: 0.0.1 
     7Version: 0.0.2 
    88Author: jensnilsson 
    99Author URI: http://jensnilsson.nu 
  • advanced-custom-fields-mapbox-geojson-field/trunk/js/input.js

    r1141021 r1142388  
    7373        } 
    7474        else { 
     75            // TODO: display an error in mapDOM 
    7576            console.log('mapbox-geojson-err-1'); 
    7677        } 
  • advanced-custom-fields-mapbox-geojson-field/trunk/readme.txt

    r1141672 r1142388  
    1616* Add multiple markers. 
    1717* Draw polylines, polygons and rectangles. 
    18 * Supports ACF5 (Pro) 
     18* Supports ACF4 and ACF5 (Pro) 
    1919 
    2020= Data = 
     
    2929 
    3030This ACF field type is compatible with: 
     31 
    3132* ACF 5 
     33* ACF 4 
    3234 
    3335= GitHub = 
     
    4648== Changelog == 
    4749 
     50= 0.0.2 = 
     51* ACF 4 support 
     52 
    4853= 0.0.1 = 
    4954* Initial Release. 
Note: See TracChangeset for help on using the changeset viewer.