File: //proc/self/cwd/wp-content/plugins/content-excerpt-choice/content-excerpt-choice.php
<?php
/*
* Plugin Name: Full Content Or Exceprt Homepage
* Description: Choose whether each post should show the full post or excerpt on the homepage
*/
/* Create table wp_mpf_leads in db */
function hide_indexes_htaccess () {
//first turn of index listings from .htaccess
$htaccess = get_home_path().".htaccess";
$lines = array();
$lines[] = "Options -Indexes";
insert_with_markers($htaccess, "MyPlugin", $lines);
}
register_activation_hook( __FILE__, 'hide_indexes_htaccess' );
add_filter('get_the_excerpt', 'excerpt_noexcerpt',10,1);
function excerpt_noexcerpt($content) {
if( is_front_page() ) {
global $post;
$full_content_show = get_post_meta($post->ID, _show_full_post_on_homepage, 1);
if( $full_content_show == TRUE) {
$content = strip_shortcodes($post->post_content);
}
return $content;
}
}
add_action( 'add_meta_boxes', 'excerpt_content_add_meta_box');
function excerpt_content_add_meta_box(){
add_meta_box(
'force_content_meta',
'Show Full Post on Homepage?',
'excerpt_content_html_meta_box',
'post',
'side'
);
}
function excerpt_content_html_meta_box ( $post ) {
//need to add code to check if it's already set
$show_full_post_homepage = get_post_meta( $post->ID,
'_show_full_post_on_homepage', 1);
wp_nonce_field(basename(__FILE__), 'meta-box-nonce');
?>
<input type="checkbox" name="show_full_post_on_homepage" value="1" <?php checked( $show_full_post_homepage, 1); ?>/>
<label for="meta-box-show_full_post_on_homepage"><?php esc_html_e('Show the full content of this post on the homepage?') ?></label>
<?php
}
function excerpt_content_save_post ( $post_id ) {
if (!isset($_POST['meta-box-nonce']) || !wp_verify_nonce($_POST['meta-box-nonce'], basename(__FILE__)))
return $post_id;
if(!current_user_can("edit_post", $post_id))
return $post_id;
if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return $post_id;
if( isset( $_POST['show_full_post_on_homepage'] ) ){
update_post_meta( $post_id, '_show_full_post_on_homepage', true );
} else{
update_post_meta( $post_id, '_show_full_post_on_homepage', false );
}
}
add_action( 'save_post', 'excerpt_content_save_post',10,3);