Plugin Directory

Changeset 2962829


Ignore:
Timestamp:
09/05/2023 07:17:23 AM (2 years ago)
Author:
daomapsieucap
Message:

Update to version 3.1.0 from GitHub

Location:
fiber-admin
Files:
24 added
2 deleted
20 edited
1 copied

Legend:

Unmodified
Added
Removed
  • fiber-admin/tags/3.1.0/changelog.txt

    r2931908 r2962829  
    11== Changelog ==
     2
     3= 3.1.0 =
     4*Release Date - 05 September 2023*
     5
     6* New feature: Coming Soon & Maintenance Mode.
     7* Changed: Improve email regex pattern.
     8* Fixed: Apply new code for database error to prevent the wrong URLs exist.
    29
    310= 3.0.0 =
  • fiber-admin/tags/3.1.0/fiberadmin.php

    r2931908 r2962829  
    44 * Plugin URI:        https://wordpress.org/plugins/fiber-admin/
    55 * Description:       💈 Bring multiple customization features to make your own WordPress admin.
    6  * Version:           3.0.0
     6 * Version:           3.1.0
    77 * Requires at least: 5.2
    88 * Requires PHP:      7.0
     
    3232
    3333define("FIBERADMIN_VERSION", $plugin_data['Version']);
    34 const FIBERADMIN_DEV_MODE = false;
     34const FIBERADMIN_DEV_MODE = true;
    3535const FIBERADMIN_FILENAME = __FILE__;
    3636define("FIBERADMIN_DIR", plugin_dir_path(__FILE__));
    3737define("FIBERADMIN_ASSETS_URL", plugin_dir_url(__FILE__) . 'assets/');
     38
     39// Coming Soon / Maintenance
     40const FIBERADMIN_ASSETS_DIR   = FIBERADMIN_DIR . 'assets/';
     41const FIBERADMIN_CSM_PATH     = FIBERADMIN_DIR . 'templates/csm-mode.php';
     42const FIBERADMIN_CSM_TEMPLATE = 'csm.php';
    3843
    3944/**
     
    4449function fiad_init(){
    4550    // helper functions
    46     include_once(FIBERADMIN_DIR . 'includes/helper.php');
     51    include_once(FIBERADMIN_DIR . 'includes/helpers.php');
    4752   
    4853    // options pages
     
    5358    include_once(FIBERADMIN_DIR . 'includes/settings/db-error.php');
    5459    include_once(FIBERADMIN_DIR . 'includes/settings/miscellaneous.php');
     60    include_once(FIBERADMIN_DIR . 'includes/settings/csm-mode.php');
    5561   
    5662    //default functions
     
    6571    include_once(FIBERADMIN_DIR . 'includes/db-error.php');
    6672    include_once(FIBERADMIN_DIR . 'includes/attachment.php');
     73    include_once(FIBERADMIN_DIR . 'includes/csm-mode.php');
    6774}
    6875
     
    128135    return $links;
    129136}
     137
     138add_action('admin_head', 'fiad_admin_additional_css');
     139function fiad_admin_additional_css(){
     140    $page_csm_ids = fiad_get_page_template_ids("csm", true, true);
     141    if($page_csm_ids){
     142        $extra_styles = '<style>';
     143        foreach($page_csm_ids as $index => $id){
     144            $extra_styles .= $index > 0 ? ',' : '';
     145            $extra_styles .= '#the-list #post-' . $id . ' .column-title .row-title:before';
     146        }
     147        $extra_styles .= '
     148                    {content: "CSM";
     149                    background-color: #f3efe3;
     150                    color: #333;
     151                    display: inline-block;
     152                    padding: 0 5px;
     153                    margin-right: 10px;}';
     154        $extra_styles .= '</style>';
     155       
     156        echo $extra_styles;
     157    }
     158}
     159
     160/**
     161 * Enqueue admin script
     162 */
     163
     164add_action('admin_enqueue_scripts', 'fiad_enqueue_admin_script');
     165function fiad_enqueue_admin_script(){
     166    $suffix = '';
     167    if(!FIBERADMIN_DEV_MODE){
     168        $suffix = '.min';
     169    }
     170    wp_register_script('fiber-admin', FIBERADMIN_ASSETS_URL . 'js/fiber-admin' . $suffix . '.js', ['jquery'], FIBERADMIN_VERSION);
     171}
  • fiber-admin/tags/3.1.0/includes/attachment.php

    r2931908 r2962829  
    3838   
    3939    public function fiad_cleanup_attachment_name($filename, $filename_raw){
    40         //variable
    41         $path_info          = pathinfo($filename);
    42         $file_extension     = fiad_array_key_exists('extension', $path_info);
    43         $sanitized_filename = basename($filename, "." . $file_extension);
     40        $file_extension = pathinfo($filename, PATHINFO_EXTENSION);
     41        $exclude_exts   = ['css', 'js']; // only apply for media attachment, not for code
    4442       
    45         $sanitized_filename = strtolower($sanitized_filename);
    46        
    47         //handle urlencoded chars
    48         preg_match_all('/%[0-9A-Fa-f]{2}/', $filename_raw, $matches);
    49         $urlencoded_chars = $matches[0];
    50         if($urlencoded_chars){
    51             $urlencoded_chars   = array_map(function($char){
    52                 return strtolower(trim($char, '%'));
    53             }, $urlencoded_chars);
    54             $sanitized_filename = str_replace($urlencoded_chars, "", $sanitized_filename);
     43        if($file_extension && !in_array($file_extension, $exclude_exts)){
     44            $sanitized_filename = basename($filename, "." . $file_extension);
     45            $sanitized_filename = strtolower($sanitized_filename);
     46           
     47            //handle urlencoded chars
     48            preg_match_all('/%[0-9A-Fa-f]{2}/', $filename_raw, $matches);
     49            $urlencoded_chars = fiad_array_key_exists(0, $matches);
     50            if($urlencoded_chars){
     51                $urlencoded_chars   = array_map(function($char){
     52                    return strtolower(trim($char, '%'));
     53                }, $urlencoded_chars);
     54                $sanitized_filename = str_replace($urlencoded_chars, "", $sanitized_filename);
     55            }
     56           
     57            //special chars case
     58            $sanitized_filename = $this->fiad_handle_special_chars($sanitized_filename);
     59           
     60            return $sanitized_filename . "." . $file_extension;
    5561        }
    5662       
    57         //special chars case
    58         $sanitized_filename = $this->fiad_handle_special_chars($sanitized_filename);
    59        
    60         return $sanitized_filename . "." . $file_extension;
     63        return $filename;
    6164    }
    6265   
  • fiber-admin/tags/3.1.0/includes/content.php

    r2931908 r2962829  
    4141   
    4242    public function fiad_auto_convert_email_address($content){
    43         $enable_auto_convert = true;
     43        $content         = do_shortcode($content);// get content without shortcode
     44        $content_pattern = "/>([^<]*)</";
    4445       
    45         // Skip if the content has mailto link
    46         if(strpos($content, 'mailto') !== false){
    47             return $content;
    48         }
     46        return preg_replace_callback($content_pattern, [$this, 'fiad_replace_email_with_link'], $content);
     47    }
     48   
     49    public function fiad_replace_email_with_link($matches){
     50        $email_pattern = "/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z]{2,})/";
     51        $replace       = '<a href="mailto:$1" title="$1">$1</a>';
     52        // matches[0]: return the whole content with html tags
     53        // matches[1]: return the content between tags
     54        $email_content = $matches[1];
     55        $new_content   = preg_replace($email_pattern, $replace, $email_content);
    4956       
    50         // Skip if the content has email in HTML attribute
    51         $att_email_regex = '/<\w+.*?\K[\w-]+=["\']*\s*(?:\w+\s*)*[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\s*(?:[\'"]?(?:\w+\s*)*[\'"]?)?["\']*(?=.*?>)/mi';
    52         preg_match($att_email_regex, $content, $email_matches);
    53         if($email_matches){
    54             $enable_auto_convert = false;
    55         }
    56        
    57         // Skip replace email address
    58         if(!$enable_auto_convert){
    59             return $content;
    60         }
    61        
    62         // Detect and create email link
    63         $search  = ['/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z]{2,})/'];
    64         $replace = ['<a href="mailto:$1" title="$1">$1</a>'];
    65        
    66         return preg_replace($search, $replace, $content);
     57        return str_replace($matches[1], $new_content, $matches[0]);
    6758    }
    6859   
  • fiber-admin/tags/3.1.0/includes/db-error.php

    r2745323 r2962829  
    1010class Fiber_Admin_DB_Error{
    1111    public function __construct(){
    12         add_action('admin_init', array($this, 'fiad_db_error_file'));
    13         register_activation_hook(FIBERADMIN_FILENAME, array($this, 'fiad_db_error_file'));
    14         register_deactivation_hook(FIBERADMIN_FILENAME, array($this, 'fiad_remove_db_error_file'));
     12        add_action('admin_init', [$this, 'fiad_db_error_file']);
     13        register_activation_hook(FIBERADMIN_FILENAME, [$this, 'fiad_db_error_file']);
     14        register_deactivation_hook(FIBERADMIN_FILENAME, [$this, 'fiad_remove_db_error_file']);
    1515    }
    1616   
     
    2323            $content_htaccess = WP_CONTENT_DIR . '/.htaccess';
    2424            if(file_exists($content_htaccess)){
    25                 $lines   = array();
     25                $lines   = [];
    2626                $lines[] = '<Files db-error.php>';
    2727                $lines[] = '    Allow From All';
     
    4040            $bg_color         = fiad_get_db_error_option('db_error_bg');
    4141            $style            = $bg_color ? 'body {background-color: ' . $bg_color . '}' : '';
     42            $server           = $_SERVER;
     43            $http             = fiad_array_key_exists('HTTPS', $server) ? "https://" : "http://";
     44            $http_host        = $http . fiad_array_key_exists('HTTP_HOST', $server);
    4245           
    4346            $php = '<?php';
     
    4851            $php .= PHP_EOL;
    4952            $php .= 'header(\'Retry-After: 3600\');';
     53            $php .= PHP_EOL;
     54            $php .= '$absolute_url = "' . $http_host . '" . explode($_SERVER[\'DOCUMENT_ROOT\'], __DIR__)[1];';
    5055            $php .= PHP_EOL;
    5156            $php .= '?>';
     
    7681                    }
    7782                    </style>";
    78             $html .= '<link rel="icon" type="image/png" href="' . get_site_icon_url() . '"/>';
     83            $html .= '<link rel="icon" type="image/png" href="<?= $absolute_url; ?>' . fiad_get_file_upload_path(get_site_icon_url()) . '"/>';
    7984            $html .= '</head>';
    8085            $html .= '<body class="db-error">';
     
    8590            if($logo){
    8691                $html .= '<div class="db-error__logo">';
    87                 $html .= '<img src="' . $logo . '"  alt="' . get_bloginfo('name') . '" width="' . $logo_width . '" height="' . $logo_height . '"/>';
     92                $html .= '<img src="<?= $absolute_url; ?>' . fiad_get_file_upload_path($logo) . '"  alt="' . get_bloginfo('name') . '" width="' . $logo_width . '" height="' . $logo_height . '"/>';
    8893                $html .= '</div>';
    8994            }
  • fiber-admin/tags/3.1.0/includes/default.php

    r2912732 r2962829  
    4040            if(!fiad_get_general_option('enable_admin_toolbar')){
    4141                add_filter('show_admin_bar', '__return_false');
     42                add_action('wp_print_styles', [$this, 'fiad_deregister_styles'], 100);
     43            }elseif(!fiad_is_admin_user_role()){
    4244                add_action('wp_print_styles', [$this, 'fiad_deregister_styles'], 100);
    4345            }
  • fiber-admin/tags/3.1.0/includes/settings/db-error.php

    r2696536 r2962829  
    1717            'fiad_db_error_group',
    1818            'fiad_db_error',
    19             array($this, 'sanitize_text_field')
     19            [$this, 'sanitize_text_field']
    2020        );
    2121       
     
    2323            'fiad_db_error_section',
    2424            '<span class="dashicons dashicons-admin-generic"></span> General',
    25             array($this, 'fiad_section_info'),
     25            [$this, 'fiad_section_info'],
    2626            'fiber-admin-db-error'
    2727        );
     
    3030            'db_error_enable', // id
    3131            'Activate', // title
    32             array($this, 'fiad_db_error_enable'), // callback
     32            [$this, 'fiad_db_error_enable'], // callback
    3333            'fiber-admin-db-error', // page
    3434            'fiad_db_error_section' // section
     
    3838            'db_error_title',
    3939            'Title',
    40             array($this, 'fiad_db_error_title'),
     40            [$this, 'fiad_db_error_title'],
    4141            'fiber-admin-db-error',
    4242            'fiad_db_error_section'
     
    4646            'db_error_logo',
    4747            'Logo',
    48             array($this, 'fiad_db_error_logo'),
     48            [$this, 'fiad_db_error_logo'],
    4949            'fiber-admin-db-error',
    5050            'fiad_db_error_section'
     
    5454            'db_error_logo_size',
    5555            'Logo size',
    56             array($this, 'fiad_db_error_logo_size'),
     56            [$this, 'fiad_db_error_logo_size'],
    5757            'fiber-admin-db-error',
    5858            'fiad_db_error_section'
     
    6262            'db_error_bg_color',
    6363            'Background Color',
    64             array($this, 'fiad_db_error_bg'),
     64            [$this, 'fiad_db_error_bg'],
    6565            'fiber-admin-db-error',
    6666            'fiad_db_error_section'
     
    7070            'db_error_message',
    7171            'Error Message',
    72             array($this, 'fiad_db_error_message'),
     72            [$this, 'fiad_db_error_message'],
    7373            'fiber-admin-db-error',
    7474            'fiad_db_error_section'
     
    7878            'db_error_extra_css',
    7979            'Extra CSS',
    80             array($this, 'fiad_db_error_extra_css'),
     80            [$this, 'fiad_db_error_extra_css'],
    8181            'fiber-admin-db-error',
    8282            'fiad_db_error_section'
     
    164164                $db_error_message = $default_error_message;
    165165            }
    166             wp_editor($db_error_message, 'db_error_message', array(
     166            wp_editor($db_error_message, 'db_error_message', [
    167167                'default_editor' => 'tinymce',
    168168                'textarea_name'  => 'fiad_db_error[db_error_message]',
    169169                'media_buttons'  => false,
    170170                'textarea_rows'  => 5,
    171             ));
     171            ]);
    172172            ?>
    173173        </fieldset>
     
    176176   
    177177    public function fiad_db_error_extra_css(){
     178        $id = "db-error-extra-css";
     179        fiad_code_editor('text/css', $id);
    178180        ?>
    179181        <fieldset>
    180182            <textarea
     183                    id=<?= $id; ?>
    181184                    name="fiad_db_error[db_error_extra_css]"><?php echo esc_html(fiad_get_db_error_option('db_error_extra_css')); ?></textarea>
    182185        </fieldset>
  • fiber-admin/tags/3.1.0/includes/settings/setting.php

    r2707981 r2962829  
    1111   
    1212    public function __construct(){
    13         add_action('admin_menu', array($this, 'fiad_setting'));
    14         add_action('admin_init', array($this, 'fiad_setting_init'));
     13        add_action('admin_menu', [$this, 'fiad_setting']);
     14        add_action('admin_init', [$this, 'fiad_setting_init']);
    1515       
    1616        // register styles
    17         add_action("admin_enqueue_scripts", array($this, 'fiad_styles'));
     17        add_action("admin_enqueue_scripts", [$this, 'fiad_styles']);
    1818    }
    1919   
     
    4444            'manage_options',
    4545            'fiber-admin',
    46             array($this, 'fiad_setting_html')
     46            [$this, 'fiad_setting_html']
    4747        );
    4848    }
     
    8888   
    8989    public function fiad_setting_tabs(){
    90         return array(
     90        return [
    9191            'white-label'   => 'White Label',
    9292            'cpo'           => 'Custom Post Order',
    9393            'duplicate'     => 'Duplicate Post',
    9494            'db-error'      => 'Database Error',
     95            'csm-mode'      => 'Coming Soon & Maintenance Mode',
    9596            'miscellaneous' => 'Miscellaneous',
    96         );
     97        ];
    9798    }
    9899   
     
    127128                $miscellaneous->fiad_miscellaneous_init();
    128129                break;
     130            case 'csm-mode':
     131                $csm_mode = new Fiber_Admin_CSM_Mode_Settings();
     132                $csm_mode->fiad_csm_mode_init();
     133                break;
    129134            default:
    130135                $white_label = new Fiber_Admin_White_Label_Settings();
     
    136141        do_settings_sections('fiber-admin-' . $current);
    137142       
     143        $this->fiad_preview_mode($current);
     144    }
     145   
     146    public function fiad_preview_mode($current){
     147        $message = __('Please enable "Activate" option and save the settings first!', 'fiber-admin');
    138148        if($current == 'db-error'){
     149            $can_preview = fiad_check_db_error_file();
     150            $url         = content_url('db-error.php');
     151        }else{
     152            $mode        = fiad_get_csm_mode_option('mode');
     153            $can_preview = (bool) fiad_get_csm_mode_option('page');
     154            $url         = get_site_url() . '/' . $mode . '?preview=true';
     155            $message     = __('Please "Save Changes" for the first time', 'fiber-admin');
     156        }
     157        if($current == 'db-error' || $current == 'csm-mode'){
    139158            echo '<input type="submit" name="fiber-admin-submit" id="fiber-admin-submit" class="button button-primary" value="Save Changes">';
    140             if(!fiad_check_db_error_file()){
     159            if(!$can_preview){
    141160                ?>
    142                 <p class="description"><?php echo __('Preview is not available. Please enable "Activate" option and save the settings first!', 'fiber-admin'); ?></p>
     161                <p class="description"><?php echo __('Preview is not available. ' . $message, 'fiber-admin'); ?></p>
    143162                <?php
    144163            }else{
    145164                $txt_preview = __('Preview', 'fiber-admin');
    146165                ?>
    147                 <a class="button" href="<?php echo content_url('db-error.php'); ?>" target="_blank"
     166                <a class="button" href="<?php echo $url; ?>" target="_blank"
    148167                   title="<?php echo $txt_preview; ?>">
    149168                    <?php echo $txt_preview; ?>
     
    177196                    $option_key = 'fiad_miscellaneous';
    178197                    break;
     198                case 'csm-mode':
     199                    $option_key = 'fiad_csm_mode';
     200                    break;
    179201                default:
    180202                    $option_key = 'fiber_admin';
    181203                    break;
    182204            }
     205           
     206            $ignore_key = [
     207                'db_error_message',
     208                'csm_extra_css',
     209                'csm_extra_js',
     210                'db_error_extra_css',
     211                'login_extra_css',
     212            ];
    183213           
    184214            if(isset($_POST[$option_key])){
    185215                $options = $new_options = $_POST[$option_key];
    186216                foreach($options as $key => $value){
    187                     if($key != 'db_error_message' && !is_array($new_options[$key])){
     217                    if(!in_array($key, $ignore_key) && !is_array($new_options[$key])){
    188218                        $new_options[$key] = sanitize_text_field($value);
    189219                    }
    190220                }
    191221            }else{
    192                 $new_options = array();
     222                $new_options = [];
    193223            }
    194224           
  • fiber-admin/tags/3.1.0/includes/settings/white-label.php

    r2857421 r2962829  
    2222       
    2323        // Plugin scripts
    24         $suffix = '';
    25         if(!FIBERADMIN_DEV_MODE){
    26             $suffix = '.min';
    27         }
    28         wp_enqueue_script('fiber-admin', FIBERADMIN_ASSETS_URL . 'js/fiber-admin' . $suffix . '.js', array('jquery'), FIBERADMIN_VERSION);
     24        wp_enqueue_script('fiber-admin');
    2925    }
    3026   
     
    3329            'fiad_white_label_group',
    3430            'fiber-admin-white-label',
    35             array($this, 'sanitize_text_field')
     31            [$this, 'sanitize_text_field']
    3632        );
    3733       
     
    3935            'fiad_branding_section',
    4036            '<span class="dashicons dashicons-wordpress"></span> Branding',
    41             array($this, 'fiad_section_info'),
     37            [$this, 'fiad_section_info'],
    4238            'fiber-admin-white-label'
    4339        );
     
    4642            'hide_wordpress_branding', // id
    4743            'Hide WordPress Branding', // title
    48             array($this, 'fiad_hide_wordpress_branding'), // callback
     44            [$this, 'fiad_hide_wordpress_branding'], // callback
    4945            'fiber-admin-white-label', // page
    5046            'fiad_branding_section' // section
     
    5450            'enable_admin_toolbar', // id
    5551            'Enable Admin Toolbar', // title
    56             array($this, 'fiad_enable_admin_toolbar'), // callback
     52            [$this, 'fiad_enable_admin_toolbar'], // callback
    5753            'fiber-admin-white-label', // page
    5854            'fiad_branding_section' // section
     
    6258            'fiad_white_label_section',
    6359            '<span class="dashicons dashicons-admin-network"></span> Login',
    64             array($this, 'fiad_section_info'),
     60            [$this, 'fiad_section_info'],
    6561            'fiber-admin-white-label'
    6662        );
     
    6965            'login_logo',
    7066            'Logo',
    71             array($this, 'fiad_login_logo'),
     67            [$this, 'fiad_login_logo'],
    7268            'fiber-admin-white-label',
    7369            'fiad_white_label_section'
     
    7773            'login_logo_size',
    7874            'Logo size',
    79             array($this, 'fiad_login_logo_size'),
     75            [$this, 'fiad_login_logo_size'],
    8076            'fiber-admin-white-label',
    8177            'fiad_white_label_section'
     
    8581            'login_bg_color',
    8682            'Background Color / Image',
    87             array($this, 'fiad_login_bg'),
     83            [$this, 'fiad_login_bg'],
    8884            'fiber-admin-white-label',
    8985            'fiad_white_label_section'
     
    9389            'form_color',
    9490            'Form',
    95             array($this, 'fiad_form'),
     91            [$this, 'fiad_form'],
    9692            'fiber-admin-white-label',
    9793            'fiad_white_label_section'
     
    10197            'link_color',
    10298            'Link',
    103             array($this, 'fiad_link'),
     99            [$this, 'fiad_link'],
    104100            'fiber-admin-white-label',
    105101            'fiad_white_label_section'
     
    109105            'login_extra_css',
    110106            'Extra CSS',
    111             array($this, 'fiad_login_extra_css'),
     107            [$this, 'fiad_login_extra_css'],
    112108            'fiber-admin-white-label',
    113109            'fiad_white_label_section'
     
    240236   
    241237    public function fiad_login_extra_css(){
    242         ?>
     238        $id = "login-extra-css";
     239        fiad_code_editor('text/css', $id);
     240        ?>
     241
    243242        <fieldset>
    244243            <textarea
     244                    id=<?= $id; ?>
    245245                    name="fiber_admin[login_extra_css]"><?php echo esc_html(fiad_get_general_option('login_extra_css')); ?></textarea>
    246246        </fieldset>
  • fiber-admin/tags/3.1.0/readme.txt

    r2931908 r2962829  
    55Tested up to: 6.2.2
    66Requires PHP: 7.0
    7 Stable tag: 3.0.0
     7Stable tag: 3.1.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4747== Changelog ==
    4848
    49 = 3.0.0 =
    50 *Release Date - 28 June 2023*
     49= 3.1.0 =
     50*Release Date - 05 September 2023*
    5151
    52 * Fixed: Fix wrong email regex pattern.
    53 * Added: Improve content protection scripts.
    54 * Added: Sanitizing filename to a server-friendly version.
    55 * Added: Improve feature auto set attachment title with sanitized filename.
     52* New feature: Coming Soon & Maintenance Mode.
     53* Changed: Improve email regex pattern.
     54* Fixed: Apply new code for database error to prevent the wrong URLs exist.
  • fiber-admin/trunk/changelog.txt

    r2931908 r2962829  
    11== Changelog ==
     2
     3= 3.1.0 =
     4*Release Date - 05 September 2023*
     5
     6* New feature: Coming Soon & Maintenance Mode.
     7* Changed: Improve email regex pattern.
     8* Fixed: Apply new code for database error to prevent the wrong URLs exist.
    29
    310= 3.0.0 =
  • fiber-admin/trunk/fiberadmin.php

    r2931908 r2962829  
    44 * Plugin URI:        https://wordpress.org/plugins/fiber-admin/
    55 * Description:       💈 Bring multiple customization features to make your own WordPress admin.
    6  * Version:           3.0.0
     6 * Version:           3.1.0
    77 * Requires at least: 5.2
    88 * Requires PHP:      7.0
     
    3232
    3333define("FIBERADMIN_VERSION", $plugin_data['Version']);
    34 const FIBERADMIN_DEV_MODE = false;
     34const FIBERADMIN_DEV_MODE = true;
    3535const FIBERADMIN_FILENAME = __FILE__;
    3636define("FIBERADMIN_DIR", plugin_dir_path(__FILE__));
    3737define("FIBERADMIN_ASSETS_URL", plugin_dir_url(__FILE__) . 'assets/');
     38
     39// Coming Soon / Maintenance
     40const FIBERADMIN_ASSETS_DIR   = FIBERADMIN_DIR . 'assets/';
     41const FIBERADMIN_CSM_PATH     = FIBERADMIN_DIR . 'templates/csm-mode.php';
     42const FIBERADMIN_CSM_TEMPLATE = 'csm.php';
    3843
    3944/**
     
    4449function fiad_init(){
    4550    // helper functions
    46     include_once(FIBERADMIN_DIR . 'includes/helper.php');
     51    include_once(FIBERADMIN_DIR . 'includes/helpers.php');
    4752   
    4853    // options pages
     
    5358    include_once(FIBERADMIN_DIR . 'includes/settings/db-error.php');
    5459    include_once(FIBERADMIN_DIR . 'includes/settings/miscellaneous.php');
     60    include_once(FIBERADMIN_DIR . 'includes/settings/csm-mode.php');
    5561   
    5662    //default functions
     
    6571    include_once(FIBERADMIN_DIR . 'includes/db-error.php');
    6672    include_once(FIBERADMIN_DIR . 'includes/attachment.php');
     73    include_once(FIBERADMIN_DIR . 'includes/csm-mode.php');
    6774}
    6875
     
    128135    return $links;
    129136}
     137
     138add_action('admin_head', 'fiad_admin_additional_css');
     139function fiad_admin_additional_css(){
     140    $page_csm_ids = fiad_get_page_template_ids("csm", true, true);
     141    if($page_csm_ids){
     142        $extra_styles = '<style>';
     143        foreach($page_csm_ids as $index => $id){
     144            $extra_styles .= $index > 0 ? ',' : '';
     145            $extra_styles .= '#the-list #post-' . $id . ' .column-title .row-title:before';
     146        }
     147        $extra_styles .= '
     148                    {content: "CSM";
     149                    background-color: #f3efe3;
     150                    color: #333;
     151                    display: inline-block;
     152                    padding: 0 5px;
     153                    margin-right: 10px;}';
     154        $extra_styles .= '</style>';
     155       
     156        echo $extra_styles;
     157    }
     158}
     159
     160/**
     161 * Enqueue admin script
     162 */
     163
     164add_action('admin_enqueue_scripts', 'fiad_enqueue_admin_script');
     165function fiad_enqueue_admin_script(){
     166    $suffix = '';
     167    if(!FIBERADMIN_DEV_MODE){
     168        $suffix = '.min';
     169    }
     170    wp_register_script('fiber-admin', FIBERADMIN_ASSETS_URL . 'js/fiber-admin' . $suffix . '.js', ['jquery'], FIBERADMIN_VERSION);
     171}
  • fiber-admin/trunk/includes/attachment.php

    r2931908 r2962829  
    3838   
    3939    public function fiad_cleanup_attachment_name($filename, $filename_raw){
    40         //variable
    41         $path_info          = pathinfo($filename);
    42         $file_extension     = fiad_array_key_exists('extension', $path_info);
    43         $sanitized_filename = basename($filename, "." . $file_extension);
     40        $file_extension = pathinfo($filename, PATHINFO_EXTENSION);
     41        $exclude_exts   = ['css', 'js']; // only apply for media attachment, not for code
    4442       
    45         $sanitized_filename = strtolower($sanitized_filename);
    46        
    47         //handle urlencoded chars
    48         preg_match_all('/%[0-9A-Fa-f]{2}/', $filename_raw, $matches);
    49         $urlencoded_chars = $matches[0];
    50         if($urlencoded_chars){
    51             $urlencoded_chars   = array_map(function($char){
    52                 return strtolower(trim($char, '%'));
    53             }, $urlencoded_chars);
    54             $sanitized_filename = str_replace($urlencoded_chars, "", $sanitized_filename);
     43        if($file_extension && !in_array($file_extension, $exclude_exts)){
     44            $sanitized_filename = basename($filename, "." . $file_extension);
     45            $sanitized_filename = strtolower($sanitized_filename);
     46           
     47            //handle urlencoded chars
     48            preg_match_all('/%[0-9A-Fa-f]{2}/', $filename_raw, $matches);
     49            $urlencoded_chars = fiad_array_key_exists(0, $matches);
     50            if($urlencoded_chars){
     51                $urlencoded_chars   = array_map(function($char){
     52                    return strtolower(trim($char, '%'));
     53                }, $urlencoded_chars);
     54                $sanitized_filename = str_replace($urlencoded_chars, "", $sanitized_filename);
     55            }
     56           
     57            //special chars case
     58            $sanitized_filename = $this->fiad_handle_special_chars($sanitized_filename);
     59           
     60            return $sanitized_filename . "." . $file_extension;
    5561        }
    5662       
    57         //special chars case
    58         $sanitized_filename = $this->fiad_handle_special_chars($sanitized_filename);
    59        
    60         return $sanitized_filename . "." . $file_extension;
     63        return $filename;
    6164    }
    6265   
  • fiber-admin/trunk/includes/content.php

    r2931908 r2962829  
    4141   
    4242    public function fiad_auto_convert_email_address($content){
    43         $enable_auto_convert = true;
     43        $content         = do_shortcode($content);// get content without shortcode
     44        $content_pattern = "/>([^<]*)</";
    4445       
    45         // Skip if the content has mailto link
    46         if(strpos($content, 'mailto') !== false){
    47             return $content;
    48         }
     46        return preg_replace_callback($content_pattern, [$this, 'fiad_replace_email_with_link'], $content);
     47    }
     48   
     49    public function fiad_replace_email_with_link($matches){
     50        $email_pattern = "/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z]{2,})/";
     51        $replace       = '<a href="mailto:$1" title="$1">$1</a>';
     52        // matches[0]: return the whole content with html tags
     53        // matches[1]: return the content between tags
     54        $email_content = $matches[1];
     55        $new_content   = preg_replace($email_pattern, $replace, $email_content);
    4956       
    50         // Skip if the content has email in HTML attribute
    51         $att_email_regex = '/<\w+.*?\K[\w-]+=["\']*\s*(?:\w+\s*)*[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\s*(?:[\'"]?(?:\w+\s*)*[\'"]?)?["\']*(?=.*?>)/mi';
    52         preg_match($att_email_regex, $content, $email_matches);
    53         if($email_matches){
    54             $enable_auto_convert = false;
    55         }
    56        
    57         // Skip replace email address
    58         if(!$enable_auto_convert){
    59             return $content;
    60         }
    61        
    62         // Detect and create email link
    63         $search  = ['/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z]{2,})/'];
    64         $replace = ['<a href="mailto:$1" title="$1">$1</a>'];
    65        
    66         return preg_replace($search, $replace, $content);
     57        return str_replace($matches[1], $new_content, $matches[0]);
    6758    }
    6859   
  • fiber-admin/trunk/includes/db-error.php

    r2745323 r2962829  
    1010class Fiber_Admin_DB_Error{
    1111    public function __construct(){
    12         add_action('admin_init', array($this, 'fiad_db_error_file'));
    13         register_activation_hook(FIBERADMIN_FILENAME, array($this, 'fiad_db_error_file'));
    14         register_deactivation_hook(FIBERADMIN_FILENAME, array($this, 'fiad_remove_db_error_file'));
     12        add_action('admin_init', [$this, 'fiad_db_error_file']);
     13        register_activation_hook(FIBERADMIN_FILENAME, [$this, 'fiad_db_error_file']);
     14        register_deactivation_hook(FIBERADMIN_FILENAME, [$this, 'fiad_remove_db_error_file']);
    1515    }
    1616   
     
    2323            $content_htaccess = WP_CONTENT_DIR . '/.htaccess';
    2424            if(file_exists($content_htaccess)){
    25                 $lines   = array();
     25                $lines   = [];
    2626                $lines[] = '<Files db-error.php>';
    2727                $lines[] = '    Allow From All';
     
    4040            $bg_color         = fiad_get_db_error_option('db_error_bg');
    4141            $style            = $bg_color ? 'body {background-color: ' . $bg_color . '}' : '';
     42            $server           = $_SERVER;
     43            $http             = fiad_array_key_exists('HTTPS', $server) ? "https://" : "http://";
     44            $http_host        = $http . fiad_array_key_exists('HTTP_HOST', $server);
    4245           
    4346            $php = '<?php';
     
    4851            $php .= PHP_EOL;
    4952            $php .= 'header(\'Retry-After: 3600\');';
     53            $php .= PHP_EOL;
     54            $php .= '$absolute_url = "' . $http_host . '" . explode($_SERVER[\'DOCUMENT_ROOT\'], __DIR__)[1];';
    5055            $php .= PHP_EOL;
    5156            $php .= '?>';
     
    7681                    }
    7782                    </style>";
    78             $html .= '<link rel="icon" type="image/png" href="' . get_site_icon_url() . '"/>';
     83            $html .= '<link rel="icon" type="image/png" href="<?= $absolute_url; ?>' . fiad_get_file_upload_path(get_site_icon_url()) . '"/>';
    7984            $html .= '</head>';
    8085            $html .= '<body class="db-error">';
     
    8590            if($logo){
    8691                $html .= '<div class="db-error__logo">';
    87                 $html .= '<img src="' . $logo . '"  alt="' . get_bloginfo('name') . '" width="' . $logo_width . '" height="' . $logo_height . '"/>';
     92                $html .= '<img src="<?= $absolute_url; ?>' . fiad_get_file_upload_path($logo) . '"  alt="' . get_bloginfo('name') . '" width="' . $logo_width . '" height="' . $logo_height . '"/>';
    8893                $html .= '</div>';
    8994            }
  • fiber-admin/trunk/includes/default.php

    r2912732 r2962829  
    4040            if(!fiad_get_general_option('enable_admin_toolbar')){
    4141                add_filter('show_admin_bar', '__return_false');
     42                add_action('wp_print_styles', [$this, 'fiad_deregister_styles'], 100);
     43            }elseif(!fiad_is_admin_user_role()){
    4244                add_action('wp_print_styles', [$this, 'fiad_deregister_styles'], 100);
    4345            }
  • fiber-admin/trunk/includes/settings/db-error.php

    r2696536 r2962829  
    1717            'fiad_db_error_group',
    1818            'fiad_db_error',
    19             array($this, 'sanitize_text_field')
     19            [$this, 'sanitize_text_field']
    2020        );
    2121       
     
    2323            'fiad_db_error_section',
    2424            '<span class="dashicons dashicons-admin-generic"></span> General',
    25             array($this, 'fiad_section_info'),
     25            [$this, 'fiad_section_info'],
    2626            'fiber-admin-db-error'
    2727        );
     
    3030            'db_error_enable', // id
    3131            'Activate', // title
    32             array($this, 'fiad_db_error_enable'), // callback
     32            [$this, 'fiad_db_error_enable'], // callback
    3333            'fiber-admin-db-error', // page
    3434            'fiad_db_error_section' // section
     
    3838            'db_error_title',
    3939            'Title',
    40             array($this, 'fiad_db_error_title'),
     40            [$this, 'fiad_db_error_title'],
    4141            'fiber-admin-db-error',
    4242            'fiad_db_error_section'
     
    4646            'db_error_logo',
    4747            'Logo',
    48             array($this, 'fiad_db_error_logo'),
     48            [$this, 'fiad_db_error_logo'],
    4949            'fiber-admin-db-error',
    5050            'fiad_db_error_section'
     
    5454            'db_error_logo_size',
    5555            'Logo size',
    56             array($this, 'fiad_db_error_logo_size'),
     56            [$this, 'fiad_db_error_logo_size'],
    5757            'fiber-admin-db-error',
    5858            'fiad_db_error_section'
     
    6262            'db_error_bg_color',
    6363            'Background Color',
    64             array($this, 'fiad_db_error_bg'),
     64            [$this, 'fiad_db_error_bg'],
    6565            'fiber-admin-db-error',
    6666            'fiad_db_error_section'
     
    7070            'db_error_message',
    7171            'Error Message',
    72             array($this, 'fiad_db_error_message'),
     72            [$this, 'fiad_db_error_message'],
    7373            'fiber-admin-db-error',
    7474            'fiad_db_error_section'
     
    7878            'db_error_extra_css',
    7979            'Extra CSS',
    80             array($this, 'fiad_db_error_extra_css'),
     80            [$this, 'fiad_db_error_extra_css'],
    8181            'fiber-admin-db-error',
    8282            'fiad_db_error_section'
     
    164164                $db_error_message = $default_error_message;
    165165            }
    166             wp_editor($db_error_message, 'db_error_message', array(
     166            wp_editor($db_error_message, 'db_error_message', [
    167167                'default_editor' => 'tinymce',
    168168                'textarea_name'  => 'fiad_db_error[db_error_message]',
    169169                'media_buttons'  => false,
    170170                'textarea_rows'  => 5,
    171             ));
     171            ]);
    172172            ?>
    173173        </fieldset>
     
    176176   
    177177    public function fiad_db_error_extra_css(){
     178        $id = "db-error-extra-css";
     179        fiad_code_editor('text/css', $id);
    178180        ?>
    179181        <fieldset>
    180182            <textarea
     183                    id=<?= $id; ?>
    181184                    name="fiad_db_error[db_error_extra_css]"><?php echo esc_html(fiad_get_db_error_option('db_error_extra_css')); ?></textarea>
    182185        </fieldset>
  • fiber-admin/trunk/includes/settings/setting.php

    r2707981 r2962829  
    1111   
    1212    public function __construct(){
    13         add_action('admin_menu', array($this, 'fiad_setting'));
    14         add_action('admin_init', array($this, 'fiad_setting_init'));
     13        add_action('admin_menu', [$this, 'fiad_setting']);
     14        add_action('admin_init', [$this, 'fiad_setting_init']);
    1515       
    1616        // register styles
    17         add_action("admin_enqueue_scripts", array($this, 'fiad_styles'));
     17        add_action("admin_enqueue_scripts", [$this, 'fiad_styles']);
    1818    }
    1919   
     
    4444            'manage_options',
    4545            'fiber-admin',
    46             array($this, 'fiad_setting_html')
     46            [$this, 'fiad_setting_html']
    4747        );
    4848    }
     
    8888   
    8989    public function fiad_setting_tabs(){
    90         return array(
     90        return [
    9191            'white-label'   => 'White Label',
    9292            'cpo'           => 'Custom Post Order',
    9393            'duplicate'     => 'Duplicate Post',
    9494            'db-error'      => 'Database Error',
     95            'csm-mode'      => 'Coming Soon & Maintenance Mode',
    9596            'miscellaneous' => 'Miscellaneous',
    96         );
     97        ];
    9798    }
    9899   
     
    127128                $miscellaneous->fiad_miscellaneous_init();
    128129                break;
     130            case 'csm-mode':
     131                $csm_mode = new Fiber_Admin_CSM_Mode_Settings();
     132                $csm_mode->fiad_csm_mode_init();
     133                break;
    129134            default:
    130135                $white_label = new Fiber_Admin_White_Label_Settings();
     
    136141        do_settings_sections('fiber-admin-' . $current);
    137142       
     143        $this->fiad_preview_mode($current);
     144    }
     145   
     146    public function fiad_preview_mode($current){
     147        $message = __('Please enable "Activate" option and save the settings first!', 'fiber-admin');
    138148        if($current == 'db-error'){
     149            $can_preview = fiad_check_db_error_file();
     150            $url         = content_url('db-error.php');
     151        }else{
     152            $mode        = fiad_get_csm_mode_option('mode');
     153            $can_preview = (bool) fiad_get_csm_mode_option('page');
     154            $url         = get_site_url() . '/' . $mode . '?preview=true';
     155            $message     = __('Please "Save Changes" for the first time', 'fiber-admin');
     156        }
     157        if($current == 'db-error' || $current == 'csm-mode'){
    139158            echo '<input type="submit" name="fiber-admin-submit" id="fiber-admin-submit" class="button button-primary" value="Save Changes">';
    140             if(!fiad_check_db_error_file()){
     159            if(!$can_preview){
    141160                ?>
    142                 <p class="description"><?php echo __('Preview is not available. Please enable "Activate" option and save the settings first!', 'fiber-admin'); ?></p>
     161                <p class="description"><?php echo __('Preview is not available. ' . $message, 'fiber-admin'); ?></p>
    143162                <?php
    144163            }else{
    145164                $txt_preview = __('Preview', 'fiber-admin');
    146165                ?>
    147                 <a class="button" href="<?php echo content_url('db-error.php'); ?>" target="_blank"
     166                <a class="button" href="<?php echo $url; ?>" target="_blank"
    148167                   title="<?php echo $txt_preview; ?>">
    149168                    <?php echo $txt_preview; ?>
     
    177196                    $option_key = 'fiad_miscellaneous';
    178197                    break;
     198                case 'csm-mode':
     199                    $option_key = 'fiad_csm_mode';
     200                    break;
    179201                default:
    180202                    $option_key = 'fiber_admin';
    181203                    break;
    182204            }
     205           
     206            $ignore_key = [
     207                'db_error_message',
     208                'csm_extra_css',
     209                'csm_extra_js',
     210                'db_error_extra_css',
     211                'login_extra_css',
     212            ];
    183213           
    184214            if(isset($_POST[$option_key])){
    185215                $options = $new_options = $_POST[$option_key];
    186216                foreach($options as $key => $value){
    187                     if($key != 'db_error_message' && !is_array($new_options[$key])){
     217                    if(!in_array($key, $ignore_key) && !is_array($new_options[$key])){
    188218                        $new_options[$key] = sanitize_text_field($value);
    189219                    }
    190220                }
    191221            }else{
    192                 $new_options = array();
     222                $new_options = [];
    193223            }
    194224           
  • fiber-admin/trunk/includes/settings/white-label.php

    r2857421 r2962829  
    2222       
    2323        // Plugin scripts
    24         $suffix = '';
    25         if(!FIBERADMIN_DEV_MODE){
    26             $suffix = '.min';
    27         }
    28         wp_enqueue_script('fiber-admin', FIBERADMIN_ASSETS_URL . 'js/fiber-admin' . $suffix . '.js', array('jquery'), FIBERADMIN_VERSION);
     24        wp_enqueue_script('fiber-admin');
    2925    }
    3026   
     
    3329            'fiad_white_label_group',
    3430            'fiber-admin-white-label',
    35             array($this, 'sanitize_text_field')
     31            [$this, 'sanitize_text_field']
    3632        );
    3733       
     
    3935            'fiad_branding_section',
    4036            '<span class="dashicons dashicons-wordpress"></span> Branding',
    41             array($this, 'fiad_section_info'),
     37            [$this, 'fiad_section_info'],
    4238            'fiber-admin-white-label'
    4339        );
     
    4642            'hide_wordpress_branding', // id
    4743            'Hide WordPress Branding', // title
    48             array($this, 'fiad_hide_wordpress_branding'), // callback
     44            [$this, 'fiad_hide_wordpress_branding'], // callback
    4945            'fiber-admin-white-label', // page
    5046            'fiad_branding_section' // section
     
    5450            'enable_admin_toolbar', // id
    5551            'Enable Admin Toolbar', // title
    56             array($this, 'fiad_enable_admin_toolbar'), // callback
     52            [$this, 'fiad_enable_admin_toolbar'], // callback
    5753            'fiber-admin-white-label', // page
    5854            'fiad_branding_section' // section
     
    6258            'fiad_white_label_section',
    6359            '<span class="dashicons dashicons-admin-network"></span> Login',
    64             array($this, 'fiad_section_info'),
     60            [$this, 'fiad_section_info'],
    6561            'fiber-admin-white-label'
    6662        );
     
    6965            'login_logo',
    7066            'Logo',
    71             array($this, 'fiad_login_logo'),
     67            [$this, 'fiad_login_logo'],
    7268            'fiber-admin-white-label',
    7369            'fiad_white_label_section'
     
    7773            'login_logo_size',
    7874            'Logo size',
    79             array($this, 'fiad_login_logo_size'),
     75            [$this, 'fiad_login_logo_size'],
    8076            'fiber-admin-white-label',
    8177            'fiad_white_label_section'
     
    8581            'login_bg_color',
    8682            'Background Color / Image',
    87             array($this, 'fiad_login_bg'),
     83            [$this, 'fiad_login_bg'],
    8884            'fiber-admin-white-label',
    8985            'fiad_white_label_section'
     
    9389            'form_color',
    9490            'Form',
    95             array($this, 'fiad_form'),
     91            [$this, 'fiad_form'],
    9692            'fiber-admin-white-label',
    9793            'fiad_white_label_section'
     
    10197            'link_color',
    10298            'Link',
    103             array($this, 'fiad_link'),
     99            [$this, 'fiad_link'],
    104100            'fiber-admin-white-label',
    105101            'fiad_white_label_section'
     
    109105            'login_extra_css',
    110106            'Extra CSS',
    111             array($this, 'fiad_login_extra_css'),
     107            [$this, 'fiad_login_extra_css'],
    112108            'fiber-admin-white-label',
    113109            'fiad_white_label_section'
     
    240236   
    241237    public function fiad_login_extra_css(){
    242         ?>
     238        $id = "login-extra-css";
     239        fiad_code_editor('text/css', $id);
     240        ?>
     241
    243242        <fieldset>
    244243            <textarea
     244                    id=<?= $id; ?>
    245245                    name="fiber_admin[login_extra_css]"><?php echo esc_html(fiad_get_general_option('login_extra_css')); ?></textarea>
    246246        </fieldset>
  • fiber-admin/trunk/readme.txt

    r2931908 r2962829  
    55Tested up to: 6.2.2
    66Requires PHP: 7.0
    7 Stable tag: 3.0.0
     7Stable tag: 3.1.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4747== Changelog ==
    4848
    49 = 3.0.0 =
    50 *Release Date - 28 June 2023*
     49= 3.1.0 =
     50*Release Date - 05 September 2023*
    5151
    52 * Fixed: Fix wrong email regex pattern.
    53 * Added: Improve content protection scripts.
    54 * Added: Sanitizing filename to a server-friendly version.
    55 * Added: Improve feature auto set attachment title with sanitized filename.
     52* New feature: Coming Soon & Maintenance Mode.
     53* Changed: Improve email regex pattern.
     54* Fixed: Apply new code for database error to prevent the wrong URLs exist.
Note: See TracChangeset for help on using the changeset viewer.