Title: Compatibility Issue with WP_Stack
Last modified: August 21, 2016

---

# Compatibility Issue with WP_Stack

 *  Resolved [clariner](https://wordpress.org/support/users/clariner/)
 * (@clariner)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/compatibility-issue-with-wp_stack/)
 * We have come across with an issue incompatibility issue with WP_Stack
    ([https://github.com/markjaquith/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?
 * [http://wordpress.org/extend/plugins/mycred/](http://wordpress.org/extend/plugins/mycred/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [myCred](https://wordpress.org/support/users/designbymerovingi/)
 * (@designbymerovingi)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/compatibility-issue-with-wp_stack/#post-3805296)
 * Wow. Appreciate you taking the time to report this and your provided solution.
   I will look into this asap and make sure to include it in the next update.
 * Right now I am going through all the 1.1 requests and calculating the time it
   will take to implement it. My aim is to have 1.1 out in a week or two, so I might
   just push though a 1.0.9.4 before then to address this issue.
 *  Thread Starter [clariner](https://wordpress.org/support/users/clariner/)
 * (@clariner)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/compatibility-issue-with-wp_stack/#post-3805336)
 * Hi Gabriel,
 * No problem, always happy to help.
 * I’m happy to wait until 1.1 if you development window is that short.
 * On a side question, do you have either a skeleton addon or tutorial about creating
   one?
 *  Plugin Author [myCred](https://wordpress.org/support/users/designbymerovingi/)
 * (@designbymerovingi)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/compatibility-issue-with-wp_stack/#post-3805597)
 * I have a low work load for June so I thought I take the opportunity and spend
   it on myCRED, hence the short window.
 * Creating a tutorial on Add-ons has been on my mind for a while now but I have
   been unhappy with some aspects that I feel could be made simpler or more explanatory.
   I do not have a skeleton addon right now as I mainly just use the abstract module
   class as reference but if you give me a few days I would be more then happy to
   put one together for you.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Compatibility Issue with WP_Stack’ is closed to new replies.

 * ![](https://ps.w.org/mycred/assets/icon-128x128.gif?rev=3512531)
 * [Points Management System For Gamification, Ranks, Badges, and Loyalty Rewards Program - myCred](https://wordpress.org/plugins/mycred/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mycred/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mycred/)
 * [Active Topics](https://wordpress.org/support/plugin/mycred/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mycred/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mycred/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [myCred](https://wordpress.org/support/users/designbymerovingi/)
 * Last activity: [12 years, 11 months ago](https://wordpress.org/support/topic/compatibility-issue-with-wp_stack/#post-3805597)
 * Status: resolved