Changeset 1214050
- Timestamp:
- 08/06/2015 12:47:34 PM (11 years ago)
- Location:
- angry-creative-logger/trunk
- Files:
-
- 5 edited
-
classes/wp_cli.php (modified) (4 diffs)
-
plugin.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
routines/file_permissions.php (modified) (1 diff)
-
routines/site_visibility.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
angry-creative-logger/trunk/classes/wp_cli.php
r1189487 r1214050 28 28 $all_routines = ACI_Routine_Handler::get_inspection_routines(); 29 29 $all_routine_slugs = array(); 30 $routine_repair_methods = array(); 30 31 $force_inspect = true; 31 32 … … 93 94 } 94 95 95 if ( AC_Inspector::$error_count ) {96 if ( AC_Inspector::$error_count ) { 96 97 AC_Inspector::$error_count = 0; 97 98 continue; … … 100 101 $routine_log_count = AC_Inspector::$log_count - $total_log_count; 101 102 102 WP_CLI::success( "Inspected $routine with $routine_log_count remark(s).\n" );103 WP_CLI::success( "Inspected $routine with $routine_log_count remark(s).\n" ); 103 104 104 105 if ( $routine_log_count > 0 ) { 105 106 106 107 $repair_method = ACI_Routine_Handler::get_repair_method( $all_routines[$routine_key], $routine_options ); 108 107 109 if ( !empty( $repair_method ) ) { 108 109 WP_CLI::confirm( "Routine $routine has a repair method that may or may not fix the problem for you.\n" . 110 "Have you made a backup of your website's entire source code, uploaded files and database\n" . 111 "and want me to try and run the repair method with the risk of me messing everything up?" ); 112 113 $total_log_count = AC_Inspector::$log_count; 114 $total_error_count = AC_Inspector::$error_count; 115 $total_success_count = AC_Inspector::$success_count; 116 117 call_user_func( $repair_method ); 118 119 $routine_log_count = AC_Inspector::$log_count - $total_log_count; 120 $routine_error_count = AC_Inspector::$error_count - $total_error_count; 121 $routine_success_count = AC_Inspector::$success_count - $total_success_count; 122 123 if ( $routine_error_count > 0 ) { 124 WP_CLI::error( "Repair method for routine '$routine' yielded $routine_error_count error(s).\n" ); 125 } else if ( $routine_success_count > 0 || $routine_log_count > 0 ) { 126 WP_CLI::success( "Successfully performed repair method for routine '$routine' with no errors.\n" ); 127 } else { 128 WP_CLI::success( "Nothing seems broken. If it ain't broke, don't fix it.\n" ); 129 } 130 110 $routine_repair_methods[$routine] = $repair_method; 131 111 } 132 112 … … 138 118 139 119 } 120 121 } 122 123 if ( count( $routine_repair_methods ) > 0 ) { 124 125 WP_CLI::confirm( "One or more of your inspection routines has a repair method that may or may not fix the problem(s) for you.\n" . 126 "Have you made a backup of your website's entire source code, uploaded files and database and want me to\n" . 127 "try and repair with the risk of me messing everything up?" ); 128 129 foreach( $routine_repair_methods as $routine => $repair_method ) { 130 131 $total_log_count = AC_Inspector::$log_count; 132 $total_error_count = AC_Inspector::$error_count; 133 $total_success_count = AC_Inspector::$success_count; 134 135 call_user_func( $repair_method ); 136 137 $routine_log_count = AC_Inspector::$log_count - $total_log_count; 138 $routine_error_count = AC_Inspector::$error_count - $total_error_count; 139 $routine_success_count = AC_Inspector::$success_count - $total_success_count; 140 141 if ( $routine_error_count > 0 ) { 142 WP_CLI::error( "Repair method for routine '$routine' yielded $routine_error_count error(s).\n" ); 143 } else if ( $routine_success_count > 0 || $routine_log_count > 0 ) { 144 WP_CLI::success( "Successfully performed repair method for routine '$routine' with no errors.\n" ); 145 } else { 146 WP_CLI::success( "Nothing seems broken. If it ain't broke, don't fix it.\n" ); 147 } 148 149 } 140 150 141 151 } -
angry-creative-logger/trunk/plugin.php
r1189487 r1214050 4 4 Plugin URI: http://angrycreative.se 5 5 Description: Inspects and logs possible issues with your Wordpress installation. 6 Version: 0.8 6 Version: 0.8.1 7 7 Author: Robin Björklund, Sammy Nordström, Angry Creative AB 8 8 */ 9 9 10 define( 'ACI_PLUGIN_VERSION', '0.8 ' );10 define( 'ACI_PLUGIN_VERSION', '0.8.1' ); 11 11 12 12 define( 'ACI_PLUGIN_DIR', dirname( __FILE__ ) ); -
angry-creative-logger/trunk/readme.txt
r1189487 r1214050 4 4 Requires at least: 4.0 5 5 Tested up to: 4.2.2 6 Stable tag: 0.8 6 Stable tag: 0.8.1 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 30 30 * Added the abilitiy to define SITE_RELEASE_TIER (local/development/test/integration/stage/production) in wp-config.php 31 31 * Added repair method to site visibility routine using SITE_RELEASE_TIER for making the site public or private 32 * Added the abiltity to define HIDDEN_SITES to prevent specific sites from being made public by the site visibility repair method 32 33 33 34 = 0.7.x = -
angry-creative-logger/trunk/routines/file_permissions.php
r1189487 r1214050 177 177 if ( "/*" == $folder && in_array( "/*", self::$_options['allowed_dirs'] ) ) { 178 178 $allowed_dir = true; 179 } else if ( !empty( $folder_base ) && false !== strpos( $file_path, $folder_base ) ) { 180 $allowed_dir = true; 179 } else if ( !empty( $folder_base ) ) { 180 foreach( self::$_options['allowed_dirs'] as $dir ) { 181 if ( preg_match("|".str_replace('/*', '/.*', $dir)."|", $file_path ) ) { 182 $allowed_dir = true; 183 break; 184 } 185 } 181 186 } 182 187 } else if ( in_array( $folder, self::$_options['allowed_dirs'] ) ) { -
angry-creative-logger/trunk/routines/site_visibility.php
r1189487 r1214050 21 21 } 22 22 23 public static function is_visible( $site_id = 1 ) { 24 25 if ( is_multisite() && is_plugin_active_for_network( ACI_PLUGIN_BASENAME ) ) { 26 27 if ( intval( $site_id ) == 0 || !get_blog_details( $site_id ) ) { 28 $site_id = 1; 29 } 30 31 $visible = get_blog_details( $site_id )->public; 32 33 } else { 34 35 $visible = get_option('blog_public'); 36 37 } 38 39 return $visible ? true : false; 40 41 } 42 43 public static function should_be_visible( $site_id = 1 ) { 44 45 if ( !aci_release_tier_aware() ) { 46 return null; 47 } 48 49 $release_tier = aci_get_release_tier(); 50 51 if ( $release_tier != 'production' ) { 52 return false; 53 } 54 55 if ( defined( 'HIDDEN_SITES' ) ) { 56 57 $hidden_sites = explode( ',', HIDDEN_SITES ); 58 59 foreach ($hidden_sites as $hidden_site_id) { 60 61 $hidden_site_id = intval( trim( $hidden_site_id ) ); 62 63 if ( $hidden_site_id > 0 && $hidden_site_id == $site_id ) { 64 return false; 65 } 66 } 67 } 68 69 return true; 70 71 } 72 23 73 public static function inspect() { 24 74 … … 26 76 27 77 global $wpdb; 28 $site_ blog_ids = $wpdb->get_col("SELECT blog_id FROM ".$wpdb->prefix."blogs");78 $site_ids = $wpdb->get_col("SELECT blog_id FROM ".$wpdb->prefix."blogs"); 29 79 30 if (is_array($site_ blog_ids)) {31 foreach( $site_ blog_ids AS $site_blog_id ) {80 if (is_array($site_ids)) { 81 foreach( $site_ids AS $site_id ) { 32 82 33 if (intval($site_blog_id) > 0) { 83 if ( null === self::should_be_visible( $site_id ) ) { 84 if ( self::is_visible( $site_id ) ) { 85 AC_Inspector::log( 'Site '.$site_id.' is visible to search enginges, which may be correct as well as incorrect. Please define SITE_RELEASE_TIER in your wp-config.php to help me determine this.', __CLASS__ ); 86 } else { 87 AC_Inspector::log( 'Site '.$site_id.' is not visible to search enginges, which may be correct as well as incorrect. Please define SITE_RELEASE_TIER in your wp-config.php to help me determine this.', __CLASS__ ); 88 } 89 } 34 90 35 $visible = get_blog_details( $site_blog_id )->public; 36 37 if ( !$visible ) { 38 39 AC_Inspector::log( 'Site '.$site_blog_id.' is not visible to search engines.', __CLASS__, array( 'site_id' => $site_blog_id ) ); 40 41 } 42 91 if ( !self::is_visible( $site_id ) && true === self::should_be_visible( $site_id ) ) { 92 AC_Inspector::log( 'Site '.$site_id.' should be visible to search engines, please check your site visibility settings.', __CLASS__, array( 'site_id' => $site_id ) ); 93 } else if ( self::is_visible( $site_id ) && false === self::should_be_visible( $site_id ) ) { 94 AC_Inspector::log( 'Site '.$site_id.' should not be visible to search engines, please check your site visibility settings.', __CLASS__, array( 'site_id' => $site_id ) ); 43 95 } 44 96 … … 48 100 } else { 49 101 50 $visible = get_option('blog_public'); 102 if ( null === self::should_be_visible() ) { 103 if ( self::is_visible() ) { 104 AC_Inspector::log( 'The site is visible to search enginges, which may be correct as well as incorrect. Please define SITE_RELEASE_TIER in your wp-config.php to help me determine this.', __CLASS__ ); 105 } else { 106 AC_Inspector::log( 'The site is not visible to search enginges, which may be correct as well as incorrect. Please define SITE_RELEASE_TIER in your wp-config.php to help me determine this.', __CLASS__ ); 107 } 108 } 51 109 52 if ( ! $visible) {53 54 AC_Inspector::log( 'The site is not visible to search engines.', __CLASS__ );55 110 if ( !self::is_visible() && true === self::should_be_visible() ) { 111 AC_Inspector::log( 'The site should be visible to search engines, please check your site visibility settings.', __CLASS__, array( 'site_id' => $site_id ) ); 112 } else if ( self::is_visible( $site_id ) && false === self::should_be_visible( $site_id ) ) { 113 AC_Inspector::log( 'The site should not be visible to search engines, please check your site visibility settings.', __CLASS__, array( 'site_id' => $site_id ) ); 56 114 } 57 115 … … 67 125 } 68 126 69 $release_tier = aci_get_release_tier();70 71 127 if ( is_multisite() && is_plugin_active_for_network( ACI_PLUGIN_BASENAME ) ) { 72 128 73 129 global $wpdb; 74 $site_ blog_ids = $wpdb->get_col("SELECT blog_id FROM ".$wpdb->prefix."blogs");130 $site_ids = $wpdb->get_col("SELECT blog_id FROM ".$wpdb->prefix."blogs"); 75 131 76 if (is_array($site_ blog_ids)) {77 foreach( $site_ blog_ids AS $site_blog_id ) {132 if (is_array($site_ids)) { 133 foreach( $site_ids AS $site_id ) { 78 134 79 if (intval($site_ blog_id) > 0) {135 if (intval($site_id) > 0) { 80 136 81 $visible = get_blog_details( $site_blog_id )->public;137 $visible = self::is_visible( $site_id ); 82 138 83 if ( ( !$visible && $release_tier == 'production' ) || ( $visible && $release_tier != 'production') ) {139 if ( ( !$visible && true === self::should_be_visible( $site_id ) ) || ( $visible && false === self::should_be_visible( $site_id ) ) ) { 84 140 85 141 $visible = $visible ? 0 : 1; 86 142 87 switch_to_blog( $site_ blog_id );143 switch_to_blog( $site_id ); 88 144 update_option( 'blog_public', $visible ); 89 145 restore_current_blog(); 90 146 91 AC_Inspector::log( 'The site visibility setting for ' . get_blog_details( $site_ blog_id, true )->blogname .' is now ' . ( ( $visible ) ? ' public' : ' private' ) . '.', __CLASS__, array( 'success' => true ) );147 AC_Inspector::log( 'The site visibility setting for ' . get_blog_details( $site_id, true )->blogname .' is now ' . ( ( $visible ) ? ' public' : ' private' ) . '.', __CLASS__, array( 'success' => true ) ); 92 148 93 149 } else { 94 150 95 AC_Inspector::log( 'The site visibility setting for ' . get_blog_details( $site_ blog_id, true )->blogname .' seems correct, no action taken.', __CLASS__, array( 'log_level' => 'notice' ) );151 AC_Inspector::log( 'The site visibility setting for ' . get_blog_details( $site_id, true )->blogname .' seems correct, no action taken.', __CLASS__, array( 'log_level' => 'notice' ) ); 96 152 97 153 } … … 103 159 } else { 104 160 105 $visible = get_option('blog_public');161 $visible = self::is_visible(); 106 162 107 if ( ( !$visible && $release_tier == 'production' ) || ( $visible && $release_tier != 'production') ) {163 if ( ( !$visible && true === self::should_be_visible() ) || ( $visible && false === self::should_be_visible() ) ) { 108 164 109 165 $visible = $visible ? 0 : 1;
Note: See TracChangeset
for help on using the changeset viewer.