Created
January 23, 2023 16:54
-
-
Save BhargavBhandari90/6f24ddf7f2d7608620b9d42c990a56af to your computer and use it in GitHub Desktop.
WordPress Image Editor
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
<?php | |
add_shortcode( 'post_list', 'bunty_shortcode' ); | |
function bunty_shortcode( $attr ) { | |
ob_start(); | |
include_once ABSPATH . 'wp-admin/includes/image-edit.php'; | |
wp_image_editor( 26288 ); // change this with attachment ID. | |
return ob_get_clean(); | |
} | |
function bwp_script_callback() { | |
wp_enqueue_style( 'imgareaselect' ); | |
wp_enqueue_script( | |
'image-edit', | |
trailingslashit( site_url( 'wp-admin' ) ) . 'js/image-edit.js', | |
array( 'wp-i18n', 'jquery', 'jquery-ui-core', 'json2', 'imgareaselect', 'wp-a11y', 'wp-ajax-response' ) | |
); | |
} | |
add_action( 'wp_enqueue_scripts', 'bwp_script_callback' ); | |
function bwp_head() { | |
?> | |
<script> | |
var ajaxurl = '<?php echo admin_url( 'admin-ajax.php' ); ?>'; | |
</script> | |
<?php | |
} | |
add_action( 'wp_head', 'bwp_head' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment