Skip to content

Commit

Permalink
Move tribe() compatibility into a file that loads during plugins_load…
Browse files Browse the repository at this point in the history
…ed and add additional checks to prevent loading during plugin activation
  • Loading branch information
sc0ttkclark committed Oct 2, 2023
1 parent cbad523 commit b825eee
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 23 deletions.
2 changes: 2 additions & 0 deletions classes/PodsInit.php
Original file line number Diff line number Diff line change
Expand Up @@ -2438,6 +2438,8 @@ public function run() {

// Compatibility for Query Monitor conditionals
add_filter( 'query_monitor_conditionals', array( $this, 'filter_query_monitor_conditionals' ) );

require_once PODS_DIR . 'includes/compatibility.php';
}

/**
Expand Down
35 changes: 35 additions & 0 deletions includes/compatibility.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

/**
* @package Pods\Global\Functions\Compatibility
*/

// Add backwards compatibility for tribe() for old add-ons that may still call it.
if (
! function_exists( 'tribe_is_not_min_php_version' )
&& ! function_exists( 'tribe' )
&& ! doing_action( 'activate_plugin' )
&& ! did_action( 'activate_plugin' )
&& (
! defined( 'WP_SANDBOX_SCRAPING' )
|| ! WP_SANDBOX_SCRAPING
)
&& 'activate' !== pods_v( 'action' )
) {
/**
* Compatibility function for Pods 2.x add-ons that may still call tribe().
*
* @since 3.0.5
*
* @param string|null $slug_or_class Either the slug of a binding previously registered using singleton or
* register or the full class name that should be automagically created or
* `null` to get the container instance itself.
*
* @return mixed|null The pods_container() object or null if the function does not exist yet.
*/
function tribe( $slug_or_class = null ) {
_doing_it_wrong( 'tribe', 'tribe() is no longer included in Pods Framework directly. Please use pods_container() instead.', '3.0' );

return pods_container( $slug_or_class );
}
}
23 changes: 0 additions & 23 deletions includes/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -4570,26 +4570,3 @@ function pods_container_register_service_provider( $provider_class ) {

$container->register( $provider_class );
}

// Add backwards compatibility for tribe() for old add-ons that may still call it.
if (
! function_exists( 'tribe_is_not_min_php_version' )
&& ! function_exists( 'tribe' )
) {
/**
* Compatibility function for Pods 2.x add-ons that may still call tribe().
*
* @since 3.0.5
*
* @param string|null $slug_or_class Either the slug of a binding previously registered using singleton or
* register or the full class name that should be automagically created or
* `null` to get the container instance itself.
*
* @return mixed|null The pods_container() object or null if the function does not exist yet.
*/
function tribe( $slug_or_class = null ) {
_doing_it_wrong( 'tribe', 'tribe() is no longer included in Pods Framework directly. Please use pods_container() instead.', '3.0' );

return pods_container( $slug_or_class );
}
}

0 comments on commit b825eee

Please sign in to comment.