Initial Git import

This commit is contained in:
2015-09-18 11:05:56 +02:00
commit 2692f2bd0c
25 changed files with 2399 additions and 0 deletions

View File

@ -0,0 +1,43 @@
<?php
/**
* @package Dashboard
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* Add to Right Now Widget
*
* @return void
*/
function wplt_dashboard_right_now() {
$total_files = wp_count_posts( 'wplt_tick' );
echo '<tr>';
echo '<td class="first b b-tags"><a href="edit.php?post_type=wplt_tick">' . $total_files->publish . '</a></td>';
echo '<td class="t tags"><a href="edit.php?post_type=wplt_tick">' . __( 'Ticks', 'wplt2' ) . '</a></td>';
echo '</tr>';
}
add_action( 'right_now_content_table_end' , 'wplt_dashboard_right_now' );
/**
* Register dashboard widgets
*
* @return void
*/
function wplt_register_dashboard_widgets() {
wp_add_dashboard_widget( 'wplt_dashboard_downloads', __( 'Download Stats', 'wplt2' ), 'wplt_dashboard_downloads_widget' );
}
//add_action( 'wp_dashboard_setup', 'wplt_register_dashboard_widgets' );
/**
* Ticks Dashboard Widget
*
* @access private
* @since 1.0
* @return void
*/
function wplt_dashboard_ticks_widget() {
echo 'Content to follow...';
}

View File

@ -0,0 +1,99 @@
<?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' );

View File

@ -0,0 +1,219 @@
<?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' );

View File

@ -0,0 +1,151 @@
<?php
/**
* @package Settings Page
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* Register settings page
*
* @return void
*/
function wplt_register_page_settings() {
add_submenu_page( 'edit.php?post_type=wplt_tick', 'Liveticker2 ' . __( 'Settings', 'wplt2' ), __( 'Settings', 'wplt2' ), 'manage_options', 'wplt_settings', 'wplt_render_page_settings' );
}
add_action( 'admin_menu', 'wplt_register_page_settings' );
/**
* Register settings API
*
* @return void
*/
function wplt_register_settings() {
register_setting( 'wplt_settings', 'wplt2', 'wplt_validate_settings' );
// Form sections
add_settings_section( 'wplt_settings_general', __( 'General', 'wplt2' ), 'wplt_settings_general_section', __FILE__ );
add_settings_section( 'wplt_settings_uninstall', __( 'Uninstall', 'wplt2' ), 'wplt_settings_uninstall_section', __FILE__ );
// Form fields
add_settings_field( 'enable_css', __( 'Default CSS Styles', 'wplt2' ), 'wplt_settings_enable_css_field', __FILE__, 'wplt_settings_general' );
add_settings_field( 'reset_settings', __( 'Reset Settings', 'wplt2' ), 'wplt_settings_reset_settings_field', __FILE__, 'wplt_settings_uninstall' );
}
add_action( 'admin_init', 'wplt_register_settings' );
/**
* Validate settings callback
*
* @return void
*/
function wplt_validate_settings( $input ) {
$defaults = wplt_get_default_options();
$parsed = wp_parse_args( $input, $defaults );
// Fix empty default text textbox
if( trim( $input['default_text'] == '' ) ) {
$parsed['default_text'] = $defaults['default_text'];
}
return $parsed;
}
/**
* Render settings page
*
* @return void
*/
function wplt_render_page_settings() {
?>
<div class="wrap">
<div id="icon-options-general" class="icon32"><br></div>
<h2>Liveticker <?php _e( 'Settings', 'wplt2' ); ?></h2>
<?php if ( isset( $_GET['settings-updated'] ) ) {
echo '<div class="updated"><p>' . __( 'Settings updated successfully.', 'wplt2' ) . '</p></div>';
} ?>
<form action="options.php" method="post">
<?php
settings_fields( 'wplt_settings' );
do_settings_sections( __FILE__ );
?>
<p class="submit">
<input type="submit" name="submit" id="submit" class="button button-primary" value="Save Changes">
</p>
</form>
</div>
<?php
}
/**
* Render general section
*
* @return void
*/
function wplt_settings_general_section() {
return;
}
/**
* Render uninstall section
*
* @return void
*/
function wplt_settings_uninstall_section() {
return;
}
/**
* Render enable css field
*
* @return void
*/
function wplt_settings_enable_css_field() {
global $wplt_options;
$checked = $wplt_options['enable_css'];
echo '<label for="wp-liveticker2[enable_css]">';
echo '<input type="checkbox" name="wp-liveticker2[enable_css]" value="1" ' . checked( $checked, 1, false ) . ' /> ';
echo __( 'Enable', 'wplt2' );
echo '</label>';
echo '<p class="description">' . __( 'Disable this option to remove the default button styling and the Delightful Downloads CSS file.', 'wplt2' ) . '</p>';
}
/**
* Render default style field
*
* @return void
*/
function wplt_settings_default_style_field() {
global $wplt_options;
$styles = wplt_get_shortcode_styles();
$default_style = $wplt_options['default_style'];
echo '<select name="simple-downloads[default_style]">';
foreach( $styles as $key => $value ) {
$selected = ( $default_style == $key ? ' selected="selected"' : '' );
echo '<option value="' . $key . '" ' . $selected . '>' . $value . '</option>';
}
echo '</select>';
echo '<p class="description">' . __( 'The default display style.', 'wplt2' ) . '</p>';
}
/**
* Render reset settings field
*
* @return void
*/
function wplt_settings_reset_settings_field() {
global $wplt_options;
$checked = $wplt_options['reset_settings'];
echo '<label for="simple-downloads[reset_settings]">';
echo '<input type="checkbox" name="simple-downloads[reset_settings]" value="1" ' . checked( $checked, 1, false ) . ' /> ';
echo __( 'Enable', 'wplt2' );
echo '<p class="description">' . __( 'Reset plugin settings on re-activation.', 'wplt2' ) . '</p>';
echo '</label>';
}

View File

@ -0,0 +1,73 @@
<?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' );

47
includes/ajax.php Normal file
View File

@ -0,0 +1,47 @@
<?php
/**
* @package Ajax
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* Process Ajax upload file
*
* @return void
*/
function wplt_ajax_get_new_ticks() {
check_ajax_referer( 'wplt_ajax_get_new_ticks' );
// timestamp for request
$slug = $_REQUEST['sl'];
$time = $_REQUEST['ts'];
if($slug) {
// get new ticks from database
$args = array( 'post_type' => 'wplt_tick',
'posts_per_page' => '-1',
'tax_query' => array(
array( 'taxonomy' => 'wplt_ticker',
'field' => 'slug',
'terms' => $slug
)
)
);
$wp_query = new WP_Query($args);
while ($wp_query->have_posts()) : $wp_query->the_post();
$output .= '<li class="wplt_tick">
<p><span class="wplt_tick_time">'.get_the_time('d.m.Y H.i').'</span>
<span class="wplt_tick_title">'.get_the_title().'</span></p>
<p class="wplt_tick_content">'.get_the_content().'</p></li>';
endwhile;
// Echo success response
echo $output;
}
die();
}
//add_action( 'wp_ajax_wplt_download_upload', 'wplt_download_upload_ajax' );

199
includes/css/admin.css Normal file
View File

@ -0,0 +1,199 @@
/* 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;
}
}

View File

@ -0,0 +1,168 @@
/* 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;}

View File

@ -0,0 +1,12 @@
ul.wplt_ticker{list-style-type:none;}
li.wplt_tick{background-color:#F5F5F5;margin:0.1em;padding:0.1em 0.3em;}
li.wplt_tick p{margin:0.3em;}
span.wplt_tick_time{color:#002C58;font-size:0.7em;font-style:italic;}
span.wplt_tick_title{color:#002C58;font-weight:bold;margin-left:0.5em;}
p.wplt_tick_content{margin-top:-0.7em;text-indent:0.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:0.7em;font-style:italic;}
span.wplt_widget_content{color:#002C58;text-indent:0.2em;}
span.wplt_widget_content_new{color:#800000;text-indent:0.2em;}
p.wplt_widget_link{text-align:right;}

19
includes/functions.php Normal file
View File

@ -0,0 +1,19 @@
<?php
/**
* @package Functions
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* Returns default options
*
* @return array
*/
function wplt_get_default_options() {
return array(
'enable_css' => 1,
'reset_settings' => 0 z
);
}

BIN
includes/images/rss.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,71 @@
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( '<span class="error">' + err.message + '</span>' );
$( '#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( '<p>' + file.percent + '%</p>' );
} );
// 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( '<span class="success">' + response.response + '</span>' );
} );
} );

92
includes/js/admin-post.js Normal file
View File

@ -0,0 +1,92 @@
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();
} );
} );

78
includes/post-types.php Normal file
View File

@ -0,0 +1,78 @@
<?php
/**
* @package Post Types
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* Register tick post type
*
* @return void
*/
function wplt_tick_post_type() {
$args = array(
'labels' => array(
'name' => __( 'Ticks', 'wplt2' ),
'singular_name' => __( 'Tick', 'wplt2' ),
'add_new' => __( 'Add New', 'wplt2' ),
'add_new_item' => __( 'Add New Tick', 'wplt2' ),
'edit_item' => __( 'Edit Tick', 'wplt2' ),
'new_item' => __( 'New Tick', 'wplt2' ),
'all_items' => __( 'All Ticks', 'wplt2' ),
'view_item' => __( 'View Tick', 'wplt2' ),
'search_items' => __( 'Search Ticks', 'wplt2' ),
'not_found' => __( 'No Ticks found', 'wplt2' ),
'not_found_in_trash' => __( 'No Ticks found in Trash', 'wplt2' ),
'parent_item_colon' => '',
'menu_name' => __( 'Liveticker', 'wplt2' )
),
'public' => false,
'show_ui' => true,
'show_in_menu' => true,
'menu_icon' => 'dashicons-rss',
'capability_type' => 'post',
'supports' => array( 'title', 'editor', 'author'),
'taxonomies' => array('wplt_ticker')
);
register_post_type( 'wplt_tick', $args );
}
add_action( 'init', 'wplt_tick_post_type' );
/**
* Register custom taxamony (category)
*
* @return void
*/
//hook into the init action and call create_book_taxonomies when it fires
add_action( 'init', 'wplt_ticker_taxonomy', 0 );
//create two taxonomies, genres and writers for the post type "book"
function wplt_ticker_taxonomy()
{
// Add new taxonomy, make it hierarchical (like categories)
$labels = array(
'name' => _x( 'Ticker', 'taxonomy general name' ),
'singular_name' => _x( 'Ticker', 'taxonomy singular name' ),
'search_items' => __( 'Search Tickers', 'wplt2' ),
'all_items' => __( 'All Tickers', 'wplt2' ),
'parent_item' => __( 'Parent Ticker', 'wplt2' ),
'parent_item_colon' => __( 'Parent Ticker:', 'wplt2' ),
'edit_item' => __( 'Edit Ticker', 'wplt2' ),
'update_item' => __( 'Update Ticker', 'wplt2' ),
'add_new_item' => __( 'Add New Ticker', 'wplt2' ),
'new_item_name' => __( 'New Ticker', 'wplt2' ),
'menu_name' => __( 'Ticker', 'wplt2' ),
);
register_taxonomy('wplt_ticker',array('wplt_tick'), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
));
}

65
includes/rss.php Normal file
View File

@ -0,0 +1,65 @@
<?php
/**
* @package Scripts
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* Hook RSS function
* @return void
*/
if (strpos($_SERVER['REQUEST_URI'], '/feed/liveticker/') !== false) {
$args = array();
$args['ticker_slug'] = substr($_SERVER['SCRIPT_NAME'], 1);
wplt_print_feed($args);
exit;
}
function wplt_print_feed( $arguments ) {
$args = array( 'post_type' => 'wplt_tick',
'tax_query' => array(
array( 'taxonomy' => 'wplt_ticker',
'field' => 'slug',
'terms' => $arguments['ticker_slug']
)
)
);
global $wpdb;
$sql = "SELECT `ID`, DATE_FORMAT(`post_date`,'%a, %d %b %Y %T') AS `post_date_rfc`, `post_content`, `post_title` FROM `".$wpdb->prefix."posts` WHERE `post_type` = 'wplt_tick' AND `post_status` = 'publish' ORDER BY `post_date` DESC;";
$entries = $wpdb->get_results($sql);
date_default_timezone_set("Europe/Berlin");
// modify header information
header("Content-Type: application/rss+xml; charset=UTF-8");
// generate file head
$rss = '<?xml version="1.0" encoding="UTF-8"?>';
$rss .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">';
$rss .= '<channel><title>Lager Live</title>';
$rss .= '<link>http://'.$_SERVER['SERVER_NAME'].'/lagerticker</link>';
$rss .= '<atom:link href="http://'.$_SERVER['SERVER_NAME'].''.$_SERVER['REQUEST_URI'].'" rel="self" type="application/rss+xml" />';
$rss .= '<description></description>';
$rss .= '<language>de-de</language>';
$rss .= '<pubDate>'.date("r").'</pubDate>';
// build entries
foreach ( $entries as $entry ) {
//print_r($entry);
$rss .= '<item><title>'.mb_convert_encoding($entry->post_title, "ISO-8859-1", "UTF-8") .'</title>';
$rss .= '<link>http://www.dpsg-hardenberg.org/lagerticker</link>';
$rss .= '<pubDate>'.$entry->post_date_rfc.' '.date('O').'</pubDate>';
$rss .= '<description><![CDATA['.utf8_encode(mb_convert_encoding($entry->post_content, "ISO-8859-1", "UTF-8")).']]></description></item>';
}
// generate document foot
$rss .= '</channel></rss>';
print $rss;
}

55
includes/scripts.php Normal file
View File

@ -0,0 +1,55 @@
<?php
/**
* @package Scripts
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* Register scripts and styles
*
* @param string $page current page
*
* @return bool
*/
function wplt_enqueue_scripts( $page ) {
global $wplt_options;
// Register frontend CSS
wp_register_style( 'wplt-css', WPLT_PLUGIN_URL . 'includes/css/wp-liveticker2.css', '', '1.0', 'all' );
// Enqueue frontend CSS if option is enabled
if( $wplt_options['enable_css'] ) {
wp_enqueue_style( 'wplt-css' );
}
}
add_action( 'wp_enqueue_scripts', 'wplt_enqueue_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' );

68
includes/shortcodes.php Normal file
View File

@ -0,0 +1,68 @@
<?php
/**
* @package Shortcodes
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* Allow shortcodes in widgets
*/
add_filter( 'widget_text', 'do_shortcode' );
add_filter( 'wp_ajax_get_new_ticks', array( $this, 'wplt_ajax_get_new_ticks' ) );
/**
* Output Liveticker
*
* @param array atts shortcode options
*
* @return string
*/
function wplt_shortcode_ticker_show( $atts ) {
global $wplt_options;
/*$wplt_ticker_options = array();
extract(
shortcode_atts( array(
'id' => $wplt_ticker_options['id'],
'count' => $wplt_ticker_options['count'],
'order' => $wplt_ticker_options['order']
), $atts )
);*/
if($atts[0])
{
if(!$atts[1]) $atts[1] = -1;
$output .= '<ul class="wplt_ticker">';
$args = array( 'post_type' => 'wplt_tick',
'posts_per_page' => $atts[1],
'tax_query' => array(
array( 'taxonomy' => 'wplt_ticker',
'field' => 'slug',
'terms' => $atts[0]
)
)
);
$wp_query = new WP_Query($args);
while ($wp_query->have_posts()) : $wp_query->the_post();
$output .= '<li class="wplt_tick">
<p><span class="wplt_tick_time">'.get_the_time('d.m.Y H.i').'</span>
<span class="wplt_tick_title">'.get_the_title().'</span></p>
<p class="wplt_tick_content">'.get_the_content().'</p></li>';
endwhile;
$output .= '</ul>';
$output .= '<a href="/feed/liveticker/lager-live"><img class="wplt_rss" src="/wp-content/plugins/wp-liveticker2/images/rss.jpg" alt="RSS" /></a>';
}
return $output;
}
add_shortcode( 'liveticker', 'wplt_shortcode_ticker_show' );

128
includes/widget.php Normal file
View File

@ -0,0 +1,128 @@
<?php
class wplt_widget extends WP_Widget {
function wplt_widget() {
parent::WP_Widget( false, $name = 'Liveticker' );
}
function widget( $args, $instance ) {
extract( $args );
$title = apply_filters( 'wplt_catlit', $instance['title'] );
$category = apply_filters( 'wplt_catlit', $instance['category'] );
$count = apply_filters( 'wplt_catlit', $instance['count'] );
$link = apply_filters( 'wplt_catlit', $instance['link'] );
$highlight = apply_filters( 'wplt_catlit', $instance['highlight'] );
$highlight_time = apply_filters( 'wplt_catlit', $instance['highlight_time'] );
$ajax = apply_filters( 'wplt_catlit', $instance['ajax'] );
?>
<?php
echo $before_widget;
?>
<?php
if ($title) {
echo $before_title . $title . $after_title;
}
?>
<ul class="wplt_widget">
<?php
$args = array( 'post_type' => 'wplt_tick',
'tax_query' => array(
array( 'taxonomy' => 'wplt_ticker',
'field' => 'slug',
'terms' => $category,
)
)
);
$wp_query = new WP_Query($args);
while ($wp_query->have_posts()) : $wp_query->the_post();
?>
<li><span class="wplt_widget_time"><?php echo get_the_time('d.m.Y - H.i'); ?></span><span class="wplt_widget_content<?php if($highlight=="1" && get_the_time('U') > (time()-$highlight_time)) echo '_new'; ?>"><br /><?php echo the_title(); ?></span></li>
<?php
if( $count > 0 && ++$cnt == $count ) break;
endwhile;
?>
</ul>
<?php
if ($link)
print '<p class="wplt_widget_link"><a href="'.$link.'">'.__( 'show all', 'wplt2' ).'...</a></p>';
echo $after_widget;
?>
<?php
}
function update( $new_instance, $old_instance ) {
return $new_instance;
}
function form( $instance ) {
$title = esc_attr( $instance['title'] );
$category = esc_attr( $instance['category'] );
$count = esc_attr( $instance['count'] );
$link = esc_attr( $instance['link'] );
$highlight = esc_attr( $instance['highlight'] );
$highlight_time = esc_attr( $instance['highlight_time'] );
$ajax = esc_attr( $instance['ajax'] );
$categories = get_terms('wplt_ticker', 'orderby=name&order=ASC');
?>
<table>
<tr>
<td><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label></td>
<td><input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /></td>
</tr>
<tr>
<td> <label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php _e( 'Ticker:', 'wplt2' ); ?></label></td>
<td>
<select id="<?php echo $this->get_field_id( 'category' ); ?>" name="<?php echo $this->get_field_name( 'category' ); ?>">
<?php foreach ($categories as $cat) {
echo '<option value="'.$cat->slug.'"'; if($category==$cat->slug) echo ' selected="selected"'; echo '>'.$cat->name.'</option>';
} ?>
</select>
</td>
</tr>
<tr>
<td><label for="<?php echo $this->get_field_id( 'count' ); ?>"><?php _e( 'Number of Ticks:', 'wplt2' ); ?></label></td>
<td>
<select id="<?php echo $this->get_field_id( 'count' ); ?>" name="<?php echo $this->get_field_name( 'count' ); ?>">
<option value="0"<?php if($count==0) echo ' selected="selected"' ?>><?php _e('all','wplt2');?></option>
<option value="1"<?php if($count==1) echo ' selected="selected"' ?>>1</option><option value="2"<?php if($count==2) echo ' selected="selected"' ?>>2</option>
<option value="3"<?php if($count==3) echo ' selected="selected"' ?>>3</option><option value="4"<?php if($count==4) echo ' selected="selected"' ?>>4</option>
<option value="5"<?php if($count==5) echo ' selected="selected"' ?>>5</option><option value="6"<?php if($count==6) echo ' selected="selected"' ?>>6</option>
<option value="7"<?php if($count==7) echo ' selected="selected"' ?>>7</option><option value="8"<?php if($count==8) echo ' selected="selected"' ?>>8</option>
<option value="9"<?php if($count==9) echo ' selected="selected"' ?>>9</option><option value="10"<?php if($count==10) echo ' selected="selected"' ?>>10</option>
</select>
</td>
</tr>
<tr>
<td><label for="<?php echo $this->get_field_id( 'link' ); ?>"><?php _e( 'Link (optional):', 'wplt2' ); ?></label></td>
<td><input class="widefat" id="<?php echo $this->get_field_id( 'link' ); ?>" name="<?php echo $this->get_field_name( 'link' ); ?>" type="text" value="<?php echo $link; ?>" /></td>
</tr>
<tr>
<td><label for="<?php echo $this->get_field_id( 'highlight' ); ?>"><?php _e( 'Highlight new:', 'wplt2' ); ?></label></td>
<td><input class="widefat" id="<?php echo $this->get_field_id( 'highlight' ); ?>" name="<?php echo $this->get_field_name( 'highlight' ); ?>" type="checkbox" value="1" <?php if($highlight=="1") echo ' checked="checked"'; ?> /></td>
</tr>
<tr>
<td><label for="<?php echo $this->get_field_id( 'highlight_time' ); ?>"><?php _e( 'Highlight time [s]:', 'wplt2' ); ?></label></td>
<td><input class="widefat" id="<?php echo $this->get_field_id( 'highlight_time' ); ?>" name="<?php echo $this->get_field_name( 'highlight_time' ); ?>" type="text" value="<?php echo $highlight_time; ?>" /></td>
</tr>
<tr>
<td><label for="<?php echo $this->get_field_id( 'ajax' ); ?>"><?php _e( 'Auto refresh:', 'wplt2' ); ?></label></td>
<td><input class="widefat" id="<?php echo $this->get_field_id( 'ajax' ); ?>" name="<?php echo $this->get_field_name( 'ajax' ); ?>" type="checkbox" value="1"<?php if($ajax=="1") echo ' checked="checked"'; ?> disabled="disabled" /> <small><?php _e( '(enables ajax)', 'wplt2' ); ?></small></td>
</tr>
</table>
<?php
}
}
add_action( 'widgets_init', 'wplt_widget_init' );
function wplt_widget_init() {
register_widget( 'wplt_widget' );
}