Skip to content

Commit

Permalink
More tweaks to $lookup logic
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0ttkclark committed Aug 1, 2012
1 parent 4a89a26 commit 1b6d64a
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 6 deletions.
6 changes: 3 additions & 3 deletions classes/PodsAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -882,9 +882,9 @@ public function save_pod ( $params ) {
foreach ( $pod[ 'options' ] as $key => $val ) {
if ( false === strpos( $key, 'built_in_' ) )
continue;
elseif ( false === strpos( $key, 'built_in_post_types_' ) )
elseif ( false !== strpos( $key, 'built_in_post_types_' ) )
$built_in_type = 'post_type';
elseif ( false === strpos( $key, 'built_in_taxonomies_' ) )
elseif ( false !== strpos( $key, 'built_in_taxonomies_' ) )
$built_in_type = 'taxonomy';
else
continue;
Expand Down Expand Up @@ -913,7 +913,7 @@ public function save_pod ( $params ) {
$lookup_built_in = 'post_type';
}

if ( !empty( $lookup_option ) && !empty( $lookup_built_in ) && isset( $built_in[ $lookup_built_in ] ) && !empty( $built_in[ $lookup_built_in ] ) ) {
if ( !empty( $lookup_option ) && !empty( $lookup_built_in ) && isset( $built_in[ $lookup_built_in ] ) ) {
foreach ( $built_in[ $lookup_built_in ] as $built_in_object => $val ) {
$search_val = 1 ^ $val;

Expand Down
4 changes: 2 additions & 2 deletions classes/PodsInit.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class PodsInit {

static $no_conflict = array();

public $meta;
static $meta;

public $version;

Expand Down Expand Up @@ -36,7 +36,7 @@ function __construct () {
add_action( 'wp_before_admin_bar_render', array( $this, 'admin_bar_links' ) );

// Init Pods Meta
$this->meta = pods_meta()->init();
self::$meta = pods_meta()->init();
}
}

Expand Down
59 changes: 58 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1268,16 +1268,63 @@ function pods_is_plugin_active ( $plugin ) {
}

/**
* Turn off conflicting / recursing actions for an object type that Pods hooks into
* Turn off conflicting / recursive actions for an object type that Pods hooks into
*
* @param string $object_type
*/
function pods_no_conflict_on ( $object_type = 'post' ) {
if ( !empty( PodsInit::$no_conflict ) && isset( PodsInit::$no_conflict[ $object_type ] ) && !empty( PodsInit::$no_conflict[ $object_type ] ) )
return;

if ( !is_object( PodsInit::$meta ) )
return;

$no_conflict = array();

if ( 'post' == $object_type ) {
$no_conflict[ 'filter' ] = array(

);

$no_conflict[ 'action' ] = array(
array( 'save_post', array( PodsInit::$meta, 'save_post' ), 10, 2 )
);
}
elseif ( 'taxonomy' == $object_type ) {
$no_conflict[ 'filter' ] = array(

);

$no_conflict[ 'action' ] = array(
array( 'edit_term', array( PodsInit::$meta, 'save_taxonomy' ), 10, 3 ),
array( 'create_term', array( PodsInit::$meta, 'save_taxonomy' ), 10, 3 )
);
}
elseif ( 'user' == $object_type ) {
$no_conflict[ 'filter' ] = array(

);

$no_conflict[ 'action' ] = array(

);
}
elseif ( 'comment' == $object_type ) {
$no_conflict[ 'filter' ] = array(

);

$no_conflict[ 'action' ] = array(

);
}

foreach ( $no_conflict as $action_filter => $conflicts ) {
foreach ( $conflicts as $args ) {
call_user_func_array( 'remove_' . $action_filter, $args );
}
}

PodsInit::$no_conflict[ $object_type ] = $no_conflict;
}

Expand All @@ -1290,5 +1337,15 @@ function pods_no_conflict_off ( $object_type = 'post' ) {
if ( empty( PodsInit::$no_conflict ) || !isset( PodsInit::$no_conflict[ $object_type ] ) || empty( PodsInit::$no_conflict[ $object_type ] ) )
return;

if ( !is_object( PodsInit::$meta ) )
return;

$no_conflict = PodsInit::$no_conflict[ $object_type ];

foreach ( $no_conflict as $action_filter => $conflicts ) {
foreach ( $conflicts as $args ) {
if ( call_user_func_array( 'has_' . $action_filter, $args ) )
call_user_func_array( 'add_' . $action_filter, $args );
}
}
}

0 comments on commit 1b6d64a

Please sign in to comment.