Example #1
0
 function meta_box($post)
 {
     // standard meta box
     ob_start();
     require 'meta-box.php';
     $meta_box = ob_get_clean();
     // nonce
     ob_start();
     wp_nonce_field(plugin_basename(__FILE__), 'sharepress-nonce');
     $nonce = ob_get_clean();
     $posted = get_post_meta($post->ID, self::META_POSTED, true);
     $scheduled = get_post_meta($post->ID, self::META_SCHEDULED, true);
     $last_posted = $last_posted_on_facebook = self::get_last_posted($post);
     $last_result = self::get_last_result($post);
     // load the meta data
     $meta = get_post_meta($post->ID, self::META, true);
     if (!$meta) {
         // defaults:
         $meta = array('message' => $post->post_title, 'title_is_message' => true, 'picture' => $this->get_default_picture(), 'let_facebook_pick_pic' => self::setting('let_facebook_pick_pic_default', 0), 'description' => $this->get_excerpt($post), 'excerpt_is_description' => true, 'targets' => self::targets() ? array_keys(self::targets()) : array(), 'enabled' => self::setting('default_behavior'), 'append_link' => self::setting('append_link', 'on') == 'on', 'delay_length' => self::setting('delay_length', 0), 'delay_unit' => self::setting('delay_unit', 'minutes'));
     } else {
         // overrides:
         if ($meta['title_is_message']) {
             $meta['message'] = $post->post_title;
         }
         if ($meta['excerpt_is_description']) {
             $meta['description'] = $this->get_excerpt($post);
         }
     }
     // targets must have at least one... try here, and enforce with javascript
     if (!$meta['targets']) {
         $meta['targets'] = self::targets() ? array_keys(self::targets()) : array();
     }
     // load the meta data
     $twitter_meta = get_post_meta($post->ID, Sharepress::META_TWITTER, true);
     if (!$twitter_meta) {
         // defaults:
         $twitter_meta = array('enabled' => Sharepress::setting('twitter_behavior', 'on'), 'hash_tag' => self::setting('twitter_default_hashtag'));
     }
     $twitter_enabled = $twitter_meta['enabled'] == 'on';
     // stash $meta globally for access from Sharepress::sort_by_selected
     self::$meta = $meta;
     // allow for pro override
     $meta_box = apply_filters('sharepress_meta_box', $meta_box, array('post' => $post, 'meta' => $meta, 'posted' => $posted, 'scheduled' => $scheduled, 'last_posted' => $last_posted, 'last_result' => $last_result, 'twitter_meta' => $twitter_meta, 'twitter_enabled' => $twitter_enabled));
     // unstash $meta
     self::$meta = null;
     // nonce, followed by the form
     echo $nonce;
     // style
     ?>
   <style>
     #sharepress_meta label { display: block; }
     #sharepress_meta fieldset { border: 1px solid #eee; padding: 8px; }
     #sharepress_meta legend { padding: 0px 4px; }
   </style>
 <?php 
     if ($posted || $scheduled || $last_posted) {
         require 'published-msg.php';
         echo $meta_box;
     } else {
         $enabled = @$_GET['sharepress'] == 'schedule' || @$meta['enabled'] == 'on' && $post->post_status != 'publish';
         require 'behavior-picker.php';
     }
 }