From d21865773b5ccc8bbf1d905f2141f18c1a677939 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Mon, 10 Aug 2009 10:48:09 -0400 Subject: [PATCH] WP 2.8 compatibility changes (Frumph) --- actions/comicpress_do-first-run.php | 6 +-- actions/comicpress_update-config.php | 10 ++--- comicpress_manager_admin.php | 56 ++++++++++++++-------------- comicpress_manager_library.php | 27 +++++++------- pages/comicpress_cpm_config.php | 6 +-- pages/comicpress_first_run.php | 4 +- readme.txt | 2 +- 7 files changed, 56 insertions(+), 55 deletions(-) diff --git a/actions/comicpress_do-first-run.php b/actions/comicpress_do-first-run.php index c713194..8a02fd2 100644 --- a/actions/comicpress_do-first-run.php +++ b/actions/comicpress_do-first-run.php @@ -1,7 +1,7 @@ is_cpm_managing_posts = true; @@ -35,10 +35,10 @@ function cpm_action_update_config() { } } - //if (function_exists('get_site_option')) { - // cpm_wpmu_save_options(); - // $cpm_config->is_wp_options = true; - //} + if ($wpmu_version) { + cpm_wpmu_save_options(); + $cpm_config->is_wp_options = true; + } if (!$cpm_config->is_wp_options) { if (!$do_write) { diff --git a/comicpress_manager_admin.php b/comicpress_manager_admin.php index 8cfe41a..bc30603 100644 --- a/comicpress_manager_admin.php +++ b/comicpress_manager_admin.php @@ -57,7 +57,7 @@ function cpm_get_plugin_path() { * Also read in the configuration and handle any POST actions. */ function cpm_add_pages() { - global $plugin_page, $access_level, $pagenow, $cpm_config, $wp_version; + global $plugin_page, $access_level, $pagenow, $cpm_config, $wp_version, $wpmu_version; load_plugin_textdomain('comicpress-manager', cpm_get_plugin_path()); @@ -107,7 +107,7 @@ function cpm_add_pages() { add_menu_page($plugin_title, __("ComicPress", 'comicpress-manager'), $access_level, $filename, "cpm_manager_index_caller", get_option('siteurl') . '/' . cpm_get_plugin_path() . '/comicpress-icon.png'); add_submenu_page($filename, $plugin_title, __("Upload", 'comicpress-manager'), $access_level, $filename, 'cpm_manager_index_caller'); - //if (!function_exists('get_site_option')) { + //if (!$wpmu_version) { add_submenu_page($filename, $plugin_title, __("Import", 'comicpress-manager'), $access_level, $filename . '-import', 'cpm_manager_import_caller'); //} @@ -730,7 +730,7 @@ function cpm_wrap_content($help_content, $activity_content, $show_sidebar = true did_first_run) { $page = "config"; } include("pages/comicpress_${page}.php"); @@ -1288,7 +1288,7 @@ function cpm_obfuscate_filename($filename) { } function cpm_do_gd_file_check_on_upload($check_file_path, $target_filename) { - global $cpm_config; + global $cpm_config, $wpmu_version; $file_ok = true; $did_filecheck = false; @@ -1624,9 +1624,9 @@ function cpm_handle_file_uploads($files) { } } } - //if (function_exists('get_site_option')) { - // if (cpm_wpmu_is_over_storage_limit()) { $ok_to_keep_uploading = false; break; } - //} + if ($wpmu_version) { + if (cpm_wpmu_is_over_storage_limit()) { $ok_to_keep_uploading = false; break; } + } } if ($ok_to_keep_uploading) { @@ -1646,9 +1646,9 @@ function cpm_handle_file_uploads($files) { } } } - //if (function_exists('get_site_option')) { - // if (cpm_wpmu_is_over_storage_limit()) { $ok_to_keep_uploading = false; } - //} + if ($wpmu_version) { + if (cpm_wpmu_is_over_storage_limit()) { $ok_to_keep_uploading = false; } + } } if ($ok_to_keep_uploading) { @@ -1859,7 +1859,7 @@ var ajax_request_uri = "/comicpress_manager_count_ * Handle any warnings that have been invoked. */ function cpm_handle_warnings() { - global $cpm_config; + global $cpm_config, $wpmu_version; // display informative messages to the use // TODO: remove separate arrays and tag messages based on an enum value @@ -1945,9 +1945,9 @@ function cpm_handle_warnings() { arsort($available_backup_files); - //if (function_exists('get_site_option')) { - //$cpm_config->show_config_editor = true; - //} else { +// if ($wpmu_version) { +// $cpm_config->show_config_editor = true; +// } else { if ($cpm_config->config_method == "comicpress-config.php") { if (!$cpm_config->can_write_config) { $update_automatically = false; @@ -1987,19 +1987,19 @@ function cpm_handle_warnings() {
show_config_editor) { echo cpm_manager_edit_config(); } ?> - +
() blog_category_info['name'] ?> properties['blogcat']) ?> - +
  • () @@ -2159,7 +2159,7 @@ function cpm_show_comicpress_details() {
  • - +
  • () @@ -2294,7 +2294,7 @@ function cpm_show_debug_info($display_none = true) { * Show the config editor. */ function cpm_manager_edit_config() { - global $cpm_config; + global $cpm_config, $wpmu_version; include('cp_configuration_options.php'); @@ -2342,7 +2342,7 @@ function cpm_manager_edit_config() { $no_wpmu = false; extract($field_info); - //$ok = (function_exists('get_site_option')) ? ($no_wpmu !== true) : true; + // $ok = ($wpmu_version) ? ($no_wpmu !== true) : true; $ok = true; if ($ok) { $description = " (" . $description . ")"; @@ -2411,7 +2411,7 @@ function cpm_manager_edit_config() { } } } ?> - + - + " /> diff --git a/comicpress_manager_library.php b/comicpress_manager_library.php index 6a6825e..03a30ef 100644 --- a/comicpress_manager_library.php +++ b/comicpress_manager_library.php @@ -65,7 +65,7 @@ function cpm_option($name) { return get_option("comicpress-manager-${name}"); } * Calculate the document root where comics are stored. */ function cpm_calculate_document_root() { - global $cpm_attempted_document_roots; + global $cpm_attempted_document_roots, $wpmu_version; $cpm_attempted_document_roots = array(); $document_root = null; @@ -86,9 +86,9 @@ function cpm_calculate_document_root() { if (is_null($document_root)) { $document_root = $_SERVER['DOCUMENT_ROOT'] . $parsed_url['path']; } - //if (function_exists('get_site_option')) { - // $document_root = cpm_wpmu_modify_path($document_root); - //} + if ($wpmu_version) { + $document_root = cpm_wpmu_modify_path($document_root); + } return untrailingslashit($document_root); } @@ -132,6 +132,7 @@ function cpm_generate_example_date($example_date) { * Build the URI to a comic file. */ function cpm_build_comic_uri($filename, $base_dir = null) { + global $wpmu_version; if (!is_null($base_dir)) { if (strlen($filename) < strlen($base_dir)) { return false; } } @@ -146,7 +147,7 @@ function cpm_build_comic_uri($filename, $base_dir = null) { $parsed_url = parse_url(get_bloginfo('url')); $path = $parsed_url['path']; - //if (function_exists('get_site_option')) { $path = cpm_wpmu_fix_admin_uri($path); } + if ($wpmu_version) { $path = cpm_wpmu_fix_folder_to_use($path); } $count = (cpm_get_subcomic_directory() !== false) ? 3 : 2; @@ -336,7 +337,7 @@ function cpm_read_comics_folder() { * Read information about the current installation. */ function cpm_read_information_and_check_config() { - global $cpm_config, $cpm_attempted_document_roots, $blog_id; + global $cpm_config, $cpm_attempted_document_roots, $blog_id, $wpmu_version; $cpm_config->config_method = read_current_theme_comicpress_config(); $cpm_config->config_filepath = get_functions_php_filepath(); @@ -388,7 +389,7 @@ function cpm_read_information_and_check_config() { $any_cpm_document_root_failures = false; - //if (!function_exists('get_site_option')) { + if (!$wpmu_version) { // is the site root configured properly? if (!file_exists(CPM_DOCUMENT_ROOT)) { $cpm_config->errors[] = sprintf(__('The comics site root %s does not exist. Check your WordPress address and address settings.', 'comicpress-manager'), CPM_DOCUMENT_ROOT); @@ -399,7 +400,7 @@ function cpm_read_information_and_check_config() { $cpm_config->errors[] = sprintf(__('The comics site root %s does not contain a WordPress index.php file. Check your WordPress address and address settings.', 'comicpress-manager'), CPM_DOCUMENT_ROOT); $any_cpm_document_root_failures = true; } - //} + } if ($any_cpm_document_root_failures) { $cpm_config->errors[] = print_r($cpm_attempted_document_roots, true); @@ -533,12 +534,12 @@ function cpm_read_information_and_check_config() { * Read the ComicPress config from a file. */ function read_current_theme_comicpress_config() { - global $cpm_config; + global $cpm_config, $wpmu_version; - //if (function_exists('get_site_option')) { - // cpm_wpmu_load_options(); - // return __("WordPress Options", 'comicpress-manager'); - //} + if ($wpmu_version) { + cpm_wpmu_load_options(); + return __("WordPress Options", 'comicpress-manager'); + } $current_theme_info = get_theme(get_current_theme()); diff --git a/pages/comicpress_cpm_config.php b/pages/comicpress_cpm_config.php index 24f706f..9bfecab 100644 --- a/pages/comicpress_cpm_config.php +++ b/pages/comicpress_cpm_config.php @@ -4,7 +4,7 @@ * The config editor dialog. */ function cpm_manager_cpm_config() { - global $cpm_config; + global $cpm_config, $wpmu_version; include(realpath(dirname(__FILE__)) . '/../cpm_configuration_options.php'); @@ -18,8 +18,8 @@ function cpm_manager_cpm_config() { 0); diff --git a/pages/comicpress_first_run.php b/pages/comicpress_first_run.php index dd7699d..078ce33 100644 --- a/pages/comicpress_first_run.php +++ b/pages/comicpress_first_run.php @@ -4,11 +4,11 @@ * The main manager screen. */ function cpm_manager_first_run($target_page) { - global $cpm_config; + global $cpm_config, $wpmu_version; $target_page = "?page=${target_page}"; - //$is_wpmu = function_exists("get_site_option"); + $is_wpmu = $wpmu_version; ob_start(); diff --git a/readme.txt b/readme.txt index 014c10d..161c88f 100644 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,7 @@ Contributors: johncoswell Tags: comicpress, webcomics, management, admin, posts, plugin Requires at least: 2.5.1 -Tested up to: 2.7.1 +Tested up to: 2.8 Stable tag: 1.4.5 Donate link: http://www.coswellproductions.com/wordpress/wordpress-plugins/