Compatibility Issue with WP_Stack
-
We have come across with an issue incompatibility issue with WP_Stack
(https://github.com/markjaquith/WP-Stack)The issue is with the usage of ABSPATH, in the ‘get’ function and ‘get_path’ function.
In the ‘get’ function ABSPATH should be removed from myCRED_ADDONS_DIR but as we use WP_Stack it is not and so when ‘get_path’ function is called ABSPATH is then appended to the file path which makes the file path invalid.
The result is that addon setting pages are not loaded when activated.
I have updated the two functions below to add support for wordpress installs based on WP_Stack
public function get( $save = false ) { $prefix = 'myCRED-addon-'; $addon_location = myCRED_ADDONS_DIR; $installed = array(); // Search for addons. should be in addons/*/myCRED-addon-*.php $addon_search = glob( $addon_location . "*/$prefix*.php" ); if ( !empty( $addon_search ) && $addon_search !== false ) { foreach ( $addon_search as $filename ) { // Handle windows if ( !defined( 'WP_STAGE' ) ) { $abspath = str_replace( '/', '', ABSPATH ); // Remove ABSPATH to prevent long string addresses. Everything starts with wp-content $sub_file = str_replace( array( $abspath, ABSPATH ), '', $filename ); } else { $sub_file = $filename; } // Get File Name preg_match( '/(.{1,})\/(.{1,})/', $sub_file, $matches ); $sub_file_name = $matches[2]; // Get Addon Information $addon_info = $this->get_addon_info( $filename, $matches[1], $sub_file_name ); // Check if addon has a requirement to prevent errors due to calls to non existing functions if ( isset( $addon_info['requires'] ) && !empty( $addon_info['requires'] ) && !function_exists( $addon_info['requires'] ) ) { continue; } // Prevent Duplicates if ( !array_key_exists( $sub_file_name, $installed ) ) { $installed[$this->make_id( $sub_file_name )] = $addon_info; } } } unset( $addon_search ); $installed = apply_filters( 'mycred_setup_addons', $installed ); if ( $save === true && $this->core->can_edit_plugin() ) { $new_data = array( 'active' => $this->active, 'installed' => $installed ); update_option( 'mycred_pref_addons', $new_data ); } $this->installed = $installed; return $installed; }
public function get_path( $key ) { $installed = $this->installed; if ( array_key_exists( $key, $installed ) ) { $file = $installed[$key]['file']; if ( !defined( 'WP_STAGE' ) ) { return ABSPATH . $installed[$key]['folder'] . $file; } else { return $installed[$key]['folder'] . $file; } } return ''; }
Hope these changes can be included in version 1.1?
- The topic ‘Compatibility Issue with WP_Stack’ is closed to new replies.