Stylesheet with lazy loading included in main class
This commit is contained in:
parent
e164efcd3a
commit
01f8b1f29f
@ -46,7 +46,7 @@ gulp.task('test-cs', function (cb) {
|
||||
// Bundle files as required for plugin distribution..
|
||||
gulp.task('bundle', ['clean'], function () {
|
||||
console.log('Collecting files for package dist/' + config.name + config.version + ' ...');
|
||||
return gulp.src(['**/*.php', '!test/**', '!vendor/**', 'README.md', 'LICENSE.md'], {base: './'})
|
||||
return gulp.src(['**/*.php', 'styles/*.css', '!test/**', '!vendor/**', 'README.md', 'LICENSE.md'], {base: './'})
|
||||
.pipe(copy('./dist/' + config.name + '.' + config.version + '/' + config.name));
|
||||
});
|
||||
|
||||
|
@ -1,99 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Media Button
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( !defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
/**
|
||||
* Display Media Button
|
||||
*
|
||||
* @param string $content existing media buttons
|
||||
*
|
||||
* @return string $content + $output
|
||||
*/
|
||||
function wplt_media_button( $context ) {
|
||||
|
||||
if( get_post_type() != 'wplt_download' ) {
|
||||
return $context . '<a href="#" id="sdm-media-button" class="button add-download" data-editor="content" title="Add Download"><span class="wp-media-buttons-icon"></span>Add Download</a>';
|
||||
}
|
||||
}
|
||||
add_filter( 'media_buttons_context', 'wplt_media_button' );
|
||||
|
||||
/**
|
||||
* Add Modal Window to Footer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wplt_media_modal() {
|
||||
global $wplt_options;
|
||||
|
||||
$downloads = new WP_Query( 'post_type=wplt_download&nopaging=true&orderby=title&order=ASC' );
|
||||
?>
|
||||
<div id="sdm-download-modal" style="display: none">
|
||||
<div class="media-modal">
|
||||
<a id="sdm-download-modal-close" class="media-modal-close" href="#" title="Close"><span class="media-modal-icon"></span></a>
|
||||
<div class="media-modal-content">
|
||||
<div class="media-frame-title">
|
||||
<h1><?php _e( 'Insert Download', 'simple-downloads' ); ?></h1>
|
||||
</div>
|
||||
<div class="left-panel">
|
||||
<div class="sdm-download-list">
|
||||
<ul id="selectable_list">
|
||||
<?php
|
||||
while ( $downloads->have_posts() ) {
|
||||
$downloads->the_post();
|
||||
echo '<li data-ID="' . get_the_ID() . '">';
|
||||
echo '<strong>' . get_the_title() . '</strong>';
|
||||
echo '<span class="download_url">' . get_post_meta( get_the_ID(), '_wplt_file_url', true ) . '</span>';
|
||||
echo '</li>';
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right-panel">
|
||||
<div class="download-details" style="display: none">
|
||||
<h3><?php _e( 'Download Details', 'simple-downloads' ); ?></h3>
|
||||
<label for="sdm-download-text"><?php _e( 'Text', 'simple-downloads' ); ?>:</label>
|
||||
<input type="text" name="sdm-download-text" id="sdm-download-text" value="<?php echo $wplt_options['default_text']; ?>"/>
|
||||
<label for="sdm-download-style"><?php _e( 'Style', 'simple-downloads' ); ?>:</label>
|
||||
<select name="sdm-download-style" id="sdm-download-style">
|
||||
<?php
|
||||
$styles = wplt_get_shortcode_styles();
|
||||
$default_style = $wplt_options['default_style'];
|
||||
|
||||
foreach( $styles as $key => $value ) {
|
||||
$selected = ( $default_style == $key ? ' selected="selected"' : '' );
|
||||
echo '<option value="' . $key . '" ' . $selected . '>' . $value . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<div class="sdm-download-color-container">
|
||||
<label for="sdm-download-color"><?php _e( 'Color', 'simple-downloads' ); ?>:</label>
|
||||
<select name="sdm-download-color" id="sdm-download-color">
|
||||
<?php
|
||||
$colors = wplt_get_shortcode_colors();
|
||||
$default_color = $wplt_options['default_color'];
|
||||
|
||||
foreach( $colors as $key => $value ) {
|
||||
$selected = ( $default_color == $key ? ' selected="selected"' : '' );
|
||||
echo '<option value="' . $key . '" ' . $selected . '>' . $value . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<input id="sdm-download-button" type="button" value="<?php _e( 'Insert Download', 'simple-downloads' ); ?>" class="button-primary" />
|
||||
<input id="sdm-filesize-button" type="button" value="<?php _e( 'Insert File Size', 'simple-downloads' ); ?>" class="button" />
|
||||
<input id="sdm-count-button"type="button" value="<?php _e( 'Insert Download Count', 'simple-downloads' ); ?>" class="button" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="media-modal-backdrop"></div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
add_action( 'admin_footer', 'wplt_media_modal' );
|
@ -1,219 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Meta-Boxes
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( !defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
/**
|
||||
* Register meta boxes
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wplt_register_meta_boxes() {
|
||||
// File
|
||||
add_meta_box( 'wplt_file', __( 'File', 'wplt2' ), 'wplt_meta_box_file', 'wplt_download', 'normal', 'high' );
|
||||
// Stats
|
||||
add_meta_box( 'wplt_stats', __( 'Download Stats', 'wplt2' ), 'wplt_meta_box_stats', 'wplt_download', 'side', 'core' );
|
||||
}
|
||||
add_action( 'add_meta_boxes', 'wplt_register_meta_boxes' );
|
||||
|
||||
/**
|
||||
* Add correct enc type for non-ajax uploads
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wplt_form_enctype() {
|
||||
if( get_post_type() == 'wplt_download' ) {
|
||||
echo ' enctype="multipart/form-data"';
|
||||
}
|
||||
}
|
||||
add_action( 'post_edit_form_tag', 'wplt_form_enctype' );
|
||||
|
||||
/**
|
||||
* Render file meta box
|
||||
*
|
||||
* @param object $post current post object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wplt_meta_box_file( $post ) {
|
||||
$file_url = get_post_meta( $post->ID, '_wplt_file_url', true );
|
||||
$file_size = get_post_meta( $post->ID, '_wplt_file_size', true );
|
||||
|
||||
global $post;
|
||||
|
||||
$plupload_init = array(
|
||||
'runtimes' => 'html5, silverlight, flash, html4',
|
||||
'browse_button' => 'plupload-browse-button',
|
||||
'container' => 'plupload-container',
|
||||
'file_data_name' => 'async-upload',
|
||||
'multiple_queues' => false,
|
||||
'max_file_size' => wp_max_upload_size() . 'b',
|
||||
'url' => admin_url( 'admin-ajax.php' ),
|
||||
'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
|
||||
'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
|
||||
'filters' => array( array( 'title' => __( 'Allowed Files' ), 'extensions' => '*' ) ),
|
||||
'multipart' => true,
|
||||
'urlstream_upload' => true,
|
||||
|
||||
// additional post data to send to our ajax hook
|
||||
'multipart_params' => array(
|
||||
'_ajax_nonce' => wp_create_nonce( 'wplt_download_upload' ),
|
||||
'action' => 'wplt_download_upload',
|
||||
'post_id' => $post->ID
|
||||
),
|
||||
);
|
||||
|
||||
// Pass to plupload
|
||||
$plupload_init = apply_filters( 'plupload_init', $plupload_init );
|
||||
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
var plupload_args = <?php echo json_encode( $plupload_init ); ?>;
|
||||
</script>
|
||||
|
||||
<div id="plupload-container" class="hide-if-no-js">
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
File URL:
|
||||
</th>
|
||||
<td id="plupload-file">
|
||||
<?php echo ($file_url !== '' ? $file_url : '-----' ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
File Size:
|
||||
</th>
|
||||
<td id="plupload-file-size">
|
||||
<?php echo ($file_size !== '' ? wplt_human_filesize( $file_size ) : '-----' ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
</th>
|
||||
<td>
|
||||
<input id="plupload-browse-button" type="button" value="<?php _e( 'Select File', 'wplt2' ); ?>" class="button" />
|
||||
<input id="plupload-upload-button" type="button" value="<?php _e( 'Upload', 'wplt2' ); ?>" class="button" style="display: none" />
|
||||
<a id="plupload-cancel-button" href="#" style="display: none">Cancel</a>
|
||||
<p class="description"><?php printf( __( 'Maximum file size: %s.', 'wplt2' ), wplt_human_filesize( wp_max_upload_size() ) ); ?></p>
|
||||
|
||||
<div id="plupload-progress" style="display: none">
|
||||
<div class="bar" style="width: 0%"></div>
|
||||
<div class="percent"><p>Uploading...</p></div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="plupload-container" class="hide-if-js">
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
File URL:
|
||||
</th>
|
||||
<td id="plupload-file">
|
||||
<?php echo ($file_url !== '' ? $file_url : '-----' ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
File Size:
|
||||
</th>
|
||||
<td id="plupload-file-size">
|
||||
<?php echo ($file_size !== '' ? wplt_human_filesize( $file_size ) : '-----' ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
</th>
|
||||
<td>
|
||||
<label for="async-upload"><?php _e( 'Upload', 'wplt2' ); ?>:</label>
|
||||
<input type="file" name="async-upload" id="async-upload" />
|
||||
<p class="description"><?php printf( __( 'Maximum file size: %s.', 'wplt2' ), wplt_human_filesize( wp_max_upload_size() ) ); ?></p> </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Save file metabox
|
||||
*
|
||||
* @param object $post current post object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wplt_meta_box_file_save( $post_id ) {
|
||||
// First check we have file present
|
||||
if( isset( $_FILES['async-upload'] ) && $_FILES['async-upload']['size'] > 0 ) {
|
||||
// Set upload dir
|
||||
add_filter( 'upload_dir', 'wplt_set_upload_dir' );
|
||||
|
||||
// Upload the file
|
||||
$file = wp_handle_upload( $_FILES['async-upload'], array( 'test_form' => false ) );
|
||||
|
||||
// Check for success
|
||||
if( isset( $file['file'] ) ) {
|
||||
// Post ID
|
||||
$post_id = $_REQUEST['post_id'];
|
||||
|
||||
// Add/update post meta
|
||||
update_post_meta( $post_id, '_wplt_file_url', $file['url'] );
|
||||
update_post_meta( $post_id, '_wplt_file_size', $_FILES['async-upload']['size'] );
|
||||
update_post_meta( $post_id, '_wplt_file_type', $file['type'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
add_action( 'save_post', 'wplt_meta_box_file_save' );
|
||||
|
||||
/**
|
||||
* Render stats meta box
|
||||
*
|
||||
* @param object $post current post object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wplt_meta_box_stats( $post ) {
|
||||
$file_count = get_post_meta( $post->ID, '_wplt_file_count', true );
|
||||
?>
|
||||
<div id="sdm-file-stats-container">
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<label for="wplt_file_count"><?php _e( 'Count' , 'wplt2' ); ?>:</label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" name="wplt_file_count" class="text-small" value="<?php echo ($file_count !== '' ? $file_count : 0 ); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Save stats meta box
|
||||
*
|
||||
* @param int $post_id current post id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wplt_meta_box_stats_save( $post_id ) {
|
||||
if( isset( $_POST['wplt_file_count'] ) ) {
|
||||
update_post_meta( $post_id, '_wplt_file_count', strip_tags( trim( $_POST['wplt_file_count'] ) ) );
|
||||
}
|
||||
}
|
||||
add_action( 'save_post', 'wplt_meta_box_stats_save' );
|
@ -1,73 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Post Types Columns
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( !defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
/**
|
||||
* Download post type column headings
|
||||
*
|
||||
* @param array $columns default columns registered by WordPress
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wplt_tick_column_headings( $columns ) {
|
||||
return array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Title', 'wplt2' ),
|
||||
'author' => __( 'Author', 'wplt2' ),
|
||||
'wplt_ticker' => __( 'Ticker', 'wplt2'),
|
||||
'date' => __( 'Date', 'wplt2' )
|
||||
);
|
||||
}
|
||||
//add_filter( 'manage_wplt_tick_posts_columns', 'wplt_tick_column_headings' );
|
||||
|
||||
/**
|
||||
* Download post type column contents
|
||||
*
|
||||
* @param array $column_name current column
|
||||
* @param int $post_id current post id provided by WordPress
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wplt_tick_column_contents( $column_name, $post_id ) {
|
||||
// Title column
|
||||
if( $column_name == 'file' ) {
|
||||
$path = get_post_meta( $post_id, '_wplt_file_url', true );
|
||||
echo wplt_download_filename( $path );
|
||||
}
|
||||
}
|
||||
add_action( 'manage_wplt_tick_posts_custom_column', 'wplt_tick_column_contents', 10, 2 );
|
||||
|
||||
/**
|
||||
* Download post type sortable columns filter
|
||||
*
|
||||
* @param array $columns as set above
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wplt_tick_column_sortable( $columns ) {
|
||||
$columns['ticks'] = 'ticks';
|
||||
|
||||
return $columns;
|
||||
}
|
||||
add_filter( 'manage_edit-wplt_tick_sortable_columns', 'wplt_tick_column_sortable' );
|
||||
|
||||
/**
|
||||
* Download post type sortable columns action
|
||||
*
|
||||
* @param array $query
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wplt_tick_column_orderby( $query ) {
|
||||
$orderby = $query->get( 'orderby');
|
||||
|
||||
if( $orderby == 'ticks' ) {
|
||||
$query->set('meta_key','_wplt_file_count');
|
||||
$query->set('orderby','meta_value_num');
|
||||
}
|
||||
}
|
||||
add_action( 'pre_get_posts', 'wplt_tick_column_orderby' );
|
@ -14,6 +14,13 @@ defined( 'ABSPATH' ) || exit;
|
||||
* WP Liveticker 2.
|
||||
*/
|
||||
class WPLiveticker2 {
|
||||
/**
|
||||
* Options tag.
|
||||
*
|
||||
* @var string OPTIONS
|
||||
*/
|
||||
const VERSION = '1.0.0';
|
||||
|
||||
/**
|
||||
* Options tag.
|
||||
*
|
||||
@ -58,6 +65,9 @@ class WPLiveticker2 {
|
||||
// Add shortcode.
|
||||
add_shortcode( 'liveticker', array( 'WPLiveticker2', 'shortcode_ticker_show' ) );
|
||||
|
||||
// Enqueue styles.
|
||||
add_action( 'wp_footer', array( 'WPLiveticker2', 'enqueue_styles' ) );
|
||||
|
||||
// Admin only actions.
|
||||
if ( is_admin() ) {
|
||||
// Add dashboard "right now" functionality.
|
||||
@ -187,6 +197,16 @@ class WPLiveticker2 {
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register frontend CSS.
|
||||
*/
|
||||
public static function enqueue_styles() {
|
||||
// Only add if shortcode is present.
|
||||
if ( self::$shortcode_present ) {
|
||||
wp_enqueue_style( 'wplt-css', WPLT2_BASE . 'styles/wp-liveticker2.min.css', '', self::VERSION, 'all' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update options.
|
||||
*
|
||||
|
1
styles/wp-liveticker2.min.css
vendored
Normal file
1
styles/wp-liveticker2.min.css
vendored
Normal file
@ -0,0 +1 @@
|
||||
ul.wplt2_ticker{list-style-type:none}li.wplt2_tick{background-color:#f5f5f5;margin:.1em;padding:.1em .3em}li.wplt2_tick p{margin:.3em}span.wplt2_tick_time{color:#002c58;font-size:.7em;font-style:italic}span.wplt2_tick_title{color:#002c58;font-weight:700;margin-left:.5em}p.wplt2_tick_content{margin-top:-.7em;text-indent:.5em}ul.wplt_2widget{list-style-type:none;margin-top:-.5em}ul.wplt2_widget li{text-align:left}span.wplt2_widget_time{font-size:.7em;font-style:italic}span.wplt2_widget_content{color:#002c58;text-indent:.2em}span.wplt2_widget_content_new{color:maroon;text-indent:.2em}p.wplt2_widget_link{text-align:right}
|
@ -36,7 +36,7 @@ defined( 'ABSPATH' ) || exit;
|
||||
// Constants.
|
||||
define( 'WPLT2_FILE', __FILE__ );
|
||||
define( 'WPLT2_DIR', plugin_dir_path( __FILE__ ) );
|
||||
define( 'WPLT2_BASE', plugin_basename( __FILE__ ) );
|
||||
define( 'WPLT2_BASE', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
// System Hooks.
|
||||
add_action( 'init', array( 'WPLiveticker2', 'register_types' ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user