Last active
December 3, 2015 09:04
-
-
Save wpweb101/076c4d9cc75367b6b29c to your computer and use it in GitHub Desktop.
Disable enfold theme builder functionality in voucher templates CPT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //Create global variable for builder | |
| global $builder_object; | |
| //Assign builder object to global variable | |
| $builder_object = $builder; | |
| //Add action for remove builder functionality from voucher templates | |
| add_action( 'admin_init', 'avia_remove_builder_functionality' ); | |
| function avia_remove_builder_functionality() { | |
| global $typenow, $pagenow, $builder_object; | |
| $remove_enfold_builder_cpt = apply_filters( 'avia_remove_enfold_builder_cpt', array( 'woovouchers', 'eddvouchers', 'wpsdealsvouchers' ) ); | |
| if( empty( $typenow ) ) {//If typenow is empty | |
| if ( !empty( $_GET['post'] ) ) {// try to pick it up from the query string | |
| $post = get_post( $_GET['post'] ); | |
| $typenow = $post->post_type; | |
| } elseif( !empty( $_POST['post_ID'] ) ) {// try to pick it up from the quick edit AJAX post | |
| $post = get_post( $_POST['post_ID'] ); | |
| $typenow = $post->post_type; | |
| } | |
| } | |
| if( ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) && in_array( $typenow, $remove_enfold_builder_cpt ) ) { | |
| remove_action('load-post.php', array( $builder_object, 'admin_init') , 5 ); | |
| remove_action('load-post-new.php', array( $builder_object, 'admin_init') , 5 ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment