| @@ -23,11 +23,9 @@ | ||
| 23 | 23 | // Add admin and network notices. |
| 24 | 24 | add_action( 'admin_notices', [ $this, 'file_error_notice' ] ); |
| 25 | 25 | add_action( 'network_admin_notices', [ $this, 'file_error_notice' ] ); |
| 26 | 26 | add_action( 'update_option_siteurl', [ $this, 'update_option_url' ], 10, 2 ); |
| 27 | - // Use updated_option (fires after the value is written) so auto_prepend_injection() | |
| 28 | - // re-reads the new value; update_option fires before the write and sees the old value. | |
| 29 | - add_action( 'updated_option', [ $this, 'update_option_ap' ], 10, 3 ); | |
| 27 | + add_action( 'update_option', [ $this, 'update_option_ap' ], 10, 3 ); | |
| 30 | 28 | |
| 31 | 29 | // If the firewall or whitelist rules do not exist, attempt to pull fresh. |
| 32 | 30 | $token = get_option( 'patchstack_api_token', false ); |
| 33 | 31 | if ( ! empty( $token ) && ( get_option( 'patchstack_firewall_rules', '' ) == '' || get_option( 'patchstack_whitelist_keys_rules' ) == '' ) && get_option( 'patchstack_license_free', 0 ) != 1 ) { |
| @@ -69,12 +67,12 @@ | ||
| 69 | 67 | <h2>Patchstack File Permission Error</h2> |
| 70 | 68 | <p><?php esc_html_e( 'The following file/folder could not be written to:<br />' . implode( '<br />', $files ), 'patchstack' ); ?></p> |
| 71 | 69 | <?php |
| 72 | 70 | foreach ( $files as $file ) { |
| 73 | - echo wp_kses( '<p><b>Debug info: </b>' . $file . ' chmod permissions: <b>' . substr( decoct( fileperms( $file ) ), -3 ) . '</b>, owned by <b>' . $this->get_file_owner_name( $file ) . '</b></p>', $this->allowed_html ); | |
| 71 | + echo wp_kses( '<p><b>Debug info: </b>' . $file . ' chmod permissions: <b>' . substr( decoct( fileperms( $file ) ), -3 ) . '</b>, owned by <b>' . posix_getpwuid( fileowner( $file ) )['name'] . '</b></p>', $this->allowed_html ); | |
| 74 | 72 | } |
| 75 | 73 | ?> |
| 76 | - <p><?php esc_html_e( '<strong>How to fix?</strong><br />CHMOD the file/folder to <strong>755</strong> through a <a href="http://www.dummies.com/web-design-development/wordpress/navigation-customization/how-to-change-file-permissions-using-filezilla-on-your-ftp-site/" target="_blank">FTP client</a>, <a href="http://support.hostgator.com/articles/cpanel/how-to-change-permissions-chmod-of-a-file" target="_blank">CPanel</a>, <a href="https://www.inmotionhosting.com/support/website/managing-files/change-file-permissions" target="_blank">WHM</a> or ask your hosting provider. Make sure file or folder ownership is set to <b>' . $this->get_file_owner_name( ABSPATH . 'index.php' ) . '</b> user .', 'patchstack_file_error_notice' ); ?></p> | |
| 74 | + <p><?php esc_html_e( '<strong>How to fix?</strong><br />CHMOD the file/folder to <strong>755</strong> through a <a href="http://www.dummies.com/web-design-development/wordpress/navigation-customization/how-to-change-file-permissions-using-filezilla-on-your-ftp-site/" target="_blank">FTP client</a>, <a href="http://support.hostgator.com/articles/cpanel/how-to-change-permissions-chmod-of-a-file" target="_blank">CPanel</a>, <a href="https://www.inmotionhosting.com/support/website/managing-files/change-file-permissions" target="_blank">WHM</a> or ask your hosting provider. Make sure file or folder ownership is set to <b>' . posix_getpwuid( fileowner( ABSPATH . 'index.php' ) )['name'] . '</b> user .', 'patchstack_file_error_notice' ); ?></p> | |
| 77 | 75 | <p><?php esc_html_e( '<strong>CHMOD properly set but still not working?</strong><br />Make sure the group/owner (chown) settings of the /wp-content/plugins/patchstack/ folder is properly setup, you may have to ask your host to fix this.', 'patchstack_file_error_notice' ); ?></p> |
| 78 | 76 | </div> |
| 79 | 77 | <?php |
| 80 | 78 | } |
| @@ -80,24 +78,8 @@ | ||
| 80 | 78 | } |
| 81 | 79 | } |
| 82 | 80 | |
| 83 | 81 | /** |
| 84 | - * Resolve the owning system user name for a file, guarding the POSIX extension | |
| 85 | - * which is not available on Windows or some hardened hosts. | |
| 86 | - * | |
| 87 | - * @param string $file | |
| 88 | - * @return string | |
| 89 | - */ | |
| 90 | - private function get_file_owner_name( $file ) { | |
| 91 | - if ( ! function_exists( 'posix_getpwuid' ) || ! function_exists( 'fileowner' ) ) { | |
| 92 | - return ''; | |
| 93 | - } | |
| 94 | - | |
| 95 | - $owner = posix_getpwuid( fileowner( $file ) ); | |
| 96 | - return isset( $owner['name'] ) ? $owner['name'] : ''; | |
| 97 | - } | |
| 98 | - | |
| 99 | - /** | |
| 100 | 82 | * When the user updates the site URL, update it on the API side as well. |
| 101 | 83 | * This needs to be done so we can communicate with the site properly. |
| 102 | 84 | * |
| 103 | 85 | * @param mixed $old_value |
| @@ -127,9 +109,9 @@ | ||
| 127 | 109 | if ( get_option( 'patchstack_license_activated', 0 ) != 1 ) { |
| 128 | 110 | return; |
| 129 | 111 | } |
| 130 | 112 | |
| 131 | - if ( $new_value && (int) get_option( 'patchstack_license_free', 0 ) == 0 ) { | |
| 113 | + if ( $new_value && get_option( 'patchstack_license_free', 0 ) == 0 ) { | |
| 132 | 114 | $this->plugin->activation->auto_prepend_injection(); |
| 133 | 115 | } else { |
| 134 | 116 | $this->plugin->activation->auto_prepend_removal(); |
| 135 | 117 | } |