Plugin Directory

Changeset 2315761


Ignore:
Timestamp:
06/01/2020 10:47:09 AM (6 years ago)
Author:
arena
Message:

code clean up and starting php 7.3 compatibility (continue/break within switch)

Location:
mailpress/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • mailpress/trunk/MailPress.php

    r2302714 r2315761  
    5151/** for mysql */
    5252global $wpdb;
    53 $wpdb->mp_mails     = $wpdb->prefix . 'mailpress_mails';
    54 $wpdb->mp_mailmeta  = $wpdb->prefix . 'mailpress_mailmeta';
    55 $wpdb->mp_users     = $wpdb->prefix . 'mailpress_users';
    56 $wpdb->mp_usermeta  = $wpdb->prefix . 'mailpress_usermeta';
    57 $wpdb->mp_stats     = $wpdb->prefix . 'mailpress_stats';
     53$wpdb->mp_mails    = $wpdb->prefix . 'mailpress_mails';
     54$wpdb->mp_mailmeta = $wpdb->prefix . 'mailpress_mailmeta';
     55$wpdb->mp_users    = $wpdb->prefix . 'mailpress_users';
     56$wpdb->mp_usermeta = $wpdb->prefix . 'mailpress_usermeta';
     57$wpdb->mp_stats    = $wpdb->prefix . 'mailpress_stats';
    5858
    5959class MailPress
    6060{
    6161    const option_name_general           = 'MailPress_general';
    62     const option_name_test              = 'MailPress_test';
    63     const option_name_logs              = 'MailPress_logs';
    64     const option_name_subscriptions     = 'MailPress_subscriptions';
    65     const option_name_smtp              = 'MailPress_smtp_config';
     62    const option_name_test              = 'MailPress_test';
     63    const option_name_logs              = 'MailPress_logs';
     64    const option_name_subscriptions         = 'MailPress_subscriptions';
     65    const option_name_smtp              = 'MailPress_smtp_config';
    6666    const option_name_sendmail          = 'MailPress_connection_sendmail';
    6767//  php mail() not supported since swiftmailer 6.x
     
    7575        require_once( 'mp-load.php' );
    7676
    77         spl_autoload_register( array( __CLASS__, 'autoload' ) );                            // for class loader
     77        spl_autoload_register( array( __CLASS__, 'autoload' ) );                    // for class loader
    7878
    7979        if ( defined( 'MP_DEBUG_LOG' ) )
     
    8686
    8787        add_action( 'plugins_loaded',           array( __CLASS__, 'plugins_loaded' ) );     // for add-ons & gettext
    88         add_action( 'init',                 array( __CLASS__, 'init' ) );               // for init
    89         add_action( 'widgets_init',         array( __CLASS__, 'widgets_init' ) );           // for widget
     88        add_action( 'init',             array( __CLASS__, 'init' ) );           // for init
     89        add_action( 'widgets_init',         array( __CLASS__, 'widgets_init' ) );       // for widget
    9090        add_action( 'shutdown',             array( __CLASS__, 'shutdown' ), 999 );      // for shutdown
    91         add_action( 'mp_process_send_draft',        array( __CLASS__, 'process' ) );            // for scheduled draft
    92 
    93         add_action( 'wp_ajax_mp_ajax',          array( __CLASS__, 'wp_ajax_mp_ajax' ) );        // for ajax
     91        add_action( 'mp_process_send_draft',        array( __CLASS__, 'process' ) );        // for scheduled draft
     92
     93        add_action( 'wp_ajax_mp_ajax',          array( __CLASS__, 'wp_ajax_mp_ajax' ) );    // for ajax
    9494        add_action( 'wp_ajax_mp_mlinks',        array( __CLASS__, 'mail_link' ) );
    95         add_action( 'wp_ajax_nopriv_mp_mlinks', array( __CLASS__, 'mail_link' ) );
     95        add_action( 'wp_ajax_nopriv_mp_mlinks',     array( __CLASS__, 'mail_link' ) );
    9696
    9797        add_action( 'wp_ajax_mp_cron',          array( __CLASS__, 'mp_cron' ) );
     
    100100        if ( is_admin() )
    101101        {
    102             register_activation_hook( plugin_basename( __FILE__ ),  array( __CLASS__, 'install' ) );    // for install
    103 
    104             add_action( 'admin_init',           array( __CLASS__, 'admin_init' ) );                 // for admin css
    105             add_action( 'admin_menu',           array( __CLASS__, 'admin_menu' ) );                 // for menu
    106 
    107             $in_plugin_update_message = 'in_plugin_update_message-' . MP_FOLDER . '/' . __FILE__;           // for plugin
    108             add_action($in_plugin_update_message,array( __CLASS__, 'in_plugin_update_message' ) );      // * update message
    109             add_filter( 'plugin_action_links',  array( __CLASS__, 'plugin_action_links' ), 10, 2 );     // * page links
    110         }
    111 
    112         add_shortcode( 'mailpress',         array( __CLASS__, 'shortcode' ) );                      // for shortcode
     102            register_activation_hook( plugin_basename( __FILE__ ), array( __CLASS__, 'install' ) ); // for install
     103
     104            add_action( 'admin_init',       array( __CLASS__, 'admin_init' ) );     // for admin css
     105            add_action( 'admin_menu',       array( __CLASS__, 'admin_menu' ) );     // for menu
     106
     107            $in_plugin_update_message = 'in_plugin_update_message-' . MP_FOLDER . '/' . __FILE__;   // for plugin
     108            add_action($in_plugin_update_message,   array( __CLASS__, 'in_plugin_update_message' ) );   // * update message
     109            add_filter( 'plugin_action_links',  array( __CLASS__, 'plugin_action_links' ), 10, 2 ); // * page links
     110        }
     111
     112        add_shortcode( 'mailpress',         array( __CLASS__, 'shortcode' ) );      // for shortcode
    113113
    114114        do_action( 'MailPress_init' );
     
    160160    }
    161161
    162     public static function capabilities()                                       // for roles & capabilities
     162    public static function capabilities()                                   // for roles & capabilities
    163163    {
    164164        include ( MP_ABSPATH . 'mp-admin/includes/capabilities/capabilities.php' );
     
    172172    }
    173173
    174     public static function widgets_init()                                       // for widget
     174    public static function widgets_init()                                   // for widget
    175175    {
    176176        register_widget( 'MP_Widget' );
     
    191191    }
    192192
    193 ////  ADMIN ////
     193//// ADMIN ////
    194194
    195195    static function heartbeat_settings( $settings )
     
    201201    static function is_bot( $HTTP_USER_AGENT = NULL )
    202202    {
    203         $bots_useragent  = array( 'googlebot', 'google', 'bingbot', 'DotBot', '/bot.html', 'msnbot', 'RU_Bot', 'ia_archiver', 'lycos', 'jeeves', 'scooter', 'fast-webcrawler', 'slurp@inktomi', 'turnitinbot', 'technorati', 'yahoo', 'findexa', 'findlinks', 'gaisbo', 'zyborg', 'surveybot', 'bloglines', 'blogsearch', 'ubsub', 'syndic8', 'userland', 'gigabot', 'become.com' );
     203        $bots_useragent = array( 'googlebot', 'google', 'bingbot', 'DotBot', '/bot.html', 'msnbot', 'RU_Bot', 'ia_archiver', 'lycos', 'jeeves', 'scooter', 'fast-webcrawler', 'slurp@inktomi', 'turnitinbot', 'technorati', 'yahoo', 'findexa', 'findlinks', 'gaisbo', 'zyborg', 'surveybot', 'bloglines', 'blogsearch', 'ubsub', 'syndic8', 'userland', 'gigabot', 'become.com' );
    204204        $HTTP_USER_AGENT = $HTTP_USER_AGENT ?? filter_input( INPUT_SERVER, 'HTTP_USER_AGENT' );
    205205        foreach ( $bots_useragent as $bot ) if ( stristr( $HTTP_USER_AGENT, $bot ) !== false ) return true;
     
    211211    public static function install()
    212212    {
    213         $min_ver_wp  = '5.4';
     213        $min_ver_wp = '5.4';
    214214        include ( MP_ABSPATH . 'mp-admin/includes/install/mailpress.php' );
    215215    }
     
    220220    {
    221221    // for global css
    222         $pathcss        = MP_ABSPATH . 'mp-admin/css/colors_' . get_user_option( 'admin_color' ) . '.css';
    223         $css_url        = '/' . MP_PATH . 'mp-admin/css/colors_' . get_user_option( 'admin_color' ) . '.css';
    224         $css_url_default= '/' . MP_PATH . 'mp-admin/css/colors_fresh.css';
    225         $css_url        = ( is_file( $pathcss ) ) ? $css_url : $css_url_default;
     222        $pathcss = MP_ABSPATH . 'mp-admin/css/colors_' . get_user_option( 'admin_color' ) . '.css';
     223        $css_url         = '/' . MP_PATH . 'mp-admin/css/colors_' . get_user_option( 'admin_color' ) . '.css';
     224        $css_url_default = '/' . MP_PATH . 'mp-admin/css/colors_fresh.css';
     225        $css_url = ( is_file( $pathcss ) ) ? $css_url : $css_url_default;
    226226        wp_register_style( 'mailPress_colors',  $css_url );
    227         wp_enqueue_style  ( 'mailPress_colors' );
     227        wp_enqueue_style( 'mailPress_colors' );
    228228
    229229    // for dashboard
     
    270270
    271271        $hub = array (  MailPress_page_mails        => 'mails',
    272                     MailPress_page_write        => 'write',
    273                     MailPress_page_edit         => 'write',
    274                     MailPress_page_revision     => 'revision',
    275                     MailPress_page_themes       => 'themes',
    276                     MailPress_page_settings     => 'settings',
    277                     MailPress_page_users        => 'users',
    278                     MailPress_page_user         => 'user',
    279                     MailPress_page_addons       => 'addons'
     272                MailPress_page_write        => 'write',
     273                MailPress_page_edit         => 'write',
     274                MailPress_page_revision     => 'revision',
     275                MailPress_page_themes       => 'themes',
     276                MailPress_page_settings     => 'settings',
     277                MailPress_page_users        => 'users',
     278                MailPress_page_user         => 'user',
     279                MailPress_page_addons       => 'addons'
    280280         );
    281         $hub  = apply_filters( 'MailPress_load_admin_page', $hub );
     281        $hub = apply_filters( 'MailPress_load_admin_page', $hub );
    282282        if ( !isset( $hub[$admin_page] ) )
    283283        {
     
    349349    {
    350350        static $_widget_id = 0;
    351         $options['widget_id'] = ( isset( $options['widget_id'] ) ) ?  $options['widget_id'] . '_' . $_widget_id : 'mf_' . $_widget_id;
     351        $options['widget_id'] = ( isset( $options['widget_id'] ) ) ? $options['widget_id'] . '_' . $_widget_id : 'mf_' . $_widget_id;
    352352        MP_Widget::widget_form( $options );
    353353        $_widget_id++;
     
    380380    {
    381381        self::$validator = new MP_Swift_EmailValidator();
    382                
    383382        return ( self::$validator->isValid( $email ) ) ? $email : false;
    384383    }
     
    389388        return $x->send( $args );
    390389    }
    391        
     390
    392391    public static function mail_link() //links in mail
    393392    {
    394393        include ( MP_ABSPATH . 'mp-includes/html/mail_link.php' );
    395394    }
    396        
     395
    397396    public static function mp_cron() //wp_cron
    398397    {
  • mailpress/trunk/mp-admin/view_logs.php

    r2054596 r2315761  
    126126            while ( ( $file = readdir( $l ) ) !== false )
    127127            {
    128                 switch ( true )
     128                    switch ( true )
    129129                {
    130130                    case ( $file[0]  == '.' ) :
     
    132132                    case ( strstr( $file, $ftmplt ) ) :
    133133                        $all++;
    134                         if ( isset( $url_parms['s'] ) && ( !strstr( $file, $url_parms['s'] ) ) ) continue;
     134                        if ( isset( $url_parms['s'] ) && ( !strstr( $file, $url_parms['s'] ) ) ) break;
    135135                        $logs[filemtime( "$path/$file" ) . $file] = $file;
    136136                    break;
  • mailpress/trunk/mp-content/add-ons/MailPress_mailinglist.php

    r2270989 r2315761  
    155155                    $_type   = ( isset( $mp_subscriptions['display_mailinglists'][$k] ) ) ? 'checkbox' : '';
    156156
    157                     if ( empty( $_type ) && empty( $checked ) ) continue;
     157                    if ( empty( $_type ) && empty( $checked ) ) break;
    158158                    if ( empty( $_type ) )
    159159                    {
     
    170170                break;
    171171                case 'select' :
    172                     if ( !isset( $mp_subscriptions['display_mailinglists'][$k] ) ) continue;
     172                    if ( !isset( $mp_subscriptions['display_mailinglists'][$k] ) ) break;
    173173
    174174                    if ( $show_option_all )
  • mailpress/trunk/mp-includes/class/MP_Mail.class.php

    r2302714 r2315761  
    782782                            case 'bcc' :
    783783                            case 'reply_to' :
    784                                 if ( !isset( $hfunc[$k] ) ) continue;
     784                                if ( !isset( $hfunc[$k] ) ) break;
    785785                                $func = $hfunc[$k];
    786786                                foreach( $v as $toemail => $toname )
  • mailpress/trunk/mp-includes/class/MP_Themes.class.php

    r2001492 r2315761  
    413413            while ( ( $theme_dir = readdir( $themes_dir ) ) !== false ) {
    414414                if ( is_dir( $theme_root . '/' . $theme_dir ) && is_readable( $theme_root . '/' . $theme_dir ) ) {
    415                     if ( $theme_dir{0} == '.' || $theme_dir == 'CVS' )
     415                    if ( substr( $theme_dir, 0, 1 ) == '.' || $theme_dir == 'CVS' )
    416416                        continue;
    417417
     
    436436                        while ( ( $theme_subdir = readdir( $theme_subdirs ) ) !== false ) {
    437437                            if ( is_dir( $subdir . '/' . $theme_dir ) && is_readable( $subdir . '/' . $theme_dir ) ) {
    438                                 if ( $theme_dir{0} == '.' || $theme_dir == 'CVS' )
     438                                if ( substr( $theme_dir, 0, 1 ) == '.' || $theme_dir == 'CVS' )
    439439                                    continue;
    440440
  • mailpress/trunk/mp-includes/class/options/dashboard/widgets/_right_now.php

    r2047720 r2315761  
    7878        </table>
    7979    </div>
     80<?php $this->add_ons(); ?>
    8081</div>
    8182</div>
    8283<?php
    8384    }
     85
     86    function add_ons()
     87    {
     88        $addons = MP_Addons::get_all();
     89        $out = array();
     90        foreach( $addons as $addon )
     91        {
     92            if ( !$addon['active'] ) continue;
     93       
     94            $haystack = $addon['Name'];
     95            $needle   = 'MailPress_';
     96            if ( strpos( $haystack, $needle ) === 0 )
     97            {
     98                $haystack = substr( $haystack, strlen( $needle ) );
     99                $haystack = ucfirst( $haystack );
     100                $out[] = $haystack;
     101            }
     102        }
     103        if ( !empty( $out ) )
     104        {
     105            echo '<div id="add-ons"><br /><hr />' . __( 'With following add-ons :', 'MailPress' ) . '<br />' . implode( ', ', $out ) . '</div>';
     106        }
     107    }
    84108}
    85109new MP_Dashboard__right_now( __( "MailPress - 'Right Now'", 'MailPress' ) );
  • mailpress/trunk/mp-load.php

    r2001482 r2315761  
    6464define ( 'MP_UPL_ABSPATH',  untrailingslashit( $ubd ) . '/mailpress/' );
    6565define ( 'MP_UPL_URL',  untrailingslashit( $ubu ) . '/mailpress/' );
    66 define ( 'MP_UPL_PATH', str_replace( trailingslashit(  get_option( 'siteurl' ) ), '', MP_UPL_URL ) );
    67 //$paths = array('MP_ABSPATH' =>MP_ABSPATH,'MP_FOLDER' =>MP_FOLDER,'MP_PATH' =>MP_PATH,'MP_CONTENT_FOLDER' =>MP_CONTENT_FOLDER,'MP_CONTENT_DIR' =>MP_CONTENT_DIR,'MP_PATH_CONTENT' =>MP_PATH_CONTENT,'MP_UPL_ABSPATH' =>MP_UPL_ABSPATH,'MP_UPL_PATH' =>MP_UPL_PATH,'MP_UPL_URL' =>MP_UPL_URL,);print_r($paths);
     66define ( 'MP_UPL_PATH', str_replace( trailingslashit( get_option( 'siteurl' ) ), '', MP_UPL_URL ) );
    6867
    6968// 2.
  • mailpress/trunk/uninstall.php

    r2001482 r2315761  
    2222        foreach( $taxonomies as $taxonomy )
    2323        {
    24             $queries[] = "DELETE FROM $wpdb->terms              WHERE term_id IN ( SELECT term_id FROM $wpdb->term_taxonomy WHERE taxonomy = '$taxonomy' );";
     24            $queries[] = "DELETE FROM $wpdb->terms WHERE term_id IN ( SELECT term_id FROM $wpdb->term_taxonomy WHERE taxonomy = '$taxonomy' );";
    2525            $queries[] = "DELETE FROM $wpdb->term_relationships WHERE term_taxonomy_id IN ( SELECT term_id FROM $wpdb->term_taxonomy WHERE taxonomy = '$taxonomy' );";
    2626            $queries[] = "DELETE FROM $wpdb->term_taxonomy WHERE taxonomy = '$taxonomy';";
Note: See TracChangeset for help on using the changeset viewer.