Plugin Directory

Changeset 2848888


Ignore:
Timestamp:
01/16/2023 06:20:33 AM (3 years ago)
Author:
kirkclarke
Message:

updated to 1.1.0, new button feature and tested for 6.1.1

Location:
customize-private-protected
Files:
8 added
2 edited

Legend:

Unmodified
Added
Removed
  • customize-private-protected/trunk/customize-private-protected.php

    r2789690 r2848888  
    44Plugin URI: https://github.com/kclarkedesign/cpp
    55Description: Use WP Customize to modify elements of password protected and private posts and pages.
    6 Version: 1.0.1
     6Version: 1.1.0
    77Author: Kirk Clarke
    88Author URI: http://kirkclarke.com
     
    2323{
    2424
     25   
     26    class WP_Customize_Input_PX_Append_Control extends WP_Customize_Control {
     27        public $type = 'text_input_px_append';
     28
     29        public function enqueue() {
     30            wp_enqueue_style( 'cpp_custom_controls_css', plugins_url('css/custom-controls.css', __FILE__));
     31        }
     32        /**
     33         * Render the control's content.
     34        */
     35        public function render_content() { ?>
     36<?php if ( ! empty( $this->label ) ) : ?>
     37<label for="<?php echo esc_attr( $input_id ); ?>"
     38    class="customize-control-title"><?php echo esc_html( $this->label ); ?></label>
     39<?php endif; ?>
     40<?php if ( ! empty( $this->description ) ) : ?>
     41<span id="<?php echo esc_attr( $description_id ); ?>"
     42    class="description customize-control-description"><?php echo $this->description; ?></span>
     43<?php endif; ?>
     44<div class="cpp-customize-control input-group">
     45    <input id="<?php echo esc_attr( $input_id ); ?>" class="form-control" type="<?php echo esc_attr( $this->type ); ?>"
     46        <?php echo $describedby_attr; ?> <?php $this->input_attrs(); ?>
     47        <?php if ( ! isset( $this->input_attrs['value'] ) ) : ?> value="<?php echo esc_attr( $this->value() ); ?>"
     48        <?php endif; ?> <?php $this->link(); ?> />
     49    <div class="input-group-append">
     50        <span class="input-group-text">px</span>
     51    </div>
     52</div>
     53<?php }
     54    }
     55
     56
    2557    $wp_customize->add_section(
    2658        'cpp_plugin_settings',
    2759        array(
    28             'title' => 'Custom Private & Protected',
     60            'title' => __('Customize Private & Protected'),
    2961            'priority'    => 20
    3062
     
    5082        array(
    5183            'type'      => 'checkbox',
    52             'label'     => 'Hide Prefix',
     84            'label'     => __('Hide Prefix'),
    5385            'section'   => 'cpp_plugin_settings',
    5486            'settings'  => 'cpp_hide_prefix',
     
    74106        array(
    75107            'type'      => 'checkbox',
    76             'label'     => 'Use Default form',
     108            'label'     => __('Use Default form'),
    77109            'section'   => 'cpp_plugin_settings',
    78110            'settings'  => 'cpp_use_default_form',
     
    85117
    86118    $wp_customize->add_setting(
     119        'cpp_prefix_private',
     120        array(
     121            'type'          => 'option',
     122            'capability'    => 'manage_options',
     123            'default'       => 'Private: ',
     124            'sanitize_callback' => 'wp_kses_post',
     125        )
     126    );
     127
     128    $wp_customize->add_control(
     129        'cpp_prefix_private',
     130        array(
     131            'label'     => __('Private Title Prefix'),
     132            'section'   => 'cpp_plugin_settings',
     133            'settings'  => 'cpp_prefix_private',
     134            'active_callback' => 'customize_pp_plugin_hide_prefix_condition'
     135        )
     136    );
     137
     138    $wp_customize->add_setting(
    87139        'cpp_prefix_protected',
    88140        array(
     
    97149        'cpp_prefix_protected',
    98150        array(
    99             'label'     => 'Protected Title Prefix',
     151            'label'     => __('Protected Title Prefix'),
    100152            'section'   => 'cpp_plugin_settings',
    101153            'settings'  => 'cpp_prefix_protected',
    102             'active_callback' => 'customize_pp_plugin_hide_prefix_condition'
    103         )
    104     );
    105 
    106     $wp_customize->add_setting(
    107         'cpp_prefix_private',
    108         array(
    109             'type'          => 'option',
    110             'capability'    => 'manage_options',
    111             'default'       => 'Private: ',
    112             'sanitize_callback' => 'wp_kses_post',
    113         )
    114     );
    115 
    116     $wp_customize->add_control(
    117         'cpp_prefix_private',
    118         array(
    119             'label'     => 'Private Title Prefix',
    120             'section'   => 'cpp_plugin_settings',
    121             'settings'  => 'cpp_prefix_private',
    122154            'active_callback' => 'customize_pp_plugin_hide_prefix_condition'
    123155        )
     
    142174        array(
    143175            'type'      => 'textarea',
    144             'label'     => 'Protected Intro Text',
     176            'label'     => __('Protected Intro Text'),
    145177            'section'   => 'cpp_plugin_settings',
    146178            'settings'  => 'cpp_text_intro',
     
    167199        array(
    168200            'type'      => 'textarea',
    169             'label'     => 'Protected Label Text',
     201            'label'     => __('Protected Label Text'),
    170202            'section'   => 'cpp_plugin_settings',
    171203            'settings'  => 'cpp_label_text',
     
    191223        'cpp_button_text',
    192224        array(
    193             'label'     => 'Protected Button Text',
     225            'label'     => __('Protected Button Text'),
    194226            'section'   => 'cpp_plugin_settings',
    195227            'settings'  => 'cpp_button_text',
     
    197229        )
    198230    );
     231
     232    //  =============================
     233    //  = Protected Button Appearance Panel
     234    //  =============================
     235
     236    /** TODO: Add ability to customize button style and/or additonal button styles */
     237
     238    $wp_customize->add_setting(
     239        'cpp_button_x_padding',
     240        array(
     241            'type'          => 'option',
     242            'capability'    => 'manage_options',
     243            'default'       => 20,
     244            'sanitize_callback' => 'wp_kses_post',
     245        )
     246    );
     247
     248    $wp_customize->add_control(
     249        new WP_Customize_Input_PX_Append_Control(
     250            $wp_customize,
     251            'cpp_button__x_padding',
     252            array(
     253                'label' => __( 'Protected Button Horizontal Padding' ),
     254                'description' => __('Controls padding inside the button to the left and right of the button text in pixels (px). Leave blank for default'),
     255                'type' => 'number',
     256                'settings'  => 'cpp_button_x_padding',
     257                'section' => 'cpp_plugin_settings',
     258                'input_attrs' => array(
     259                    'min' => 0,
     260                ),
     261                'active_callback' => 'customize_pp_plugin_hide_form_options_condition'
     262            )
     263        )
     264    );
     265
     266    $wp_customize->add_setting(
     267        'cpp_button_y_padding',
     268        array(
     269            'type'          => 'option',
     270            'capability'    => 'manage_options',
     271            'default'       => 10,
     272            'sanitize_callback' => 'wp_kses_post',
     273        )
     274    );
     275
     276    $wp_customize->add_control(
     277        new WP_Customize_Input_PX_Append_Control(
     278            $wp_customize,
     279            'cpp_button_y_padding',
     280            array(
     281                'label' => __( 'Protected Button Vertical Padding' ),
     282                'description' => __('Controls padding inside the button above and below the button text in pixels (px). Leave blank for default'),
     283                'type' => 'number',
     284                'settings'  => 'cpp_button_y_padding',
     285                'section' => 'cpp_plugin_settings',
     286                'input_attrs' => array(
     287                    'min' => 0,
     288                ),
     289                'active_callback' => 'customize_pp_plugin_hide_form_options_condition'
     290            )
     291        )
     292    );
    199293}
    200294
    201295add_action('customize_register', 'customize_pp_plugin_register_customizer');
    202296
    203 /** TODO: Add ability to customize button style and/or additonal button styles */
     297
    204298
    205299/**
     
    310404        $cpp_label = get_option('cpp_label_text', 'Password: ');
    311405        $cpp_button_text = get_option('cpp_button_text', 'Enter');
     406
     407        $y_padding = ('' == get_option('cpp_button_y_padding')) ? '' : get_option('cpp_button_y_padding') . 'px ';
     408        $x_padding = ('' == get_option('cpp_button_x_padding')) ? '' : get_option('cpp_button_x_padding') . 'px;';
     409        $cpp_button_padding = ('' == $y_padding && '' == $x_padding) ? '' : 'padding: '. $y_padding . $x_padding .'';
     410       
    312411        $label_selector = 'pwbox-' . (empty($post->ID) ? rand() : $post->ID);
    313412    }
     
    322421    if (false == $cpp_use_default_form) {
    323422        $output = $before_area . '<p>' . $cpp_intro . '</p>' . '<form class="cpp-form" action="' . esc_attr(site_url('wp-login.php?action=postpass', 'login_post')) . '" class="post-password-form" method="post">
    324         ' . '<label class="cpp-label" for="' .  esc_attr__($label_selector) . '">' . $cpp_label . ' </label><input class="cpp-password" name="post_password" id="' . $label_selector . '" type="password" size="20" maxlength="20" /><input class="cpp-submit" type="submit" name="Submit" value="' . esc_attr__($cpp_button_text) . '" />
     423        ' . '<label class="cpp-label" for="' .  esc_attr__($label_selector) . '">' . $cpp_label . ' </label><input class="cpp-password" name="post_password" id="' . $label_selector . '" type="password" size="20" maxlength="20" /><input class="cpp-submit" style="'. esc_attr__($cpp_button_padding) .'" type="submit" name="Submit" value="' . esc_attr__($cpp_button_text) . '" />
    325424        </form>' . $after_area;
    326425    } else if (function_exists('et_password_form')) { /* if divi theme */
     
    347446        if ( in_array( 'Administrator', (array) $user->roles ) || in_array( 'Super Administrator', (array) $user->roles ) ) {
    348447        echo '<div class="notice notice-info is-dismissible">
    349               <p>Find Customize Private & Protected helpful? give it a 5-star rating on WordPress</p>
     448              <p>Find Customize Private & Protected helpful? Give it a 5-star rating on WordPress</p>
    350449              <p><a href="https://wordpress.org/support/plugin/customize-private-protected/reviews/#new-post" class="" target="_blank" rel="noopener noreferrer">Sure, you deserve it!</a>
    351450             </div>';
  • customize-private-protected/trunk/readme.txt

    r2789689 r2848888  
    55Tags: page title, title prefix, password protected, widget, change prefix, change, customize, private, protect, password, prefix, remove
    66Requires at least: 5.8
    7 Tested up to: 6.0.2
    8 Stable tag: 1.0.1
     7Tested up to: 6.1.1
     8Stable tag: 1.1.0
    99Requires PHP: 7.0
    1010License: GPLv2 or later
     
    5050== Changelog ==
    5151
     52= 1.1.0 - 01-16-2023 =
     53- Tested - Passed test with WordPress version 6.1.1
     54- Feature - Added ability to customize protected button appearance
     55- Enhancement - Enabled translation in plugin labels
     56- Enhancement - Minor cleanup
     57
    5258= 1.0.1 - 09-24-2022 =
    5359- Tested - Passed test with WordPress version 6.0.2
    54 - Enchancement - Added dismissible notice for plugin review
     60- Enhancement - Added dismissible notice for plugin review
    5561
    5662= 1.0.0 - 07-21-2022 =
     
    6268= 1.0.0 - 04-06-2022 =
    6369- Tested - Passed test with WordPress version 5.9.3
    64 - Enchancement - Updated default values for button and label
     70- Enhancement - Updated default values for button and label
    6571
    6672= 0.2.0 - 01-09-2022 =
    67 - Enchancement - Made fields hide/show based on hide Prefix & Use Default checkboxes
    68 - Enchancement - Added support for Divi password form
     73- Enhancement - Made fields hide/show based on hide Prefix & Use Default checkboxes
     74- Enhancement - Added support for Divi password form
    6975- Feature - Added option to display Wordpress' default form with widgets
    7076
Note: See TracChangeset for help on using the changeset viewer.