Plugin Directory

Changeset 2284355


Ignore:
Timestamp:
04/15/2020 05:36:33 PM (6 years ago)
Author:
emojicom
Message:

Version 1.1

Location:
emojicom
Files:
3 edited
7 copied

Legend:

Unmodified
Added
Removed
  • emojicom/tags/1.1/emojicom.php

    r1925931 r2284355  
    44Description: Easily embed emojicom widgets on your WordPress site.
    55Author: emojicom
    6 Version: 1.0
     6Version: 1.1
    77Author URI: https://emojicom.io
    88*/
     
    1717function emojicom_widget_script () {
    1818  $campaignId = esc_js(get_option('emojicom_campaign_id', ''));
     19  $overrideOptions = get_option('emojicom_override_options', null);
    1920
    2021  if (empty($campaignId)) {
     
    2223  }
    2324
     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
    2432  ?>
    2533    <!-- Start emojicom.io widget -->
    2634    <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; ?>
    2940    };
    3041    </script>
  • emojicom/tags/1.1/readme.txt

    r2224978 r2284355  
    22Tags: feedback, emojis, emojicom
    33Requires at least: 3.0.1
    4 Tested up to: 5.2
     4Tested up to: 5.4
    55Requires PHP: 5.6
    66Stable tag: 1.0.0
     
    5151= 1.0 =
    5252Initial release.
     53
     54= 1.1 =
     55Added override options setting.
  • emojicom/tags/1.1/settings.php

    r1925931 r2284355  
    77}
    88
    9 function emojicom_settings_init(  ) {
     9function 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
     32function emojicom_settings_init () {
     33  $emojicom_main_section_id = 'emojicom_main__section';
     34  $emojicom_advance_section_id = 'emojicom_advance__section';
     35
    1036    register_setting(
    1137    'emojicom',
     
    1743  );
    1844
     45  register_setting(
     46    'emojicom',
     47    'emojicom_override_options',
     48    [
     49      'type' => 'string',
     50      'sanitize_callback' => 'emojicom_sanitize_json'
     51    ]
     52  );
     53
    1954    add_settings_section(
    20         'emojicom_config_section',
     55        $emojicom_main_section_id,
    2156    '',
    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'
    2466    );
    2567
     
    2870        __( 'Campaign Id', 'emojicom' ),
    2971        '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  );
    3383}
    3484
     85function emojicom_campaign_id_render () {
     86  $name = 'emojicom_campaign_id';
     87  $value = get_option('emojicom_campaign_id');
    3588
    36 function emojicom_campaign_id_render () {
    37   $value = get_option('emojicom_campaign_id');
    38 ?>
     89  ?>
    3990    <input
    4091    type="text"
     
    4394    autocapitalize="off"
    4495    spellcheck="false"
    45     name="emojicom_campaign_id"
    4696    style="min-width: 200px"
    4797    class="code"
    48     value="<?php echo $value; ?>"
     98    name="<?php echo esc_attr($name) ?>"
     99    value="<?php echo esc_attr($value) ?>"
    49100  />
    50101  <br />
    51102  <span class="description">
    52103  </span>
    53 <?php
     104  <?php
    54105}
    55106
    56 function emojicom_settings_section_callback () {
    57 ?>
     107function 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
     130function emojicom_main_section_callback () {
     131  ?>
    58132  <p>
    59133    Enter your Campaing Id below to show your widget on your site.
     
    66140    where it should appear <br /> by pasting this short code in your content: <code>[emojicom-inline]</code>
    67141  </p>
    68 <?php
     142  <?php
    69143}
    70144
     145
    71146function emojicom_options_page () {
    72 ?>
     147  ?>
    73148  <style>
    74149    .emojicom-settings h1 {
     
    95170
    96171      <?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
    99186      submit_button();
    100187      ?>
     
    103190
    104191  </div>
    105 <?php
     192  <?php
    106193}
    107194?>
  • emojicom/trunk/emojicom.php

    r1925931 r2284355  
    44Description: Easily embed emojicom widgets on your WordPress site.
    55Author: emojicom
    6 Version: 1.0
     6Version: 1.1
    77Author URI: https://emojicom.io
    88*/
     
    1717function emojicom_widget_script () {
    1818  $campaignId = esc_js(get_option('emojicom_campaign_id', ''));
     19  $overrideOptions = get_option('emojicom_override_options', null);
    1920
    2021  if (empty($campaignId)) {
     
    2223  }
    2324
     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
    2432  ?>
    2533    <!-- Start emojicom.io widget -->
    2634    <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; ?>
    2940    };
    3041    </script>
  • emojicom/trunk/readme.txt

    r2224978 r2284355  
    22Tags: feedback, emojis, emojicom
    33Requires at least: 3.0.1
    4 Tested up to: 5.2
     4Tested up to: 5.4
    55Requires PHP: 5.6
    66Stable tag: 1.0.0
     
    5151= 1.0 =
    5252Initial release.
     53
     54= 1.1 =
     55Added override options setting.
  • emojicom/trunk/settings.php

    r1925931 r2284355  
    77}
    88
    9 function emojicom_settings_init(  ) {
     9function 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
     32function emojicom_settings_init () {
     33  $emojicom_main_section_id = 'emojicom_main__section';
     34  $emojicom_advance_section_id = 'emojicom_advance__section';
     35
    1036    register_setting(
    1137    'emojicom',
     
    1743  );
    1844
     45  register_setting(
     46    'emojicom',
     47    'emojicom_override_options',
     48    [
     49      'type' => 'string',
     50      'sanitize_callback' => 'emojicom_sanitize_json'
     51    ]
     52  );
     53
    1954    add_settings_section(
    20         'emojicom_config_section',
     55        $emojicom_main_section_id,
    2156    '',
    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'
    2466    );
    2567
     
    2870        __( 'Campaign Id', 'emojicom' ),
    2971        '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  );
    3383}
    3484
     85function emojicom_campaign_id_render () {
     86  $name = 'emojicom_campaign_id';
     87  $value = get_option('emojicom_campaign_id');
    3588
    36 function emojicom_campaign_id_render () {
    37   $value = get_option('emojicom_campaign_id');
    38 ?>
     89  ?>
    3990    <input
    4091    type="text"
     
    4394    autocapitalize="off"
    4495    spellcheck="false"
    45     name="emojicom_campaign_id"
    4696    style="min-width: 200px"
    4797    class="code"
    48     value="<?php echo $value; ?>"
     98    name="<?php echo esc_attr($name) ?>"
     99    value="<?php echo esc_attr($value) ?>"
    49100  />
    50101  <br />
    51102  <span class="description">
    52103  </span>
    53 <?php
     104  <?php
    54105}
    55106
    56 function emojicom_settings_section_callback () {
    57 ?>
     107function 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
     130function emojicom_main_section_callback () {
     131  ?>
    58132  <p>
    59133    Enter your Campaing Id below to show your widget on your site.
     
    66140    where it should appear <br /> by pasting this short code in your content: <code>[emojicom-inline]</code>
    67141  </p>
    68 <?php
     142  <?php
    69143}
    70144
     145
    71146function emojicom_options_page () {
    72 ?>
     147  ?>
    73148  <style>
    74149    .emojicom-settings h1 {
     
    95170
    96171      <?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
    99186      submit_button();
    100187      ?>
     
    103190
    104191  </div>
    105 <?php
     192  <?php
    106193}
    107194?>
Note: See TracChangeset for help on using the changeset viewer.