Plugin Directory

Changeset 1908589


Ignore:
Timestamp:
07/13/2018 07:27:17 AM (8 years ago)
Author:
perfect-web-support
Message:

Version 1.18

Location:
perfectdashboard/trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • perfectdashboard/trunk/Cms/Wordpress/Api.php

    r1883279 r1908589  
    2929        }
    3030
     31        // set the en_US as a default
     32        load_default_textdomain('en_US');
     33
    3134        if (!AutoUpdater_Config::get('ssl_verify', 0))
    3235        {
  • perfectdashboard/trunk/Cms/Wordpress/Task/GetExtensions.php

    r1883279 r1908589  
    77class AutoUpdater_Cms_Wordpress_Task_GetExtensions extends AutoUpdater_Task_GetExtensions
    88{
    9     protected $servers          = array();
    10     protected $request_defaults = array();
    11     protected $current_theme    = '';
     9    protected $current_theme = '';
    1210
    1311    /**
     
    183181        $pagenow = 'update-core.php';
    184182
    185         $this->request_defaults = array(
    186             'method'              => 'GET',
    187             'timeout'             => apply_filters('http_request_timeout', 5),
    188             'redirection'         => apply_filters('http_request_redirection_count', 5),
    189             '_redirection'        => apply_filters('http_request_redirection_count', 5),
    190             'httpversion'         => apply_filters('http_request_version', '1.0'),
    191             'user-agent'          => apply_filters('http_headers_useragent',
    192                 'WordPress/' . AUTOUPDATER_WP_VERSION . '; ' . get_bloginfo('url')),
    193             'reject_unsafe_urls'  => apply_filters('http_request_reject_unsafe_urls', false),
    194             'blocking'            => true,
    195             'compress'            => false,
    196             'decompress'          => true,
    197             'sslverify'           => true,
    198             'sslcertificates'     => ABSPATH . WPINC . '/certificates/ca-bundle.crt',
    199             'stream'              => false,
    200             'filename'            => null,
    201             'limit_response_size' => null,
    202         );
     183        require_once AUTOUPDATER_WP_PLUGIN_PATH . 'Cms/Wordpress/Helper/Tracker.php';
     184        AutoUpdater_Cms_Wordpress_Helper_Tracker::initDefaults();
    203185
    204186        // catch updateservers
    205         add_filter('pre_http_request', array($this, 'catchRequest'), 11, 3);
     187        add_filter('pre_http_request', 'AutoUpdater_Cms_Wordpress_Helper_Tracker::trackRequest', 11, 3);
    206188
    207189        // delete cached data with updates
     
    359341            'success'        => true,
    360342            'updates'        => $updates,
    361             'update_servers' => $this->servers,
    362         );
    363     }
    364 
    365     /**
    366      * @param bool   $preempt
    367      * @param array  $request
    368      * @param string $url
    369      *
    370      * @return bool
    371      */
    372     public function catchRequest($preempt = false, $request = array(), $url = '')
    373     {
    374         // Cactch only commercial update servers for plugins and themes not present at the official WordPress repository
    375         if (!empty($url) && strpos($url, '://api.wordpress.org/') === false)
    376         {
    377             $data      = array_merge(array('url' => $url), $request);
    378             $cache_key = md5(serialize($data));
    379             if (!isset($this->servers[$cache_key]))
    380             {
    381                 // Remove defaults
    382                 foreach ($data as $key => $item)
    383                 {
    384                     if (isset($this->request_defaults[$key]))
    385                     {
    386                         if ($this->request_defaults[$key] === $item)
    387                         {
    388                             unset($data[$key]);
    389                         }
    390                     }
    391                     elseif (empty($item))
    392                     {
    393                         unset($data[$key]);
    394                     }
    395                 }
    396 
    397                 // Change the certificates path to relative
    398                 if (!empty($data['sslcertificates']))
    399                 {
    400                     $data['sslcertificates'] = str_replace(ABSPATH, '', $data['sslcertificates']);
    401                 }
    402 
    403                 $this->servers[$cache_key] = $data;
    404             }
    405         }
    406 
    407         return $preempt;
     343            'update_servers' => AutoUpdater_Cms_Wordpress_Helper_Tracker::getCachedRequests(),
     344        );
    408345    }
    409346
  • perfectdashboard/trunk/Cms/Wordpress/Task/PostExtensionUpdate.php

    r1883279 r1908589  
    3535        }
    3636
    37         $upgrader_path = dirname(dirname(__FILE__)) . '/Upgrader/';
     37        $upgrader_path = AUTOUPDATER_WP_PLUGIN_PATH . 'Cms/Wordpress/Upgrader/';
    3838        require_once $upgrader_path . 'Dependencies.php';
     39        require_once AUTOUPDATER_WP_PLUGIN_PATH . 'Cms/Wordpress/Helper/Tracker.php';
    3940
    4041        switch ($type)
     
    8586                    new AutoUpdater_Cms_Wordpress_Upgrader_Skin_Core());
    8687                $result   = $upgrader->upgrade($update, array('pre_check_md5' => false));
    87                 ob_end_clean();
     88                $output   = ob_get_clean();
    8889
    8990                // returns string with a new version or null on success
     
    106107                require_once $upgrader_path . 'Skin/Plugin.php';
    107108
     109                $data             = get_file_data(WP_PLUGIN_DIR . '/' . $slug, array('Version' => 'Version'));
     110                $old_version      = $data['Version'];
     111                $expected_version = $this->input('version');
     112
    108113                if ($path)
    109114                {
     
    117122                    $nonce  = 'upgrade-plugin_' . $plugin;
    118123                    $url    = 'update.php?action=upgrade-plugin&plugin=' . urlencode($plugin);
     124
     125                    $this->logInAdmin();
     126                    AutoUpdater_Cms_Wordpress_Helper_Tracker::initDefaults();
     127                    add_filter('pre_http_request', 'AutoUpdater_Cms_Wordpress_Helper_Tracker::trackRequest', 11, 3);
    119128                }
    120129
     
    125134                    ));
    126135                $result   = $path ? $upgrader->install($path) : $upgrader->upgrade($slug);
    127                 ob_end_clean();
     136                $output   = ob_get_clean();
     137
     138                $data        = get_file_data(WP_PLUGIN_DIR . '/' . $slug, array('Version' => 'Version'));
     139                $new_version = $data['Version'];
    128140                break;
    129141
     
    133145                require_once $upgrader_path . 'Theme.php';
    134146                require_once $upgrader_path . 'Skin/Theme.php';
     147
     148                $data             = get_file_data(WP_CONTENT_DIR . '/themes/' . $slug, array('Version' => 'Version'));
     149                $old_version      = $data['Version'];
     150                $expected_version = $this->input('version');
    135151
    136152                if ($path)
     
    145161                    $nonce = 'upgrade-theme_' . $theme;
    146162                    $url   = 'update.php?action=upgrade-theme&theme=' . urlencode($theme);;
     163
     164                    $this->logInAdmin();
     165                    AutoUpdater_Cms_Wordpress_Helper_Tracker::initDefaults();
     166                    add_filter('pre_http_request', 'AutoUpdater_Cms_Wordpress_Helper_Tracker::trackRequest', 11, 3);
    147167                }
    148168
     
    153173                    ));
    154174                $result   = $path ? $upgrader->install($path) : $upgrader->upgrade($slug);
    155                 ob_end_clean();
     175                $output   = ob_get_clean();
     176
     177                $data        = get_file_data(WP_CONTENT_DIR . '/themes/' . $slug, array('Version' => 'Version'));
     178                $new_version = $data['Version'];
    156179                break;
    157180
     
    174197                        ));
    175198                    $result   = $upgrader->bulk_upgrade();
    176                     ob_end_clean();
     199                    $output   = ob_get_clean();
    177200
    178201                    // returns an array of results on success, or true if there are no updates
     
    181204                        $result = true;
    182205                    }
     206                    elseif ($result === true)
     207                    {
     208                        $result = new WP_Error('up_to_date', 'There are no translations updates');
     209                    }
    183210                }
    184211                else
     
    190217        $filemanager->clearPhpCache();
    191218
    192         if ($result === true || is_null($result))
     219        $errors = isset($upgrader) ? $upgrader->skin->get_errors() : array();
     220        if (is_wp_error($result))
     221        {
     222            /** @var WP_Error $result */
     223            $errors[$result->get_error_code()] = $result->get_error_message();
     224            $result                            = false;
     225        }
     226
     227        if (array_key_exists('up_to_date', $errors) &&
     228            (!isset($expected_version, $new_version) || $expected_version && version_compare($expected_version, $new_version, '<=')))
    193229        {
    194230            return array(
    195231                'success' => true,
    196             );
    197         }
    198         elseif (is_wp_error($result))
    199         {
    200             /** @var WP_Error $result */
     232                'message' => $errors['up_to_date'] != 'up_to_date' ? $errors['up_to_date'] : 'Up-to-date'
     233            );
     234        }
     235        elseif (array_key_exists('no_package', $errors))
     236        {
     237            $result            = false;
    201238            $response['error'] = array(
    202                 'code'    => $result->get_error_code(),
    203                 'message' => $result->get_error_message(),
    204             );
    205 
    206             if ($response['error']['code'] == 'up_to_date')
    207             {
    208                 return array(
    209                     'success' => true,
    210                     'message' => 'Up to date',
    211                 );
    212             }
    213         }
    214         elseif ($result === false)
    215         {
    216             $errors = $upgrader->skin->get_errors();
    217             if (array_search('up_to_date', $errors))
    218             {
    219                 return array(
    220                     'success' => true,
    221                     'message' => 'Up to date',
    222                 );
    223             }
    224 
     239                'code'    => 'no_package_warning',
     240                'message' => $errors['no_package']
     241            );
     242            unset($errors['no_package']);
     243        }
     244        elseif (isset($old_version, $new_version) && version_compare($old_version, $new_version, '='))
     245        {
     246            $result            = false;
    225247            $response['error'] = array(
    226                 'code'    => 'update_failed',
    227                 'message' => array_shift($errors),
    228             );
    229 
    230             if (count($errors) > 0)
    231             {
    232                 $response['error']['messages'] = $errors;
    233             }
     248                'code'    => 'no_update_warning',
     249                'message' => 'No update was performed, current version ' . $new_version . ' remains'
     250            );
     251        }
     252
     253        if ($result === true || is_null($result))
     254        {
     255            return array(
     256                'success' => true,
     257            );
    234258        }
    235259        elseif (!is_null($result) && !is_bool($result))
    236260        {
    237261            $response['error'] = array(
    238                 'code'    => 'unknown',
    239                 'message' => var_export($result, true),
    240             );
     262                'code'    => 'unknown_error',
     263                'message' => 'Dump: ' . var_export($result, true)
     264            );
     265        }
     266
     267        if (count($errors))
     268        {
     269            $response['errors'] = $errors;
     270        }
     271
     272        if (!empty($output))
     273        {
     274            AutoUpdater_Log::debug('Updater output: ' . $output);
     275        }
     276
     277        if ($requests = AutoUpdater_Cms_Wordpress_Helper_Tracker::getCachedRequests())
     278        {
     279            AutoUpdater_Log::debug('Updater requests: ' . print_r($requests, true));
    241280        }
    242281
    243282        return $response;
    244283    }
     284
     285    /**
     286     * @return bool
     287     */
     288    protected function logInAdmin()
     289    {
     290        $users = get_users(array('role' => 'administrator', 'number' => 1));
     291        if (!empty($users[0]->ID))
     292        {
     293            require_once ABSPATH . 'wp-includes/pluggable.php';
     294            wp_set_current_user($users[0]->ID);
     295        }
     296
     297        return is_user_logged_in();
     298    }
    245299}
  • perfectdashboard/trunk/Cms/Wordpress/Upgrader/Skin/Core.php

    r1883279 r1908589  
    3939        if (is_string($errors))
    4040        {
    41             $this->errors[] = $errors;
     41            $this->errors[$errors] = $message = $errors;
    4242        }
    4343        elseif (is_wp_error($errors))
    4444        {
    4545            /** @var WP_Error $errors */
    46             $this->errors[] = 'Code: ' . $errors->get_error_code() . ' Message: ' . $errors->get_error_message();
     46            $message = 'Error code: ' . $errors->get_error_code() . ', message: ' . $errors->get_error_message();
     47
     48            $this->errors[$errors->get_error_code()] = $errors->get_error_message();
    4749        }
    4850        else
    4951        {
    50             $this->errors[] = var_export($errors, true);
     52            $error   = var_export($errors, true);
     53            $message = 'Unknown error, dump: ' . $error;
     54
     55            $this->errors['unknown_error'] = $error;
    5156        }
     57
     58        AutoUpdater_Log::debug($message);
    5259    }
    5360
  • perfectdashboard/trunk/Cms/Wordpress/Upgrader/Skin/Languagepack.php

    r1883279 r1908589  
    3939        if (is_string($errors))
    4040        {
    41             $this->errors[] = $errors;
     41            $this->errors[$errors] = $message = $errors;
    4242        }
    4343        elseif (is_wp_error($errors))
    4444        {
    4545            /** @var WP_Error $errors */
    46             $this->errors[] = 'Code: ' . $errors->get_error_code() . ' Message: ' . $errors->get_error_message();
     46            $message = 'Error code: ' . $errors->get_error_code() . ', message: ' . $errors->get_error_message();
     47
     48            $this->errors[$errors->get_error_code()] = $errors->get_error_message();
    4749        }
    4850        else
    4951        {
    50             $this->errors[] = var_export($errors, true);
     52            $error   = var_export($errors, true);
     53            $message = 'Unknown error, dump: ' . $error;
     54
     55            $this->errors['unknown_error'] = $error;
    5156        }
     57
     58        AutoUpdater_Log::debug($message);
    5259    }
    5360
  • perfectdashboard/trunk/Cms/Wordpress/Upgrader/Skin/Plugin.php

    r1883279 r1908589  
    3939        if (is_string($errors))
    4040        {
    41             $this->errors[] = $errors;
     41            $this->errors[$errors] = $message = $errors;
    4242        }
    4343        elseif (is_wp_error($errors))
    4444        {
    4545            /** @var WP_Error $errors */
    46             $this->errors[] = 'Code: ' . $errors->get_error_code() . ' Message: ' . $errors->get_error_message();
     46            $message = 'Error code: ' . $errors->get_error_code() . ', message: ' . $errors->get_error_message();
     47
     48            $this->errors[$errors->get_error_code()] = $errors->get_error_message();
    4749        }
    4850        else
    4951        {
    50             $this->errors[] = var_export($errors, true);
     52            $error   = var_export($errors, true);
     53            $message = 'Unknown error, dump: ' . $error;
     54
     55            $this->errors['unknown_error'] = $error;
    5156        }
     57
     58        AutoUpdater_Log::debug($message);
    5259    }
    5360
  • perfectdashboard/trunk/Cms/Wordpress/Upgrader/Skin/Theme.php

    r1883279 r1908589  
    3939        if (is_string($errors))
    4040        {
    41             $this->errors[] = $errors;
     41            $this->errors[$errors] = $message = $errors;
    4242        }
    4343        elseif (is_wp_error($errors))
    4444        {
    4545            /** @var WP_Error $errors */
    46             $this->errors[] = 'Code: ' . $errors->get_error_code() . ' Message: ' . $errors->get_error_message();
     46            $message = 'Error code: ' . $errors->get_error_code() . ', message: ' . $errors->get_error_message();
     47
     48            $this->errors[$errors->get_error_code()] = $errors->get_error_message();
    4749        }
    4850        else
    4951        {
    50             $this->errors[] = var_export($errors, true);
     52            $error   = var_export($errors, true);
     53            $message = 'Unknown error, dump: ' . $error;
     54
     55            $this->errors['unknown_error'] = $error;
    5156        }
     57
     58        AutoUpdater_Log::debug($message);
    5259    }
    5360
  • perfectdashboard/trunk/app/Admin.php

    r1883279 r1908589  
    115115            $update_themes                  = AutoUpdater_Config::get('update_themes', 0);
    116116            $excluded_themes_unprepared     = AutoUpdater_Config::get('excluded_themes');
    117             $time_of_day                    = AutoUpdater_Config::get('time_of_day', 1);
     117            $time_of_day                    = AutoUpdater_Config::get('time_of_day', 'night');
    118118            $notification_end_user_email    = AutoUpdater_Config::get('notification_end_user_email');
     119            $notification_on_success        = AutoUpdater_Config::get('notification_on_success', 1);
     120            $notification_on_failure        = AutoUpdater_Config::get('notification_on_failure', 1);
    119121
    120122            $excluded_extensions = array();
     
    318320                'time_of_day'                 => isset($_POST['time_of_day']) ? $_POST['time_of_day'] : 'night',
    319321                'notification_end_user_email' => isset($_POST['notification_end_user_email']) ? $_POST['notification_end_user_email'] : '',
     322                'notification_on_success'     => isset($_POST['notification_on_success']) ? $_POST['notification_on_success'] : 1,
     323                'notification_on_failure'     => isset($_POST['notification_on_failure']) ? $_POST['notification_on_failure'] : 1,
    320324            );
    321325        }
  • perfectdashboard/trunk/lib/src/Config.php

    r1883279 r1908589  
    284284        }
    285285
     286        if (isset($settings->notification_on_success))
     287        {
     288            $this->setOption('notification_on_success', (int) $settings->notification_on_success);
     289        }
     290        if (isset($settings-> notification_on_failure))
     291        {
     292            $this->setOption('notification_on_failure', (int) $settings->notification_on_failure);
     293        }
    286294
    287295        // Notifications in CMS dashboard
     
    406414                $settings['notification_end_user_email'] = (string) $data['notification_end_user_email'];
    407415                if ((string) $this->getOption('notification_end_user_email') !== $settings['notification_end_user_email'])
     416                {
     417                    $changed = true;
     418                }
     419            }
     420            if (array_key_exists('notification_on_success', $data))
     421            {
     422                $settings['notification_on_success'] = (int) $data['notification_on_success'];
     423                if ((int) $this->getOption('notification_on_success') !== $settings['notification_on_success'])
     424                {
     425                    $changed = true;
     426                }
     427            }
     428            if (array_key_exists('notification_on_failure', $data))
     429            {
     430                $settings['notification_on_failure'] = (int) $data['notification_on_failure'];
     431                if ((int) $this->getOption('notification_on_failure') !== $settings['notification_on_failure'])
    408432                {
    409433                    $changed = true;
  • perfectdashboard/trunk/perfectdashboard.php

    r1883279 r1908589  
    44 * Plugin URI: https://perfectdashboard.com/?utm_source=backend&utm_medium=installer&utm_campaign=in&utm_term=WP
    55 * Description:
    6  * Version: 1.17.0
     6 * Version: 1.18.0
    77 * Text Domain: autoupdater
    88 * Author: Perfect Dashboard
     
    3232    version_compare(PHP_VERSION, '5.3', '>='))
    3333{
    34     $data = get_plugin_data(__FILE__, false, false);
     34    $data = get_file_data(__FILE__, array('Version' => 'Version'));
    3535
    3636    define('AUTOUPDATER_WP_PLUGIN_NAME', 'Perfect Dashboard');
  • perfectdashboard/trunk/readme.txt

    r1883279 r1908589  
    55Requires at least: 3.0
    66Tested up to: 4.9.6
    7 Stable tag: 1.17.0
     7Stable tag: 1.18.0
    88License: GNU/GPL
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
  • perfectdashboard/trunk/tmpl/configuration_form_autoupdater_fields.tmpl.php

    r1883281 r1908589  
    180180        </td>
    181181    </tr>
     182    <tr>
     183        <th scope="row">
     184            <label><?php _e('Notification on successful update', 'autoupdater') ?></label>
     185        </th>
     186        <td>
     187            <label>
     188                <input type="radio" name="notification_on_success" value="0" <?php if (!$notification_on_success) echo 'checked="checked"'; ?>>
     189                <?php _e('No') ?>
     190            </label>
     191            <label>
     192                <input type="radio" name="notification_on_success" value="1" <?php if ($notification_on_success) echo 'checked="checked"'; ?>>
     193                <?php _e('Yes') ?>
     194            </label>
     195            <p class="description">
     196                <?php _e('Receive a notification after a successful update', 'autoupdater') ?>
     197            </p>
     198        </td>
     199    </tr>
     200    <tr>
     201        <th scope="row">
     202            <label><?php _e('Notification on failed update', 'autoupdater') ?></label>
     203        </th>
     204        <td>
     205            <label>
     206                <input type="radio" name="notification_on_failure" value="0" <?php if (!$notification_on_failure) echo 'checked="checked"'; ?>>
     207                <?php _e('No') ?>
     208            </label>
     209            <label>
     210                <input type="radio" name="notification_on_failure" value="1" <?php if ($notification_on_failure) echo 'checked="checked"'; ?>>
     211                <?php _e('Yes') ?>
     212            </label>
     213            <p class="description">
     214                <?php _e('Receive a notification after a failed update', 'autoupdater') ?>
     215            </p>
     216        </td>
     217    </tr>
    182218    </tbody>
    183219</table>
Note: See TracChangeset for help on using the changeset viewer.