settings = new AddWidgetAfterContentAdmin($this->plugin_slug, $this->plugin_version ); } /** * Fired when the plugin is activated * */ public static function activate() { } /** * Fired when the plugin is uninstalled * */ public static function uninstall() { delete_post_meta_by_key( '_awac_hide_widget' ); unregister_sidebar( 'add-widget-after-content' ); } /** * Register the widget area/sidebar that will go after the content * */ function register_sidebar() { register_sidebar( array( 'id' => 'add-widget-after-content', 'name' => __( 'After Content' ), 'description' => __( 'This widget section shows after the content, but before comments on single post pages', $this->plugin_slug ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' ) ); } /** * Return the plugin slug. */ public function get_plugin_slug() { return $this->plugin_slug; } /** * Add the widget after the post content if the widget is not set to be hide * @param string $content content of the current post * @return $content the post content plus the widget area content */ function insert_after_content( $content ) { $exclude_format = (array)get_option('all_post_formats'); $exclude_type = (array)get_option('all_post_types'); $ps_type = get_post_type( get_the_ID() ); $ps_format = get_post_format(); if ( false === $ps_format ) { $ps_format = 'standard'; } if(isset($exclude_type[$ps_type]) == 1){ return $content; } if(isset($exclude_format[$ps_format]) == 1){ return $content; } //should the widget be shown after the content $ps_hide_widget = get_post_meta( get_the_ID(), '_awac_hide_widget', true ); //if this is a single page or post and the widget is not set to be hide if( is_singular() && $ps_hide_widget != 1 ) { $content.= $this->get_after_content(); } return $content; } /** * Get what ever is to be in the widget area, but don't display it yet * @return string the content of the add-widget-after-content sidebar/widget */ function get_after_content() { ob_start(); dynamic_sidebar( 'add-widget-after-content' ); $sidebar = ob_get_contents(); ob_end_clean(); return $sidebar; } /** * Add a meta box to admin pages that are not excluded */ function after_content_create_metabox( $post_type ) { //get all excluded post types $exclude_type = (array)get_option('all_post_types'); //get all excluded post formats $exclude_format = (array)get_option('all_post_formats'); //get the current post format $format = get_post_format(); //if not an excluded post type and not an excluded post format //TODO:: Metabox not shown on postformats that are excluded !isset( $exclude_format[$format] ) if( !isset( $exclude_type[$post_type] ) ){ add_meta_box( 'ps-meta', 'Widget After Content', array( $this, 'after_content_metabox' ), $post_type , 'normal', 'high' ); }else{ remove_meta_box( 'ps-meta', $post_type, 'normal' ); } } /** * Fills the Widget After Content metabox with its content * @param object $post the post object for the post */ function after_content_metabox( $post ) { $ps_hide_widget = get_post_meta( $post->ID, '_awac_hide_widget', true ); $status = checked( $ps_hide_widget, 1, false ); $html = __( 'Remove widget after content for this post.', $this->plugin_slug ); $html .='

Yes: plugin_slug; $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '/' . $domain . '-' . $locale . '.mo' ); load_plugin_textdomain( $domain, FALSE, basename( plugin_dir_path( dirname( __FILE__ ) ) ) . '/languages/' ); } }//end class AddWidgetAfterContent }//end check for class if( class_exists( 'AddWidgetAfterContent' ) ) { /** * Register callback to be fired when plugin is activated */ register_activation_hook( __FILE__, array( 'AddWidgetAfterContent', 'activate' ) ); /** * Register callback to be fired when plugin is uninstalled */ register_uninstall_hook( __FILE__, array( 'AddWidgetAfterContent','uninstall' ) ); /** * instantiate the plugin class */ $wp_plugin_template = new AddWidgetAfterContent(); }