Skip to content

Instantly share code, notes, and snippets.

@tlovett1
Created June 24, 2013 20:18
Show Gist options
  • Save tlovett1/5853244 to your computer and use it in GitHub Desktop.
Save tlovett1/5853244 to your computer and use it in GitHub Desktop.
fun fun fun
<?php
/**
* Replace the excerpt meta box with a more user friendly summary meta box.
*
*/
class VB_Summary_Meta_Box {
/*
* Class variables
*/
var $nonce_summary = 'vb_gamesbeat_summary_nonce';
/*
* Register actions
* @uses add_action
*/
function __construct() {
add_action( 'add_meta_boxes', array( $this, 'action_add_meta_boxes' ) );
add_action( 'save_post', array( $this, 'action_save_post' ) );
}
/*
* Add and remove meta boxes
* @uses add_meta_box, remove_meta_box
* @action admin_init
*/
function action_add_meta_boxes() {
remove_meta_box( 'postexcerpt', 'post', 'normal' );
add_meta_box( 'vb-gamesbeat-summary', 'Summary', array( $this, 'meta_box_summary' ), 'post', 'advanced', 'core' );
}
/*
* Render Editor's Note meta box
*
* @param object $post
* @uses get_post_meta, esc_attr, esc_url, wp_create_nonce
*/
function meta_box_summary( $post ) {
$excerpt = stripslashes_deep( $post->post_excerpt );
?>
<label class="screen-reader-text" for="vb_gamesbeat_summary"><?php _e('Summary') ?></label><textarea rows="1" cols="40" name="vb_gamesbeat_summary" id="vb_gamesbeat_summary" style="margin:0; height:4em; width:98%;"><?php echo $excerpt; // textarea_escaped ?></textarea>
<p><?php _e('This is a brief summary of your article that will appear on GamesBeat, Facebook, etc. Keep it very short, very sweet!'); ?></p>
<input type="hidden" name="<?php echo esc_attr( $this->nonce_summary ); ?>" value="<?php echo wp_create_nonce( 'nonce_' . $this->nonce_summary ); ?>" />
<?php
}
/*
* Save meta box data
* @param int $post_id
* @uses DOING_AUTOSAVE, wp_verify_nonce, sanitize_text_field
* @action save_post
* @return null
*/
function action_save_post( $post_id ) {
global $wpdb;
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return $post_id;
// Editor's Note
if ( isset( $_POST[$this->nonce_summary] ) && wp_verify_nonce( $_POST[$this->nonce_summary], 'nonce_' . $this->nonce_summary ) ) {
$summary = stripslashes_deep( $_POST['vb_gamesbeat_summary'] );
$_POST['excerpt'] = $summary;
// use the excerpt field
$where = array( 'ID' => $post_id );
$success = $wpdb->update( $wpdb->posts, array( 'post_excerpt' => $summary ), $where );
$fp = fopen( '/vagrant/www/test', 'a+' );
fwrite( $fp, "\n\n\nsave_post:\n" . $summary );
}
}
}
$VB_Summary_Meta_Box = new VB_Summary_Meta_Box;
@Johnklein94
Copy link

Johnklein94 commented May 26, 2022

Если уже решили попытать удачу, то делайте это в проверенном вегас игры казино (https://vulkanvegas-102.com/ru) . Ведь если играть на деньги в лицензионном заведении, можно быть уверенным за свой вклад и что нет никакого обмана. Играю в своё удовольствие и зарабатываю.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment