当前位置: 首页>>代码示例>>PHP>>正文


PHP MainWP_Utility::getWPFilesystem方法代码示例

本文整理汇总了PHP中MainWP_Utility::getWPFilesystem方法的典型用法代码示例。如果您正苦于以下问题:PHP MainWP_Utility::getWPFilesystem方法的具体用法?PHP MainWP_Utility::getWPFilesystem怎么用?PHP MainWP_Utility::getWPFilesystem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MainWP_Utility的用法示例。


在下文中一共展示了MainWP_Utility::getWPFilesystem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: trashExtension

 public static function trashExtension()
 {
     ob_start();
     $slug = $_POST['slug'];
     include_once ABSPATH . '/wp-admin/includes/plugin.php';
     $thePlugin = get_plugin_data($slug);
     if ($thePlugin != null && $thePlugin != '') {
         deactivate_plugins($slug);
     }
     if (file_exists(ABSPATH . '/wp-admin/includes/screen.php')) {
         include_once ABSPATH . '/wp-admin/includes/screen.php';
     }
     include_once ABSPATH . '/wp-admin/includes/file.php';
     include_once ABSPATH . '/wp-admin/includes/template.php';
     include_once ABSPATH . '/wp-admin/includes/misc.php';
     include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
     include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php';
     include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php';
     MainWP_Utility::getWPFilesystem();
     /** @global WP_Filesystem_Base $wp_filesystem */
     global $wp_filesystem;
     if (empty($wp_filesystem)) {
         $wp_filesystem = new WP_Filesystem_Direct(null);
     }
     $pluginUpgrader = new Plugin_Upgrader();
     $thePlugin = get_plugin_data($slug);
     if ($thePlugin != null && $thePlugin != '') {
         $pluginUpgrader->delete_old_plugin(null, null, null, array('plugin' => $slug));
     }
     ob_end_clean();
     die(json_encode(array('result' => 'SUCCESS')));
 }
开发者ID:jexmex,项目名称:mainwp,代码行数:32,代码来源:page-mainwp-extensions.php

示例2: checkDirectoryMainWPDirectory

 protected static function checkDirectoryMainWPDirectory()
 {
     $dirs = MainWP_Utility::getMainWPDir();
     $path = $dirs[0];
     if (!is_dir(dirname($path))) {
         //return self::renderDirectoryRow('MainWP upload directory', $path, 'Writable', 'Directory not found', false);
         return self::renderDirectoryRow('MainWP Upload Directory', 'Writable', 'Not Found', false, self::ERROR);
     }
     $hasWPFileSystem = MainWP_Utility::getWPFilesystem();
     /** @global WP_Filesystem_Base $wp_filesystem */
     global $wp_filesystem;
     if ($hasWPFileSystem && !empty($wp_filesystem)) {
         if (!$wp_filesystem->is_writable($path)) {
             //return self::renderDirectoryRow('MainWP upload directory', $path, 'Writable', 'Directory not writable', false);
             return self::renderDirectoryRow('MainWP Upload Directory', 'Writable', 'Not Writable', false, self::ERROR);
         }
     } else {
         if (!is_writable($path)) {
             //return self::renderDirectoryRow('MainWP upload directory', $path, 'Writable', 'Directory not writable', false);
             return self::renderDirectoryRow('MainWP Upload Directory', 'Writable', 'Not Writable', false, self::ERROR);
         }
     }
     //return self::renderDirectoryRow('MainWP upload directory', $path, 'Writable', '/', true);
     return self::renderDirectoryRow('MainWP Upload Directory', 'Writable', 'Writable', true, self::ERROR);
 }
开发者ID:jexmex,项目名称:mainwp,代码行数:25,代码来源:page-mainwp-server-information.php

示例3: installPlugin

 public static function installPlugin($url, $activatePlugin = false)
 {
     $hasWPFileSystem = MainWP_Utility::getWPFilesystem();
     /** @global WP_Filesystem_Base $wp_filesystem */
     global $wp_filesystem;
     if (file_exists(ABSPATH . '/wp-admin/includes/screen.php')) {
         include_once ABSPATH . '/wp-admin/includes/screen.php';
     }
     include_once ABSPATH . '/wp-admin/includes/template.php';
     include_once ABSPATH . '/wp-admin/includes/misc.php';
     include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
     include_once ABSPATH . '/wp-admin/includes/plugin.php';
     $installer = new WP_Upgrader();
     $ssl_verifyhost = get_option('mainwp_sslVerifyCertificate');
     $ssl_api_verifyhost = get_option('mainwp_api_sslVerifyCertificate') === false || get_option('mainwp_api_sslVerifyCertificate') == 1 ? 1 : 0;
     if ($ssl_verifyhost === '0' || $ssl_api_verifyhost == 0) {
         add_filter('http_request_args', array(MainWP_Extensions::getClassName(), 'noSSLFilterFunction'), 99, 2);
     }
     add_filter('http_request_args', array(MainWP_Extensions::getClassName(), 'http_request_reject_unsafe_urls'), 99, 2);
     $result = $installer->run(array('package' => $url, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => false, 'clear_working' => true, 'hook_extra' => array()));
     remove_filter('http_request_args', array(MainWP_Extensions::getClassName(), 'http_request_reject_unsafe_urls'), 99, 2);
     if ($ssl_verifyhost === '0') {
         remove_filter('http_request_args', array(MainWP_Extensions::getClassName(), 'noSSLFilterFunction'), 99);
     }
     if (is_wp_error($result)) {
         if ($result->get_error_data() && is_string($result->get_error_data())) {
             $error = $result->get_error_data();
             MainWP_Helper::error($error);
         } else {
             $error = $result->get_error_code();
             MainWP_Helper::error(implode(', ', $error));
         }
     }
     $error = $output = $plugin_slug = null;
     if (is_wp_error($result)) {
         if ($result->get_error_data() && is_string($result->get_error_data())) {
             $error = $result->get_error_data();
         } else {
             $error = $result->get_error_code();
         }
     } else {
         $path = $result['destination'];
         foreach ($result['source_files'] as $srcFile) {
             // to fix bug
             if ($srcFile == 'readme.txt') {
                 continue;
             }
             $thePlugin = get_plugin_data($path . $srcFile);
             if ($thePlugin != null && $thePlugin != '' && $thePlugin['Name'] != '') {
                 $output .= __('Successfully installed the plugin', 'mainwp') . ' ' . $thePlugin['Name'] . ' ' . $thePlugin['Version'];
                 $plugin_slug = $result['destination_name'] . '/' . $srcFile;
                 if ($activatePlugin) {
                     activate_plugin($path . $srcFile, '', false, true);
                     do_action('mainwp_api_extension_activated', $path . $srcFile);
                 }
                 break;
             }
         }
     }
     if (!empty($error)) {
         $return['error'] = $error;
     } else {
         $return['result'] = 'SUCCESS';
         $return['output'] = $output;
         $return['slug'] = $plugin_slug;
     }
     return $return;
 }
开发者ID:reeslo,项目名称:mainwp,代码行数:68,代码来源:page-mainwp-extensions.php

示例4: save

 /**
  * Save the file to the specified path
  * @return boolean TRUE on success
  */
 function save($path)
 {
     $wpFileSystem = MainWP_Utility::getWPFilesystem();
     if ($wpFileSystem != null) {
         $path = str_replace(MainWP_Utility::getBaseDir(), '', $path);
         $moved = $wpFileSystem->put_contents($path, file_get_contents($_FILES['qqfile']['tmp_name']));
     } else {
         $moved = move_uploaded_file($_FILES['qqfile']['tmp_name'], $path);
     }
     if (!$moved) {
         return false;
     }
     return true;
 }
开发者ID:reeslo,项目名称:mainwp,代码行数:18,代码来源:page-mainwp-install-bulk.php


注:本文中的MainWP_Utility::getWPFilesystem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。