Changeset 3186871
- Timestamp:
- 11/13/2024 02:46:54 AM (17 months ago)
- Location:
- autocomplete-google-address/trunk
- Files:
-
- 3 edited
-
admin_settings.php (modified) (2 diffs)
-
autocomplete-google-address.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
autocomplete-google-address/trunk/admin_settings.php
r3018474 r3186871 1 1 <?php 2 // including meta box2 // Including meta box 3 3 include('metabox/init.php'); 4 4 5 add_action('cmb2_admin_init', 'myprefix_register_theme_options_metabox'); 5 6 6 add_action( 'cmb2_admin_init', 'myprefix_register_theme_options_metabox' ); 7 // Enqueue custom styles for CMB2 fields 8 add_action('admin_enqueue_scripts', 'myprefix_custom_cmb2_styles'); 9 function myprefix_custom_cmb2_styles() { 10 $custom_css = " 11 /* Style the metabox container */ 12 #myprefix_option_metabox .cmb2-wrap { 13 width: 97%; 14 background: #f7f7f7; 15 border: 1px solid #ddd; 16 padding: 20px; 17 border-radius: 8px; 18 box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); 19 } 20 21 /* Style the title */ 22 #myprefix_option_metabox h2.hndle { 23 font-size: 1.5em; 24 color: #333; 25 padding: 0 0 10px; 26 margin: 0; 27 } 28 29 /* Style each field label */ 30 #myprefix_option_metabox .cmb2-metabox .cmb-th label { 31 font-weight: bold; 32 color: #555; 33 } 34 35 /* Style input fields */ 36 #myprefix_option_metabox .cmb2-metabox input[type='text'] { 37 width: 100%; 38 padding: 8px; 39 border-radius: 5px; 40 border: 1px solid #ccc; 41 box-sizing: border-box; 42 } 43 44 /* Style description text */ 45 #myprefix_option_metabox .cmb2-metabox .cmb2-metabox-description { 46 font-style: italic; 47 color: #888; 48 margin-top: 5px; 49 } 50 "; 51 52 wp_add_inline_style('wp-admin', $custom_css); 53 } 54 7 55 /** 8 56 * Hook in and register a metabox to handle a theme options page and adds a menu item. … … 10 58 function myprefix_register_theme_options_metabox() { 11 59 12 /** 13 * Registers options page menu item and form. 14 */ 15 $cmb_options = new_cmb2_box( array( 16 'id' => 'myprefix_option_metabox', 17 'title' => esc_html__( 'Autocomplete', 'myprefix' ), 18 'object_types' => array( 'options-page' ), 60 $cmb_options = new_cmb2_box(array( 61 'id' => 'myprefix_option_metabox', 62 'title' => esc_html__('Autocomplete Settings', 'myprefix'), 63 'object_types' => array('options-page'), 64 'option_key' => 'autocomplete', 65 'icon_url' => 'dashicons-location-alt', 66 'capability' => 'manage_options', 67 'cmb_styles' => false, 68 )); 19 69 20 /* 21 * The following parameters are specific to the options-page box 22 * Several of these parameters are passed along to add_menu_page()/add_submenu_page(). 23 */ 24 'option_key' => 'autocomplete', // The option key and admin menu page slug. 25 'icon_url' => 'dashicons-location-alt', // Menu icon. Only applicable if 'parent_slug' is left empty. 26 // 'menu_title' => esc_html__( 'Options', 'myprefix' ), // Falls back to 'title' (above). 27 // 'parent_slug' => 'themes.php', // Make options page a submenu item of the themes menu. 28 'capability' => 'manage_options', // Cap required to view options-page. 29 // 'position' => 1, // Menu position. Only applicable if 'parent_slug' is left empty. 30 // 'admin_menu_hook' => 'network_admin_menu', // 'network_admin_menu' to add network-level options page. 31 // 'display_cb' => false, // Override the options-page form output (CMB2_Hookup::options_page_output()). 32 // 'save_button' => esc_html__( 'Save Theme Options', 'myprefix' ), // The text for the options-page save button. Defaults to 'Save'. 33 'cmb_styles' => false, 34 ) ); 35 /* 36 * Options fields ids only need 37 * to be unique within this box. 38 * Prefix is not needed. 39 */ 40 $cmb_options->add_field( array( 41 'name' => __( 'Google Place API Key', 'myprefix' ), 42 'desc' => __( 'Type your Google Place Api key here', 'myprefix' ), 43 'id' => 'google_place_api', 44 'type' => 'text', 45 'default' => '', 46 ) ); 70 $cmb_options->add_field(array( 71 'name' => __('Google Place API Key', 'myprefix'), 72 'desc' => __('Enter your Google Place API key here.', 'myprefix'), 73 'id' => 'google_place_api', 74 'type' => 'text', 75 'default' => '', 76 )); 47 77 48 $cmb_options->add_field( array( 49 'name' => __( 'Form ID', 'myprefix' ), 50 'desc' => __( 'Type your Form ID without "#". if you want to add multiple ID just seprate by " , " ', 'myprefix' ), 51 'id' => 'form_id', 52 'type' => 'text', 53 'default' => '', 54 ) ); 55 $cmb_options->add_field( array( 56 'name' => __( 'Autocomplete Pro Features ', 'myprefix' ), 57 'desc' => __( '<ul> 58 <ol>2 Type of Address (Full Address & Smart Address)</ol> 59 <ol>Use in unlimited form</ol> 60 <ol>Work on any form</ol> 61 <ol>single or multiple Country restriction</ol> 62 <ol>Woocommerce location map picker with autocomplete all input</ol> 63 <ol><a href="https://checkout.freemius.com/mode/dialog/plugin/6886/plan/11211/">Go For Pro</a></ol> 78 $cmb_options->add_field(array( 79 'name' => __('Form ID', 'myprefix'), 80 'desc' => __('Enter Form ID(s) without "#". Use commas for multiple IDs.', 'myprefix'), 81 'id' => 'form_id', 82 'type' => 'text', 83 'default' => '', 84 )); 64 85 65 </ul>', 'myprefix' ), 66 'id' => 'ext', 67 'type' => 'title', 68 'default' => '', 69 ) ); 86 $cmb_options->add_field(array( 87 'name' => __('Autocomplete Pro Features', 'myprefix'), 88 'desc' => __( 89 '<div style="border: 1px solid #ddd; padding: 15px; border-radius: 8px; background: #f9f9f9;"> 90 <ul style="margin: 0; padding: 0 20px;"> 91 <li>Full and Smart Address types</li> 92 <li>Unlimited form use</li> 93 <li>Works on any form</li> 94 <li>Country restriction support</li> 95 <li>WooCommerce location map picker</li> 96 </ul> 97 <div style="display: flex; gap: 10px; margin-top: 20px;"> 98 <a href="https://checkout.freemius.com/mode/dialog/plugin/6886/plan/11211/" 99 style="display: inline-block; padding: 10px 20px; font-size: 16px; color: white; background-color: orange; text-decoration: none; border-radius: 5px; transition: background-color 0.3s;"> 100 Go For Pro 101 </a> 102 <a href="https://devsupport.vercel.app/" 103 target="_blank" 104 style="display: inline-block; padding: 10px 20px; font-size: 16px; color: white; background-color: green; text-decoration: none; border-radius: 5px; transition: background-color 0.3s;"> 105 Buy Pro From Developer 106 </a> 107 </div> 108 </div>', 109 'myprefix' 110 ), 111 'id' => 'ext', 112 'type' => 'title', 113 )); 70 114 } 115 71 116 /** 72 117 * Wrapper function around cmb2_get_option 73 * @since 0.1.074 * @param string $key Options array key75 * @param mixed $default Optional default value118 * @since 0.1.0 119 * @param string $key Options array key 120 * @param mixed $default Optional default value 76 121 * @return mixed Option value 77 122 */ 78 function myprefix_get_option( $key = '', $default = false ) { 79 if ( function_exists( 'cmb2_get_option' ) ) { 80 // Use cmb2_get_option as it passes through some key filters. 81 return cmb2_get_option( 'autocomplete', $key, $default ); 82 } 83 // Fallback to get_option if CMB2 is not loaded yet. 84 $opts = get_option( 'autocomplete', $default ); 85 $val = $default; 86 if ( 'all' == $key ) { 87 $val = $opts; 88 } elseif ( is_array( $opts ) && array_key_exists( $key, $opts ) && false !== $opts[ $key ] ) { 89 $val = $opts[ $key ]; 90 } 91 return $val; 123 function myprefix_get_option($key = '', $default = false) { 124 if (function_exists('cmb2_get_option')) { 125 return cmb2_get_option('autocomplete', $key, $default); 126 } 127 $opts = get_option('autocomplete', $default); 128 $val = $default; 129 if ('all' == $key) { 130 $val = $opts; 131 } elseif (is_array($opts) && array_key_exists($key, $opts) && false !== $opts[$key]) { 132 $val = $opts[$key]; 133 } 134 return $val; 92 135 } -
autocomplete-google-address/trunk/autocomplete-google-address.php
r3018474 r3186871 4 4 * Plugin URI: https://www.nishelement.com/google-autocomplete-pro 5 5 * Description: This plugin will help you to add autocomplete google addres features by using google place api 6 * Version: 2.0. 26 * Version: 2.0.3 7 7 * Requires at least: 5.0 8 8 * Tested up to: 5.7 … … 27 27 define( 'AUTOCOMPLET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 28 28 29 // Scripts are including 30 add_action( 'wp_enqueue_scripts', 'autocomplete_google_enqueue_scripts' ); 29 add_action('wp_enqueue_scripts', 'autocomplete_google_enqueue_scripts'); 31 30 function autocomplete_google_enqueue_scripts() { 32 $google_api_key = myprefix_get_option( 'google_place_api' ); 33 wp_enqueue_script('autocomplet-custom',AUTOCOMPLET__PLUGIN_URL.'js/custom.js',array('jquery-core','jquery'),'',true); 34 wp_enqueue_script('google-maps','https://maps.googleapis.com/maps/api/js?key='.(!empty($google_api_key) ? $google_api_key : 'AIzaSyB16sGmIekuGIvYOfNoW9T44377IU2d2Es').'&libraries=places',array('jquery-core','jquery','autocomplet-custom'),'1.0',true); 31 $google_api_key = myprefix_get_option('google_place_api'); 35 32 33 // Enqueue the custom script that depends on Google Maps 34 wp_enqueue_script( 35 'autocomplet-custom', 36 AUTOCOMPLET__PLUGIN_URL . 'src/custom.js', 37 array('jquery-core', 'jquery'), 38 '', 39 true 40 ); 41 42 // Enqueue the Google Maps API script 43 wp_enqueue_script( 44 'google-maps', 45 'https://maps.googleapis.com/maps/api/js?key=' . (!empty($google_api_key) ? $google_api_key : 'AIzaSyB16sGmIekuGIvYOfNoW9T44377IU2d2Es') . '&loading=async&libraries=places', 46 array('jquery-core', 'jquery', 'autocomplet-custom'), 47 '1.0', 48 true 49 ); 50 51 // Add async and defer attributes to the Google Maps script 52 wp_script_add_data('google-maps', 'async', true); 53 wp_script_add_data('google-maps', 'defer', true); 36 54 } 55 37 56 // Putting on wp head 38 57 add_action('wp_head','autocomplet_set_google_autocompletegen'); … … 66 85 67 86 <script> 68 var input _fields = '<?php echo implode(',' , $search_fields);?>';87 var inputFields = '<?php echo implode(',' , $search_fields);?>'; 69 88 </script> 70 89 <?php } 71 90 72 add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), ' add_support_link_wpse_pro7' );91 add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'support_link' ); 73 92 74 function add_support_link_wpse_pro7( $links ) {75 $links[] = '<a href="https://checkout.freemius.com/mode/dialog/plugin/6886/plan/11211/" target="_blank">Go For Pro</a> | <a href="https:// youtu.be/2vVqEOcOvKk?si=WOyROQ6dghAP3hkk" target="_blank">Setup Video</a>';93 function support_link( $links ) { 94 $links[] = '<a href="https://checkout.freemius.com/mode/dialog/plugin/6886/plan/11211/" target="_blank">Go For Pro</a> | <a href="https://devsupport.vercel.app/" target="_blank">Contact Developer</a> | <a href="https://youtu.be/2vVqEOcOvKk?si=WOyROQ6dghAP3hkk" target="_blank">Setup Video</a>'; 76 95 return $links; 77 96 } -
autocomplete-google-address/trunk/readme.txt
r3018474 r3186871 4 4 Tags: Autocomplete,Google Address Autocomplete,Autocomplete Google Address,Address Autocomplete 5 5 Requires at least: 5.0 6 Tested up to: 6. 4.26 Tested up to: 6.7 7 7 Stable tag: trunk 8 8 Requires PHP: 5.4 … … 54 54 55 55 == Upgrade Notice == 56 design upgrade, developer support added, map api consol error solved, typescript added for better readability and code maintenance, tested with lates wordpress 6.7 57 == 2.0.3 == 56 58 simple upgrade 57 59 == 2.0.2 ==
Note: See TracChangeset
for help on using the changeset viewer.