コード例 #1
0
 protected function save_post($post_id, $name = '', $value = '')
 {
     // user can
     $post_type = get_post_type($post_id);
     $post_type = get_post_type_object($post_type);
     if (!$post_type) {
         return false;
     }
     if (!current_user_can($post_type->cap->edit_post, $post_id)) {
         return false;
     }
     // TODO add Options check credentials
     // save
     $content = Content::get($post_id);
     $content->{$name} = $value;
     $content->update();
     $content = (string) $content;
     if (!empty($content)) {
         //		        $post = get_post( $post_id );
         //		        $post->post_content = $content;
         //		        wp_update_post( $post );
         wp_update_post(array('ID' => $post_id, 'post_content' => $content));
     }
     return true;
 }
コード例 #2
0
 public function body_class($classes)
 {
     $content = Content::get();
     // TODO global static method to check credentials
     if (empty($content)) {
         return $classes;
     }
     return !(bool) $content->skeleton ? $classes : array_merge($classes, array(str_replace('.', '-', basename($content->skeleton)), basename($content->skeleton, '.skt')));
     // TODO substr to last "." instead
 }
コード例 #3
0
 public function meta_box($post)
 {
     wp_nonce_field(Skeletons::get('slug'), Skeletons::get('slug'));
     $select = sprintf('<select id="_%s" name="_%s">', Skeletons::get('slug'), Skeletons::get('slug'));
     $select .= sprintf('<option value="">%s</option>', __('Select Skeleton', Skeletons::get('textdomain')));
     foreach ($this->get_skeletons($post->post_type) as $skeleton => $name) {
         // TODO template like header interprate
         $content = Content::get($post);
         //$content = ( ! (bool)$content->skeleton ) ? $content->skeleton : '';
         $select .= sprintf('<option value="%s" %s>%s</option>', $skeleton, selected($skeleton, $content->skeleton, false), $name);
     }
     $select .= '</select>';
     echo apply_filters(Skeletons::get('slug') . '\\meta_box', $select);
 }
コード例 #4
0
 public function edit_form_after_title($post)
 {
     // TODO global static method to check credentials
     if (!in_array($post->post_type, Options::instance()->post_types)) {
         return;
     }
     $content = Content::get($post);
     if (!(bool) $content->skeleton) {
         return;
     }
     remove_post_type_support($post->post_type, 'editor');
     echo Skeletons::get_template('editor-template.php', array('id' => Skeletons::apply_filters('template\\editor\\id', Skeletons::get('slug') . '\\content'), 'content' => Skeletons::apply_filters('template\\editor', $content)));
 }