diff --git a/css/customizer.css b/css/customizer.css new file mode 100644 index 0000000..c178fbc --- /dev/null +++ b/css/customizer.css @@ -0,0 +1,23 @@ +.oblique-upgrade-to-pro-button { + padding: 3px 6px !important; + line-height: 1.5 !important; + font-size: 9px !important; + color: #ffffff !important; + background-color: #EA6F60; + letter-spacing: 1px; + text-transform: uppercase; +} +.customizer-review-link { + padding-top: 10px; + text-align: center; +} + +.customizer-review-link p { + font-size: 12px; + margin-bottom: 0; +} + +.customizer-review-link span { + font-size: 12px; + width: 12px; +} \ No newline at end of file diff --git a/functions.php b/functions.php index b2824fa..86e9725 100644 --- a/functions.php +++ b/functions.php @@ -287,3 +287,11 @@ function oblique_html5shiv() { * Styles */ require get_template_directory() . '/inc/styles.php'; + +/** + * Customizer styles + */ +function oblique_customizer_styles() { + wp_enqueue_style( 'oblique-customizer-styles', get_template_directory_uri() . '/css/customizer.css' ); +} +add_action( 'customize_controls_print_styles', 'oblique_customizer_styles' ); \ No newline at end of file diff --git a/inc/customizer.php b/inc/customizer.php index 34aa42e..e735acf 100644 --- a/inc/customizer.php +++ b/inc/customizer.php @@ -881,9 +881,37 @@ function oblique_registers() { wp_enqueue_script( 'oblique_customizer_script', get_template_directory_uri() . '/js/oblique_customizer.js', array("jquery"), '20120206', true ); wp_localize_script( 'oblique_customizer_script', 'obliqueCustomizerObject', array( - 'github' => __('GitHub','oblique'), - 'review' => __('Leave a Review', 'oblique'), - 'documentation' => __('Documentation', 'oblique') + 'documentation' => __('Documentation', 'oblique'), + 'pro' => __('View PRO version', 'oblique') ) ); } add_action( 'customize_controls_enqueue_scripts', 'oblique_registers' ); + +/* ajax callback for dismissable Asking for reviews */ +add_action( 'wp_ajax_oblique_dismiss_asking_for_reviews','oblique_dismiss_asking_for_reviews_callback' ); +add_action( 'wp_ajax_nopriv_oblique_dismiss_asking_for_reviews','oblique_dismiss_asking_for_reviews_callback' ); +/** + * Dismiss asking for reviews + */ +function oblique_dismiss_asking_for_reviews_callback() { + + if( !empty($_POST['ask']) ) { + set_theme_mod('oblique_ask_for_review',esc_attr($_POST['ask'])); + } + die(); +} +add_action( 'customize_controls_enqueue_scripts', 'oblique_asking_for_reviews_script' ); +function oblique_asking_for_reviews_script() { + + $oblique_review = 'yes'; + + $oblique_ask_for_review = get_theme_mod('oblique_ask_for_review'); + if( !empty($oblique_ask_for_review) ) { + $oblique_review = $oblique_ask_for_review; + } + wp_enqueue_script( 'oblique-asking-for-reviews-js', get_template_directory_uri() . '/js/oblique_reviews.js', array('jquery') ); + wp_localize_script( 'oblique-asking-for-reviews-js', 'obliqueAskingForReviewsObject', array( + 'ask' => $oblique_review, + 'ajaxurl' => admin_url( 'admin-ajax.php' ), + ) ); +} \ No newline at end of file diff --git a/js/oblique_customizer.js b/js/oblique_customizer.js index d4fcac6..e146825 100644 --- a/js/oblique_customizer.js +++ b/js/oblique_customizer.js @@ -13,13 +13,13 @@ jQuery(document).ready(function() { if( jQuery( ".oblique-upsells" ).length ) { - jQuery('.oblique-upsells').append('{documentation}'.replace('{documentation}', obliqueCustomizerObject.documentation)); - jQuery('.oblique-upsells').append('{github}'.replace('{github}', obliqueCustomizerObject.github)); - jQuery('.oblique-upsells').append('{review}'.replace('{review}', obliqueCustomizerObject.review)); + jQuery('.oblique-upsells').append('{documentation}'.replace('{documentation}', obliqueCustomizerObject.documentation)); } if ( !jQuery( ".oblique-upsells" ).length ) { jQuery('#customize-theme-controls > ul').prepend(''); } + + jQuery('.preview-notice').append('{pro}'.replace('{pro}',obliqueCustomizerObject.pro)); }); diff --git a/js/oblique_reviews.js b/js/oblique_reviews.js new file mode 100644 index 0000000..c75496c --- /dev/null +++ b/js/oblique_reviews.js @@ -0,0 +1,41 @@ +jQuery(document).ready(function($) { + + var load_ask_for_reviews = function(){ + $.ajax({ + type : "POST", + data : {action: 'oblique_dismiss_asking_for_reviews'}, + dataType : "html", + url : obliqueAskingForReviewsObject.ajaxurl, + success : function(data){ + if( obliqueAskingForReviewsObject.ask == 'no') { + jQuery('.customizer-review-link').remove(); + } else { + jQuery('#customize-theme-controls').append('
Star this theme on WordPress.org!