Last active
October 6, 2018 06:17
-
-
Save shehabkhan013/c60da4226d276c2bd1e0923458b1f54e to your computer and use it in GitHub Desktop.
CMB2 Post Format Interactivity Add
This file contains 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
//includ the Js file is js folder | |
(function ($) { | |
$(document).ready(function () { | |
$("#post-formats-select .post-format").on("click", function () { | |
if ($(this).attr("id") == "post-format-image") { | |
$("#_alpha_image_information").show(); | |
} else { | |
$("#_alpha_image_information").hide(); | |
} | |
}); | |
if (alpha_pf.format != "image") { | |
$("#_alpha_image_information").hide(); | |
} | |
}); | |
})(jQuery); |
This file contains 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
// 1st this function add functions.php file | |
function alpha_admin_assets( $hook ) { | |
if ( isset( $_REQUEST['post'] ) || isset( $_REQUEST['post_ID'] ) ) { | |
$post_id = empty( $_REQUEST['post_ID'] ) ? $_REQUEST['post'] : $_REQUEST['post_ID']; | |
} | |
if ( "post.php" == $hook ) { | |
$post_format = get_post_format($post_id); | |
wp_enqueue_script( "admin-js", get_theme_file_uri( "/assets/js/admin.js" ), array( "jquery" ), VERSION, true ); | |
wp_localize_script("admin-js","alpha_pf",array("format"=>$post_format)); | |
} | |
} | |
add_action( "admin_enqueue_scripts", "alpha_admin_assets" ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment