Plugin Directory

Changeset 3401956


Ignore:
Timestamp:
11/24/2025 03:08:20 PM (3 months ago)
Author:
tryfalan
Message:

Fix plugin warning and errors. Fix script backend URL

Location:
the-get-hired-button
Files:
16 added
3 edited

Legend:

Unmodified
Added
Removed
  • the-get-hired-button/trunk/readme.txt

    r3395622 r3401956  
    55Tested up to: 6.8
    66Requires PHP: 7.4
    7 Stable tag: 1.2
     7Stable tag: 1.3.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010
     11The Get Hired Button — Simple, Automatic, and Ready to Go
     12
    1113== Description ==
    1214
    13 The Get Hired Button — Simple, Automatic, and Ready to Go
    1415Once you install the plugin, the Get Hired Button usually appears on your site automatically. 🎉
    1516No complicated setup. No coding. It just works.
     
    180181== Changelog ==
    181182
    182 = 1.0 - 2024-11-13 =
     183= 1.0.0 - 2025-11-13 =
    183184* Initial release
    184185* Token-based authentication
     
    191192* Uninstall cleanup
    192193
    193 = 1.1 - 2024-11-14 =
     194= 1.1.0 - 2025-11-14 =
    194195* Update README with improved Instructions and Description
    195196
     197= 1.2.0 - 2025-11-14 =
     198* Updated README to fix formatting in Troubleshooting and For Developers sections.
     199
     200= 1.3.0 - 2025-11-24 =
     201* Updated plugin version to 1.3.0 in readme and main plugin file.
     202* Fix plugin warnings and errors of Plugin Check tool.
     203* Fix script URL to use correct URL.
     204
    196205== Upgrade Notice ==
    197206
    198 = 1.0.0 =
     207= 1.0 =
    199208Initial release of The Get Hired Button plugin.
    200209
    201210= 1.1 =
    202 Updated README with improved Instructions and Description
     211No code changes. Updated README with improved Instructions and Description
     212
     213= 1.2 =
     214No code changes. Updated README to fix formatting in Troubleshooting and For Developers sections.
     215
     216= 1.3 =
     217* Updated plugin version to 1.3.0 in readme and main plugin file.
     218* Fix plugin warnings and errors of Plugin Check tool.
     219* Fix script URL to use correct URL.
  • the-get-hired-button/trunk/the-get-hired-button.php

    r3395129 r3401956  
    44 * Plugin URI: https://www.tryme.co/get-hired-button
    55 * Description: Add TryMe's Get Hired button to your WordPress site to help candidates apply directly from your career pages
    6  * Version: 1.0.0
     6 * Version: 1.3.0
    77 * Requires at least: 5.8
    88 * Requires PHP: 7.4
     
    1919}
    2020
    21 // Define plugin constants
    22 if (!defined('GHB_VERSION')) {
    23     define('GHB_VERSION', '1.0.0');
     21// Define plugin constants with proper 4+ character prefix
     22if (!defined('THEGEHIB_VERSION')) {
     23    define('THEGEHIB_VERSION', '1.3.0');
    2424}
    25 if (!defined('GHB_PLUGIN_FILE')) {
    26     define('GHB_PLUGIN_FILE', __FILE__);
     25if (!defined('THEGEHIB_PLUGIN_FILE')) {
     26    define('THEGEHIB_PLUGIN_FILE', __FILE__);
    2727}
    28 if (!defined('GHB_PLUGIN_DIR')) {
    29     define('GHB_PLUGIN_DIR', plugin_dir_path(__FILE__));
     28if (!defined('THEGEHIB_PLUGIN_DIR')) {
     29    define('THEGEHIB_PLUGIN_DIR', plugin_dir_path(__FILE__));
    3030}
    3131
    3232// Check if class already exists
    33 if (!class_exists('GetHired_Button')) {
    34 
    35     class GetHired_Button {
    36 
    37         private $option_name = 'gethired_button_token';
    38 
     33if (!class_exists('TheGetHiredButton_Plugin')) {
     34
     35    class TheGetHiredButton_Plugin {
     36       
     37        private $option_name = 'thegehib_button_token';
     38       
    3939        public function __construct() {
    4040            // Add settings page
    4141            add_action('admin_menu', array($this, 'add_admin_menu'));
    4242            add_action('admin_init', array($this, 'register_settings'));
    43 
     43           
     44            // Enqueue admin styles properly
     45            add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_styles'));
     46           
    4447            // Add script to frontend
    4548            add_action('wp_enqueue_scripts', array($this, 'add_button_script'));
    46 
     49           
    4750            // Add activation hook
    48             register_activation_hook(GHB_PLUGIN_FILE, array($this, 'activate'));
    49         }
    50 
     51            register_activation_hook(THEGEHIB_PLUGIN_FILE, array($this, 'activate'));
     52        }
     53       
    5154        /**
    5255         * Plugin activation hook
     
    5861                add_option($this->option_name, '', '', 'no');
    5962            }
    60 
     63           
    6164            // Set activation flag
    62             add_option('gethired_button_activated', time(), '', 'no');
    63 
     65            add_option('thegehib_button_activated', time(), '', 'no');
     66           
    6467            // Flush rewrite rules (if needed in future)
    6568            flush_rewrite_rules();
    6669        }
    67 
     70       
    6871        /**
    6972         * Add admin menu
     
    7881            );
    7982        }
    80 
     83       
     84        /**
     85         * Enqueue admin styles properly using WordPress functions
     86         */
     87        public function enqueue_admin_styles($hook) {
     88            // Only load on our settings page
     89            if ('settings_page_the-get-hired-button' !== $hook) {
     90                return;
     91            }
     92           
     93            // Register a dummy style handle to attach inline styles to
     94            wp_register_style('thegehib-admin-styles', false, array(), THEGEHIB_VERSION);
     95            wp_enqueue_style('thegehib-admin-styles');
     96           
     97            // Add inline styles using WordPress function
     98            $custom_css = "
     99                .thegehib-list {
     100                    margin: 10px 0 0 20px;
     101                    list-style-position: outside;
     102                }
     103                .thegehib-status-box {
     104                    margin-top: 15px;
     105                    padding: 12px;
     106                    border-left: 4px solid;
     107                }
     108                .thegehib-status-box.success {
     109                    background: #d4edda;
     110                    border-color: #28a745;
     111                    color: #155724;
     112                }
     113                .thegehib-status-box.warning {
     114                    background: #fff3cd;
     115                    border-color: #ffc107;
     116                    color: #856404;
     117                }
     118                .thegehib-status-box p {
     119                    margin: 0;
     120                }
     121                .thegehib-status-box p + p {
     122                    margin-top: 10px;
     123                }
     124                .thegehib-status-box .description {
     125                    font-size: 12px;
     126                }
     127            ";
     128           
     129            wp_add_inline_style('thegehib-admin-styles', $custom_css);
     130        }
     131       
    81132        /**
    82133         * Register settings
     
    84135        public function register_settings() {
    85136            register_setting(
    86                 'gethired_button_settings',
     137                'thegehib_button_settings',
    87138                $this->option_name,
    88139                array(
     
    92143                )
    93144            );
    94 
     145           
    95146            add_settings_section(
    96                 'gethired_button_main_section',
     147                'thegehib_button_main_section',
    97148                __('Button Configuration', 'the-get-hired-button'),
    98149                array($this, 'section_callback'),
    99150                'the-get-hired-button'
    100151            );
    101 
     152           
    102153            add_settings_field(
    103                 'gethired_button_token_field',
     154                'thegehib_button_token_field',
    104155                __('Widget Token', 'the-get-hired-button'),
    105156                array($this, 'token_field_callback'),
    106157                'the-get-hired-button',
    107                 'gethired_button_main_section'
    108             );
    109         }
    110 
     158                'thegehib_button_main_section'
     159            );
     160        }
     161       
    111162        /**
    112163         * Sanitize token input
     
    117168                return '';
    118169            }
    119 
     170           
    120171            $token = sanitize_text_field($token);
    121172            $token = trim($token);
    122 
     173           
    123174            // Validate token format (UUID v4 format)
    124175            if (!empty($token) && !preg_match('/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i', $token)) {
    125176                add_settings_error(
    126                     'gethired_button_token',
     177                    'thegehib_button_token',
    127178                    'invalid_token',
    128179                    __('Warning: The token format appears to be invalid. Please verify you copied the correct token from your TryMe dashboard.', 'the-get-hired-button'),
     
    130181                );
    131182            }
    132 
     183           
    133184            return $token;
    134185        }
    135 
     186       
    136187        /**
    137188         * Settings section description
     
    149200            echo '</p>';
    150201            echo '</div>';
    151 
     202           
    152203            echo '<div class="notice notice-info inline" style="margin-top: 20px;">';
    153204            echo '<p><strong>' . esc_html__('Optional: Add Your Widget Token', 'the-get-hired-button') . '</strong></p>';
    154205            echo '<p>' . esc_html__('Only needed if auto-connect didn\'t work.', 'the-get-hired-button') . '</p>';
    155             echo '<ol class="gethired-list">';
     206            echo '<ol class="thegehib-list">';
    156207            echo '<li>';
    157208            printf(
     
    173224            echo '<p style="margin-top: 10px;">💡 <em>' . esc_html__('Tip: If you skip the token, the plugin still runs safely in automatic mode if your website domain matches widget\'s', 'the-get-hired-button') . '</em></p>';
    174225            echo '</div>';
    175 
    176             // Add inline styles for proper list formatting
    177             $this->output_admin_styles();
    178         }
    179 
    180         /**
    181          * Output admin styles using WordPress classes
    182          */
    183         private function output_admin_styles() {
    184             ?>
    185             <style type="text/css">
    186                 .gethired-list {
    187                     margin: 10px 0 0 20px;
    188                     list-style-position: outside;
    189                 }
    190                 .gethired-status-box {
    191                     margin-top: 15px;
    192                     padding: 12px;
    193                     border-left: 4px solid;
    194                 }
    195                 .gethired-status-box.success {
    196                     background: #d4edda;
    197                     border-color: #28a745;
    198                     color: #155724;
    199                 }
    200                 .gethired-status-box.warning {
    201                     background: #fff3cd;
    202                     border-color: #ffc107;
    203                     color: #856404;
    204                 }
    205                 .gethired-status-box p {
    206                     margin: 0;
    207                 }
    208                 .gethired-status-box p + p {
    209                     margin-top: 10px;
    210                 }
    211                 .gethired-status-box .description {
    212                     font-size: 12px;
    213                 }
    214             </style>
    215             <?php
    216         }
    217 
     226        }
     227       
    218228        /**
    219229         * Token field HTML
     
    221231        public function token_field_callback() {
    222232            $token = get_option($this->option_name, '');
    223 
     233           
    224234            // Error handling for get_option
    225235            if (is_wp_error($token)) {
     
    227237            }
    228238            ?>
    229             <input
    230                 type="text"
    231                 name="<?php echo esc_attr($this->option_name); ?>"
    232                 value="<?php echo esc_attr($token); ?>"
     239            <input 
     240                type="text" 
     241                name="<?php echo esc_attr($this->option_name); ?>" 
     242                value="<?php echo esc_attr($token); ?>" 
    233243                class="regular-text code"
    234244                placeholder="<?php esc_attr_e('Optional: e.g., 3017b28d-f02c-4dad-8101-1629d462aa6c', 'the-get-hired-button'); ?>"
    235                 aria-describedby="gethired-token-description"
     245                aria-describedby="thegehib-token-description"
    236246            />
    237             <p class="description" id="gethired-token-description">
     247            <p class="description" id="thegehib-token-description">
    238248                <?php esc_html_e('Paste your widget token here (optional)', 'the-get-hired-button'); ?>
    239249            </p>
    240250            <?php
    241 
     251           
    242252            // Show status based on configuration
    243253            if (!empty($token)) {
    244254                ?>
    245                 <div class="gethired-status-box success">
     255                <div class="thegehib-status-box success">
    246256                    <p><strong><?php esc_html_e('✓ Token Connected', 'the-get-hired-button'); ?></strong></p>
    247257                    <p class="description">
     
    252262            } else {
    253263                ?>
    254                 <div class="gethired-status-box warning">
     264                <div class="thegehib-status-box warning">
    255265                    <p><strong><?php esc_html_e('⚡ Automatic Mode', 'the-get-hired-button'); ?></strong></p>
    256266                    <p class="description">
     
    261271            }
    262272        }
    263 
     273       
    264274        /**
    265275         * Settings page HTML
     
    273283                );
    274284            }
    275 
    276             settings_errors('gethired_button_messages');
     285           
     286            settings_errors('thegehib_button_messages');
    277287            ?>
    278288            <div class="wrap">
    279289                <h1><?php echo esc_html(get_admin_page_title()); ?></h1>
    280 
     290               
    281291                <form action="options.php" method="post">
    282292                    <?php
    283                     settings_fields('gethired_button_settings');
     293                    settings_fields('thegehib_button_settings');
    284294                    do_settings_sections('the-get-hired-button');
    285295                    submit_button(__('Save Settings', 'the-get-hired-button'));
    286296                    ?>
    287297                </form>
    288 
     298               
    289299                <hr class="wp-header-end">
    290 
     300               
    291301                <h2><?php esc_html_e('Troubleshooting', 'the-get-hired-button'); ?></h2>
    292302                <ul class="ul-disc">
     
    312322                    </li>
    313323                </ul>
    314 
     324               
    315325                <hr>
    316 
     326               
    317327                <p style="font-style: italic; color: #666;">
    318328                    <?php esc_html_e('Thanks for using the Get Hired Button — helping you turn every visitor into an opportunity.', 'the-get-hired-button'); ?>
    319329                </p>
    320 
     330               
    321331                <p class="description">
    322332                    <?php
     
    324334                        /* translators: %s: Plugin version number */
    325335                        esc_html__('Plugin Version: %s', 'the-get-hired-button'),
    326                         esc_html(GHB_VERSION)
     336                        esc_html(THEGEHIB_VERSION)
    327337                    );
    328338                    ?>
     
    331341            <?php
    332342        }
    333 
     343       
    334344        /**
    335345         * Add button script to page
     
    337347         */
    338348        public function add_button_script() {
    339             // Don't load in admin area (backend)
    340             if (is_admin()) {
    341                 return;
    342             }
    343 
    344             // Get token with error handling
    345             $token = get_option($this->option_name, '');
    346             if (is_wp_error($token)) {
    347                 $token = '';
    348             }
    349 
    350             // Build script URL
    351             $script_url = 'https://www.tryme.co/widgets.js';
    352 
    353             // Build query parameters
    354             $query_params = array(
    355                 'v' => GHB_VERSION
    356             );
    357 
    358             // Add token if available
    359             if (!empty($token)) {
    360                 $query_params['token'] = $token;
    361             }
    362 
    363             // Enqueue the script properly
    364             wp_enqueue_script(
    365                 'gethired-button-widget',           // Handle
    366                 add_query_arg($query_params, $script_url), // URL with params
    367                 array(),                            // No dependencies
    368                 GHB_VERSION,                        // Version (for cache busting)
    369                 array(                              // Args array (WP 6.3+)
    370                     'strategy' => 'async',          // Load asynchronously
    371                     'in_footer' => false            // Load in header (body_open compatible)
    372                 )
    373             );
     349          // Don't load in admin area (backend)
     350          if (is_admin()) {
     351              return;
     352          }
     353         
     354          // Get token with error handling
     355          $token = get_option($this->option_name, '');
     356          if (is_wp_error($token)) {
     357              $token = '';
     358          }
     359         
     360          // Build script URL based on token availability
     361          if (!empty($token)) {
     362              // With token: /widgets/:token
     363              $script_url = 'http://www.tryme.local:3000/widgets/' . $token;
     364          } else {
     365              // Without token: /widgets
     366              $script_url = 'http://www.tryme.local:3000/widgets';
     367          }
     368         
     369          // Enqueue the script properly
     370          wp_enqueue_script(
     371              'thegehib-button-widget',           // Handle
     372              $script_url,                        // URL with token in path (if available)
     373              array(),                            // No dependencies
     374              THEGEHIB_VERSION,                   // Version (for cache busting)
     375              array(                              // Args array (WP 6.3+)
     376                  'strategy' => 'async',          // Load asynchronously
     377                  'in_footer' => false            // Load in header (body_open compatible)
     378              )
     379          );
    374380        }
    375381    }
    376 
     382   
    377383    // Initialize the plugin
    378     new GetHired_Button();
     384    new TheGetHiredButton_Plugin();
    379385
    380386} // End class_exists check
  • the-get-hired-button/trunk/uninstall.php

    r3395129 r3401956  
    66 * It cleans up all plugin data from the database.
    77 *
    8  * @package GetHiredButton
     8 * @package TheGetHiredButton
    99 */
    1010
     
    1515
    1616// Delete plugin options
    17 delete_option('gethired_button_token');
    18 delete_option('gethired_button_activated');
     17delete_option('thegehib_button_token');
     18delete_option('thegehib_button_activated');
    1919
    2020// For multisite installations
    2121if (is_multisite()) {
    2222    // Get all sites using WordPress function
    23     $sites = get_sites(array(
     23    $thegehib_sites = get_sites(array(
    2424        'number' => 0, // Get all sites
    2525        'fields' => 'ids' // Only return IDs
    2626    ));
    27 
    28     foreach ($sites as $site_id) {
    29         switch_to_blog($site_id);
    30 
     27   
     28    foreach ($thegehib_sites as $thegehib_site_id) {
     29        switch_to_blog($thegehib_site_id);
     30       
    3131        // Delete options for each site
    32         delete_option('gethired_button_token');
    33         delete_option('gethired_button_activated');
    34 
     32        delete_option('thegehib_button_token');
     33        delete_option('thegehib_button_activated');
     34       
    3535        restore_current_blog();
    3636    }
Note: See TracChangeset for help on using the changeset viewer.