edd_admin_footer_for_thickbox

Admin Footer For Thickbox.

Description

edd_admin_footer_for_thickbox(); 

Prints the footer code needed for the Insert Download TinyMCE button.


Usage

  1. if ( !function_exists( 'edd_admin_footer_for_thickbox' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'easy-digital-downloads/includes/admin/thickbox.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = edd_admin_footer_for_thickbox(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/admin/thickbox.php  
  1. function edd_admin_footer_for_thickbox() { 
  2. global $pagenow, $typenow; 
  3.  
  4. // Only run in post/page creation and edit screens 
  5. if ( in_array( $pagenow, array( 'post.php', 'page.php', 'post-new.php', 'post-edit.php' ) ) && $typenow != 'download' ) { ?> 
  6. <script type="text/javascript"> 
  7. function insertDownload() { 
  8. var id = jQuery('#products').val(),  
  9. direct = jQuery('#select-edd-direct').val(),  
  10. style = jQuery('#select-edd-style').val(),  
  11. color = jQuery('#select-edd-color').is(':visible') ? jQuery('#select-edd-color').val() : '',  
  12. text = jQuery('#edd-text').val() || '<?php _e( "Purchase", "easy-digital-downloads" ); ?>'; 
  13.  
  14. // Return early if no download is selected 
  15. if ('' === id) { 
  16. alert('<?php _e( "You must choose a download", "easy-digital-downloads" ); ?>'); 
  17. return; 
  18.  
  19. if( '2' == direct ) { 
  20. direct = ' direct="true"'; 
  21. } else { 
  22. direct = ''; 
  23.  
  24. // Send the shortcode to the editor 
  25. window.send_to_editor('[purchase_link id="' + id + '" style="' + style + '" color="' + color + '" text="' + text + '"' + direct +']'); 
  26. jQuery(document).ready(function ($) { 
  27. $('#select-edd-style').change(function () { 
  28. if ($(this).val() === 'button') { 
  29. $('#edd-color-choice').slideDown(); 
  30. } else { 
  31. $('#edd-color-choice').slideUp(); 
  32. }); 
  33. }); 
  34. </script> 
  35.  
  36. <div id="choose-download" style="display: none;"> 
  37. <div class="wrap" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;"> 
  38. <p><?php echo sprintf( __( 'Use the form below to insert the shortcode for purchasing a %s', 'easy-digital-downloads' ), edd_get_label_singular() ); ?></p> 
  39. <div> 
  40. <?php echo EDD()->html->product_dropdown( array( 'chosen' => true )); ?> 
  41. </div> 
  42. <?php if( edd_shop_supports_buy_now() ) : ?> 
  43. <div> 
  44. <select id="select-edd-direct" style="clear: both; display: block; margin-bottom: 1em; margin-top: 1em;"> 
  45. <option value="0"><?php _e( 'Choose the button behavior', 'easy-digital-downloads' ); ?></option> 
  46. <option value="1"><?php _e( 'Add to Cart', 'easy-digital-downloads' ); ?></option> 
  47. <option value="2"><?php _e( 'Direct Purchase Link', 'easy-digital-downloads' ); ?></option> 
  48. </select> 
  49. </div> 
  50. <?php endif; ?> 
  51. <div> 
  52. <select id="select-edd-style" style="clear: both; display: block; margin-bottom: 1em; margin-top: 1em;"> 
  53. <option value=""><?php _e( 'Choose a style', 'easy-digital-downloads' ); ?></option> 
  54. <?php 
  55. $styles = array( 'button', 'text link' ); 
  56. foreach ( $styles as $style ) { 
  57. echo '<option value="' . $style . '">' . $style . '</option>'; 
  58. ?> 
  59. </select> 
  60. </div> 
  61. <?php 
  62. $colors = edd_get_button_colors(); 
  63. if( $colors ) { ?> 
  64. <div id="edd-color-choice" style="display: none;"> 
  65. <select id="select-edd-color" style="clear: both; display: block; margin-bottom: 1em;"> 
  66. <option value=""><?php _e('Choose a button color', 'easy-digital-downloads' ); ?></option> 
  67. <?php 
  68. foreach ( $colors as $key => $color ) { 
  69. echo '<option value="' . str_replace( ' ', '_', $key ) . '">' . $color['label'] . '</option>'; 
  70. ?> 
  71. </select> 
  72. </div> 
  73. <?php } ?> 
  74. <div> 
  75. <input type="text" class="regular-text" id="edd-text" value="" placeholder="<?php _e( 'Link text . . .', 'easy-digital-downloads' ); ?>"/> 
  76. </div> 
  77. <p class="submit"> 
  78. <input type="button" id="edd-insert-download" class="button-primary" value="<?php echo sprintf( __( 'Insert %s', 'easy-digital-downloads' ), edd_get_label_singular() ); ?>" onclick="insertDownload();" /> 
  79. <a id="edd-cancel-download-insert" class="button-secondary" onclick="tb_remove();"><?php _e( 'Cancel', 'easy-digital-downloads' ); ?></a> 
  80. </p> 
  81. </div> 
  82. </div> 
  83. <?php