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


PHP UpdraftPlus_Options::options_table方法代码示例

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


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

示例1: restored_table

 private function restored_table($table, $import_table_prefix, $old_table_prefix)
 {
     global $wpdb, $updraftplus;
     if ($table == $import_table_prefix . UpdraftPlus_Options::options_table()) {
         $this->restore_configuration_bundle($table);
     }
     if (preg_match('/^([\\d+]_)?options$/', substr($table, strlen($import_table_prefix)), $matches)) {
         if ($this->is_multisite && !empty($matches[1]) || !$this->is_multisite && $table == $import_table_prefix . 'options') {
             $mprefix = empty($matches[1]) ? '' : $matches[1];
             $new_table_name = $import_table_prefix . $mprefix . "options";
             // WordPress has an option name predicated upon the table prefix. Yuk.
             if ($import_table_prefix != $old_table_prefix) {
                 $updraftplus->log("Table prefix has changed: changing options table field(s) accordingly (" . $mprefix . "options)");
                 echo sprintf(__('Table prefix has changed: changing %s table field(s) accordingly:', 'updraftplus'), 'option') . ' ';
                 if (false === $wpdb->query("UPDATE {$new_table_name} SET option_name='{$import_table_prefix}" . $mprefix . "user_roles' WHERE option_name='{$old_table_prefix}" . $mprefix . "user_roles' LIMIT 1")) {
                     echo __('Error', 'updraftplus');
                     $updraftplus->log("Error when changing options table fields: " . $wpdb->last_error);
                 } else {
                     $updraftplus->log("Options table fields changed OK");
                     echo __('OK', 'updraftplus');
                 }
                 echo '<br>';
             }
             // Now deal with the situation where the imported database sets a new over-ride upload_path that is absolute - which may not be wanted
             $new_upload_path = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM {$import_table_prefix}" . $mprefix . "options WHERE option_name = %s LIMIT 1", 'upload_path'));
             $new_upload_path = is_object($new_upload_path) ? $new_upload_path->option_value : '';
             // The danger situation is absolute and points somewhere that is now perhaps not accessible at all
             if (!empty($new_upload_path) && $new_upload_path != $this->prior_upload_path && strpos($new_upload_path, '/') === 0 || preg_match('#^[A-Za-z]:[/\\\\]#', $new_upload_path)) {
                 // $this->old_siteurl != untrailingslashit(site_url()) is not a perfect proxy for "is a migration" (other possibilities exist), but since the upload_path option should not exist since WP 3.5 anyway, the chances of other possibilities are vanishingly small
                 if (!file_exists($new_upload_path) || $this->old_siteurl != $this->our_siteurl) {
                     if (!file_exists($new_upload_path)) {
                         $updraftplus->log_e("Uploads path (%s) does not exist - resetting (%s)", $new_upload_path, $this->prior_upload_path);
                     } else {
                         $updraftplus->log_e("Uploads path (%s) has changed during a migration - resetting (to: %s)", $new_upload_path, $this->prior_upload_path);
                     }
                     if (false === $wpdb->query("UPDATE {$import_table_prefix}" . $mprefix . "options SET option_value='" . esc_sql($this->prior_upload_path) . "' WHERE option_name='upload_path' LIMIT 1")) {
                         echo __('Error', 'updraftplus');
                         $updraftplus->log("Error when changing upload path: " . $wpdb->last_error);
                         $updraftplus->log("Failed");
                     }
                     #update_option('upload_path', $this->prior_upload_path);
                 }
             }
             # TODO:Do on all WPMU tables
             if ($table == $import_table_prefix . 'options') {
                 # Bad plugin that hard-codes path references - https://wordpress.org/plugins/custom-content-type-manager/
                 $cctm_data = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM {$new_table_name} WHERE option_name = %s LIMIT 1", 'cctm_data'));
                 if (!empty($cctm_data->option_value)) {
                     $cctm_data = maybe_unserialize($cctm_data->option_value);
                     if (is_array($cctm_data) && !empty($cctm_data['cache']) && is_array($cctm_data['cache'])) {
                         $cctm_data['cache'] = array();
                         $updraftplus->log_e("Custom content type manager plugin data detected: clearing option cache");
                         update_option('cctm_data', $cctm_data);
                     }
                 }
                 # Another - http://www.elegantthemes.com/gallery/elegant-builder/
                 $elegant_data = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM {$new_table_name} WHERE option_name = %s LIMIT 1", 'et_images_temp_folder'));
                 if (!empty($elegant_data->option_value)) {
                     $dbase = basename($elegant_data->option_value);
                     $wp_upload_dir = wp_upload_dir();
                     $edir = $wp_upload_dir['basedir'];
                     if (!is_dir($edir . '/' . $dbase)) {
                         @mkdir($edir . '/' . $dbase);
                     }
                     $updraftplus->log_e("Elegant themes theme builder plugin data detected: resetting temporary folder");
                     update_option('et_images_temp_folder', $edir . '/' . $dbase);
                 }
             }
             # The gantry menu plugin sometimes uses too-long transient names, causing the timeout option to be missing; and hence the transient becomes permanent.
             # WP 3.4 onwards has $wpdb->delete(). But we support 3.2 onwards.
             $wpdb->query("DELETE FROM {$new_table_name} WHERE option_name LIKE '_transient_gantry-menu%' OR option_name LIKE '_transient_timeout_gantry-menu%'");
             # Jetpack: see: https://wordpress.org/support/topic/issues-with-dev-site
             if ($this->old_siteurl != $this->our_siteurl) {
                 $wpdb->query("DELETE FROM {$new_table_name} WHERE option_name = 'jetpack_options'");
             }
         }
     } elseif ($import_table_prefix != $old_table_prefix && preg_match('/^([\\d+]_)?usermeta$/', substr($table, strlen($import_table_prefix)), $matches)) {
         # This table is not a per-site table, but per-install
         $updraftplus->log("Table prefix has changed: changing usermeta table field(s) accordingly");
         echo sprintf(__('Table prefix has changed: changing %s table field(s) accordingly:', 'updraftplus'), 'usermeta') . ' ';
         $errors_occurred = false;
         if (false === strpos($old_table_prefix, '_')) {
             // Old, slow way: do it row-by-row
             // By Jul 2015, doing this on the updraftplus.com database took 20 minutes on a slow test machine
             $old_prefix_length = strlen($old_table_prefix);
             $um_sql = "SELECT umeta_id, meta_key \n\t\t\t\t\tFROM {$import_table_prefix}usermeta \n\t\t\t\t\tWHERE meta_key \n\t\t\t\t\tLIKE '" . str_replace('_', '\\_', $old_table_prefix) . "%'";
             $meta_keys = $wpdb->get_results($um_sql);
             foreach ($meta_keys as $meta_key) {
                 //Create new meta key
                 $new_meta_key = $import_table_prefix . substr($meta_key->meta_key, $old_prefix_length);
                 $query = "UPDATE " . $import_table_prefix . "usermeta \n\t\t\t\t\t\tSET meta_key='" . $new_meta_key . "' \n\t\t\t\t\t\tWHERE umeta_id=" . $meta_key->umeta_id;
                 if (false === $wpdb->query($query)) {
                     $errors_occurred = true;
                 }
             }
         } else {
             // New, fast way: do it in a single query
             $sql = "UPDATE {$import_table_prefix}usermeta SET meta_key = REPLACE(meta_key, '{$old_table_prefix}', '{$import_table_prefix}') WHERE meta_key LIKE '" . str_replace('_', '\\_', $old_table_prefix) . "%';";
             if (false === $wpdb->query($sql)) {
                 $errors_occurred = true;
//.........这里部分代码省略.........
开发者ID:nikintharan,项目名称:campaign,代码行数:101,代码来源:restorer.php


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