From 79ded75db49bbd13bb7adcaa4b7a0420cb92f1a1 Mon Sep 17 00:00:00 2001 From: Stefan Kalscheuer Date: Mon, 21 Sep 2015 17:21:40 +0200 Subject: [PATCH] CSS loading moved from init to enqueue_scripts Stylesheet compressed, obsolete scripts removed --- includes/ajax.php | 1 + includes/css/admin.css | 199 ------------------------ includes/css/less/simple-downloads.less | 168 -------------------- includes/css/wp-liveticker2.min.css | 1 + includes/js/admin-post-download.js | 71 --------- includes/js/admin-post.js | 92 ----------- includes/scripts.php | 51 +----- 7 files changed, 8 insertions(+), 575 deletions(-) delete mode 100644 includes/css/admin.css delete mode 100644 includes/css/less/simple-downloads.less create mode 100644 includes/css/wp-liveticker2.min.css delete mode 100644 includes/js/admin-post-download.js delete mode 100644 includes/js/admin-post.js diff --git a/includes/ajax.php b/includes/ajax.php index 7783fcd..d4f8106 100644 --- a/includes/ajax.php +++ b/includes/ajax.php @@ -31,6 +31,7 @@ function wplt_ajax_get_new_ticks() { ); $wp_query = new WP_Query($args); + $output = ''; while ($wp_query->have_posts()) : $wp_query->the_post(); $output .= '
  • diff --git a/includes/css/admin.css b/includes/css/admin.css deleted file mode 100644 index d9232f1..0000000 --- a/includes/css/admin.css +++ /dev/null @@ -1,199 +0,0 @@ -/* Post Type Columns */ -.wp-list-table .column-downloads, -.wp-list-table .column-file, -.wp-list-table .column-shortcode, -.wp-list-table .column-ip, -.wp-list-table .column-ddate { - width: 15%; -} - -/* Download Modal Window */ -#sdm-download-modal .media-modal-content { - padding: 20px; -} - -#sdm-download-modal .media-modal-content .media-frame-title { - position: static; - margin: -20px -20px 0 -20px; - border-bottom: 1px solid #dfdfdf; -} - -.media-modal-content .left-panel { - position: absolute; - top: 45px; - bottom: 0; - left: 0; - width: 66%; - overflow: auto; -} - -.media-modal-content .right-panel { - position: absolute; - top: 0; - right: 0; - bottom: 0; - width: 20%; - padding: 45px 5% 10px 5%; - border-left: 1px solid #dfdfdf; - background-color: whiteSmoke; -} - -.sdm-download-list ul { - margin: 0 20px; -} - -.sdm-download-list { - margin: 20px 0; -} - -.sdm-download-list ul li { - margin: 10px 0; - padding: 5px; - border: 1px solid #dfdfdf; -} - -.sdm-download-list ul li.ui-selected { - box-shadow: 0 0 0 1px white,0 0 0 5px #1E8CBE; -} - -.sdm-download-list .download_url { - display: block; - margin-top: 3px; - color: gray; -} - -.right-panel .download-details h3 { - font-weight: bold; - text-transform: uppercase; - font-size: 12px; - color: #777; - text-shadow: 0 1px 0 white; - margin: 0 0 8px; -} - -.right-panel .download-details label { - display: block; - margin: 10px 0 5px; - color: #999; -} - -.right-panel .download-details input[type=text] { - display: block; - width: 100%; - padding: 6px 8px; -} - -.right-panel .download-details select { - display: block; - margin: 0 auto; - width: 100%; -} - -.right-panel .download-details #sdm-download-button { - margin-top: 30px; -} - -.right-panel .download-details input[type=button] { - display: block; - margin: 0 auto; - width: 100%; - height: auto; - margin-top: 10px; - padding: 10px 0; - font-size: 16px; -} - -/* Meta Box File Buttons */ -#plupload-browse-button, #plupload-upload-button { - margin-right: 4px; -} - -a#plupload-cancel-button { - padding: 1px 2px; - border-bottom: 1px solid red; - color: red; - text-decoration: none; -} - -a#plupload-cancel-button:hover { - background-color: red; - color: white; -} - -/* Meta Box File Progress */ -#plupload-progress { - position: relative; - margin-top: 10px; - width: 100%; - height: 30px; - border: 1px solid #ddd; -} - -#plupload-progress .bar { - height: 30px; - background-color: rgba(255, 255, 255, 0.5); -} - -#plupload-progress .percent { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 30px; - text-align: center; - font-size: 20px; - font-weight: bold; - line-height: 30px; - color: #ddd; -} - -#plupload-progress .percent p { - margin: 0; -} - -/* Meta Box File Success */ -#plupload-container .success { - color: green; -} - -#plupload-container .error { - color: red; -} - -/* Menu Icon */ -#menu-posts-sdm_download .wp-menu-image { - background: transparent url("/wp-content/plugins/simple-downloads/includes/images/menu.png") no-repeat; - background-position: 0 -35px !important; -} - -#menu-posts-sdm_download:hover .wp-menu-image, #menu-posts-sdm_download.wp-has-current-submenu .wp-menu-image { - background-position: 0 -3px !important; -} - -/* Media Button */ -#sdm-media-button { - padding-left: .4em; -} - -#sdm-media-button span.wp-media-buttons-icon { - background: transparent url("/wp-content/plugins/simple-downloads/includes/images/media-button.png") no-repeat; - background-position: -1px 0; -} - -@media only screen and (-Webkit-min-device-pixel-ratio: 1.5), -only screen and (-moz-min-device-pixel-ratio: 1.5), -only screen and (-o-min-device-pixel-ratio: 3/2), -only screen and (min-device-pixel-ratio: 1.5) { - - /* Menu Icon */ - #menu-posts-sdm_download .wp-menu-image { - background-image: url("/wp-content/plugins/simple-downloads/includes/images/menu@x2.png"); - background-size: 28px 64px !important; - } - - /* Media Button */ - #sdm-media-button span.wp-media-buttons-icon { - background-image: url("/wp-content/plugins/simple-downloads/includes/images/media-button@x2.png"); - background-size: 16px 16px !important; - } -} \ No newline at end of file diff --git a/includes/css/less/simple-downloads.less b/includes/css/less/simple-downloads.less deleted file mode 100644 index c568ca5..0000000 --- a/includes/css/less/simple-downloads.less +++ /dev/null @@ -1,168 +0,0 @@ -/* Button style by http://www.joepettersson.com/css3-buttons/ */ - -.download-button { - display: inline-block; - font-size: 12px; - text-decoration: none!important; - font-family: Helvetica, Arial, sans serif; - padding: 8px 12px; - border-radius: 3px; - -moz-border-radius: 3px; - box-shadow: inset 0px 0px 2px #fff; - -o-box-shadow: inset 0px 0px 2px #fff; - -webkit-box-shadow: inset 0px 0px 2px #fff; - -moz-box-shadow: inset 0px 0px 2px #fff; -} -.download-button:active { - box-shadow: inset 0px 0px 3px #999; - -o-box-shadow: inset 0px 0px 3px #999; - -webkit-box-shadow: inset 0px 0px 3px #999; - -moz-box-shadow: inset 0px 0px 3px #999; -} - -/* The styles for the grey button */ -.button-grey { - color: #444; - border: 1px solid #d0d0d0; - background-image: -moz-linear-gradient(#ededed, #e1e1e1); - background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#e1e1e1), to(#ededed)); - background-image: -webkit-linear-gradient(#ededed, #e1e1e1); - background-image: -o-linear-gradient(#ededed, #e1e1e1); - text-shadow: 1px 1px 1px #fff; - background-color: #e1e1e1; -} -.button-grey:hover { - border: 1px solid #b0b0b0; - background-image: -moz-linear-gradient(#e1e1e1, #ededed); - background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#ededed), to(#e1e1e1)); - background-image: -webkit-linear-gradient(#e1e1e1, #ededed); - background-image: -o-linear-gradient(#e1e1e1, #ededed); - background-color: #ededed; -} -.button-grey:active {border: 1px solid #666;} - -/* The styles for the red button */ -.button-red { - color: #923c47; - border: 1px solid #d96d7c; - background-image: -moz-linear-gradient(#f997b0, #f6677b); - background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f6677b), to(#f997b0)); - background-image: -webkit-linear-gradient(#f997b0, #f6677b); - background-image: -o-linear-gradient(#f997b0, #f6677b); - text-shadow: 1px 1px 1px #fdbcc7; - background-color: #f6677b; -} -.button-red:hover { - border: 1px solid #c75964; - background-image: -moz-linear-gradient(#f6677b, #f997b0); - background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f997b0), to(#f6677b)); - background-image: -webkit-linear-gradient(#f6677b, #f997b0); - background-image: -o-linear-gradient(#f6677b, #f997b0); - background-color: #f997b0; -} -.button-red:active {border: 1px solid #ab3e4b;} - -/* The styles for the blue button */ -.button-blue { - color: #41788c; - border: 1px solid #6fb1c7; - background-image: -moz-linear-gradient(#aae5f7, #73d0f1); - background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#73d0f1), to(#aae5f7)); - background-image: -webkit-linear-gradient(#aae5f7, #73d0f1); - background-image: -o-linear-gradient(#aae5f7, #73d0f1); - text-shadow: 1px 1px 1px #bfeafb; - background-color: #73d0f1; -} -.button-blue:hover { - border: 1px solid #4690ad; - background-image: -moz-linear-gradient(#73d0f1, #aae5f7); - background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#aae5f7), to(#73d0f1)); - background-image: -webkit-linear-gradient(#73d0f1, #aae5f7); - background-image: -o-linear-gradient(#73d0f1, #aae5f7); - background-color: #aae5f7; -} -.button-blue:active {border: 1px solid #3b778b;} - -/* The styles for the green button */ -.button-green { - color: #5a742d; - border: 1px solid #95b959; - background-image: -moz-linear-gradient(#cae387, #a5cb5e); - background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#a5cb5e), to(#cae387)); - background-image: -webkit-linear-gradient(#cae387, #a5cb5e); - background-image: -o-linear-gradient(#cae387, #a5cb5e); - text-shadow: 1px 1px 1px #dff4bc; - background-color: #a5cb5e; -} -.button-green:hover { - border: 1px solid #687e30; - background-image: -moz-linear-gradient(#a5cb5e, #cae387); - background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#cae387), to(#a5cb5e)); - background-image: -webkit-linear-gradient(#a5cb5e, #cae387); - background-image: -o-linear-gradient(#a5cb5e, #cae387); - background-color: #cae387; -} -.button-green:active {border: 1px solid #506320;} - -/* The styles for the black button */ -.button-black { - color: #fff; - border: 1px solid #4d4d4d; - background-image: -moz-linear-gradient(#656565, #454545); - background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#454545), to(#656565)); - background-image: -webkit-linear-gradient(#656565, #454545); - background-image: -o-linear-gradient(#656565, #454545); - text-shadow: 1px 1px 1px #6d6d6d; - background-color: #454545; -} -.button-black:hover { - border: 1px solid #363636; - background-image: -moz-linear-gradient(#454545, #656565); - background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#656565), to(#454545)); - background-image: -webkit-linear-gradient(#454545, #656565); - background-image: -o-linear-gradient(#454545, #656565); - background-color: #656565; -} -.button-black:active {border: 1px solid #000;} - -/* The styles for the yellow button */ -.button-yellow { - color: #986a39; - border: 1px solid #e6b650; - background-image: -moz-linear-gradient(#ffd974, #febf4d); - background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#febf4d), to(#ffd974)); - background-image: -webkit-linear-gradient(#ffd974, #febf4d); - background-image: -o-linear-gradient(#ffd974, #febf4d); - text-shadow: 1px 1px 1px #fbe5ac; - background-color: #febf4d; -} -.button-yellow:hover { - border: 1px solid #c1913d; - background-image: -moz-linear-gradient(#febf4d, #ffd974); - background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#ffd974), to(#febf4d)); - background-image: -webkit-linear-gradient(#febf4d, #ffd974); - background-image: -o-linear-gradient(#febf4d, #ffd974); - background-color: #ffd974; -} -.button-yellow:active {border: 1px solid #936b26;} - -/* The styles for the purple button */ -.button-purple { - color: #7e5d7c; - border: 1px solid #cd93c6; - background-image: -moz-linear-gradient(#e9c4e3, #d798d1); - background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#d798d1), to(#e9c4e3)); - background-image: -webkit-linear-gradient(#e9c4e3, #d798d1); - background-image: -o-linear-gradient(#e9c4e3, #d798d1); - text-shadow: 1px 1px 1px #f1ceef; - background-color: #d798d1; -} -.button-purple:hover { - border: 1px solid #886382; - background-image: -moz-linear-gradient(#d798d1, #e9c4e3); - background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#e9c4e3), to(#d798d1)); - background-image: -webkit-linear-gradient(#d798d1, #e9c4e3); - background-image: -o-linear-gradient(#d798d1, #e9c4e3); - background-color: #e9c4e3; -} -.button-purple:active {border: 1px solid #6a4664;} \ No newline at end of file diff --git a/includes/css/wp-liveticker2.min.css b/includes/css/wp-liveticker2.min.css new file mode 100644 index 0000000..ca5f170 --- /dev/null +++ b/includes/css/wp-liveticker2.min.css @@ -0,0 +1 @@ +ul.wplt_ticker{list-style-type:none}li.wplt_tick{background-color:#f5f5f5;margin:.1em;padding:.1em .3em}li.wplt_tick p{margin:.3em}span.wplt_tick_time{color:#002c58;font-size:.7em;font-style:italic}span.wplt_tick_title{color:#002c58;font-weight:bold;margin-left:.5em}p.wplt_tick_content{margin-top:-0.7em;text-indent:.5em}ul.wplt_widget{list-style-type:none;margin-top:-0.5em}ul.wplt_widget li{text-align:left}span.wplt_widget_time{font-size:.7em;font-style:italic}span.wplt_widget_content{color:#002c58;text-indent:.2em}span.wplt_widget_content_new{color:maroon;text-indent:.2em}p.wplt_widget_link{text-align:right} \ No newline at end of file diff --git a/includes/js/admin-post-download.js b/includes/js/admin-post-download.js deleted file mode 100644 index 4abb845..0000000 --- a/includes/js/admin-post-download.js +++ /dev/null @@ -1,71 +0,0 @@ -jQuery( document ).ready( function( $ ){ - - var uploader = new plupload.Uploader( plupload_args ); - - // User clicks upload - $( '#plupload-upload-button' ).click( function( e ) { - $( '#plupload-upload-button' ).fadeOut( 'fast' ); - $( '#plupload-cancel-button' ).fadeOut( 'fast' ); - $( '#plupload-progress' ).slideDown( 'fast', function() { - uploader.start(); - } ); - - e.preventDefault(); - } ); - - // User clicks cancel - $( '#plupload-cancel-button' ).click( function( e ) { - // Empty queue - uploader.splice(); - e.preventDefault(); - - $( '#plupload-file' ).html( '----' ); - $( '#plupload-file-size' ).html( '----' ); - $( '#plupload-browse-button' ).removeAttr( 'disabled' ); - $( '#plupload-upload-button' ).fadeOut( 'fast' ); - $( '#plupload-cancel-button' ).fadeOut( 'fast' ); - - } ); - - // Init - uploader.init(); - - // File added to queue - uploader.bind('FilesAdded', function( up, files ) { - plupload.each( files, function( file ) { - $( '#plupload-file' ).html( file.name ); - $( '#plupload-file-size' ).html( plupload.formatSize( file.size ) ); - } ); - - $( '#plupload-browse-button' ).attr( 'disabled', 'disabled' ); - $( '#plupload-upload-button' ).fadeIn( 'fast' ); - $( '#plupload-cancel-button' ).fadeIn( 'fast' ); - - up.refresh(); - } ); - - // Error - uploader.bind( 'Error', function( up, err ) { - $( '#plupload-file' ).html( '' + err.message + '' ); - $( '#plupload-file-size' ).html( '----' ); - - up.refresh(); - } ); - - // Progress bar - uploader.bind( 'UploadProgress', function( up, file ) { - $( '#plupload-progress .bar' ).css( 'width', file.percent + '%' ); - $( '#plupload-progress .percent' ).html( '

    ' + file.percent + '%

    ' ); - } ); - - // File uploaded - uploader.bind( 'FileUploaded', function( up, file, response ) { - $( '#plupload-browse-button' ).removeAttr( 'disabled' ); - $( '#plupload-upload-button' ).fadeOut( 'fast' ); - $( '#plupload-cancel-button' ).fadeOut( 'fast' ); - $( '#plupload-progress' ).slideUp( 'fast' ); - $( '#plupload-file' ).html( '' + response.response + '' ); - - } ); - -} ); \ No newline at end of file diff --git a/includes/js/admin-post.js b/includes/js/admin-post.js deleted file mode 100644 index 721d64c..0000000 --- a/includes/js/admin-post.js +++ /dev/null @@ -1,92 +0,0 @@ -jQuery( document ).ready( function( $ ){ - - var download_id; - - // Display download modal - $( '#sdm-media-button' ).click( function( e ) { - $( '#sdm-download-modal' ).show(); - - e.preventDefault(); - } ); - - // Close download modal - $( '#sdm-download-modal-close' ).click( function( e ) { - $( '#sdm-download-modal' ).hide(); - - e.preventDefault(); - } ); - - $( '.media-modal-backdrop' ).click( function() { - $( '#sdm-download-modal' ).hide(); - } ); - - // Hide/show color select - if( $( '#sdm-download-style' ).val() == 'button' ) { - $( '.sdm-download-color-container' ).show(); - } - else { - $( '.sdm-download-color-container' ).hide(); - } - - // Hide/show color select on change - $( '#sdm-download-style' ).change( function() { - if( $( '#sdm-download-style' ).val() == 'button' ) { - $( '.sdm-download-color-container' ).slisdmwn(); - } - else { - $( '.sdm-download-color-container' ).slideUp(); - } - } ); - - // Selectable list items - var selectableOpts = { - selected: function( e, ui ) { - download_id = $( ui.selected ).attr( 'data-ID' ); - $( '.download-details' ).show(); - } - }; - - // Set selectable item - $( '#selectable_list' ).selectable( selectableOpts ); - - // Download insert button - $( '#sdm-download-button' ).click( function() { - var download_text = $( '#sdm-download-text' ).val(); - var download_style = $( '#sdm-download-style' ).val(); - var download_color = $( '#sdm-download-color' ).val(); - - // Check if button and add color - if( download_style == 'button' ) { - color = ' color="' + download_color + '"' - } - else { - color = '' - } - - // Add to editor - window.send_to_editor( '[download id=' + download_id + ' text="' + download_text + '" style="' + download_style + '"' + color + ']' ); - - // Hide modal - $( '#sdm-download-modal' ).hide(); - } ); - - // Download filesize button - $( '#sdm-filesize-button' ).click( function() { - // Add to editor - window.send_to_editor( '[download_size id=' + download_id + ']' ); - - // Hide modal - $( '#sdm-download-modal' ).hide(); - } ); - - // Download count button - $( '#sdm-count-button' ).click( function() { - // Add to editor - window.send_to_editor( '[download_count id=' + download_id + ']' ); - - // Hide modal - $( '#sdm-download-modal' ).hide(); - } ); - - -} ); \ No newline at end of file diff --git a/includes/scripts.php b/includes/scripts.php index e760cc2..925638a 100644 --- a/includes/scripts.php +++ b/includes/scripts.php @@ -7,52 +7,13 @@ if ( !defined( 'ABSPATH' ) ) exit; /** - * Register scripts and styles + * Enqueue scripts and styles if shortcode present * @return bool */ -function wplt_register_scripts() { +function wplt_enqueue_scripts() { + global $post; // Register frontend CSS - wp_register_style( 'wplt-css', WPLT_PLUGIN_URL . 'includes/css/wp-liveticker2.css', '', WPLT_VERSION, 'all' ); + if ( has_shortcode( $post->post_content, 'liveticker') ) + wp_enqueue_style( 'wplt-css', WPLT_PLUGIN_URL . 'includes/css/wp-liveticker2.min.css', '', WPLT_VERSION, 'all' ); } -add_action( 'init', 'wplt_register_scripts' ); - -/** - * Print scripts and styles if shortcode is present. - * @return bool - */ -function wplt_print_scripts() { - global $wplt_options; - - if( $wplt_options['enable_css'] && $wplt_options['shortcode_present'] ) { - wp_print_styles( 'wplt-css' ); - } -} -add_action( 'wp_footer', 'wplt_print_scripts' ); - -/** - * Register admin scripts and style - * - * @param string $page current page - * - * @return bool - */ -function wplt_admin_enqueue_scripts( $page ) { - // Register scripts - wp_register_script( 'wplt-admin-js-post', WPLT_PLUGIN_URL . 'includes/js/admin-post.js', array( 'jquery', 'jquery-ui-selectable' ), '1.0', true ); - wp_register_script( 'wplt-admin-js-post-download', WPLT_PLUGIN_URL . 'includes/js/admin-post-download.js', array( 'jquery', 'plupload-all' ), '1.0', true ); - - // Enqueue on all admin pages - wp_enqueue_style( 'wplt-admin-css', WPLT_PLUGIN_URL . 'includes/css/admin.css' ); - - // Enqueue on wplt_download post add/edit screen - if( in_array( $page, array( 'post.php', 'post-new.php', 'post-edit.php' ) ) && get_post_type() == 'wplt_download' ) { - wp_enqueue_script( 'plupload-all' ); - wp_enqueue_script( 'wplt-admin-js-post-tick' ); - } - - // Enqueue on all other add/edit screen - if( in_array( $page, array( 'post.php', 'post-new.php', 'post-edit.php', 'page.php' ) ) && get_post_type() != 'wplt_download' ) { - wp_enqueue_script( 'wplt-admin-js-post' ); - } -} -//add_action( 'admin_enqueue_scripts', 'wplt_admin_enqueue_scripts' ); \ No newline at end of file +add_action( 'wp_enqueue_scripts', 'wplt_enqueue_scripts' ); \ No newline at end of file