Plugin Directory

Changeset 2572050


Ignore:
Timestamp:
07/26/2021 05:55:03 AM (5 years ago)
Author:
eyeone
Message:

Redesign settings page and plugin options, 5.8 WordPress compability check.

Location:
eyeone/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • eyeone/trunk/README.txt

    r2554919 r2572050  
    33Tags: eyeone, eye one, videocalls, videocall, video, call, schedule, schedulling
    44Requires at least: 4.6
    5 Tested up to: 5.6
    6 Stable tag: 1.0.0
     5Tested up to: 5.8
     6Stable tag: 1.1.0
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    7777= 1.0.0 =
    7878* Update settings page
     79
     80= 1.1.0 =
     81* Redesign settings page and plugin options, 5.8 WordPress compability check.
  • eyeone/trunk/admin/class-eyeone-admin.php

    r2554919 r2572050  
    7171        if (array_key_exists('eyeone_widget_id', $_POST)) {
    7272            $eyeOneWidgetId = preg_replace('/[^0-9]/', '', $_POST['eyeone_widget_id']);
    73             if (preg_match('/[0-9]+/', $eyeOneWidgetId) &&  $eyeOneWidgetId > 0) {
     73            if (preg_match('/[0-9]+/', $eyeOneWidgetId) && $eyeOneWidgetId > 0) {
    7474                update_post_meta(
    7575                    $postId,
     
    8989    }
    9090
    91     function getWidgetList()
    92     {
    93         $apikey = get_option('eyeone_api_key');
    94         if (!is_null($apikey) && preg_match('/[a-zA-Z0-9-]+/', $apikey)) {
    95             $response = wp_remote_get('https://app.eye.one/api/v2/public/widgets/' . $apikey);
    96             $body     = wp_remote_retrieve_body($response);
    97             if ($body) {
    98                 $widgets = json_decode($body, true);
    99                 return $widgets;
    100             }
    101         }
    102         return [];
    103     }
    104 
    10591    function createWidgetSelect($post)
    10692    {
    10793        $selectedWidget = get_post_meta($post->ID, '_eyeone_widget_meta_key', true);
    108 ?>
     94        ?>
    10995        <div class="ey-setting-desc"><?php esc_html_e("Select one of your widgets to show it at this page.", 'eyeone'); ?></div>
    11096        <?php
     
    116102        }
    117103        ?>
    118         <div class="ey-setting"> <label for="eyeone_widget_id"><?php esc_html_e(($selectedWidget ? 'Selected widget:' : 'Choose a widget:'), 'eyeone'); ?></label>
     104        <div class="ey-setting">
     105            <label for="eyeone_widget_id"
     106                   class="ey-widget-select-label"><?php esc_html_e(($selectedWidget ? 'Selected widget:' : 'Choose a widget:'), 'eyeone'); ?></label>
    119107            <select name="eyeone_widget_id" id="eyeone_widget_id" class="ey-widget-select">
    120108                <option value=""><?php esc_html_e("No widget", 'eyeone'); ?></option>
     
    123111                foreach ($widgets as $widget) {
    124112                    if ($widget["id"] == $selectedWidget) {
    125                         echo '<option value="' .  esc_attr($widget["id"]) . '" selected>' .  esc_attr($widget["name"]) . ' - (type: ' . esc_attr($widget["type"]) . ')</option>';
     113                        echo '<option value="' . esc_attr($widget["id"]) . '" selected>' . esc_attr($widget["name"]) . ' - (type: ' . esc_attr($widget["type"]) . ')</option>';
    126114                    } else {
    127                         echo '<option value="' .  esc_attr($widget["id"]) . '">' .  esc_attr($widget["name"]) . ' - (type: ' . esc_attr($widget["type"]) . ')</option>';
     115                        echo '<option value="' . esc_attr($widget["id"]) . '">' . esc_attr($widget["name"]) . ' - (type: ' . esc_attr($widget["type"]) . ')</option>';
    128116                    }
    129117                }
     
    132120        </div>
    133121
    134 <?php
     122        <?php
     123    }
     124
     125    function getWidgetList()
     126    {
     127        $apikey = get_option('eyeone_api_key');
     128        if (!is_null($apikey) && preg_match('/[a-zA-Z0-9-]+/', $apikey)) {
     129            $response = wp_remote_get('https://app.eye.one/api/v2/public/widgets/' . $apikey);
     130            $body = wp_remote_retrieve_body($response);
     131            if ($body) {
     132                $widgets = json_decode($body, true);
     133                return $widgets;
     134            }
     135        }
     136        return [];
    135137    }
    136138
     
    142144            array($this, 'createWidgetSelect'),
    143145            'post',
    144             'normal',
     146            'side',
    145147            'high'
    146148        );
     
    151153            array($this, 'createWidgetSelect'),
    152154            'page',
    153             'normal',
     155            'side',
    154156            'high'
    155157        );
     
    191193            'eyeone_general_section',
    192194            array(
    193                 'type'      => 'input',
    194                 'subtype'   => 'text',
    195                 'id'    => 'eyeone_api_key',
    196                 'name'      => 'eyeone_api_key',
     195                'type' => 'input',
     196                'subtype' => 'text',
     197                'id' => 'eyeone_api_key',
     198                'name' => 'eyeone_api_key',
    197199                'required' => 'true',
    198200                'get_options_list' => '',
     
    222224        foreach ($allTypes as $page) {
    223225            $widgetId = get_post_meta($page->ID, '_eyeone_widget_meta_key', true);
    224             $widgetName =  $this->getWidgetName($widgetId, $widgets);
     226            $widgetName = $this->getWidgetName($widgetId, $widgets);
    225227            if ($widgetId) {
    226228                add_settings_field(
    227229                    'eyeone_page_widget_status_' . $page->ID,
    228                     $page->post_title . ($widgetName ? '<br/> (' . $widgetName . ')' : ''),
     230                    $page->post_title . ' <a href="' . get_edit_post_link($page->ID) . '">(#' . $page->ID . ')</a>' . ($widgetName ? '<br/><small> (' . $widgetName . ')' : '</small>'),
    229231                    array($this, 'eyeone_render_settings_field'),
    230232                    'eyeone_general_settings',
    231233                    'eyeone_widgets_section',
    232234                    array(
    233                         'type'      => 'input',
    234                         'subtype'   => 'list',
    235                         'id'    => 'eyeone_page_widget_status_' . $page->ID,
    236                         'name'      => 'eyeone_page_widget_status_' . $page->ID,
     235                        'type' => 'input',
     236                        'subtype' => 'list',
     237                        'id' => 'eyeone_page_widget_status_' . $page->ID,
     238                        'name' => 'eyeone_page_widget_status_' . $page->ID,
    237239                        'required' => 'true',
    238                         'disabled' =>  $widgetName ? false : true,
     240                        'disabled' => $widgetName ? false : true,
    239241                        'get_options_list' => '',
    240242                        'value_type' => 'normal',
     
    248250                    array($this, 'sanitizeEyeOneWidgetStatus')
    249251                );
    250             };
    251         }
    252     }
     252            }
     253        }
     254    }
     255
    253256    public function getWidgetName($widgetId, $widgets)
    254257    {
     
    260263        return null;
    261264    }
     265
    262266    public function eyeone_display_general_info()
    263267    {
    264268        _e('In order to have widgets working properly you need an Eye One API key and an active account.', 'eyeone');
    265269    }
     270
    266271    public function eyeone_display_widgetlist_info()
    267272    {
    268273        _e('Here you can check all pages that have widget setup and you can turn it off here if you want it temporarily disabled.', 'eyeone');
    269274    }
     275
    270276    public function eyeone_render_settings_field($args)
    271277    {
  • eyeone/trunk/admin/css/eyeone-admin.css

    r2554919 r2572050  
    11#ey-admin .page-title {
    2   background: url("../img/eyeone-logo-black.svg") no-repeat left center;
    3   background-size: 32px;
    4   padding-left: 42px;
    5   line-height: 32px;
    6   margin-bottom: 20px;
     2    background: url("../img/eyeone-logo-black.svg") no-repeat left center;
     3    background-size: 32px;
     4    padding-left: 42px;
     5    line-height: 32px;
     6    margin-bottom: 20px;
    77}
    88
    99.ey-logo {
    10   background: url("../img/eyeone-logo-black.svg") no-repeat left center;
    11   padding-left: 42px;
    12   height: 32px;
    13   margin-top: 32px;
    14   margin-bottom: 20px;
     10    background: url("../img/eyeone-logo-black.svg") no-repeat left center;
     11    padding-left: 42px;
     12    height: 32px;
     13    margin-bottom: 20px;
     14}
     15
     16.ey-widget-select-label {
     17    display: inline-block;
     18    margin-bottom: 8px;
    1519}
    1620
    1721.ey-widget-select {
    18   margin-left: 16px;
    19   vertical-align: baseline;
     22    vertical-align: baseline;
     23    width: 100%;
     24    box-sizing: border-box;
    2025}
    2126
    2227.ey-setting {
    23   margin-top: 16px;
     28    margin-top: 16px;
    2429}
    2530
    2631.ey-setting-desc {
    27   margin-top: 16px;
     32    margin-top: 16px;
    2833}
    2934
    3035.ey-widget-list-element {
    31   text-transform: capitalize;
     36    text-transform: capitalize;
    3237}
    3338
    3439.ey-setting {
    35   margin-top: 16px;
     40    margin-top: 16px;
    3641}
    3742
    3843.ey-link {
    39   text-decoration: none;
     44    text-decoration: none;
    4045}
    4146
    4247.ey-button {
    43   background-color: black;
    44   min-width: 130px;
    45   height: 46px;
    46   font-size: 16px;
    47   font-weight: 500;
    48   text-align: center;
    49   border-radius: 6px;
    50   color: #fff;
    51   display: flex;
    52   align-items: center;
    53   justify-content: center;
    54   width: 180px;
    55   margin-right: 16px;
    56   text-decoration: none;
     48    background-color: black;
     49    min-width: 130px;
     50    height: 46px;
     51    font-size: 16px;
     52    font-weight: 500;
     53    text-align: center;
     54    border-radius: 6px;
     55    color: #fff;
     56    display: flex;
     57    align-items: center;
     58    justify-content: center;
     59    width: 180px;
     60    margin-right: 16px;
     61    text-decoration: none;
    5762}
    5863
    5964.ey-buttons {
    60   display: flex;
    61   margin-top: 32px;
     65    display: flex;
     66    margin-top: 12px;
    6267}
     68
     69.ey-metabox .inside {
     70    padding-bottom: 20px;
     71    padding-left: 20px;
     72}
     73
     74.ey-metabox h2 {
     75    font-size: 16px !important;
     76    font-weight: 600 !important;
     77}
     78
     79.ey-metabox ul {
     80    margin-bottom: 0;
     81}
     82
     83.ey-metabox ul li {
     84    border-bottom: solid 1px #DCDCDE;
     85    padding: 10px 0;
     86    margin: 0;
     87}
     88
     89.ey-metabox ul li:last-child {
     90    border-bottom: none;
     91}
  • eyeone/trunk/admin/js/eyeone-admin.js

    r2554919 r2572050  
    33    //Currently nothing to do here.
    44})( jQuery );
     5
     6
  • eyeone/trunk/admin/partials/eyeone-admin-settings-display.php

    r2554919 r2572050  
    11<div id="ey-admin">
    2     <div class="ey-logo"></div>
    3     <div><?php esc_html_e("Eye One widget plugin let's your visitors easily schedule an Eye One appointment with you as well as instantly make a videocall request.", 'eyeone'); ?></div>
    4     <div>
    5         <div class="ey-buttons">
    6             <a class="ey-link" href="https://app.eye.one/">
    7                 <div class="ey-button"><?php esc_html_e("Sign in", 'eyeone'); ?></div>
    8             </a>
    9         </div>
    10         <br />
    11         <h2><?php esc_html_e("You can setup your widget looks in Eye One panel.", 'eyeone'); ?></h2>
    12         <div><?php esc_html_e("Customize your widget looks and interaction type in your Eye One account's settings.", 'eyeone'); ?></div>
    132
    14     </div>
    15     <br />
    16     <h2><?php esc_html_e("Below you can find few steps that will help you get your unique API key for Eye One widget.", 'eyeone'); ?></h2>
    17     <div>
    18         <ul>
    19             <li><?php esc_html_e("1. First make sure that you have an active account registered at Eye One.", 'eyeone'); ?></li>
    20             <li><?php esc_html_e("2. Go to", 'eyeone'); ?> <a href="https://app.eye.one/settings/website-integration"><?php esc_html_e("Eye One Website Integration", 'eyeone'); ?></a></li>
    21             <li><?php esc_html_e("3. Scroll down to the bottom of the page and click Copy API Key", 'eyeone'); ?></li>
    22             <li><?php esc_html_e("4. Now your unique API key is copied to your clipboard", 'eyeone'); ?></li>
    23             <li><?php esc_html_e("5. Paste your API key into API key field below and save changes.", 'eyeone'); ?></li>
    24         </ul>
    25     </div>
    26     <?php
    27     $widgets = getWidgetList();
    28     if (count($widgets) > 0) {
    29         echo '<br /><h2>';
    30         esc_html_e('Your current active widgets:', 'eyeone');
    31         echo '</h2>';
    32     } else {
    33         echo '<br /><h2>';
    34         esc_html_e('Your current active widgets:', 'eyeone');
    35         echo '</h2><div>';
    36         esc_html_e('If you actually have widgets defined, then make sure that API key is correct.', 'eyeone');
    37         echo '</div>';
    38     }
    39     ?>
    40     <div>
    41         <ul>
    42             <?php
    43             foreach ($widgets as $widget) {
    44                 echo '<li class="ey-widget-list-element"><strong>' . esc_attr($widget["name"]) . '</strong> (' . esc_attr($widget["type"]) . ')</li>';
    45             }
    46             ?>
    47         </ul>
    48     </div>
    49     <br />
    503
    51     <?php settings_errors(); ?>
    52     <form method="POST" action="options.php">
    53         <?php
    54         settings_fields('eyeone_general_settings');
    55         do_settings_sections('eyeone_general_settings');
    56         ?>
    57         <?php submit_button(); ?>
    58     </form>
     4    <div id="welcome-panel" class="welcome-panel">
     5        <div class="welcome-panel-content">
     6            <div class="ey-logo"></div>
     7            <p class="about-description"
     8               style="margin-bottom: 0;"><?php esc_html_e("Eye One widget plugin let's your visitors easily schedule an Eye One appointment with you as well as instantly make a videocall request.", 'eyeone'); ?></p>
     9            <div class="ey-buttons">
     10                <a class="ey-link" href="https://app.eye.one/">
     11                    <div class="ey-button"><?php esc_html_e("Sign in", 'eyeone'); ?></div>
     12                </a>
     13            </div>
     14            <br/>
     15            <hr/>
     16            <div class="welcome-panel-column-container">
     17                <div class="welcome-panel-column" style="width: 50%;">
     18                    <h3 style="padding-right: 30px;"><?php esc_html_e("Below you can find few steps that will help you get your unique API key for Eye One widget.", 'eyeone'); ?></h3>
     19                    <ul>
     20                        <li><?php esc_html_e("1. First make sure that you have an active account registered at Eye One.", 'eyeone'); ?></li>
     21                        <li>
     22                            <?php esc_html_e("2. Go to", 'eyeone'); ?>
     23                            <a href="https://app.eye.one/settings/website-integration"><?php esc_html_e("Eye One Website Integration", 'eyeone'); ?></a>
     24                        </li>
     25                        <li><?php esc_html_e("3. Scroll down to the bottom of the page and click Copy API Key", 'eyeone'); ?></li>
     26                        <li><?php esc_html_e("4. Now your unique API key is copied to your clipboard", 'eyeone'); ?></li>
     27                        <li><?php esc_html_e("5. Paste your API key into API key field below and save changes.", 'eyeone'); ?></li>
     28                    </ul>
     29                </div>
     30                <div class="welcome-panel-column" style="width: 50%;">
     31                    <h3><?php esc_html_e("You can setup your widget looks in Eye One panel.", 'eyeone'); ?></h3>
     32                    <p><?php esc_html_e("Customize your widget looks and interaction type in your Eye One account's settings.", 'eyeone'); ?></p>
     33                </div>
     34
     35            </div>
     36        </div>
     37    </div>
     38
     39
     40    <div id="dashboard-widgets" class="metabox-holder ey-metabox">
     41        <div id="postbox-container-1" class="postbox-container" style="width: 100%">
     42            <div id="metabox" class="postbox">
     43                <?php $widgets = getWidgetList(); ?>
     44                <div class="inside">
     45                    <div class="main">
     46                        <h2><?php esc_html_e('Your current active widgets:', 'eyeone'); ?></h2>
     47                        <?php if (count($widgets) <= 0) { ?>
     48                            <?php esc_html_e('If you actually have widgets defined, then make sure that API key is correct.', 'eyeone'); ?>
     49                        <?php } else { ?>
     50                            <ul>
     51                                <?php
     52                                foreach ($widgets as $widget) {
     53                                    echo '<li class="ey-widget-list-element"><strong>' . esc_attr($widget["name"]) . '</strong> (' . esc_attr($widget["type"]) . ')</li>';
     54                                }
     55                                ?>
     56                            </ul>
     57                        <?php } ?>
     58                    </div>
     59                </div>
     60            </div>
     61        </div>
     62    </div>
     63
     64    <br/>
     65    <div id="dashboard-widgets" class="metabox-holder ey-metabox">
     66        <div id="postbox-container-1" class="postbox-container" style="width: 100%">
     67            <div id="metabox" class="postbox">
     68                <div class="inside">
     69                    <div class="main">
     70                        <?php settings_errors(); ?>
     71                        <form method="POST" action="options.php">
     72                            <?php
     73                            settings_fields('eyeone_general_settings');
     74                            do_settings_sections('eyeone_general_settings');
     75                            ?>
     76                            <?php submit_button(); ?>
     77                        </form>
     78                    </div>
     79                </div>
     80            </div>
     81        </div>
     82    </div>
    5983</div>
    6084
     
    6286function getWidgetName($widgetId, $widgets)
    6387{
    64     foreach ($widgets as $widget) {
    65         if ($widgetId == $widget["id"]) {
    66             return esc_attr($widget["name"]);
    67         }
    68     }
     88    foreach ($widgets as $widget) {
     89        if ($widgetId == $widget["id"]) {
     90            return esc_attr($widget["name"]);
     91        }
     92    }
    6993}
     94
    7095function getWidgetList()
    7196{
    72     $apikey = get_option('eyeone_api_key');
    73     if (!is_null($apikey) && preg_match('/[a-zA-Z0-9-]+', $apikey)) {
    74         $response = wp_remote_get('https://app.eye.one/api/v2/public/widgets/' . $apikey);
    75         $body    = wp_remote_retrieve_body($response);
    76         if ($body) {
    77             $widgets = json_decode($body, true);
    78             return $widgets;
    79         }
    80     }
    81     return [];
     97    $apikey = get_option('eyeone_api_key');
     98    if (!is_null($apikey) && preg_match('/[a-zA-Z0-9-]+/', $apikey)) {
     99        $response = wp_remote_get('https://app.eye.one/api/v2/public/widgets/' . $apikey);
     100        $body = wp_remote_retrieve_body($response);
     101        if ($body) {
     102            $widgets = json_decode($body, true);
     103            return $widgets;
     104        }
     105    }
     106    return [];
    82107}
     108
    83109?>
  • eyeone/trunk/eyeone-plugin.php

    r2554919 r2572050  
    1414 * Plugin URI:        https://eye.one
    1515 * Description:       Add Eye One widget to your website and let your visitors schedule appointment with you or videocall your directly
    16  * Version:           1.0.0
     16 * Version:           1.1.0
     17 * Requires at least: 4.6
     18 * Requires PHP:      5.6
    1719 * Author:            Eye One
    1820 * License:           GPL-2.0+
Note: See TracChangeset for help on using the changeset viewer.