Plugin Directory

Changeset 3480873


Ignore:
Timestamp:
03/12/2026 07:11:40 AM (2 weeks ago)
Author:
codeatoz
Message:

Version 1.2.0 - Modern admin UI, inline toggle, duplicate and delete rules, updated readme and screenshots

Location:
codeatoz-hide-price-for-stores
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • codeatoz-hide-price-for-stores/trunk/codeatoz-hide-price-for-stores.php

    r3477743 r3480873  
    33 * Plugin Name: Hide Price for WooCommerce – CodeAtoZ
    44 * Description: Control price visibility for WooCommerce stores using flexible rules.
    5  * Version:     1.1.0
     5 * Version:     1.2.0
    66 * Author:      CodeAtoZ
    77 * Author URI:  https://codeatoz.com
  • codeatoz-hide-price-for-stores/trunk/includes/Admin/RuleEditor.php

    r3463970 r3480873  
    4040            ],
    4141        ];
     42
     43        $pro_url = 'https://codeatoz.com/hide-price-for-stores-pro-woocommerce-price-visibility-plugin-codeatoz/';
    4244        ?>
    4345        <div class="wrap">
    44             <h1><?php esc_html_e( 'Edit Hide Price Rule', 'codeatoz-hide-price-for-stores' ); ?></h1>
     46
     47            <!-- Page Header -->
     48            <div class="catz-page-header">
     49                <h1 class="catz-page-header__title">
     50                    <?php echo null !== $rule_index
     51                        ? esc_html__( 'Edit Rule', 'codeatoz-hide-price-for-stores' )
     52                        : esc_html__( 'New Rule', 'codeatoz-hide-price-for-stores' );
     53                    ?>
     54                </h1>
     55                <a href="<?php echo esc_url( admin_url( 'admin.php?page=codeatoz-hide-price' ) ); ?>"
     56                   style="color:#646970;text-decoration:none;font-size:13px;">
     57                    ← <?php esc_html_e( 'Back to Rules', 'codeatoz-hide-price-for-stores' ); ?>
     58                </a>
     59            </div>
    4560
    4661            <form method="post">
    4762                <?php wp_nonce_field( 'codeatoz_hp_save_rule' ); ?>
    4863
    49                 <table class="form-table">
    50 
    51                     <tr>
    52                         <th><?php esc_html_e( 'Rule Name', 'codeatoz-hide-price-for-stores' ); ?></th>
    53                         <td>
    54                             <input type="text"
    55                                    name="rule[name]"
    56                                    value="<?php echo esc_attr( $rule['name'] ); ?>"
    57                                    class="regular-text"
    58                                    required>
    59                         </td>
    60                     </tr>
    61 
    62                     <tr>
    63                         <th><?php esc_html_e( 'Enable Rule', 'codeatoz-hide-price-for-stores' ); ?></th>
    64                         <td>
    65                             <label>
    66                                 <input type="checkbox" name="rule[enabled]" value="1"
    67                                     <?php checked( ! empty( $rule['enabled'] ) ); ?>>
    68                                 <?php esc_html_e( 'Active', 'codeatoz-hide-price-for-stores' ); ?>
    69                             </label>
    70                         </td>
    71                     </tr>
    72 
    73                     <tr>
    74                         <th><?php esc_html_e( 'Priority', 'codeatoz-hide-price-for-stores' ); ?></th>
    75                         <td>
    76                             <input type="number"
    77                                    name="rule[priority]"
    78                                    value="<?php echo esc_attr( $rule['priority'] ); ?>"
    79                                    min="1">
    80                             <p class="description">
    81                                 <?php esc_html_e( 'Lower number = higher priority', 'codeatoz-hide-price-for-stores' ); ?>
    82                             </p>
    83                         </td>
    84                     </tr>
    85 
    86                     <tr>
    87                         <th><?php esc_html_e( 'User Condition', 'codeatoz-hide-price-for-stores' ); ?></th>
    88                         <td>
    89                             <label>
    90                                 <input type="checkbox"
    91                                        name="rule[conditions][user][]"
    92                                        value="guest"
    93                                     <?php checked( in_array( 'guest', $rule['conditions']['user'], true ) ); ?>>
    94                                 <?php esc_html_e( 'Guests', 'codeatoz-hide-price-for-stores' ); ?>
    95                             </label><br>
    96 
    97                             <label>
    98                                 <input type="checkbox"
    99                                        name="rule[conditions][user][]"
    100                                        value="logged_in"
    101                                     <?php checked( in_array( 'logged_in', $rule['conditions']['user'], true ) ); ?>>
    102                                 <?php esc_html_e( 'Logged-in users', 'codeatoz-hide-price-for-stores' ); ?>
    103                             </label>
    104                         </td>
    105                     </tr>
    106 
    107                     <tr>
    108                         <th><?php esc_html_e( 'User Roles', 'codeatoz-hide-price-for-stores' ); ?></th>
    109                         <td>
    110                             <?php
    111                             $wp_roles = wp_roles();
    112                             foreach ( $wp_roles->roles as $key => $role ) :
    113                             ?>
    114                                 <label>
     64                <div class="catz-editor-wrap">
     65
     66                    <!-- Main Column -->
     67                    <div class="catz-editor-main">
     68
     69                        <!-- General Settings -->
     70                        <div class="catz-section">
     71                            <div class="catz-section__header">
     72                                <span class="catz-section__header-icon">⚙️</span>
     73                                <span class="catz-section__title"><?php esc_html_e( 'General', 'codeatoz-hide-price-for-stores' ); ?></span>
     74                            </div>
     75                            <div class="catz-section__body">
     76
     77                                <div class="catz-field">
     78                                    <label class="catz-label" for="catz-rule-name">
     79                                        <?php esc_html_e( 'Rule Name', 'codeatoz-hide-price-for-stores' ); ?>
     80                                    </label>
     81                                    <input type="text"
     82                                           id="catz-rule-name"
     83                                           name="rule[name]"
     84                                           value="<?php echo esc_attr( $rule['name'] ); ?>"
     85                                           class="catz-input"
     86                                           placeholder="<?php esc_attr_e( 'e.g. Hide prices for guests', 'codeatoz-hide-price-for-stores' ); ?>"
     87                                           required>
     88                                </div>
     89
     90                                <div class="catz-field">
     91                                    <label class="catz-label"><?php esc_html_e( 'Status', 'codeatoz-hide-price-for-stores' ); ?></label>
     92                                    <label class="catz-toggle-row">
     93                                        <input type="checkbox" name="rule[enabled]" value="1"
     94                                            <?php checked( ! empty( $rule['enabled'] ) ); ?>>
     95                                        <span><?php esc_html_e( 'Rule is active', 'codeatoz-hide-price-for-stores' ); ?></span>
     96                                    </label>
     97                                </div>
     98
     99                                <div class="catz-field">
     100                                    <label class="catz-label" for="catz-rule-priority">
     101                                        <?php esc_html_e( 'Priority', 'codeatoz-hide-price-for-stores' ); ?>
     102                                    </label>
     103                                    <input type="number"
     104                                           id="catz-rule-priority"
     105                                           name="rule[priority]"
     106                                           value="<?php echo esc_attr( $rule['priority'] ); ?>"
     107                                           class="catz-input"
     108                                           min="1">
     109                                    <span class="catz-desc"><?php esc_html_e( 'Lower number = higher priority. Rules with the same priority run in order.', 'codeatoz-hide-price-for-stores' ); ?></span>
     110                                </div>
     111
     112                            </div>
     113                        </div>
     114
     115                        <!-- Conditions -->
     116                        <div class="catz-section">
     117                            <div class="catz-section__header">
     118                                <span class="catz-section__header-icon">🎯</span>
     119                                <span class="catz-section__title"><?php esc_html_e( 'Conditions', 'codeatoz-hide-price-for-stores' ); ?></span>
     120                            </div>
     121                            <div class="catz-section__body">
     122
     123                                <!-- User Type -->
     124                                <div class="catz-field">
     125                                    <label class="catz-label"><?php esc_html_e( 'User Type', 'codeatoz-hide-price-for-stores' ); ?></label>
     126                                    <div class="catz-check-grid">
     127                                        <label class="catz-check-item">
     128                                            <input type="checkbox"
     129                                                   name="rule[conditions][user][]"
     130                                                   value="guest"
     131                                                <?php checked( in_array( 'guest', $rule['conditions']['user'], true ) ); ?>>
     132                                            <span><?php esc_html_e( 'Guests', 'codeatoz-hide-price-for-stores' ); ?></span>
     133                                        </label>
     134                                        <label class="catz-check-item">
     135                                            <input type="checkbox"
     136                                                   name="rule[conditions][user][]"
     137                                                   value="logged_in"
     138                                                <?php checked( in_array( 'logged_in', $rule['conditions']['user'], true ) ); ?>>
     139                                            <span><?php esc_html_e( 'Logged-in users', 'codeatoz-hide-price-for-stores' ); ?></span>
     140                                        </label>
     141                                    </div>
     142                                </div>
     143
     144                                <!-- User Roles -->
     145                                <div class="catz-field">
     146                                    <label class="catz-label"><?php esc_html_e( 'User Roles', 'codeatoz-hide-price-for-stores' ); ?></label>
     147                                    <div class="catz-check-grid">
     148                                        <?php
     149                                        $wp_roles = wp_roles();
     150                                        foreach ( $wp_roles->roles as $key => $role ) :
     151                                        ?>
     152                                            <label class="catz-check-item">
     153                                                <input type="checkbox"
     154                                                       name="rule[conditions][roles][]"
     155                                                       value="<?php echo esc_attr( $key ); ?>"
     156                                                    <?php checked( in_array( $key, $rule['conditions']['roles'], true ) ); ?>>
     157                                                <span><?php echo esc_html( $role['name'] ); ?></span>
     158                                            </label>
     159                                        <?php endforeach; ?>
     160                                    </div>
     161                                </div>
     162
     163                                <!-- Product IDs -->
     164                                <div class="catz-field">
     165                                    <label class="catz-label" for="catz-product-ids">
     166                                        <?php esc_html_e( 'Product IDs', 'codeatoz-hide-price-for-stores' ); ?>
     167                                    </label>
     168                                    <input type="text"
     169                                           id="catz-product-ids"
     170                                           class="catz-input"
     171                                           name="rule[conditions][products]"
     172                                           value="<?php echo esc_attr( implode( ', ', $rule['conditions']['products'] ) ); ?>"
     173                                           placeholder="e.g. 42, 87, 120">
     174                                    <span class="catz-desc"><?php esc_html_e( 'Comma-separated product IDs. Leave blank to apply to all products.', 'codeatoz-hide-price-for-stores' ); ?></span>
     175                                </div>
     176
     177                                <!-- Product Categories -->
     178                                <?php
     179                                $terms = get_terms( [
     180                                    'taxonomy'   => 'product_cat',
     181                                    'hide_empty' => false,
     182                                ] );
     183                                if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) :
     184                                ?>
     185                                <div class="catz-field">
     186                                    <label class="catz-label"><?php esc_html_e( 'Product Categories', 'codeatoz-hide-price-for-stores' ); ?></label>
     187                                    <div class="catz-check-grid">
     188                                        <?php foreach ( $terms as $term ) : ?>
     189                                            <label class="catz-check-item">
     190                                                <input type="checkbox"
     191                                                       name="rule[conditions][categories][]"
     192                                                       value="<?php echo esc_attr( $term->term_id ); ?>"
     193                                                    <?php checked( in_array( $term->term_id, $rule['conditions']['categories'], true ) ); ?>>
     194                                                <span><?php echo esc_html( $term->name ); ?></span>
     195                                            </label>
     196                                        <?php endforeach; ?>
     197                                    </div>
     198                                </div>
     199                                <?php endif; ?>
     200
     201                            </div>
     202                        </div>
     203
     204                        <!-- Actions -->
     205                        <div class="catz-section">
     206                            <div class="catz-section__header">
     207                                <span class="catz-section__header-icon">⚡</span>
     208                                <span class="catz-section__title"><?php esc_html_e( 'Actions', 'codeatoz-hide-price-for-stores' ); ?></span>
     209                            </div>
     210                            <div class="catz-section__body">
     211
     212                                <label class="catz-action-item">
    115213                                    <input type="checkbox"
    116                                            name="rule[conditions][roles][]"
    117                                            value="<?php echo esc_attr( $key ); ?>"
    118                                         <?php checked( in_array( $key, $rule['conditions']['roles'], true ) ); ?>>
    119                                     <?php echo esc_html( $role['name'] ); ?>
    120                                 </label><br>
    121                             <?php endforeach; ?>
    122                         </td>
    123                     </tr>
    124 
    125                     <tr>
    126                         <th><?php esc_html_e( 'Product IDs', 'codeatoz-hide-price-for-stores' ); ?></th>
    127                         <td>
    128                             <input type="text"
    129                                    class="regular-text"
    130                                    name="rule[conditions][products]"
    131                                    value="<?php echo esc_attr( implode( ',', $rule['conditions']['products'] ) ); ?>">
    132                         </td>
    133                     </tr>
    134 
    135                     <tr>
    136                         <th><?php esc_html_e( 'Product Categories', 'codeatoz-hide-price-for-stores' ); ?></th>
    137                         <td>
    138                             <?php
    139                             $terms = get_terms( [
    140                                 'taxonomy'   => 'product_cat',
    141                                 'hide_empty' => false,
    142                             ] );
    143 
    144                             if ( is_wp_error( $terms ) ) {
    145                                 $terms = [];
    146                             }
    147 
    148                             foreach ( $terms as $term ) :
    149                             ?>
    150                                 <label>
     214                                           name="rule[actions][hide_price]"
     215                                           value="1"
     216                                        <?php checked( ! empty( $rule['actions']['hide_price'] ) ); ?>>
     217                                    <div class="catz-action-item__text">
     218                                        <strong><?php esc_html_e( 'Hide Price', 'codeatoz-hide-price-for-stores' ); ?></strong>
     219                                        <small><?php esc_html_e( 'Remove the product price from display.', 'codeatoz-hide-price-for-stores' ); ?></small>
     220                                    </div>
     221                                </label>
     222
     223                                <label class="catz-action-item">
    151224                                    <input type="checkbox"
    152                                            name="rule[conditions][categories][]"
    153                                            value="<?php echo esc_attr( $term->term_id ); ?>"
    154                                         <?php checked( in_array( $term->term_id, $rule['conditions']['categories'], true ) ); ?>>
    155                                     <?php echo esc_html( $term->name ); ?>
    156                                 </label><br>
    157                             <?php endforeach; ?>
    158                         </td>
    159                     </tr>
    160 
    161                     <tr>
    162                         <th><?php esc_html_e( 'Actions', 'codeatoz-hide-price-for-stores' ); ?></th>
    163                         <td>
    164                             <label>
    165                                 <input type="checkbox"
    166                                        name="rule[actions][hide_price]"
    167                                        value="1"
    168                                     <?php checked( ! empty( $rule['actions']['hide_price'] ) ); ?>>
    169                                 <?php esc_html_e( 'Hide price', 'codeatoz-hide-price-for-stores' ); ?>
    170                             </label><br><br>
    171 
    172                             <label>
    173                                 <input type="checkbox"
    174                                        name="rule[actions][hide_cart]"
    175                                        value="1"
    176                                     <?php checked( ! empty( $rule['actions']['hide_cart'] ) ); ?>>
    177                                 <?php esc_html_e( 'Hide Add to Cart button', 'codeatoz-hide-price-for-stores' ); ?>
    178                             </label><br><br>
    179 
    180                             <label>
    181                                 <?php esc_html_e( 'Replacement Text', 'codeatoz-hide-price-for-stores' ); ?><br>
    182                                 <input type="text"
    183                                        class="regular-text"
    184                                        name="rule[actions][replace_text]"
    185                                        value="<?php echo esc_attr( $rule['actions']['replace_text'] ); ?>">
    186                             </label>
    187                         </td>
    188                     </tr>
    189 
    190                 </table>
    191 
    192                 <?php submit_button(
    193                     __( 'Save Rule', 'codeatoz-hide-price-for-stores' ),
    194                     'primary',
    195                     'codeatoz_hp_save_rule'
    196                 ); ?>
     225                                           name="rule[actions][hide_cart]"
     226                                           value="1"
     227                                        <?php checked( ! empty( $rule['actions']['hide_cart'] ) ); ?>>
     228                                    <div class="catz-action-item__text">
     229                                        <strong><?php esc_html_e( 'Hide Add to Cart Button', 'codeatoz-hide-price-for-stores' ); ?></strong>
     230                                        <small><?php esc_html_e( 'Remove the Add to Cart button from the product.', 'codeatoz-hide-price-for-stores' ); ?></small>
     231                                    </div>
     232                                </label>
     233
     234                                <div class="catz-field" style="margin-top:14px;">
     235                                    <label class="catz-label" for="catz-replace-text">
     236                                        <?php esc_html_e( 'Replacement Text', 'codeatoz-hide-price-for-stores' ); ?>
     237                                    </label>
     238                                    <input type="text"
     239                                           id="catz-replace-text"
     240                                           class="catz-input"
     241                                           name="rule[actions][replace_text]"
     242                                           value="<?php echo esc_attr( $rule['actions']['replace_text'] ); ?>"
     243                                           placeholder="<?php esc_attr_e( 'e.g. Login to see price', 'codeatoz-hide-price-for-stores' ); ?>">
     244                                    <span class="catz-desc"><?php esc_html_e( 'Optional text shown where the price was. Leave blank to show nothing.', 'codeatoz-hide-price-for-stores' ); ?></span>
     245                                </div>
     246
     247                            </div>
     248                        </div>
     249
     250                        <!-- Save Bar -->
     251                        <div class="catz-save-bar">
     252                            <?php submit_button(
     253                                __( 'Save Rule', 'codeatoz-hide-price-for-stores' ),
     254                                'primary',
     255                                'codeatoz_hp_save_rule',
     256                                false
     257                            ); ?>
     258                            <a href="<?php echo esc_url( admin_url( 'admin.php?page=codeatoz-hide-price' ) ); ?>" class="catz-back-link">
     259                                <?php esc_html_e( 'Cancel', 'codeatoz-hide-price-for-stores' ); ?>
     260                            </a>
     261                        </div>
     262
     263                    </div><!-- /.catz-editor-main -->
     264
     265                    <!-- Sidebar -->
     266                    <div class="catz-editor-sidebar">
     267
     268                        <div class="catz-info-box">
     269                            <div class="catz-info-box__header"><?php esc_html_e( 'How Rules Work', 'codeatoz-hide-price-for-stores' ); ?></div>
     270                            <div class="catz-info-box__body">
     271                                <?php esc_html_e( 'A rule matches when ALL selected conditions are met. Leave a condition empty to match any.', 'codeatoz-hide-price-for-stores' ); ?>
     272                                <ul>
     273                                    <li><?php esc_html_e( 'Lower priority number = runs first', 'codeatoz-hide-price-for-stores' ); ?></li>
     274                                    <li><?php esc_html_e( 'Roles only apply to logged-in users', 'codeatoz-hide-price-for-stores' ); ?></li>
     275                                    <li><?php esc_html_e( 'Product IDs override category rules', 'codeatoz-hide-price-for-stores' ); ?></li>
     276                                </ul>
     277                            </div>
     278                        </div>
     279
     280                        <!-- Animated Pro Card -->
     281                        <div class="catz-pro-card">
     282                            <div class="catz-pro-card__bg">
     283
     284                                <div class="catz-pro-card__head">
     285                                    <div class="catz-pro-card__headline">
     286                                        <span class="catz-pro-card__eyebrow"><?php esc_html_e( 'CodeAtoZ', 'codeatoz-hide-price-for-stores' ); ?></span>
     287                                        <p class="catz-pro-card__title"><?php esc_html_e( 'Hide Price for Stores', 'codeatoz-hide-price-for-stores' ); ?></p>
     288                                        <span class="catz-pro-card__sub"><?php esc_html_e( '30+ targeting conditions for B2B, wholesale & membership stores.', 'codeatoz-hide-price-for-stores' ); ?></span>
     289                                    </div>
     290                                    <span class="catz-pro-card__badge">PRO</span>
     291                                </div>
     292
     293                                <div class="catz-pro-card__price-strip">
     294                                    <div class="catz-pro-card__price"><sup>$</sup>39</div>
     295                                    <div class="catz-pro-card__period">
     296                                        <?php esc_html_e( 'one-time payment', 'codeatoz-hide-price-for-stores' ); ?><br>
     297                                        <?php esc_html_e( 'Lifetime updates · 1 year support', 'codeatoz-hide-price-for-stores' ); ?>
     298                                    </div>
     299                                    <div class="catz-pro-card__guarantee">
     300                                        <strong>✓ <?php esc_html_e( '30-Day Guarantee', 'codeatoz-hide-price-for-stores' ); ?></strong>
     301                                        <?php esc_html_e( 'No-questions refund', 'codeatoz-hide-price-for-stores' ); ?>
     302                                    </div>
     303                                </div>
     304
     305                                <ul class="catz-pro-card__features">
     306                                    <li><span class="catz-check">✓</span><?php esc_html_e( 'Schedule rules by date / time', 'codeatoz-hide-price-for-stores' ); ?></li>
     307                                    <li><span class="catz-check">✓</span><?php esc_html_e( 'Geo-targeting by country', 'codeatoz-hide-price-for-stores' ); ?></li>
     308                                    <li><span class="catz-check">✓</span><?php esc_html_e( 'Cart value & purchase history rules', 'codeatoz-hide-price-for-stores' ); ?></li>
     309                                    <li><span class="catz-check">✓</span><?php esc_html_e( 'Custom HTML price replacement', 'codeatoz-hide-price-for-stores' ); ?></li>
     310                                    <li><span class="catz-check">✓</span><?php esc_html_e( 'Redirect action (301/302)', 'codeatoz-hide-price-for-stores' ); ?></li>
     311                                    <li><span class="catz-check">✓</span><?php esc_html_e( 'Analytics dashboard', 'codeatoz-hide-price-for-stores' ); ?></li>
     312                                    <li><span class="catz-check">✓</span><?php esc_html_e( 'Inquiry manager + priority support', 'codeatoz-hide-price-for-stores' ); ?></li>
     313                                </ul>
     314
     315                                <div class="catz-pro-card__divider"></div>
     316
     317                                <div class="catz-pro-card__footer">
     318                                    <a href="<?php echo esc_url( $pro_url ); ?>" target="_blank" class="catz-pro-card__cta">
     319                                        <?php esc_html_e( 'Get Pro — $39 Lifetime', 'codeatoz-hide-price-for-stores' ); ?>
     320                                        <span class="catz-pro-card__cta-arrow">→</span>
     321                                    </a>
     322                                    <p class="catz-pro-card__fine"><?php esc_html_e( 'Secure checkout · Stripe & PayPal', 'codeatoz-hide-price-for-stores' ); ?></p>
     323                                </div>
     324
     325                            </div>
     326                        </div><!-- /.catz-pro-card -->
     327
     328                    </div><!-- /.catz-editor-sidebar -->
     329
     330                </div><!-- /.catz-editor-wrap -->
     331
    197332            </form>
    198333        </div>
  • codeatoz-hide-price-for-stores/trunk/includes/Admin/SettingsPage.php

    r3463970 r3480873  
    1010    public static function init() {
    1111        add_action( 'admin_menu', [ __CLASS__, 'register_menu' ] );
     12        add_action( 'admin_enqueue_scripts', [ __CLASS__, 'enqueue_assets' ] );
     13    }
     14
     15    public static function enqueue_assets( $hook ) {
     16        if ( false === strpos( $hook, 'codeatoz-hide-price' ) ) {
     17            return;
     18        }
     19        wp_enqueue_style(
     20            'codeatoz-hide-price-admin',
     21            plugin_dir_url( CODEATOZ_HP_FILE ) . 'assets/admin.css',
     22            [],
     23            CODEATOZ_HP_VERSION
     24        );
     25        wp_enqueue_script(
     26            'codeatoz-hide-price-admin',
     27            plugin_dir_url( CODEATOZ_HP_FILE ) . 'assets/admin.js',
     28            [],
     29            CODEATOZ_HP_VERSION,
     30            true
     31        );
    1232    }
    1333
     
    2949        }
    3050
    31         // Safely read action parameter
    3251        $action = isset( $_GET['action'] )
    3352            ? sanitize_text_field( wp_unslash( $_GET['action'] ) )
    3453            : '';
    3554
     55        if ( in_array( $action, [ 'toggle', 'duplicate', 'delete' ], true ) ) {
     56            self::handle_action( $action );
     57            return;
     58        }
     59
    3660        if ( $action === 'edit' ) {
    3761            RuleEditor::render();
     
    3963        }
    4064
    41         $rules = get_option( 'codeatoz_hp_rules', [] );
     65        $saved   = isset( $_GET['saved'] ) ? sanitize_text_field( wp_unslash( $_GET['saved'] ) ) : '';
     66        $rules   = get_option( 'codeatoz_hp_rules', [] );
     67        $pro_url = 'https://codeatoz.com/hide-price-for-stores-pro-woocommerce-price-visibility-plugin-codeatoz/';
    4268        ?>
    4369        <div class="wrap">
    44             <h1>
    45                 <?php esc_html_e( 'CodeAtoZ – Hide Price Rules', 'codeatoz-hide-price-for-stores' ); ?>
     70
     71            <!-- Pro Banner -->
     72            <div class="catz-pro-banner">
     73                <div class="catz-pro-banner__left">
     74                    <div class="catz-pro-banner__icon">🚀</div>
     75                    <div class="catz-pro-banner__text">
     76                        <strong><?php esc_html_e( 'Unlock Hide Price Pro', 'codeatoz-hide-price-for-stores' ); ?></strong>
     77                        <span><?php esc_html_e( 'More conditions, redirect rules, date scheduling & priority support.', 'codeatoz-hide-price-for-stores' ); ?></span>
     78                    </div>
     79                </div>
     80                <div class="catz-pro-banner__features">
     81                    <span class="catz-pro-banner__pill">
     82                        <svg viewBox="0 0 16 16" fill="currentColor"><path d="M8 1l2.2 4.4L15 6.3l-3.5 3.4.8 4.8L8 12.1 3.7 14.5l.8-4.8L1 6.3l4.8-.9z"/></svg>
     83                        <?php esc_html_e( 'Date Scheduling', 'codeatoz-hide-price-for-stores' ); ?>
     84                    </span>
     85                    <span class="catz-pro-banner__pill">
     86                        <svg viewBox="0 0 16 16" fill="currentColor"><path d="M8 1l2.2 4.4L15 6.3l-3.5 3.4.8 4.8L8 12.1 3.7 14.5l.8-4.8L1 6.3l4.8-.9z"/></svg>
     87                        <?php esc_html_e( 'Redirect Rules', 'codeatoz-hide-price-for-stores' ); ?>
     88                    </span>
     89                    <span class="catz-pro-banner__pill">
     90                        <svg viewBox="0 0 16 16" fill="currentColor"><path d="M8 1l2.2 4.4L15 6.3l-3.5 3.4.8 4.8L8 12.1 3.7 14.5l.8-4.8L1 6.3l4.8-.9z"/></svg>
     91                        <?php esc_html_e( 'Priority Support', 'codeatoz-hide-price-for-stores' ); ?>
     92                    </span>
     93                </div>
     94                <a href="<?php echo esc_url( $pro_url ); ?>" target="_blank" class="catz-pro-banner__cta">
     95                    <?php esc_html_e( 'Upgrade to Pro', 'codeatoz-hide-price-for-stores' ); ?>
     96                    <svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 8h10M9 4l4 4-4 4"/></svg>
     97                </a>
     98            </div>
     99
     100            <!-- Page Header -->
     101            <div class="catz-page-header">
     102                <h1 class="catz-page-header__title">
     103                    <?php esc_html_e( 'Hide Price Rules', 'codeatoz-hide-price-for-stores' ); ?>
     104                    <span class="catz-badge">Free</span>
     105                </h1>
    46106                <a href="<?php echo esc_url( admin_url( 'admin.php?page=codeatoz-hide-price&action=edit' ) ); ?>"
    47                    class="page-title-action">
     107                   class="catz-btn-primary">
     108                    <svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2.2"><path d="M8 3v10M3 8h10"/></svg>
    48109                    <?php esc_html_e( 'Add Rule', 'codeatoz-hide-price-for-stores' ); ?>
    49110                </a>
    50             </h1>
    51 
    52             <?php if ( empty( $rules ) ) : ?>
    53                 <p><?php esc_html_e( 'No rules created yet.', 'codeatoz-hide-price-for-stores' ); ?></p>
    54             <?php else : ?>
    55                 <table class="widefat striped">
    56                     <thead>
    57                         <tr>
    58                             <th><?php esc_html_e( 'Rule Name', 'codeatoz-hide-price-for-stores' ); ?></th>
    59                             <th><?php esc_html_e( 'Priority', 'codeatoz-hide-price-for-stores' ); ?></th>
    60                             <th><?php esc_html_e( 'Status', 'codeatoz-hide-price-for-stores' ); ?></th>
    61                             <th><?php esc_html_e( 'Actions', 'codeatoz-hide-price-for-stores' ); ?></th>
    62                         </tr>
    63                     </thead>
    64                     <tbody>
    65                         <?php foreach ( $rules as $index => $rule ) : ?>
     111            </div>
     112
     113            <!-- Flash notices -->
     114            <?php if ( $saved === 'toggled' ) : ?>
     115                <div class="catz-notice catz-notice--success">✓ <?php esc_html_e( 'Rule status updated.', 'codeatoz-hide-price-for-stores' ); ?></div>
     116            <?php elseif ( $saved === 'duplicated' ) : ?>
     117                <div class="catz-notice catz-notice--success">✓ <?php esc_html_e( 'Rule duplicated successfully.', 'codeatoz-hide-price-for-stores' ); ?></div>
     118            <?php elseif ( $saved === 'deleted' ) : ?>
     119                <div class="catz-notice catz-notice--warning">✓ <?php esc_html_e( 'Rule deleted.', 'codeatoz-hide-price-for-stores' ); ?></div>
     120            <?php endif; ?>
     121
     122            <!-- Rules Table -->
     123            <div class="catz-card">
     124                <?php if ( empty( $rules ) ) : ?>
     125                    <div class="catz-empty-state">
     126                        <span class="catz-empty-state__icon">📋</span>
     127                        <p><?php esc_html_e( 'No rules created yet. Add your first rule to start hiding prices.', 'codeatoz-hide-price-for-stores' ); ?></p>
     128                        <a href="<?php echo esc_url( admin_url( 'admin.php?page=codeatoz-hide-price&action=edit' ) ); ?>"
     129                           class="catz-btn-primary">
     130                            <?php esc_html_e( 'Create First Rule', 'codeatoz-hide-price-for-stores' ); ?>
     131                        </a>
     132                    </div>
     133                <?php else : ?>
     134                    <table class="catz-rules-table">
     135                        <thead>
    66136                            <tr>
    67                                 <td><?php echo esc_html( $rule['name'] ?? '—' ); ?></td>
    68                                 <td><?php echo esc_html( $rule['priority'] ?? 10 ); ?></td>
    69                                 <td>
    70                                     <?php
    71                                     echo ! empty( $rule['enabled'] )
    72                                         ? esc_html__( 'Enabled', 'codeatoz-hide-price-for-stores' )
    73                                         : esc_html__( 'Disabled', 'codeatoz-hide-price-for-stores' );
    74                                     ?>
    75                                 </td>
    76                                 <td>
    77                                     <a href="<?php echo esc_url(
    78                                         admin_url(
    79                                             'admin.php?page=codeatoz-hide-price&action=edit&rule=' . absint( $index )
    80                                         )
    81                                     ); ?>">
    82                                         <?php esc_html_e( 'Edit', 'codeatoz-hide-price-for-stores' ); ?>
    83                                     </a>
    84                                 </td>
     137                                <th><?php esc_html_e( 'Rule Name', 'codeatoz-hide-price-for-stores' ); ?></th>
     138                                <th><?php esc_html_e( 'Priority', 'codeatoz-hide-price-for-stores' ); ?></th>
     139                                <th><?php esc_html_e( 'Status', 'codeatoz-hide-price-for-stores' ); ?></th>
     140                                <th><?php esc_html_e( 'Actions', 'codeatoz-hide-price-for-stores' ); ?></th>
    85141                            </tr>
    86                         <?php endforeach; ?>
    87                     </tbody>
    88                 </table>
    89             <?php endif; ?>
     142                        </thead>
     143                        <tbody>
     144                            <?php foreach ( $rules as $index => $rule ) :
     145                                $enabled    = ! empty( $rule['enabled'] );
     146                                $toggle_url = wp_nonce_url(
     147                                    admin_url( 'admin.php?page=codeatoz-hide-price&action=toggle&rule=' . absint( $index ) ),
     148                                    'catz_toggle_' . $index
     149                                );
     150                                $dup_url    = wp_nonce_url(
     151                                    admin_url( 'admin.php?page=codeatoz-hide-price&action=duplicate&rule=' . absint( $index ) ),
     152                                    'catz_duplicate_' . $index
     153                                );
     154                                $delete_url = wp_nonce_url(
     155                                    admin_url( 'admin.php?page=codeatoz-hide-price&action=delete&rule=' . absint( $index ) ),
     156                                    'catz_delete_' . $index
     157                                );
     158                            ?>
     159                                <tr>
     160                                    <td>
     161                                        <span class="catz-rule-name"><?php echo esc_html( $rule['name'] ?? '—' ); ?></span>
     162                                    </td>
     163                                    <td>
     164                                        <span class="catz-priority-badge"><?php echo esc_html( $rule['priority'] ?? 10 ); ?></span>
     165                                    </td>
     166                                    <td>
     167                                        <a href="<?php echo esc_url( $toggle_url ); ?>"
     168                                           class="catz-toggle-switch <?php echo $enabled ? 'catz-toggle-switch--on' : 'catz-toggle-switch--off'; ?>"
     169                                           title="<?php echo $enabled ? esc_attr__( 'Click to disable', 'codeatoz-hide-price-for-stores' ) : esc_attr__( 'Click to enable', 'codeatoz-hide-price-for-stores' ); ?>">
     170                                            <span class="catz-toggle-switch__track">
     171                                                <span class="catz-toggle-switch__thumb"></span>
     172                                            </span>
     173                                            <span class="catz-toggle-switch__label">
     174                                                <?php echo $enabled
     175                                                    ? esc_html__( 'Enabled', 'codeatoz-hide-price-for-stores' )
     176                                                    : esc_html__( 'Disabled', 'codeatoz-hide-price-for-stores' );
     177                                                ?>
     178                                            </span>
     179                                        </a>
     180                                    </td>
     181                                    <td>
     182                                        <div class="catz-row-actions">
     183                                            <a href="<?php echo esc_url( admin_url( 'admin.php?page=codeatoz-hide-price&action=edit&rule=' . absint( $index ) ) ); ?>"
     184                                               class="catz-action-link catz-action-link--edit">
     185                                                <svg width="12" height="12" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M11.5 2.5l2 2L5 13H3v-2L11.5 2.5z"/></svg>
     186                                                <?php esc_html_e( 'Edit', 'codeatoz-hide-price-for-stores' ); ?>
     187                                            </a>
     188                                            <a href="<?php echo esc_url( $dup_url ); ?>"
     189                                               class="catz-action-link catz-action-link--dup">
     190                                                <svg width="12" height="12" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8"><rect x="5" y="5" width="8" height="8" rx="1"/><path d="M3 11V3h8"/></svg>
     191                                                <?php esc_html_e( 'Duplicate', 'codeatoz-hide-price-for-stores' ); ?>
     192                                            </a>
     193                                            <a href="<?php echo esc_url( $delete_url ); ?>"
     194                                               class="catz-action-link catz-action-link--delete"
     195                                               data-confirm="<?php esc_attr_e( 'Are you sure you want to delete this rule? This cannot be undone.', 'codeatoz-hide-price-for-stores' ); ?>">
     196                                                <svg width="12" height="12" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M3 4h10M6 4V2h4v2M5 4v9h6V4"/></svg>
     197                                                <?php esc_html_e( 'Delete', 'codeatoz-hide-price-for-stores' ); ?>
     198                                            </a>
     199                                        </div>
     200                                    </td>
     201                                </tr>
     202                            <?php endforeach; ?>
     203                        </tbody>
     204                    </table>
     205                <?php endif; ?>
     206            </div>
     207
    90208        </div>
    91209        <?php
    92210    }
     211
     212    // ----------------------------------------------------------------
     213    // Action handlers — toggle / duplicate / delete
     214    // ----------------------------------------------------------------
     215
     216    private static function handle_action( string $action ) {
     217
     218        if ( ! current_user_can( 'manage_woocommerce' ) ) {
     219            wp_die( esc_html__( 'Sorry, you are not allowed to perform this action.', 'codeatoz-hide-price-for-stores' ) );
     220        }
     221
     222        $index = isset( $_GET['rule'] ) ? absint( wp_unslash( $_GET['rule'] ) ) : null;
     223
     224        if ( null === $index ) {
     225            wp_safe_redirect( admin_url( 'admin.php?page=codeatoz-hide-price' ) );
     226            exit;
     227        }
     228
     229        $nonce_key = 'catz_' . $action . '_' . $index;
     230        if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['_wpnonce'] ) ), $nonce_key ) ) {
     231            wp_die( esc_html__( 'Security check failed.', 'codeatoz-hide-price-for-stores' ) );
     232        }
     233
     234        $rules = get_option( 'codeatoz_hp_rules', [] );
     235
     236        if ( ! isset( $rules[ $index ] ) ) {
     237            wp_safe_redirect( admin_url( 'admin.php?page=codeatoz-hide-price' ) );
     238            exit;
     239        }
     240
     241        switch ( $action ) {
     242
     243            case 'toggle':
     244                $rules[ $index ]['enabled'] = empty( $rules[ $index ]['enabled'] );
     245                update_option( 'codeatoz_hp_rules', $rules );
     246                wp_safe_redirect( admin_url( 'admin.php?page=codeatoz-hide-price&saved=toggled' ) );
     247                exit;
     248
     249            case 'duplicate':
     250                $copy            = $rules[ $index ];
     251                $copy['name']    = sprintf(
     252                    /* translators: %s = original rule name */
     253                    __( '%s (Copy)', 'codeatoz-hide-price-for-stores' ),
     254                    $copy['name']
     255                );
     256                $copy['enabled'] = false;
     257                $rules[]         = $copy;
     258                update_option( 'codeatoz_hp_rules', $rules );
     259                wp_safe_redirect( admin_url( 'admin.php?page=codeatoz-hide-price&saved=duplicated' ) );
     260                exit;
     261
     262            case 'delete':
     263                array_splice( $rules, $index, 1 );
     264                update_option( 'codeatoz_hp_rules', array_values( $rules ) );
     265                wp_safe_redirect( admin_url( 'admin.php?page=codeatoz-hide-price&saved=deleted' ) );
     266                exit;
     267        }
     268    }
    93269}
  • codeatoz-hide-price-for-stores/trunk/readme.txt

    r3477750 r3480873  
    11=== Hide Price for WooCommerce – CodeAtoZ ===
    22Contributors: codeatoz
    3 Tags: woocommerce, hide price, hide add to cart, b2b, wholesale
     3Tags: woocommerce, hide price, hide add to cart, b2b, wholesale, catalog mode, price visibility
    44Requires at least: 6.0
    55Tested up to: 6.9
     
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010
     11== Short Description ==
    1112Hide WooCommerce product prices and Add to Cart buttons using flexible rule-based conditions — ideal for B2B, wholesale, and catalog-mode stores.
    1213
    1314== Description ==
    1415
    15 Hide price in WooCommerce stores using flexible rule-based conditions. Hide Price for WooCommerce – CodeAtoZ allows store owners to hide product prices and Add to Cart buttons based on user roles, login status, products, or categories.
     16CodeAtoZ – Hide Price for Stores gives WooCommerce store owners complete control over product price visibility.
    1617
    17 Whether you're running a B2B store, wholesale platform, members-only shop, or catalog-mode website, this plugin gives you complete control over WooCommerce price visibility without breaking core functionality.
     18Whether you're running a B2B store, wholesale platform, members-only shop, or catalog-mode website, this plugin allows you to hide product prices and Add to Cart buttons based on flexible rule conditions — without breaking WooCommerce functionality.
    1819
    19 Unlike CSS-based hiding methods, this plugin applies secure server-side logic to remove prices across:
     20Unlike CSS-based hiding methods, this plugin applies server-side logic to securely remove prices across:
    2021
    2122• Shop pages 
     
    2526• WooCommerce Store API 
    2627
    27 This plugin is ideal for:
     28Perfect for:
    2829
    29 • B2B & wholesale WooCommerce stores 
     30• B2B & wholesale stores 
    3031• Member-only pricing models 
    31 • Catalog-only WooCommerce websites 
     32• Catalog-only WooCommerce stores 
    3233• Quote-based businesses 
    3334• Private or restricted pricing models 
    3435
    35 The plugin can also be used to hide price until login for WooCommerce stores.
    36 
    37 Lightweight. Secure. Clean integration with WooCommerce.
     36Lightweight. Secure. Clean integration.
    3837
    3938---
     
    5958
    6059= Custom Replacement Text =
    61 Display a custom message instead of price such as:
    62 
    63 • "Login to view price" 
    64 • "Request a quote" 
     60Display a custom message instead of price:
     61• "Login to view price"
     62• "Request a quote"
    6563• "Contact us for pricing"
    6664
    6765= Secure Server-Side Enforcement =
    68 Prevents price exposure via browser inspection or frontend manipulation.
     66Prevents price exposure via inspection tools.
    6967
    7068= WooCommerce API Safe =
    71 Fully compatible with WooCommerce REST API and headless setups.
     69Fully compatible with REST API and headless setups.
    7270
    7371---
     
    7674
    7775= Rule Name =
    78 Internal reference name visible in the admin panel.
     76Internal reference name visible in admin.
    7977
    8078= Enable Rule =
     
    8280
    8381= Priority =
    84 Lower number = higher priority. 
     82Lower number = higher priority.
    8583Rules are evaluated in ascending order.
    8684
    8785= User Condition =
    88 Apply the rule to guests or logged-in users.
     86Apply rule to guests or logged-in users.
    8987
    9088= User Roles =
    91 Select specific WordPress roles. 
     89Select specific WordPress roles.
    9290Supports custom roles created by other plugins.
    9391
    9492= Product IDs =
    95 Comma-separated product IDs. 
    96 Leave empty to apply the rule globally.
     93Comma-separated product IDs.
     94Leave empty to apply globally.
    9795
    9896= Product Categories =
    99 Select WooCommerce categories to restrict rule scope.
     97Select categories to restrict rule scope.
    10098
    10199= Hide Add to Cart Button =
    102 Removes the purchase button when the rule is applied.
     100Removes purchase button when enabled.
    103101
    104102= Replacement Text =
    105 Custom message shown instead of the price.
     103Custom message shown instead of price.
    106104
    107 Rules are evaluated server-side during WooCommerce price rendering to ensure consistent behavior across the store.
     105Rules are evaluated server-side during WooCommerce price rendering.
    108106
    109107---
     
    111109== Installation ==
    112110
    113 1. Install the plugin from the WordPress Plugin Directory or upload manually.
     1111. Install via WordPress Plugin Directory or upload manually.
    1141122. Activate the plugin.
    115 3. Navigate to **WooCommerce → Hide Price**.
    116 4. Create and configure your rules.
    117 5. Save and test on the frontend.
     1133. Navigate to WooCommerce → Hide Price.
     1144. Create and configure rules.
     1155. Save and test on frontend.
    118116
    119117---
     
    122120
    123121= Does this work with variable products? =
    124 Yes. The plugin supports both simple and variable products.
     122Yes.
    125123
    126124= Does this hide prices in WooCommerce REST API? =
    127 Yes. Prices are hidden in REST API responses when the rule applies.
     125Yes.
    128126
    129127= Can I create a catalog-only store? =
    130 Yes. You can create a global rule that hides both price and Add to Cart button.
     128Yes. Enable a global rule hiding price and Add to Cart.
    131129
    132 = Does the plugin use CSS to hide prices? =
     130= Does it use CSS to hide prices? =
    133131No. It uses secure server-side logic.
    134132
    135 = Will this slow down my store? =
    136 No. The plugin is lightweight and optimized for WooCommerce performance.
     133= Will it slow down my store? =
     134No. It is lightweight and optimized.
    137135
    138136---
     
    148146• Ensure WordPress and WooCommerce are updated 
    149147• Verify no theme conflicts 
    150 • Confirm you are using the latest plugin version 
     148• Confirm latest plugin version 
    151149
    152150We actively maintain and improve this plugin.
     
    162160• Rule export/import 
    163161• Enhanced UI improvements 
    164 • Additional compatibility improvements 
     162• Additional compatibility enhancements 
    165163
    166 User feedback helps guide development.
     164User feedback helps shape development.
    167165
    168166---
     
    177175
    178176---
    179 
     177 
    180178== Changelog ==
    181 
    182 = 1.1.0 =
    183 * Improved plugin name for better WordPress.org search visibility
    184 * Enhanced readme and SEO description
    185 * Documentation improvements
    186179
    187180= 1.0.0 =
Note: See TracChangeset for help on using the changeset viewer.