Skip to content

Instantly share code, notes, and snippets.

@hellofromtonya
Created February 3, 2018 23:15
Show Gist options
  • Save hellofromtonya/18e82f397dba1fbc8ea169a3b26dcac5 to your computer and use it in GitHub Desktop.
Save hellofromtonya/18e82f397dba1fbc8ea169a3b26dcac5 to your computer and use it in GitHub Desktop.
Fixed beans_replace_action and beans_replace_action_hook in Beans 1.5.0
<?php
function beans_replace_action( $id, $hook = null, $callback = null, $priority = null, $args = null ) {
$action = _beans_build_action_array( $hook, $callback, $priority, $args );
// If no changes were passed in, there's nothing to modify. Bail out.
if ( empty( $action ) ) {
return false;
}
// Set and get the latest "replaced" action.
$action = _beans_merge_action( $id, $action, 'replaced' );
// Modify the action.
$is_modified = beans_modify_action( $id, $hook, $callback, $priority, $args );
// Now merge the current action with the replaced one.
_beans_merge_action( $id, $action, 'added' );
return $is_modified;
}
function beans_replace_action_hook( $id, $hook ) {
if ( empty( $hook ) || ! is_string( $hook ) ) {
return false;
}
return beans_replace_action( $id, $hook );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment