Changeset 2852999
- Timestamp:
- 01/23/2023 03:58:19 PM (3 years ago)
- Location:
- acf-yandex-maps-field
- Files:
-
- 2 added
- 1 deleted
- 7 edited
-
assets/Screenshot_1.png (added)
-
assets/screenshot-1.png (deleted)
-
assets/screenshot-2.png (modified) (previous)
-
assets/screenshot-3.png (modified) (previous)
-
assets/screenshot-4.png (modified) (previous)
-
assets/screenshot-5.png (added)
-
trunk/acf-yandex-map-fields.php (modified) (2 diffs)
-
trunk/fields/class-acf-yandex-map-v4.php (modified) (2 diffs)
-
trunk/fields/class-acf-yandex-map-v5.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
acf-yandex-maps-field/trunk/acf-yandex-map-fields.php
r2832537 r2852999 39 39 add_action( 'acf/include_field_types', [$this, 'include_field'] ); 40 40 add_action( 'acf/register_fields', [$this, 'include_field'] ); 41 // settings page 42 add_action( 'admin_init', [$this, 'ymf_settings_init'] ); 43 add_action( 'admin_menu', [$this, 'options_page'] ); 44 41 45 } 42 46 … … 56 60 } 57 61 62 function ymf_settings_init() { 63 64 // Register a new setting for "ymf" page. 65 register_setting( 'acf-yandex-map', 'ymf_options' ); 66 67 // Register a new section in the "ymf" page. 68 add_settings_section( 69 'ymf_section_developers', 70 '', [$this, 'section_developers_callback'], 71 'acf-yandex-map' 72 ); 73 // Register a new field in the "ymf_section_developers" section, inside the "ymf" page. 74 add_settings_field( 75 'ymf_field_api_key', // As of WP 4.6 this value is used only internally. 76 // Use $args' label_for to populate the id inside the callback. 77 __( 'Yandex api key', 'acf-yandex-map' ), 78 [$this, 'field_api_key'], 79 'acf-yandex-map', 80 'ymf_section_developers', 81 [ 82 'label_for' => 'ymf_field_api_key', 83 'class' => 'ymf_row', 84 'ymf_custom_data' => 'custom', 85 ] 86 ); 87 } 88 89 function section_developers_callback( $args ) { 90 91 } 92 93 function field_api_key( $args ) { 94 95 // Get the value of the setting we've registered with register_setting() 96 $options = get_option( 'ymf_options' ); 97 ?> 98 <input type="text" 99 id="<?php echo esc_attr( $args['label_for'] ); ?>" 100 data-custom="<?php echo esc_attr( $args['ymf_custom_data'] ); ?>" 101 name="ymf_options[<?php echo esc_attr( $args['label_for'] ); ?>]" 102 value="<?php echo isset( $options[ $args['label_for'] ] ) ? $options[ $args['label_for'] ] : null; ?>"> 103 104 <?php 105 } 106 107 function options_page() { 108 109 add_submenu_page( 110 'options-general.php', 111 'ACF Yandex Map Settings', 112 'ACF Yandex Map Settings', 113 'manage_options', 114 'acf-yandex-map', 115 [$this, 'options_page_html'] 116 ); 117 } 118 119 function options_page_html() { 120 121 // check user capabilities 122 if ( ! current_user_can( 'manage_options' ) ) { 123 return; 124 } 125 126 // add error/update messages 127 128 // check if the user have submitted the settings 129 // WordPress will add the "settings-updated" $_GET parameter to the url 130 // if ( isset( $_GET['settings-updated'] ) ) { 131 // // add settings saved message with the class of "updated" 132 // add_settings_error( 'ymf_messages', 'ymf_message', __( 'Settings Saved', 'acf-yandex-map' ), 'updated' ); 133 // } 134 135 // show error/update messages 136 settings_errors( 'ymf_messages' ); 137 ?> 138 <div class="wrap"> 139 <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> 140 <form action="options.php" method="post"> 141 <?php 142 // output security fields for the registered setting "ymf" 143 settings_fields( 'acf-yandex-map' ); 144 // output setting sections and their fields 145 // (sections are registered for "ymf", each field is registered to a specific section) 146 do_settings_sections( 'acf-yandex-map' ); 147 // output save settings button 148 submit_button( 'Save Settings' ); 149 ?> 150 </form> 151 </div> 152 <?php 153 } 154 58 155 } 59 156 -
acf-yandex-maps-field/trunk/fields/class-acf-yandex-map-v4.php
r2832537 r2852999 53 53 $url = $this->settings['url']; 54 54 $version = $this->settings['version']; 55 wp_register_script( 'yandex-map-api', '//api-maps.yandex.ru/2.1/?lang=' . get_bloginfo( 'language' ), ['jquery'], $version ); 55 $options = get_option('ymf_options'); 56 $api_key = $options['ymf_field_api_key'] ?? ''; 57 wp_register_script( 'yandex-map-api', '//api-maps.yandex.com/2.1/?lang=' . get_bloginfo( 'language' ) .'&apikey=' . $api_key, ['jquery'], $version ); 56 58 wp_register_script( 'yandex-map-frontend', "{$url}js/acf-yandex-map-frontend.js", ['yandex-map-api'], 'acf-yandex-map' ); 57 59 wp_enqueue_script( 'yandex-map-frontend' ); … … 287 289 $url = $this->settings['url']; 288 290 $version = $this->settings['version']; 289 290 wp_register_script( 'yandex-map-api', '//api-maps.yandex.ru/2.1/?lang=' . get_bloginfo( 'language' ), ['jquery'], $version ); 291 $options = get_option('ymf_options'); 292 $api_key = $options['ymf_field_api_key'] ?? ''; 293 wp_register_script( 'yandex-map-api', '//api-maps.yandex.com/2.1/?lang=' . get_bloginfo( 'language' ) .'&apikey=' . $api_key, ['jquery'], $version ); 291 294 wp_register_script( 'acf-yandex', "{$url}js/acf-yandex-map-admin.js", ['yandex-map-api'], $version, true ); 292 295 -
acf-yandex-maps-field/trunk/fields/class-acf-yandex-map-v5.php
r2832537 r2852999 50 50 $url = $this->settings['url']; 51 51 $version = $this->settings['version']; 52 wp_register_script( 'yandex-map-api', '//api-maps.yandex.ru/2.1/?lang=' . get_bloginfo( 'language' ), ['jquery'], $version ); 52 $options = get_option('ymf_options'); 53 $api_key = $options['ymf_field_api_key'] ?? ''; 54 wp_register_script( 'yandex-map-api', '//api-maps.yandex.com/2.1/?lang=' . get_bloginfo( 'language' ) .'&apikey=' . $api_key, ['jquery'], $version ); 53 55 wp_register_script( 'yandex-map-frontend', "{$url}js/acf-yandex-map-frontend.js", ['yandex-map-api'], 'acf-yandex-map' ); 54 56 wp_enqueue_script( 'yandex-map-frontend' ); … … 197 199 $url = $this->settings['url']; 198 200 $version = $this->settings['version']; 199 200 wp_register_script( 'yandex-map-api', '//api-maps.yandex.ru/2.1/?lang=' . get_bloginfo( 'language' ), ['jquery'], $version ); 201 $options = get_option('ymf_options'); 202 $api_key = $options['ymf_field_api_key'] ?? ''; 203 wp_register_script( 'yandex-map-api', '//api-maps.yandex.com/2.1/?lang=' . get_bloginfo( 'language' ) .'&apikey=' . $api_key, ['jquery'], $version ); 201 204 wp_register_script( 'acf-yandex', "{$url}js/acf-yandex-map-admin.js", ['yandex-map-api'], $version, true ); 202 205 -
acf-yandex-maps-field/trunk/readme.txt
r2833168 r2852999 36 36 == Screenshots == 37 37 38 1. Select field type 39 2. Field configuration 40 3. Example of the new field in action 41 4. Output on the frontend 38 1. Add Api key 39 2. Select field type 40 3. Field configuration 41 4. Example of the new field in action 42 5. Output on the frontend 42 43 43 44 == Changelog ==
Note: See TracChangeset
for help on using the changeset viewer.