Here Version: 2.0 Author: Andrew Kaser Author URI: http://www.andrewkaser.com Text-Domain: ak-featured-posted */ /* Copyright 2012 ANDREW KASER (email : Kaser@CSSBoss.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class ak_featured_post_widget extends WP_Widget { public function form( $instance ) { // define & set default values if ( isset( $instance[ 'text_area' ] ) ) { $text_area = $instance[ 'text_area' ]; } else { $text_area = __( '' , 'ak-featured-posted' ); } if ( isset( $instance[ 'category' ] ) ) { $category = $instance[ 'category' ]; } else { $category = __( 'Featured' , 'ak-featured-posted' ); } if ( isset( $instance[ 'title' ] ) ) { $title = $instance[ 'title' ]; } else { $title = __( 'Featured Post' , 'ak-featured-posted' ); } if ( isset( $instance[ 'show_post_limit' ] ) ) { $show_post_limit = $instance[ 'show_post_limit' ]; } else { $show_post_limit = __( '1' , 'ak-featured-posted' ); } if ( isset( $instance[ 'order_post' ] ) ) { $order_post = $instance[ 'order_post' ]; } else { $order_post = __( 'DESC' , 'ak-featured-posted' ); } if ( isset( $instance[ 'link_title_to_cat' ] ) ) { $link_title_to_archive = $instance[ 'link_title_to_cat' ]; } else { $link_title_to_archive = __( 'checked' , 'ak-featured-posted' ); } if ( isset( $instance[ 'show_post_title' ] ) ) { $show_post_title = $instance[ 'show_post_title' ]; } else { $show_post_title = __( 'checked' , 'ak-featured-posted' ); } if ( isset( $instance[ 'show_featured_image' ] ) ) { $show_featured_image = $instance[ 'show_featured_image' ]; } else { $show_featured_image = __( 'checked' , 'ak-featured-posted' ); } if ( isset( $instance[ 'image_align' ] ) ) { $image_align = $instance[ 'image_align' ]; } else { $image_align = __( 'center' , 'ak-featured-posted' ); } if ( isset( $instance[ 'image_size' ] ) ) { $image_size = $instance[ 'image_size' ]; } else { $image_size = __( 'medium' , 'ak-featured-posted' ); } if ( isset( $instance[ 'image_width' ] ) ) { $image_width = $instance[ 'image_width' ]; } else { $image_width = __( '' , 'ak-featured-posted' ); } if ( isset( $instance[ 'image_height' ] ) ) { $image_height = $instance[ 'image_height' ]; } else { $image_height = __( '' , 'ak-featured-posted' ); } if ( isset( $instance[ 'post_type' ] ) ) { $post_type = $instance[ 'post_type' ]; } else { $post_type = __( 'post' , 'ak-featured-posted' ); } if ( isset( $instance[ 'custom_post_type' ] ) ) { $custom_post_type = $instance[ 'custom_post_type' ]; } else { $custom_post_type = __( '' , 'ak-featured-posted' ); } if ( isset( $instance[ 'show_support_link' ] ) ) { $show_support_link = $instance[ 'show_support_link' ]; } else { $show_support_link = __( 'checked' , 'ak-featured-posted' ); } if ( isset( $instance[ 'show_excerpt' ] ) ) { $show_excerpt = $instance[ 'show_excerpt' ]; } else { $show_excerpt = __( 'checked' , 'ak-featured-posted' ); } $post_type_id = $this->get_field_id( 'post_type' ); ?>
class="hidden_options">
onchange="showLinktitle(this)" />
onchange="showFeaturedImageOps(this)"/>
class="hidden_options">
class="hidden_options">
class="hidden_options"> style="width:65px;text-align:center;" /> style="width:69px; text-align:center;" />
/>
/>
CSSBoss.com - Youtube - Donate ♥
'.$title.''.$after_title; $category = ''; } else { echo $before_title . ''.$title.''.$after_title; } } else { echo $before_title . $title . $after_title; } } // some post type checks real quick if ( $post_type == "custom" ) { $post_type = $custom_post_type; } echo 'Powered By AK Featured Post
'; echo $after_widget; // end widget $post = $post_old; // finally, restoring the original post data, as if we never even touched it ;) } //PARTYS OVER GUYS no more fun stuff public function __construct() { parent::__construct( 'ak_featured_post_widget', // Base ID 'AK: Featured Post', // Name array( 'description' => __( 'Display the latest post from a category', 'ak-featured-posted' ), ) // Args ); } public function ak_featured_post() { $widget_ops = array( 'classname'=>'ak-featured-post', // class that will be added to li element in widgeted area ul 'description'=>'Display post from category' // description displayed in admin ); $control_ops = array( 'width'=>200, 'height'=>250, // width of input widget in admin 'id_base'=>'ak-featured-post' // base of id of li element ex. id="example-widget-1" ); $this->WP_Widget( 'ak_featured_post', 'AK: Featured Post', $widget_ops, $control_ops ); // "Example Widget" will be name in control panel } public function update( $new_instance, $old_instance ) { // save the widget info $instance = array(); $instance['text_area'] = $new_instance['text_area']; $instance['show_post_limit'] = strip_tags( $new_instance['show_post_limit'] ); $instance['order_post'] = strip_tags( $new_instance['order_post'] ); $instance['post_type'] = strip_tags( $new_instance['post_type'] ); $instance['custom_post_type'] = strip_tags( $new_instance['custom_post_type'] ); $instance['category'] = strip_tags( $new_instance['category'] ); $instance['title'] = strip_tags( $new_instance['title'] ); $instance['image_align'] = strip_tags( $new_instance['image_align'] ); $instance['image_size'] = strip_tags( $new_instance['image_size'] ); $instance['image_width'] = strip_tags( $new_instance['image_width'] ); $instance['image_height'] = strip_tags( $new_instance['image_height'] ); $instance['link_title_to_cat'] = ( isset( $new_instance['link_title_to_cat'] ) ? 1 : 0 ); $instance['show_post_title'] = ( isset( $new_instance['show_post_title'] ) ? 1 : 0 ); $instance['show_featured_image'] = ( isset( $new_instance['show_featured_image'] ) ? 1 : 0 ); $instance['show_support_link'] = ( isset( $new_instance['show_support_link'] ) ? 1 : 0 ); $instance['show_excerpt'] = ( isset( $new_instance['show_excerpt'] ) ? 1 : 0 ); return $instance; } } function ak_admin_js_enque( $hook ) { if( $hook == 'widgets.php' ) wp_enqueue_script( 'my_custom_script', plugins_url('/akfp_admin_widget.js', __FILE__) , array( 'jquery' ) ); } add_action( 'admin_enqueue_scripts', 'ak_admin_js_enque' ); add_action( 'widgets_init', create_function( '', 'register_widget( "ak_featured_post_widget" );' ) ); ?>