diff --git a/README.md b/README.md
index 7966754..61cd518 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-WP SVG Icons v3.1
+WP SVG Icons v3.1.1
=============
- **Contributors** : eherman24
@@ -118,6 +118,13 @@ If you buy the pro version you will also receive support and updates for one yea
#### Changelog
+= 3.1.1 - March 5th, 2015 =
+* Fixed bug where clicking custom icon didn't load it into the preview container
+* Added new setting to delete custom icon pack on plugin uninstall
+* Re-wrote uninstall function to remove all plugin created options
+* Added 2 week upgrade/review notification
+* Minor style enhancements and bug fixes
+
= 3.1 - March 3rd, 2015 =
* Fix link styles overriding WordPress defaults
* Minified default icon styles, added appropriate element classes and enqueued across dashboard
diff --git a/admin/class-wp-svg-icons-admin.php b/admin/class-wp-svg-icons-admin.php
index b0f89e1..710e483 100644
--- a/admin/class-wp-svg-icons-admin.php
+++ b/admin/class-wp-svg-icons-admin.php
@@ -53,7 +53,19 @@ public function __construct( $plugin_name, $version ) {
add_action( 'wp_update_nav_menu_item', array( $this, 'wp_svg_icons_update_custom_nav_fields'), 10, 3 );
// action hook which handles the ajax request of deleting files
- add_action('wp_ajax_svg_delete_custom_pack', array( &$this , 'svg_delete_custom_pack_ajax' ) );
+ add_action('wp_ajax_svg_delete_custom_pack', array( &$this , 'svg_delete_custom_pack_ajax' ) );
+
+ // custom font pack found error
+ add_action('admin_notices', array( &$this , 'wp_svg_customPack_installed_error' ) );
+
+ // set the custom upload directory
+ add_action( 'admin_head', array( &$this , 'wp_svg_change_downloads_upload_dir' ) , 999 );
+
+ // check the users plugin installation date
+ add_action( 'admin_init', array( &$this , 'wp_svg_icons_check_installation_date' ) );
+
+ // dismissable notice admin side
+ add_action( 'admin_init', array( &$this , 'wp_svg_icons_stop_bugging_me' ), 5 );
}
/**
@@ -116,13 +128,7 @@ public function enqueue_scripts() {
// enqueue our nav scripts/styles
$this->enqueue_custom_nav_scripts_on_nav_menu_page();
-
- // custom font pack found error
- add_action('admin_notices', array( &$this , 'wp_svg_customPack_installed_error' ) );
-
- // set the custom upload directory
- add_action( 'admin_head', array( &$this , 'wp_svg_change_downloads_upload_dir' ) , 999 );
-
+
}
// ajax delete our .zip and entire directory for the custom pack!
@@ -338,6 +344,78 @@ public function recursive_delete_directory( $dir ) {
}
}
+ /*
+ wp_svg_icons_stop_bugging_me()
+ Remove the Review us notification when user clicks 'Dismiss'
+ @since v3.1.1
+ */
+ public function wp_svg_icons_stop_bugging_me() {
+ $nobug = "";
+ if ( isset( $_GET['wp_svg_icons_nobug'] ) ) {
+ $nobug = esc_attr( $_GET['wp_svg_icons_nobug'] );
+ }
+ if ( 1 == $nobug ) {
+ add_option( 'wp_svg_icons_review_stop_bugging_me', TRUE );
+ }
+ }
+
+ /*
+ wp_svg_icons_check_installation_date()
+ checks the user installation date, and adds our action
+ - if it's past 2 weeks we ask the user for a review :)
+ @since v3.1.1
+ */
+ public function wp_svg_icons_check_installation_date() {
+
+ // add a new option to store the plugin activation date/time
+ // @since v3.1.1
+ // this is used to notify the user that they should review after 2 weeks
+ if ( !get_option( 'wp_svg_icons_activation_date' ) ) {
+ add_option( 'wp_svg_icons_activation_date', strtotime( "now" ) );
+ }
+
+ $stop_bugging_me = get_option( 'wp_svg_icons_review_stop_bugging_me' );
+
+ if( !$stop_bugging_me ) {
+ $install_date = get_option( 'wp_svg_icons_activation_date' );
+ $past_date = strtotime( '-0 days' );
+ if ( $past_date >= $install_date && current_user_can( 'install_plugins' ) ) {
+ add_action( 'admin_notices', array( &$this , 'wp_svg_icons_display_review_us_notice' ) );
+ }
+ }
+
+ }
+
+ /*
+ Display our admin notification
+ asking for a review, and for user feedback
+ @since v3.1.1
+ */
+ public function wp_svg_icons_display_review_us_notice() {
+ /* Lets only display our admin notice on YT4WP pages to not annoy the hell out of people :) */
+ if ( in_array( get_current_screen()->base , array( 'dashboard' , 'toplevel_page_wp-svg-icons' , 'wp-svg-icons_page_wp-svg-icons-custom-set' , 'wp-svg-icons_page_wp_svg_icons' , 'wp-svg-icons_page_wp-svg-icons-upgrade' , 'post' ) ) ) {
+ // Review URL - Change to the URL of your plugin on WordPress.org
+ $reviewurl = 'https://wordpress.org/support/view/plugin-reviews/svg-vector-icon-plugin';
+ $go_pro_url = 'http://www.evan-herman.com/wordpress-plugin/wp-svg-icons/';
+ $http_https = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
+ $current_url = "$http_https$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
+ $nobugurl = add_query_arg( 'wp_svg_icons_nobug', '1', $current_url );
+ global $current_user;
+ get_currentuserinfo();
+ if ( '' != $current_user->user_firstname ) {
+ $review_message = '
' . sprintf( __( "Hey" , "wp-svg-icons" ) . " " . $current_user->user_firstname . __( ", You've been using" , "wp-svg-icons" ) . " WP SVG Icons " . __( "for 2 weeks now. We certainly hope you're enjoying the power and all the features packed into the free version. If so, leave us a review, we'd love to hear what you have to say. If you're really enjoying the plugin, consider upgrading to the pro version for some added features and premium support." , "wp-svg-icons" ) . " " . __( "Leave A Review" , "wp-svg-icons" ) . " " . __( "Upgrade to Pro" , "wp-svg-icons" ) . " " . __( "Dismiss" , "wp-svg-icons" ) . " ", $reviewurl, $go_pro_url, $nobugurl ) . '
';
+ } else {
+ $review_message = '' . sprintf( __( "Hey there, it looks like you've been using" , "wp-svg-icons" ) . " WP SVG Icons " . __( "for 2 weeks now. We certainly hope you're enjoying the power and all the features packed into the free version. If so, leave us a review, we'd love to hear what you have to say. If you're really enjoying the plugin, consider upgrading to the pro version for some added features and premium support." , "wp-svg-icons" ) . " " . __( "Leave A Review" , "wp-svg-icons" ) . " " . __( "Upgrade to Pro" , "wp-svg-icons" ) . " " . __( "Dismiss" , "wp-svg-icons" ) . " ", $reviewurl, $go_pro_url, $nobugurl ) . '
';
+ }
+ ?>
+
+
+
+
+ .mhl,.glyph .fs0,.glyph fieldset,.mbl,.mhl>h1:first-child{display:none}.glyph span:first-child{display:block;width:100%;font-size:1.5em}.glyph span:last-child{line-height:.9;font-size:15px;display:none}.glyph{color:#333}.selected{color:#F80;background:#d8d8d8}.selected span:last-child{color:#666}.custom-pack-container-ajax .glyph{width:29px}.wp-svg-icon-preview .previewIcon{font-size:90px;display:block;margin:10px auto 0}.wp-svg-icons-wrap .custom-pack-container-ajax .glyph{padding:10px 7px 0!important}.bgc1>.mhl,.mbl,.wrap .current-font-pack .mhl>h1:first-child{display:none}.wrap .current-font-pack .glyph{background:0 0;margin:.25em .35em .25em 0;width:1.5em;padding:.35em;box-shadow:none;-o-transition:.15s;-ms-transition:.15s;-moz-transition:.15s;-webkit-transition:.15s;transition:.15s;font-size:1.75em}.wrap .current-font-pack .glyph:hover{cursor:pointer;color:#ff8000}.glyph .fs0,.wrap .current-font-pack .glyph fieldset{display:none}.wrap .current-font-pack .glyph span:first-child{display:block;width:100%;font-size:1.5em}.wrap .current-font-pack .glyph span:last-child{line-height:.9;font-size:15px;display:none}.wrap .current-font-pack .glyph{color:#333}.wrap .current-font-pack .selected{color:#F80;background:#d8d8d8}.wrap .current-font-pack .selected span:last-child{color:#666}.wrap .current-font-pack .wp-svg-icon-preview-box{margin-top:-6em}.wrap .current-font-pack .wp-svg-icon-preview{font-size:8em}.wrap .current-font-pack .wp-svg-icon-preview-box i{display:block;margin-top:-.5em;padding-top:5px}.wrap .current-font-pack .wp-svg-icon-preview div{margin-top:10px}.wp-svg-icons_page_wp-svg-icons-custom-set ::selection{background:#FF8000}.toplevel_page_wp-svg-icons .wp-menu-image img{margin-top:-3px}.dashicons-wp-svg-gift:before{content:"\e099"!important;font-size:18px}#advanced-shortcode-attr-list{display:none;margin:0 35px}#advanced-shortcode-attr-list li{width:46.5%;float:left}.shortcode-attr-right-column{float:right!important}.wp-svg-advanced-shortcode-attr-row strong{display:block;margin-bottom:.25em}.wp-svg-advanced-shortcode-attr-row .shortcode-attr-right-column .wp-picker-container{width:100%}.wp-svg-advanced-shortcode-attr-row{display:block;width:100%;float:left}.wp-svg-advanced-shortcode-attr-row:nth-child(2){margin-top:1em}#advanced-shortcode-attr-toggle{font-size:11px}#icon-size-input{max-width:75px;margin-top:1em;text-align:center}.wp-svg-happy{-o-transition:.15s;-ms-transition:.15s;-moz-transition:.15s;-webkit-transition:.15s;transition:.15s}.wp-svg-happy:hover{color:#FF8000}
\ No newline at end of file
+.custom-pack-container-ajax{width:100%}.custom-pack-container-ajax [class*=" wp-svg-custom-"],.custom-pack-container-ajax [class^=wp-svg-custom-]{font-size:2.75em!important}.bgc1>.mhl,.glyph .fs0,.glyph fieldset,.mbl,.mhl>h1:first-child{display:none}.glyph span:first-child{display:block;width:100%;font-size:1.5em}.glyph span:last-child{line-height:.9;font-size:15px;display:none}.glyph{color:#333}.selected{color:#F80;background:#d8d8d8}.selected span:last-child{color:#666}.custom-pack-container-ajax .glyph{width:29px}.wp-svg-icon-preview .previewIcon{font-size:90px;display:block;margin:10px auto 0}.wp-svg-icons-wrap .custom-pack-container-ajax .glyph{padding:10px 7px 0!important}.bgc1>.mhl,.mbl,.wrap .current-font-pack .mhl>h1:first-child{display:none}.wrap .current-font-pack .glyph{background:0 0;margin:.25em .35em .25em 0;width:1.5em;padding:.35em;box-shadow:none;-o-transition:.15s;-ms-transition:.15s;-moz-transition:.15s;-webkit-transition:.15s;transition:.15s;font-size:1.75em}.wrap .current-font-pack .glyph:hover{cursor:pointer;color:#ff8000}.glyph .fs0,.wrap .current-font-pack .glyph fieldset{display:none}.wrap .current-font-pack .glyph span:first-child{display:block;width:100%;font-size:1.5em}.wrap .current-font-pack .glyph span:last-child{line-height:.9;font-size:15px;display:none}.wrap .current-font-pack .glyph{color:#333}.wrap .current-font-pack .selected{color:#F80;background:#d8d8d8}.wrap .current-font-pack .selected span:last-child{color:#666}.wrap .current-font-pack .wp-svg-icon-preview-box{margin-top:-6em}.wrap .current-font-pack .wp-svg-icon-preview{font-size:8em}.wrap .current-font-pack .wp-svg-icon-preview-box i{display:block;margin-top:-.5em;padding-top:5px}.wrap .current-font-pack .wp-svg-icon-preview div{margin-top:10px}.wp-svg-icons_page_wp-svg-icons-custom-set ::selection{background:#FF8000}.toplevel_page_wp-svg-icons .wp-menu-image img{margin-top:-3px}.dashicons-wp-svg-gift:before{content:"\e099"!important;font-size:18px}#advanced-shortcode-attr-list{display:none;margin:0 35px}#advanced-shortcode-attr-list li{width:46.5%;float:left}.shortcode-attr-right-column{float:right!important}.wp-svg-advanced-shortcode-attr-row strong{display:block;margin-bottom:.25em}.wp-svg-advanced-shortcode-attr-row .shortcode-attr-right-column .wp-picker-container{width:100%}.wp-svg-advanced-shortcode-attr-row{display:block;width:100%;float:left}.wp-svg-advanced-shortcode-attr-row:nth-child(2){margin-top:1em}#advanced-shortcode-attr-toggle{font-size:11px}#icon-size-input{max-width:75px;margin-top:1em;text-align:center}.wp-svg-happy{-o-transition:.15s;-ms-transition:.15s;-moz-transition:.15s;-webkit-transition:.15s;transition:.15s}.wp-svg-happy:hover{color:#FF8000}#review-wp-svg-icons-notice{display:block;margin:5px 20px 2px 0px;border-left:4px solid #7ad03a;margin-top:1.5em;padding:2px 10px;background:url(../images/evan-herman-mascot.png) right bottom no-repeat #fff;background-size:120px;background-position-y:29px}#review-wp-svg-icons-notice .button-container{display:block;text-align:center}
\ No newline at end of file
diff --git a/admin/js/wordpress-svg-icon-plugin-scripts.js b/admin/js/wordpress-svg-icon-plugin-scripts.js
index c052cc1..7a51905 100644
--- a/admin/js/wordpress-svg-icon-plugin-scripts.js
+++ b/admin/js/wordpress-svg-icon-plugin-scripts.js
@@ -1 +1 @@
-/*
WP SVG ICON PLUGIN SCRIPTS
Compiled by Evan Herman - www.Evan-Herman.com
*/
jQuery(document).ready( function() {
// select default icon element wrapper on initial page load
iconWrapperClick( jQuery( this ) , localized_data.default_icon_element );
var interval = null;
var x = 0;
function check_thick() {
interval = setInterval(function() {
if( jQuery( '#TB_ajaxContent' ).is( ':visible' ) ) {
x = 0;
if( jQuery( '.icon-wrapper' ).hasClass( 'selected-element-wrap' ) ) {
return;
}
jQuery( '.custom-pack-tab' ).removeAttr( 'style' );
iconWrapperClick( jQuery( this ) , localized_data.default_icon_element );
jQuery( '.element_selection_container' ).find( jQuery( '.icon-wrapper[alt="' + localized_data.default_icon_element + '"]' ) ).addClass( 'selected-element-wrap' );
} else {
x = 1;
}
}, 50);
};
// run our check thickbox function
// on initial page load
check_thick();
// if a custom icon pack is not installed,
// lets make sure that the custom tab remains hidden
if( localized_data.custom_pack_active != 'true' ) {
setInterval(function() {
if( jQuery( '#TB_ajaxContent' ).is( ':visible' ) ) {
jQuery( '.custom-pack-tab' ).hide();
}
}, 50);
}
// when a user clicks on an icon,
// load'er up to the preview box
function buttonClick() {
var glyphUnicode = jQuery( 'input[type=text].glyph_unicode', this ).val();
var iconClass = jQuery( this ).find( 'div' ).attr( 'class' ).replace( 'fs1' , '' );
var selectedIconWrapper = jQuery( '.selected-element-wrap' ).attr( 'alt' );
jQuery('.glyph').removeClass('selected');
jQuery(this).addClass('selected');
jQuery('.copy_paste_input').text('[wp-svg-icons icon="'+iconClass.trim()+'" wrap="'+selectedIconWrapper+'"]');
jQuery('input[type=text].expansion_glyph_unicode').css('background-color','#eee');
jQuery('input[type=text].glyph_unicode').css('background-color','#eee');
jQuery('input[type=text].glyph_unicode', this).css('background-color','#FF8000', 'font-color', '#000');
jQuery('.wp-svg-icon-preview').html('');
jQuery( '.wp-svg-iconset1-preview' ).fadeIn( 'fast' );
// Fade in the insert icon button
if( jQuery( '#TB_ajaxContent' ).is( ':visible' ) ) {
jQuery( '.insert-wp-svg-icon' ).fadeIn();
jQuery('#TB_ajaxContent').animate({ scrollTop: 0 }, 'slow'); // scroll thickbox back up
} else {
jQuery('html, body').animate({ scrollTop: 0 }, 'slow'); // scroll html body
}
};
function iconWrapperClick( button, element ) {
if ( jQuery( '.custom-pack-tab' ).hasClass( 'nav-tab-active' ) ) {
var active_tab = 'custom';
} else {
var active_tab = 'default';
}
var iconClass = jQuery( '.wp-svg-iconset1-all-glyphs' ).find( '.glyph-demo.selected' ).find( 'div' ).attr( 'class' );
// if the icon class is undefined, we're probably on the custom pack tab
if( iconClass === undefined ) {
// reset up the variable
var iconClass = jQuery( '.custom-pack-container-ajax' ).find( '.glyph.selected' ).find( 'span:first-child' ).attr( 'class' );
}
jQuery( '.icon-wrapper' ).removeClass( 'selected-element-wrap' );
jQuery( button ).addClass( 'selected-element-wrap' );
var selectedIconWrapper = element;
if( iconClass ) {
iconClass = iconClass.replace( 'fs1' , '' );
if( active_tab == 'custom' ) {
var newIconClass = iconClass.replace( 'wp-svg-custom-' , '' );
// swap out the example container for the new element
jQuery( '.copy_paste_input' ).text('[wp-svg-icons custom_icon="'+newIconClass.trim()+'" wrap="'+selectedIconWrapper+'"]');
} else {
// swap out the example container for the new element
jQuery( '.copy_paste_input' ).text('[wp-svg-icons icon="'+iconClass.trim()+'" wrap="'+selectedIconWrapper+'"]');
}
} else {
// no icon was selected yet...but we can still add our wrap
// swap out the example container for the new element
jQuery( '.copy_paste_input' ).text('[wp-svg-icons icon="" wrap=""]');
}
};
jQuery( '.element_selection_container' ).find( jQuery( '.icon-wrapper[alt="' + localized_data.default_icon_element + '"]' ) ).addClass( 'selected-element-wrap' );
/* Change selected icon wrapper */
jQuery( 'body' ).on( 'click' , '.icon-wrapper ' , function() {
iconWrapperClick( jQuery( this ) , jQuery( this ).attr( 'alt' ) );
});
/* Change the icon */
jQuery( 'body' ).on( 'click' , '.glyph-demo' , buttonClick );
// set up a timer...
var delay = (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})();
});
// insert our icon into the editor
function insert_wp_SVG_icon_to_editor() {
var icon_code = jQuery( '.copy_paste_input' ).text();
tb_remove();
window.send_to_editor( icon_code );
event.preventDefault();
}
// click the tab nav, to toggle between default and custom pcaks on edit.php
function load_custom_pack( e ) {
jQuery( '.nav-tab' ).removeClass( 'nav-tab-active' );
jQuery( e ).addClass( 'nav-tab-active' );
if( jQuery( '.custom-pack-container-ajax' ).is( ":empty" ) ) {
jQuery( '.wp-svg-iconset1-all-glyphs' ).fadeOut( 'fast' , function() {
jQuery(".custom-pack-container-ajax").load( localized_data.site_url + "/wp-content/uploads/wp-svg-icons/custom-pack/demo.html" );
jQuery.get( localized_data.site_url + "/wp-content/uploads/wp-svg-icons/custom-pack/style.css", function( data ) {
jQuery("head").append("");
});
});
jQuery('.custom-pack-container-ajax').on( 'click' , '.glyph' , function() {
jQuery('.glyph').removeClass("selected");
jQuery(this).addClass("selected");
jQuery('html, body').animate({ scrollTop: 0 }, 'slow');
var glyphCode = jQuery(this).find('.mls').text();
var newGlyphCode = glyphCode.replace( 'wp-svg-' , '' );
var glyphCode = jQuery.trim(glyphCode);
glyphCode = glyphCode.replace( 'wp-svg-custom-' , '' );
var selectedIconWrapper = jQuery( '.selected-element-wrap' ).attr( 'alt' );
// Fade in the insert icon button
if( jQuery( '#TB_ajaxContent' ).is( ':visible' ) ) {
jQuery( '.insert-wp-svg-icon' ).fadeIn();
jQuery('#TB_ajaxContent').animate({ scrollTop: 0 }, 'slow'); // scroll thickbox back up
} else {
jQuery('html, body').animate({ scrollTop: 0 }, 'slow'); // scroll html body
}
//console.log(glyphCode);
jQuery('.copy_paste_input').text('[wp-svg-icons custom_icon="'+glyphCode.trim()+'" wrap="'+selectedIconWrapper+'"]');
jQuery('.wp-svg-icon-preview').remove();
jQuery('.wp-svg-icon-preview-box > i').after(" ");
jQuery('.previewIcon').fadeIn();
});
} else {
jQuery( '.wp-svg-iconset1-all-glyphs' ).fadeOut( 'fast' , function() {
jQuery(".custom-pack-container-ajax").fadeIn();
});
}
}
function show_defualt_pack( e ) {
if( jQuery( '.default-icon-pack ' ).hasClass( 'nav-tab-active' ) ) {
return false;
} else {
jQuery( '.nav-tab' ).removeClass( 'nav-tab-active' );
jQuery( e ).addClass( 'nav-tab-active' );
jQuery( '.custom-pack-container-ajax' ).fadeOut( 'fast' , function() {
jQuery( '.wp-svg-iconset1-all-glyphs' ).fadeIn( 'fast' );
});
}
}
function build_the_icon_shortcode( e ) {
// store the element wrap variable
var element_wrap = jQuery( '.element_selection_container' ).find( '.selected-element-wrap' ).attr( 'alt' );
var icon_name = jQuery( '.glyph.selected' ).find( '.mls' ).text().replace( 'wp-svg-' , '' ).replace( 'custom-' , '' ).trim();
if( jQuery( e ).hasClass( 'yes-adv-attr' ) ) {
var selected_element = jQuery( '.glyph.selected' ).length;
if( selected_element > 0 ) { // check if an icon was selected
// check if were on a custom icon pack, or the default icon pack
if ( jQuery( '.custom-pack-tab' ).hasClass( 'nav-tab-active' ) ) {
var active_tab = 'custom';
} else {
var active_tab = 'default';
}
// create an array for our attributes
var custom_shortcode_attr_array = [];
var shortcode = jQuery( '.copy_paste_input' ).text();
// icon name
if( icon_name ) {
if( active_tab == 'custom' ) {
custom_shortcode_attr_array.push( 'custom_icon="'+icon_name+'"' );
} else { // defualt icon
custom_shortcode_attr_array.push( 'icon="'+icon_name+'"' );
}
}
// element icon wrap
if( element_wrap ) {
custom_shortcode_attr_array.push( 'wrap="'+element_wrap+'"' );
}
// console.log( custom_shortcode_attr_array );
jQuery( '.copy_paste_input' ).text( '[wp-svg-icons '+custom_shortcode_attr_array.join( ' ' )+']' );
} else { // if not...just toggle the advanced attrs
}
} else {
// store default
jQuery( '.copy_paste_input' ).text( '[wp-svg-icons icon="'+icon_name+'" wrap="'+element_wrap+'"]' );
}
}
\ No newline at end of file
+/*
WP SVG ICON PLUGIN SCRIPTS
Compiled by Evan Herman - www.Evan-Herman.com
*/
jQuery(document).ready( function() {
// select default icon element wrapper on initial page load
iconWrapperClick( jQuery( this ) , localized_data.default_icon_element );
var interval = null;
var x = 0;
function check_thick() {
interval = setInterval(function() {
if( jQuery( '#TB_ajaxContent' ).is( ':visible' ) ) {
x = 0;
if( jQuery( '.icon-wrapper' ).hasClass( 'selected-element-wrap' ) ) {
return;
}
jQuery( '.custom-pack-tab' ).removeAttr( 'style' );
iconWrapperClick( jQuery( this ) , localized_data.default_icon_element );
jQuery( '.element_selection_container' ).find( jQuery( '.icon-wrapper[alt="' + localized_data.default_icon_element + '"]' ) ).addClass( 'selected-element-wrap' );
} else {
x = 1;
}
}, 50);
};
// run our check thickbox function
// on initial page load
check_thick();
// if a custom icon pack is not installed,
// lets make sure that the custom tab remains hidden
if( localized_data.custom_pack_active != 'true' ) {
setInterval(function() {
if( jQuery( '#TB_ajaxContent' ).is( ':visible' ) ) {
jQuery( '.custom-pack-tab' ).hide();
}
}, 50);
}
// when a user clicks on an icon,
// load'er up to the preview box
function buttonClick() {
var glyphUnicode = jQuery( 'input[type=text].glyph_unicode', this ).val();
var iconClass = jQuery( this ).find( 'div' ).attr( 'class' ).replace( 'fs1' , '' );
var selectedIconWrapper = jQuery( '.selected-element-wrap' ).attr( 'alt' );
jQuery('.glyph').removeClass('selected');
jQuery(this).addClass('selected');
jQuery('.copy_paste_input').text('[wp-svg-icons icon="'+iconClass.trim()+'" wrap="'+selectedIconWrapper+'"]');
jQuery('input[type=text].expansion_glyph_unicode').css('background-color','#eee');
jQuery('input[type=text].glyph_unicode').css('background-color','#eee');
jQuery('input[type=text].glyph_unicode', this).css('background-color','#FF8000', 'font-color', '#000');
jQuery('.wp-svg-icon-preview').html('');
jQuery( '.wp-svg-iconset1-preview' ).fadeIn( 'fast' );
// Fade in the insert icon button
if( jQuery( '#TB_ajaxContent' ).is( ':visible' ) ) {
jQuery( '.insert-wp-svg-icon' ).fadeIn();
jQuery('#TB_ajaxContent').animate({ scrollTop: 0 }, 'slow'); // scroll thickbox back up
} else {
jQuery('html, body').animate({ scrollTop: 0 }, 'slow'); // scroll html body
}
};
function iconWrapperClick( button, element ) {
if ( jQuery( '.custom-pack-tab' ).hasClass( 'nav-tab-active' ) ) {
var active_tab = 'custom';
} else {
var active_tab = 'default';
}
var iconClass = jQuery( '.wp-svg-iconset1-all-glyphs' ).find( '.glyph-demo.selected' ).find( 'div' ).attr( 'class' );
// if the icon class is undefined, we're probably on the custom pack tab
if( iconClass === undefined ) {
// reset up the variable
var iconClass = jQuery( '.custom-pack-container-ajax' ).find( '.glyph.selected' ).find( 'span:first-child' ).attr( 'class' );
}
jQuery( '.icon-wrapper' ).removeClass( 'selected-element-wrap' );
jQuery( button ).addClass( 'selected-element-wrap' );
var selectedIconWrapper = element;
if( iconClass ) {
iconClass = iconClass.replace( 'fs1' , '' );
if( active_tab == 'custom' ) {
var newIconClass = iconClass.replace( 'wp-svg-custom-' , '' );
// swap out the example container for the new element
jQuery( '.copy_paste_input' ).text('[wp-svg-icons custom_icon="'+newIconClass.trim()+'" wrap="'+selectedIconWrapper+'"]');
} else {
// swap out the example container for the new element
jQuery( '.copy_paste_input' ).text('[wp-svg-icons icon="'+iconClass.trim()+'" wrap="'+selectedIconWrapper+'"]');
}
} else {
// no icon was selected yet...but we can still add our wrap
// swap out the example container for the new element
jQuery( '.copy_paste_input' ).text('[wp-svg-icons icon="" wrap=""]');
}
};
jQuery( '.element_selection_container' ).find( jQuery( '.icon-wrapper[alt="' + localized_data.default_icon_element + '"]' ) ).addClass( 'selected-element-wrap' );
/* Change selected icon wrapper */
jQuery( 'body' ).on( 'click' , '.icon-wrapper ' , function() {
iconWrapperClick( jQuery( this ) , jQuery( this ).attr( 'alt' ) );
});
/* Change the icon */
jQuery( 'body' ).on( 'click' , '.glyph-demo' , buttonClick );
// set up a timer...
var delay = (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})();
});
// insert our icon into the editor
function insert_wp_SVG_icon_to_editor() {
var icon_code = jQuery( '.copy_paste_input' ).text();
tb_remove();
window.send_to_editor( icon_code );
event.preventDefault();
}
// click the tab nav, to toggle between default and custom pcaks on edit.php
function load_custom_pack( e ) {
jQuery( '.nav-tab' ).removeClass( 'nav-tab-active' );
jQuery( e ).addClass( 'nav-tab-active' );
if( jQuery( '.custom-pack-container-ajax' ).is( ":empty" ) ) {
jQuery( '.wp-svg-iconset1-all-glyphs' ).fadeOut( 'fast' , function() {
jQuery(".custom-pack-container-ajax").load( localized_data.site_url + "/wp-content/uploads/wp-svg-icons/custom-pack/demo.html" );
jQuery.get( localized_data.site_url + "/wp-content/uploads/wp-svg-icons/custom-pack/style.css", function( data ) {
jQuery("head").append("");
});
});
jQuery('.custom-pack-container-ajax').on( 'click' , '.glyph' , function() {
jQuery('.glyph').removeClass("selected");
jQuery(this).addClass("selected");
jQuery('html, body').animate({ scrollTop: 0 }, 'slow');
var glyphCode = jQuery(this).find('.mls').text();
var newGlyphCode = glyphCode.replace( 'wp-svg-' , '' );
var glyphCode = jQuery.trim(glyphCode);
glyphCode = glyphCode.replace( 'wp-svg-custom-' , '' );
var selectedIconWrapper = jQuery( '.selected-element-wrap' ).attr( 'alt' );
// Fade in the insert icon button
if( jQuery( '#TB_ajaxContent' ).is( ':visible' ) ) {
jQuery( '.insert-wp-svg-icon' ).fadeIn();
jQuery('#TB_ajaxContent').animate({ scrollTop: 0 }, 'slow'); // scroll thickbox back up
} else {
jQuery('html, body').animate({ scrollTop: 0 }, 'slow'); // scroll html body
}
//console.log(glyphCode);
jQuery('.copy_paste_input').text('[wp-svg-icons custom_icon="'+glyphCode.trim()+'" wrap="'+selectedIconWrapper+'"]');
jQuery('.wp-svg-icon-preview').remove();
jQuery('.wp-svg-icon-preview-box > i').after(" ");
jQuery('.previewIcon').fadeIn();
});
} else {
jQuery( '.wp-svg-iconset1-all-glyphs' ).fadeOut( 'fast' , function() {
jQuery(".custom-pack-container-ajax").fadeIn();
});
}
}
function show_defualt_pack( e ) {
if( jQuery( '.default-icon-pack ' ).hasClass( 'nav-tab-active' ) ) {
return false;
} else {
jQuery( '.nav-tab' ).removeClass( 'nav-tab-active' );
jQuery( e ).addClass( 'nav-tab-active' );
jQuery( '.custom-pack-container-ajax' ).fadeOut( 'fast' , function() {
jQuery( '.wp-svg-iconset1-all-glyphs' ).fadeIn( 'fast' );
});
}
}
function build_the_icon_shortcode( e ) {
// store the element wrap variable
var element_wrap = jQuery( '.element_selection_container' ).find( '.selected-element-wrap' ).attr( 'alt' );
var icon_name = jQuery( '.glyph.selected' ).find( '.mls' ).text().replace( 'wp-svg-' , '' ).replace( 'custom-' , '' ).trim();
if( jQuery( e ).hasClass( 'yes-adv-attr' ) ) {
var selected_element = jQuery( '.glyph.selected' ).length;
if( selected_element > 0 ) { // check if an icon was selected
// check if were on a custom icon pack, or the default icon pack
if ( jQuery( '.custom-pack-tab' ).hasClass( 'nav-tab-active' ) ) {
var active_tab = 'custom';
} else {
var active_tab = 'default';
}
// create an array for our attributes
var custom_shortcode_attr_array = [];
var shortcode = jQuery( '.copy_paste_input' ).text();
// icon name
if( icon_name ) {
if( active_tab == 'custom' ) {
custom_shortcode_attr_array.push( 'custom_icon="'+icon_name+'"' );
} else { // defualt icon
custom_shortcode_attr_array.push( 'icon="'+icon_name+'"' );
}
}
// element icon wrap
if( element_wrap ) {
custom_shortcode_attr_array.push( 'wrap="'+element_wrap+'"' );
}
// console.log( custom_shortcode_attr_array );
jQuery( '.copy_paste_input' ).text( '[wp-svg-icons '+custom_shortcode_attr_array.join( ' ' )+']' );
} else { // if not...just toggle the advanced attrs
}
} else {
// store default
jQuery( '.copy_paste_input' ).text( '[wp-svg-icons icon="'+icon_name+'" wrap="'+element_wrap+'"]' );
}
}
\ No newline at end of file
diff --git a/admin/partials/wp-svg-icons-default-icons-page.php b/admin/partials/wp-svg-icons-default-icons-page.php
index 3122c72..634cf33 100644
--- a/admin/partials/wp-svg-icons-default-icons-page.php
+++ b/admin/partials/wp-svg-icons-default-icons-page.php
@@ -47,40 +47,7 @@
-
-
-
-
-
+
@@ -117,48 +84,6 @@
-
-
diff --git a/admin/partials/wp-svg-icons-icon-page.php b/admin/partials/wp-svg-icons-icon-page.php
index 1608518..bc98d2c 100644
--- a/admin/partials/wp-svg-icons-icon-page.php
+++ b/admin/partials/wp-svg-icons-icon-page.php
@@ -81,6 +81,7 @@ function wp_svg_icons_settings_init( ) {
register_setting( 'wp_svg_icons_settings_page', 'wp_svg_icons_enqueue_defualt_icon_pack' );
register_setting( 'wp_svg_icons_settings_page', 'wp_svg_icons_defualt_icon_container' );
+ register_setting( 'wp_svg_icons_settings_page', 'wp_svg_icons_clear_all_data_on_uninstall' );
/* Register settings section */
add_settings_section(
@@ -107,6 +108,15 @@ function wp_svg_icons_settings_init( ) {
'wp_svg_icons_settings_page',
'wp_svg_icons_plugin_section'
);
+
+ /* Delete Custom Icon Pack On Uninstall Setting */
+ add_settings_field(
+ 'wp_svg_icons_clear_all_data_on_uninstall',
+ __( 'Clear Data on Uninstall', 'wp-svg-icons' ),
+ 'wp_svg_icons_clear_all_data_on_uninstall_callback',
+ 'wp_svg_icons_settings_page',
+ 'wp_svg_icons_plugin_section'
+ );
}
add_action( 'admin_init', 'wp_svg_icons_settings_init' );
@@ -149,6 +159,24 @@ function wp_svg_icons_enqueue_defualt_icon_container_callback( ) {
' . __( 'not' , 'wp-svg-icons' ) . ' ' . __( 'be deleted on uninstall.' , 'wp-svg-icons' );
+ }
+ ?>
+ value='1'>
+
+ * @link http://www.evan-herman.com/wordpress-plugin/wp-svg-icons/
+ */
+
+class WP_SVG_Icons_Uninstall {
+
+ /**
+ * Clean up our plugin options so we leave no orphan settings
+ * in the users database. No one likes useless data floating around.
+ *
+ * @since 3.1.1
+ */
+ public static function uninstall() {
+
+ $clear_all_data_on_uninstall = get_option( 'wp_svg_icons_clear_all_data_on_uninstall' , '1' );
+
+ // Step #1
+ // clean up our plugin settings
+ delete_options( 'wp_svg_icons_enqueue_defualt_icon_pack' );
+ delete_options( 'wp_svg_icons_defualt_icon_container' );
+ delete_options( 'wp_svg_icons_clear_all_data_on_uninstall' );
+ delete_options( 'wp_svg_icons_review_stop_bugging_me' );
+ delete_options( 'wp_svg_icons_activation_date' );
+
+ // Step #2
+ // check if the user wants to remove the custom icon pack installed
+ // and do so, if set
+ if ( $clear_all_data_on_uninstall == '1' ) {
+ $dest = wp_upload_dir();
+ $dest_path = $dest['path'];
+ $split_path = explode( 'uploads/' , $dest_path );
+ $custom_pack_dir = $split_path[0] . 'uploads/wp-svg-icons/';
+ if ( is_dir( $custom_pack_dir ) ) {
+ WP_SVG_Icons_Uninstall::wp_svg_icons_delete_entire_directory( $custom_pack_dir );
+ }
+ }
+
+ }
+
+ // recursive delete directory
+ public function wp_svg_icons_delete_entire_directory( $dir ) {
+ if ( is_dir( $dir ) ) {
+ $objects = scandir( $dir );
+ foreach ($objects as $object ) {
+ if ( $object != "." && $object != ".." ) {
+ if ( filetype( $dir."/".$object) == "dir" ) WP_SVG_Icons_Uninstall::wp_svg_icons_delete_entire_directory( $dir."/".$object); else unlink( $dir."/".$object );
+ }
+ }
+ reset( $objects );
+ rmdir( $dir );
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/readme.txt b/readme.txt
index 5d4f0f0..774d1d3 100644
--- a/readme.txt
+++ b/readme.txt
@@ -4,7 +4,7 @@ Donate link: https://www.evan-herman.com/contact/?contact-reason=I%20want%20to%2
Tags: wordpress, icons, evan, herman, icon, set, svg, wp, icomoon, ico, moon, wp, zoom, wp-zoom, wpzoom, broccolidry, metoicons, iconic, plugin, responsive, bootstrap, font, awesome, font awesome, twitter, glyphicons, glyph, web, font, webfont, custom, icons, import, upload, zip
Requires at least: 3.5
Tested up to: 4.1.1
-Stable tag: 3.1
+Stable tag: 3.1.1
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -127,6 +127,13 @@ If you buy the pro version you will also receive support and updates for one yea
== Changelog ==
+= 3.1.1 - March 5th, 2015 =
+* Fixed bug where clicking custom icon didn't load it into the preview container
+* Added new setting to delete custom icon pack on plugin uninstall
+* Re-wrote uninstall function to remove all plugin created options
+* Added 2 week upgrade/review notification
+* Minor style enhancements and bug fixes
+
= 3.1 - March 3rd, 2015 =
* Fix link styles overriding WordPress defaults
* Minified default icon styles, added appropriate element classes and enqueued across dashboard
@@ -189,6 +196,12 @@ If you buy the pro version you will also receive support and updates for one yea
== Upgrade Notice ==
+= 3.1.1 - March 5th, 2015 =
+* Fixed bug where clicking custom icon didn't load it into the preview container
+* Added new setting to delete custom icon pack on plugin uninstall
+* Re-wrote uninstall function to remove all plugin created options
+* Added 2 week upgrade/review notification
+
= 3.1 - March 3rd, 2015 =
* Fix link styles overriding WordPress defaults
* Minified default icon styles, added appropriate element classes and enqueued across dashboard
diff --git a/uninstall.php b/uninstall.php
deleted file mode 100644
index 031a582..0000000
--- a/uninstall.php
+++ /dev/null
@@ -1,18 +0,0 @@
-