| 1 |
<?php |
| 2 |
require_once('../../../wp-load.php'); |
| 3 |
require_once('../../../wp-admin/includes/admin.php'); |
| 4 |
do_action('admin_init'); |
| 5 |
|
| 6 |
if ( ! is_user_logged_in() ) |
| 7 |
die('You must be logged in to access this script.'); |
| 8 |
|
| 9 |
if(!isset($shortcodesXYZEH)) |
| 10 |
$shortcodesXYZEH = new XYZ_Insert_Html_TinyMCESelector(); |
| 11 |
|
| 12 |
global $wpdb; |
| 13 |
// $ordered_sct = array_keys($shortcode_tags); |
| 14 |
// sort($ordered_sct); |
| 15 |
|
| 16 |
$ordered_sct = $wpdb->get_results( "SELECT * FROM ".$wpdb->prefix."xyz_ihs_short_code WHERE status='1' ORDER BY id DESC" ); |
| 17 |
?> |
| 18 |
|
| 19 |
(function() { |
| 20 |
//******* Load plugin specific language pack |
| 21 |
|
| 22 |
tinymce.create('tinymce.plugins.<?php echo $shortcodesXYZEH->buttonName; ?>', { |
| 23 |
/** |
| 24 |
* Initializes the plugin, this will be executed after the plugin has been created. |
| 25 |
* This call is done before the editor instance has finished it's initialization so use the onInit event |
| 26 |
* of the editor instance to intercept that event. |
| 27 |
* |
| 28 |
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in. |
| 29 |
* @param {string} url Absolute URL to where the plugin is located. |
| 30 |
*/ |
| 31 |
init : function(ed, url) { |
| 32 |
|
| 33 |
}, |
| 34 |
|
| 35 |
/** |
| 36 |
* Creates control instances based in the incomming name. This method is normally not |
| 37 |
* needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons |
| 38 |
* but you sometimes need to create more complex controls like listboxes, split buttons etc then this |
| 39 |
* method can be used to create those. |
| 40 |
* |
| 41 |
* @param {String} n Name of the control to create. |
| 42 |
* @param {tinymce.ControlManager} cm Control manager to use inorder to create new control. |
| 43 |
* @return {tinymce.ui.Control} New control instance or null if no control was created. |
| 44 |
*/ |
| 45 |
createControl : function(n, cm) { |
| 46 |
if(n=='<?php echo $shortcodesXYZEH->buttonName; ?>'){ |
| 47 |
var mlb = cm.createListBox('<?php echo $shortcodesXYZEH->buttonName; ?>List', { |
| 48 |
title : 'HTML Snippets', |
| 49 |
onselect : function(v) { //Option value as parameter |
| 50 |
if(v != ''){ |
| 51 |
if(tinyMCE.activeEditor.selection.getContent() != ''){ |
| 52 |
tinyMCE.activeEditor.selection.setContent('[' + v + ']' + tinyMCE.activeEditor.selection.getContent() + '[/' + v + ']'); |
| 53 |
} |
| 54 |
else{ |
| 55 |
tinyMCE.activeEditor.selection.setContent('[' + v + ']'); |
| 56 |
} |
| 57 |
} |
| 58 |
} |
| 59 |
}); |
| 60 |
|
| 61 |
// Add some values to the list box |
| 62 |
<?php foreach($ordered_sct as $sct):?> |
| 63 |
mlb.add('<?php echo $sct->title;?>', '<?php echo 'xyz-ihs snippet="'.$sct->title.'"';?>'); |
| 64 |
<?php endforeach;?> |
| 65 |
|
| 66 |
// Return the new listbox instance |
| 67 |
return mlb; |
| 68 |
} |
| 69 |
|
| 70 |
return null; |
| 71 |
}, |
| 72 |
|
| 73 |
|
| 74 |
}); |
| 75 |
|
| 76 |
// Register plugin |
| 77 |
tinymce.PluginManager.add('<?php echo $shortcodesXYZEH->buttonName; ?>', tinymce.plugins.<?php echo $shortcodesXYZEH->buttonName; ?>); |
| 78 |
})(); |
| 79 |
|