Changeset 2284355
- Timestamp:
- 04/15/2020 05:36:33 PM (6 years ago)
- Location:
- emojicom
- Files:
-
- 3 edited
- 7 copied
-
tags/1.1 (copied) (copied from emojicom/trunk)
-
tags/1.1/emojicom.php (copied) (copied from emojicom/trunk/emojicom.php) (3 diffs)
-
tags/1.1/index.php (copied) (copied from emojicom/trunk/index.php)
-
tags/1.1/oembed.php (copied) (copied from emojicom/trunk/oembed.php)
-
tags/1.1/readme.txt (copied) (copied from emojicom/trunk/readme.txt) (2 diffs)
-
tags/1.1/settings.php (copied) (copied from emojicom/trunk/settings.php) (7 diffs)
-
tags/1.1/shortcodes.php (copied) (copied from emojicom/trunk/shortcodes.php)
-
trunk/emojicom.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/settings.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
emojicom/tags/1.1/emojicom.php
r1925931 r2284355 4 4 Description: Easily embed emojicom widgets on your WordPress site. 5 5 Author: emojicom 6 Version: 1. 06 Version: 1.1 7 7 Author URI: https://emojicom.io 8 8 */ … … 17 17 function emojicom_widget_script () { 18 18 $campaignId = esc_js(get_option('emojicom_campaign_id', '')); 19 $overrideOptions = get_option('emojicom_override_options', null); 19 20 20 21 if (empty($campaignId)) { … … 22 23 } 23 24 25 $overrideOptionsJson = null; 26 27 if (!empty($overrideOptions)) { 28 $overrideOptionsJson = str_replace(array("\n"), " ", $overrideOptions); 29 $overrideOptionsJson = trim(preg_replace("/\s\s+/", " ", $overrideOptionsJson)); 30 } 31 24 32 ?> 25 33 <!-- Start emojicom.io widget --> 26 34 <script> 27 window.EMOJICOM_WIDGET = { 28 campaign: "<?php echo $campaignId; ?>" 35 window.emojicom_widget = { 36 campaign: "<?php echo $campaignId; ?>", 37 <?php if (!empty($overrideOptionsJson)) : ?> 38 overrideOptions: <?php echo $overrideOptionsJson; ?>, 39 <?php endif; ?> 29 40 }; 30 41 </script> -
emojicom/tags/1.1/readme.txt
r2224978 r2284355 2 2 Tags: feedback, emojis, emojicom 3 3 Requires at least: 3.0.1 4 Tested up to: 5. 24 Tested up to: 5.4 5 5 Requires PHP: 5.6 6 6 Stable tag: 1.0.0 … … 51 51 = 1.0 = 52 52 Initial release. 53 54 = 1.1 = 55 Added override options setting. -
emojicom/tags/1.1/settings.php
r1925931 r2284355 7 7 } 8 8 9 function emojicom_settings_init( ) { 9 function emojicom_sanitize_json($input) { 10 $json = json_decode($input, true); 11 if ($json === null) { 12 return ''; 13 } 14 15 if (!is_array($json)) { 16 return ''; 17 } 18 19 if (isset($json[0])) { 20 return ''; 21 } 22 23 $encoded = json_encode($json, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_FORCE_OBJECT); 24 25 if ($encoded === FALSE) { 26 return ''; 27 } 28 29 return $encoded; 30 } 31 32 function emojicom_settings_init () { 33 $emojicom_main_section_id = 'emojicom_main__section'; 34 $emojicom_advance_section_id = 'emojicom_advance__section'; 35 10 36 register_setting( 11 37 'emojicom', … … 17 43 ); 18 44 45 register_setting( 46 'emojicom', 47 'emojicom_override_options', 48 [ 49 'type' => 'string', 50 'sanitize_callback' => 'emojicom_sanitize_json' 51 ] 52 ); 53 19 54 add_settings_section( 20 'emojicom_config_section',55 $emojicom_main_section_id, 21 56 '', 22 'emojicom_settings_section_callback', 23 'emojicom' 57 'emojicom_main_section_callback', 58 'emojicom_main' 59 ); 60 61 add_settings_section( 62 $emojicom_advance_section_id, 63 '', 64 '', 65 'emojicom_advanced' 24 66 ); 25 67 … … 28 70 __( 'Campaign Id', 'emojicom' ), 29 71 'emojicom_campaign_id_render', 30 'emojicom', 31 'emojicom_config_section' 32 ); 72 'emojicom_main', 73 $emojicom_main_section_id 74 ); 75 76 add_settings_field( 77 'emojicom_override_options', 78 __( 'Override options', 'emojicom' ), 79 'emojicom_override_options_render', 80 'emojicom_advanced', 81 $emojicom_advance_section_id 82 ); 33 83 } 34 84 85 function emojicom_campaign_id_render () { 86 $name = 'emojicom_campaign_id'; 87 $value = get_option('emojicom_campaign_id'); 35 88 36 function emojicom_campaign_id_render () { 37 $value = get_option('emojicom_campaign_id'); 38 ?> 89 ?> 39 90 <input 40 91 type="text" … … 43 94 autocapitalize="off" 44 95 spellcheck="false" 45 name="emojicom_campaign_id"46 96 style="min-width: 200px" 47 97 class="code" 48 value="<?php echo $value; ?>" 98 name="<?php echo esc_attr($name) ?>" 99 value="<?php echo esc_attr($value) ?>" 49 100 /> 50 101 <br /> 51 102 <span class="description"> 52 103 </span> 53 <?php104 <?php 54 105 } 55 106 56 function emojicom_settings_section_callback () { 57 ?> 107 function emojicom_override_options_render () { 108 $name = 'emojicom_override_options'; 109 $value = get_option($name); 110 111 ?> 112 <textarea 113 type="text" 114 autocomplete="off" 115 autocorrect="off" 116 autocapitalize="off" 117 spellcheck="false" 118 rows="10" 119 style="min-width: 300px" 120 class="code" 121 name="<?php echo esc_attr($name) ?>" 122 ><?php echo esc_textarea($value) ?></textarea> 123 <br /> 124 <span class="description"> 125 Valid JSON object 126 </span> 127 <?php 128 } 129 130 function emojicom_main_section_callback () { 131 ?> 58 132 <p> 59 133 Enter your Campaing Id below to show your widget on your site. … … 66 140 where it should appear <br /> by pasting this short code in your content: <code>[emojicom-inline]</code> 67 141 </p> 68 <?php142 <?php 69 143 } 70 144 145 71 146 function emojicom_options_page () { 72 ?>147 ?> 73 148 <style> 74 149 .emojicom-settings h1 { … … 95 170 96 171 <?php 97 settings_fields('emojicom'); 98 do_settings_sections('emojicom'); 172 settings_fields('emojicom'); 173 do_settings_sections('emojicom_main'); 174 ?> 175 176 <details> 177 <summary> 178 Advanced options 179 </summary> 180 <?php 181 do_settings_sections('emojicom_advanced'); 182 ?> 183 </details> 184 185 <?php 99 186 submit_button(); 100 187 ?> … … 103 190 104 191 </div> 105 <?php192 <?php 106 193 } 107 194 ?> -
emojicom/trunk/emojicom.php
r1925931 r2284355 4 4 Description: Easily embed emojicom widgets on your WordPress site. 5 5 Author: emojicom 6 Version: 1. 06 Version: 1.1 7 7 Author URI: https://emojicom.io 8 8 */ … … 17 17 function emojicom_widget_script () { 18 18 $campaignId = esc_js(get_option('emojicom_campaign_id', '')); 19 $overrideOptions = get_option('emojicom_override_options', null); 19 20 20 21 if (empty($campaignId)) { … … 22 23 } 23 24 25 $overrideOptionsJson = null; 26 27 if (!empty($overrideOptions)) { 28 $overrideOptionsJson = str_replace(array("\n"), " ", $overrideOptions); 29 $overrideOptionsJson = trim(preg_replace("/\s\s+/", " ", $overrideOptionsJson)); 30 } 31 24 32 ?> 25 33 <!-- Start emojicom.io widget --> 26 34 <script> 27 window.EMOJICOM_WIDGET = { 28 campaign: "<?php echo $campaignId; ?>" 35 window.emojicom_widget = { 36 campaign: "<?php echo $campaignId; ?>", 37 <?php if (!empty($overrideOptionsJson)) : ?> 38 overrideOptions: <?php echo $overrideOptionsJson; ?>, 39 <?php endif; ?> 29 40 }; 30 41 </script> -
emojicom/trunk/readme.txt
r2224978 r2284355 2 2 Tags: feedback, emojis, emojicom 3 3 Requires at least: 3.0.1 4 Tested up to: 5. 24 Tested up to: 5.4 5 5 Requires PHP: 5.6 6 6 Stable tag: 1.0.0 … … 51 51 = 1.0 = 52 52 Initial release. 53 54 = 1.1 = 55 Added override options setting. -
emojicom/trunk/settings.php
r1925931 r2284355 7 7 } 8 8 9 function emojicom_settings_init( ) { 9 function emojicom_sanitize_json($input) { 10 $json = json_decode($input, true); 11 if ($json === null) { 12 return ''; 13 } 14 15 if (!is_array($json)) { 16 return ''; 17 } 18 19 if (isset($json[0])) { 20 return ''; 21 } 22 23 $encoded = json_encode($json, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_FORCE_OBJECT); 24 25 if ($encoded === FALSE) { 26 return ''; 27 } 28 29 return $encoded; 30 } 31 32 function emojicom_settings_init () { 33 $emojicom_main_section_id = 'emojicom_main__section'; 34 $emojicom_advance_section_id = 'emojicom_advance__section'; 35 10 36 register_setting( 11 37 'emojicom', … … 17 43 ); 18 44 45 register_setting( 46 'emojicom', 47 'emojicom_override_options', 48 [ 49 'type' => 'string', 50 'sanitize_callback' => 'emojicom_sanitize_json' 51 ] 52 ); 53 19 54 add_settings_section( 20 'emojicom_config_section',55 $emojicom_main_section_id, 21 56 '', 22 'emojicom_settings_section_callback', 23 'emojicom' 57 'emojicom_main_section_callback', 58 'emojicom_main' 59 ); 60 61 add_settings_section( 62 $emojicom_advance_section_id, 63 '', 64 '', 65 'emojicom_advanced' 24 66 ); 25 67 … … 28 70 __( 'Campaign Id', 'emojicom' ), 29 71 'emojicom_campaign_id_render', 30 'emojicom', 31 'emojicom_config_section' 32 ); 72 'emojicom_main', 73 $emojicom_main_section_id 74 ); 75 76 add_settings_field( 77 'emojicom_override_options', 78 __( 'Override options', 'emojicom' ), 79 'emojicom_override_options_render', 80 'emojicom_advanced', 81 $emojicom_advance_section_id 82 ); 33 83 } 34 84 85 function emojicom_campaign_id_render () { 86 $name = 'emojicom_campaign_id'; 87 $value = get_option('emojicom_campaign_id'); 35 88 36 function emojicom_campaign_id_render () { 37 $value = get_option('emojicom_campaign_id'); 38 ?> 89 ?> 39 90 <input 40 91 type="text" … … 43 94 autocapitalize="off" 44 95 spellcheck="false" 45 name="emojicom_campaign_id"46 96 style="min-width: 200px" 47 97 class="code" 48 value="<?php echo $value; ?>" 98 name="<?php echo esc_attr($name) ?>" 99 value="<?php echo esc_attr($value) ?>" 49 100 /> 50 101 <br /> 51 102 <span class="description"> 52 103 </span> 53 <?php104 <?php 54 105 } 55 106 56 function emojicom_settings_section_callback () { 57 ?> 107 function emojicom_override_options_render () { 108 $name = 'emojicom_override_options'; 109 $value = get_option($name); 110 111 ?> 112 <textarea 113 type="text" 114 autocomplete="off" 115 autocorrect="off" 116 autocapitalize="off" 117 spellcheck="false" 118 rows="10" 119 style="min-width: 300px" 120 class="code" 121 name="<?php echo esc_attr($name) ?>" 122 ><?php echo esc_textarea($value) ?></textarea> 123 <br /> 124 <span class="description"> 125 Valid JSON object 126 </span> 127 <?php 128 } 129 130 function emojicom_main_section_callback () { 131 ?> 58 132 <p> 59 133 Enter your Campaing Id below to show your widget on your site. … … 66 140 where it should appear <br /> by pasting this short code in your content: <code>[emojicom-inline]</code> 67 141 </p> 68 <?php142 <?php 69 143 } 70 144 145 71 146 function emojicom_options_page () { 72 ?>147 ?> 73 148 <style> 74 149 .emojicom-settings h1 { … … 95 170 96 171 <?php 97 settings_fields('emojicom'); 98 do_settings_sections('emojicom'); 172 settings_fields('emojicom'); 173 do_settings_sections('emojicom_main'); 174 ?> 175 176 <details> 177 <summary> 178 Advanced options 179 </summary> 180 <?php 181 do_settings_sections('emojicom_advanced'); 182 ?> 183 </details> 184 185 <?php 99 186 submit_button(); 100 187 ?> … … 103 190 104 191 </div> 105 <?php192 <?php 106 193 } 107 194 ?>
Note: See TracChangeset
for help on using the changeset viewer.