first commit
This commit is contained in:
BIN
wp-content/themes/nuzi/framework/shortcode/images/iconsmall.png
Normal file
BIN
wp-content/themes/nuzi/framework/shortcode/images/iconsmall.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
103
wp-content/themes/nuzi/framework/shortcode/js/shortcode.js
Normal file
103
wp-content/themes/nuzi/framework/shortcode/js/shortcode.js
Normal file
@ -0,0 +1,103 @@
|
||||
(function() {
|
||||
tinymce.PluginManager.requireLangPack('twshortcodegenerator');
|
||||
tinymce.create('tinymce.plugins.twshortcodegenerator', {
|
||||
init : function(ed, url) {
|
||||
ed.addCommand('twshortcodegenerator', function() {
|
||||
jQuery( '<div id="shortcode_container_dialog" data-current="none" />').append(jQuery('#tw-shortcode-template').html()).dialog({
|
||||
title: 'Select the Shortcode',
|
||||
resizable: true,
|
||||
width: 800,
|
||||
// height: 500,
|
||||
modal: true,
|
||||
open: function(){
|
||||
jQuery(this).closest('.ui-dialog').addClass('tw-pb-main-container');
|
||||
jQuery(this).closest('.ui-dialog').focus();
|
||||
pbModalInitActions(jQuery(this));
|
||||
},
|
||||
close: function(){
|
||||
jQuery('#shortcode_container_dialog').closest('.ui-dialog').remove();
|
||||
jQuery('body>#shortcode_container_dialog').remove();
|
||||
},
|
||||
buttons: {
|
||||
"Done": function() {
|
||||
twInsertShortcode();
|
||||
jQuery(this).dialog("close");
|
||||
},
|
||||
"Cancel": function() {
|
||||
jQuery(this).dialog("close");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
ed.addButton('twshortcodegenerator', {title : 'ThemeWaves Shortcode Generator',cmd : 'twshortcodegenerator',image : url + '/../images/iconsmall.png'})
|
||||
},
|
||||
createControl : function(n, cm) {return null;},
|
||||
getInfo : function() {return {longname : "Shortcode",author : '',authorurl : '',infourl : '',version : "1.0"};}
|
||||
});
|
||||
tinymce.PluginManager.add('twshortcodegenerator', tinymce.plugins.twshortcodegenerator);
|
||||
})();
|
||||
// Functions
|
||||
function twGetShortcode($itemSlug){
|
||||
jQuery('#shortcode_container_dialog').addClass('loading-shortcode');
|
||||
jQuery('#shortcode_container_dialog>.custom-field-container').html('');
|
||||
jQuery.ajax({
|
||||
type: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action':'get_modal_shortcode',
|
||||
'shortcode_name':$itemSlug
|
||||
},
|
||||
success: function(response){
|
||||
jQuery('#shortcode_container_dialog>.custom-field-container').html(jQuery(response).find('.data>.custom-field-container').first().html());
|
||||
jQuery("#shortcode_container_dialog").attr('data-current',$itemSlug).removeClass('loading-shortcode');
|
||||
pbModalInitActions(jQuery("#shortcode_container_dialog"));
|
||||
}
|
||||
});
|
||||
}
|
||||
function twInsertShortcode(){
|
||||
var $shortcodeContainer = jQuery("#shortcode_container_dialog");
|
||||
var $itemSlug = $shortcodeContainer.attr('data-current');
|
||||
if($itemSlug!=='none'){
|
||||
var item = '';
|
||||
$shortcodeContainer.each(function(){
|
||||
var $currentItem=jQuery(this);
|
||||
item += '{"slug":"'+$itemSlug+'","size":"shortcode-size",';
|
||||
item += '"settings":{';
|
||||
jQuery('.custom-field-container>.field-item>.field-data>.field',$currentItem).each(function(index){
|
||||
var $currentField=jQuery(this);
|
||||
if(index){item += ',';}
|
||||
if($currentField.attr('data-type')==='container'){
|
||||
item += '"'+$currentField.attr('data-name')+'":{';
|
||||
$currentField.children('.container-item').each(function(itemIndex){
|
||||
var $currentContainerItem=jQuery(this);
|
||||
if(itemIndex){item += ',';}
|
||||
item += '"'+itemIndex+'":{';
|
||||
jQuery('.content>.field-item>.field-data>.field',$currentContainerItem).each(function(fieldIndex){
|
||||
var $currentContainerItemField = jQuery(this);
|
||||
if(fieldIndex){item += ',';}
|
||||
item += '"'+$currentContainerItemField.attr('data-name')+'":"'+encodeURIComponent($currentContainerItemField.val())+'"';
|
||||
});
|
||||
item += '}';
|
||||
});
|
||||
item += '}';
|
||||
}else{
|
||||
item += '"'+$currentField.attr('data-name')+'":"'+encodeURIComponent($currentField.val())+'"';
|
||||
}
|
||||
}).promise().done(function(){
|
||||
item +='}}';
|
||||
});
|
||||
}).promise().done(function(){
|
||||
jQuery.ajax({
|
||||
type: "POST",
|
||||
url : ajaxurl,
|
||||
data: {
|
||||
'action':'get_printed_item',
|
||||
'data':encodeURIComponent(item)
|
||||
},
|
||||
success: function(response){
|
||||
window.tinyMCE.execInstanceCommand($currentContentEditor, 'mceInsertContent', false, response);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
89
wp-content/themes/nuzi/framework/shortcode/shortcode.php
Normal file
89
wp-content/themes/nuzi/framework/shortcode/shortcode.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
if (!function_exists('add_tw_tinymce_plugin')){
|
||||
function add_tw_tinymce_plugin($plugin_array) {
|
||||
$plugin_array['twshortcodegenerator'] = get_template_directory_uri().'/framework/shortcode/js/shortcode.js';
|
||||
return $plugin_array;
|
||||
}
|
||||
}
|
||||
if (!function_exists('register_tw_button')){
|
||||
function register_tw_button($buttons) {
|
||||
array_push($buttons, "|", "twshortcodegenerator");
|
||||
return $buttons;
|
||||
}
|
||||
}
|
||||
if (!function_exists('add_tw_button')){
|
||||
function add_tw_button() {
|
||||
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') )
|
||||
return;
|
||||
if ( get_user_option('rich_editing') == 'true') {
|
||||
add_filter('mce_external_plugins', 'add_tw_tinymce_plugin');
|
||||
add_filter('mce_buttons', 'register_tw_button');
|
||||
}
|
||||
}
|
||||
}
|
||||
add_action('init', 'add_tw_button');
|
||||
|
||||
if (!function_exists('my_refresh_mce')){
|
||||
function my_refresh_mce($ver) {
|
||||
$ver += 3;
|
||||
return $ver;
|
||||
}
|
||||
}
|
||||
add_filter( 'tiny_mce_version', 'my_refresh_mce');
|
||||
require_once (THEME_PATH . "/framework/shortcode/shortcode_render.php");
|
||||
//====== START - Functions ======
|
||||
if (!function_exists('init_admin_shortcode_html')){
|
||||
function init_admin_shortcode_html(){
|
||||
global $tw_pbItems; ?>
|
||||
<div id="tw-shortcode-template" style="display: none;">
|
||||
<div class="general-field-container">
|
||||
<div class="field-item clearfix type-select">
|
||||
<div class="field-title">Select Shortcode</div>
|
||||
<div class="field-data">
|
||||
<select id="style_shortcode" data-type="select" class="field">
|
||||
<option value="none"><?php _e('Select Shortcode','themewaves'); ?></option><?php
|
||||
if(!empty($tw_pbItems)){
|
||||
foreach ($tw_pbItems as $pbItemSlug => $pbItemArray) {
|
||||
if(empty($pbItemArray['only']) || $pbItemArray['only']==='shortcode'){
|
||||
echo '<option value="' . $pbItemSlug . '" >' . $pbItemArray['name'] . '</option>';
|
||||
}
|
||||
}
|
||||
} ?>
|
||||
</select>
|
||||
<span class="select-text"></span>
|
||||
</div>
|
||||
<div class="field-desc">Select Shortcode</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="custom-field-container"></div>
|
||||
</div><?php
|
||||
}
|
||||
}
|
||||
add_action( 'admin_head', 'init_admin_shortcode_html', 1 );
|
||||
|
||||
if (!function_exists('getModalShortcode')) {
|
||||
function getModalShortcode() {
|
||||
if (!empty($_REQUEST['shortcode_name'])) {
|
||||
die(pbGetItem($_REQUEST['shortcode_name']));
|
||||
}
|
||||
}
|
||||
} add_action('wp_ajax_get_modal_shortcode', 'getModalShortcode');
|
||||
|
||||
if (!function_exists('getPrintShortcode')) {
|
||||
function getPrintShortcode() {
|
||||
if (!empty($_REQUEST['get_print_shortcode'])) {
|
||||
die(pbGetItem($_REQUEST['get_print_shortcode']));
|
||||
}
|
||||
die('<div class="error">Empty Reqeist</div>');
|
||||
}
|
||||
} add_action('wp_ajax_get_print_shortcode', 'getPrintShortcode');
|
||||
|
||||
if (!function_exists('getPrintedItem')) {
|
||||
function getPrintedItem(){
|
||||
if (!empty($_REQUEST['data'])) {
|
||||
$item_array = json_decode(rawUrlDecode($_REQUEST['data']), true);
|
||||
die(pbGetContentBuilderItem($item_array));
|
||||
}
|
||||
die('<div class="error">Empty Reqeist</div>');
|
||||
}
|
||||
} add_action('wp_ajax_get_printed_item', 'getPrintedItem');
|
1281
wp-content/themes/nuzi/framework/shortcode/shortcode_render.php
Normal file
1281
wp-content/themes/nuzi/framework/shortcode/shortcode_render.php
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user