Skip to content

Commit

Permalink
1.1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
kprajapatii committed Mar 21, 2023
1 parent 690fe70 commit dedd0c1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ayecode/wp-super-duper",
"version": "1.1.16",
"version": "1.1.17",
"type": "library",
"description": "Lets you create a widget, block and shortcode all from the one file .",
"keywords": ["WordPress","super duper","wp"],
Expand Down
37 changes: 20 additions & 17 deletions wp-super-duper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

if ( ! class_exists( 'WP_Super_Duper' ) ) {

define( 'SUPER_DUPER_VER', '1.1.16' );
define( 'SUPER_DUPER_VER', '1.1.17' );

/**
* A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
Expand Down Expand Up @@ -129,8 +129,9 @@ public function __construct( $options ) {
add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );

// add generator text to admin head
// add generator text to head
add_action( 'admin_head', array( $this, 'generator' ) );
add_action( 'wp_head', array( $this, 'generator' ) );
}

do_action( 'wp_super_duper_widget_init', $options, $this );
Expand Down Expand Up @@ -343,10 +344,25 @@ public static function get_picker( $editor_id = '' ) {
}

/**
* Output the version in the admin header.
* Output the version in the header.
*/
public function generator() {
echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />';
$file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
$plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );

// Find source plugin/theme of SD
$source = array();
if ( strpos( $file, $plugins_dir ) !== false ) {
$source = explode( "/", plugin_basename( $file ) );
} else if ( function_exists( 'get_theme_root' ) ) {
$themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );

if ( strpos( $file, $themes_dir ) !== false ) {
$source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
}
}

echo '<meta name="generator" content="WP Super Duper v' . $this->version . '"' . ( ! empty( $source[0] ) ? ' data-sd-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />';
}

/**
Expand Down Expand Up @@ -790,10 +806,8 @@ function sd_copy_to_clipboard() {
Gets the shortcode options.
*/
function sd_get_shortcode_options($this) {

$short_code = jQuery($this).val();
if ($short_code) {

var data = {
'action': 'super_duper_get_widget_settings',
'shortcode': $short_code,
Expand Down Expand Up @@ -824,18 +838,15 @@ function sd_get_shortcode_options($this) {
jQuery('#TB_ajaxContent').css('width', 'auto').css('height', '75vh');
}, 200);


return response;
});
}

}

/*
Builds and inserts the shortcode into the viewer.
*/
function sd_build_shortcode($id) {

var multiSelects = {};
var multiSelectsRemove = [];

Expand Down Expand Up @@ -878,11 +889,9 @@ function sd_build_shortcode($id) {
$form_data = $form_data.concat($ms_arr);
}


if ($form_data) {
$content = '';
$form_data.forEach(function (element) {

if (element.value) {
$field_name = element.name.substr(element.name.indexOf("][") + 2);
$field_name = $field_name.replace("]", "");
Expand All @@ -892,7 +901,6 @@ function sd_build_shortcode($id) {
$output = $output + " " + $field_name + '="' + element.value + '"';
}
}

});
}
$output = $output + "]";
Expand All @@ -905,7 +913,6 @@ function sd_build_shortcode($id) {
jQuery('#TB_ajaxContent #sd-shortcode-output').html($output);
}


/*
Delay the init of the textareas for 1 second.
*/
Expand All @@ -919,10 +926,8 @@ function sd_build_shortcode($id) {
Init the textareas to be able to show the shortcode builder button.
*/
function sd_init_textareas() {

// General textareas
jQuery(document).on('focus', 'textarea', function () {

if (jQuery(this).hasClass('wp-editor-area')) {
// insert the shortcode button to the textarea lable if not there already
if (!jQuery(this).parent().find('.sd-lable-shortcode-inserter').length) {
Expand Down Expand Up @@ -994,7 +999,6 @@ function sd_init_textareas() {
// jQuery(this).parent().parent().find('.wpb_element_label').append(sd_shortcode_button());
// }
// });

}

/**
Expand Down Expand Up @@ -1043,7 +1047,6 @@ function sd_shortcode_button($id) {
return '<?php echo self::shortcode_button();?>';
}
}

</script>
<?php
}
Expand Down

0 comments on commit dedd0c1

Please sign in to comment.