Plugin Directory

Changeset 1525061


Ignore:
Timestamp:
10/31/2016 02:48:05 AM (9 years ago)
Author:
iambriansreed
Message:

Fixes SVN merge issues, notices updates, adds warning for legacy post type data

Location:
advanced-custom-post-types
Files:
25 added
6 edited

Legend:

Unmodified
Added
Removed
  • advanced-custom-post-types/trunk/acpt.php

    r1523580 r1525061  
    33Plugin Name: Advanced Custom Post Types
    44Description: Customise WordPress with custom post types
    5 Version: 0.4.5
     5Version: 0.5.0
    66Author: iambriansreed
    77Author URI: http://iambrian.com/
  • advanced-custom-post-types/trunk/admin/class-load.php

    r1523580 r1525061  
    33namespace Advanced_Custom_Post_Types\Admin {
    44
    5     use Advanced_Custom_Post_Types\Debug;
    65    use Advanced_Custom_Post_Types\Load_Main;
    76    use Advanced_Custom_Post_Types\Load_Base;
     
    9392                }
    9493
    95                 Notices::set( false );
     94                Notices::remove_all();
    9695            }
    9796        }
  • advanced-custom-post-types/trunk/admin/class-meta-boxes.php

    r1523578 r1525061  
    22
    33namespace Advanced_Custom_Post_Types\Admin;
    4 
    5 use Advanced_Custom_Post_Types\Debug;
    64
    75class Meta_Boxes {
     
    1311    public function __construct( Fields $fields ) {
    1412
     13        global $post;
     14
    1515        $this->fields = $fields;
    1616
    1717        $this->plugin_dir_url = plugin_dir_url( __FILE__ );
     18
     19        $this->set_field_values( $post );
    1820
    1921        foreach ( $fields->groups() as $name => $field_group ) {
     
    4648    }
    4749
    48     /**
    49      * @param $hook
    50      */
    51     public function admin_enqueue_scripts( $hook ) {
     50    public function admin_enqueue_scripts() {
    5251
    5352        wp_dequeue_style( 'select2' );
     
    203202    public function set_field_values( $post ) {
    204203
    205         global $pagenow;
    206 
    207204        if ( $this->field_values ) {
    208205            return;
    209206        }
    210207
    211         if ( 'post-new.php' === $pagenow ) {
    212             $this->field_values = $this->fields->defaults();
    213         } else {
    214             $post_type_data = json_decode( $post->post_content, true );
     208        $this->field_values = $this->fields->defaults();
     209
     210        $post_type_data = $post->post_content ? json_decode( $post->post_content, true ) : false;
     211
     212        if ( $post_type_data && is_array( $post_type_data ) &&
     213             isset( $post_type_data['args'] ) && is_array( $post_type_data['args'] )
     214        ) {
    215215            foreach ( $post_type_data['args'] as $name => $value ) {
    216216                $this->field_values[ 'acpt_' . $name ] = $value;
    217217            }
     218        } else {
     219
     220            Notices::add_warning( 'There was an error loading your Custom Post Type.' );
    218221        }
    219222    }
     
    225228
    226229    /**
    227      * @param $post
    228230     * @param $field
    229231     *
  • advanced-custom-post-types/trunk/admin/class-notices.php

    r1506712 r1525061  
    66
    77    /**
     8     * add an error notice to users notices
     9     *
     10     * @param $message
     11     * @param bool $is_dismissible
     12     */
     13    public static function add_error( $message, $is_dismissible = true ) {
     14        self::add( $message, 'error', $is_dismissible );
     15    }
     16
     17    /**
     18     * add a warning notice to users notices
     19     *
     20     * @param $message
     21     * @param bool $is_dismissible
     22     */
     23    public static function add_warning( $message, $is_dismissible = true ) {
     24        self::add( $message, 'warning', $is_dismissible );
     25    }
     26
     27    /**
     28     * add an success notice to users notices
     29     *
     30     * @param $message
     31     * @param bool $is_dismissible
     32     */
     33    public static function add_success( $message, $is_dismissible = true ) {
     34        self::add( $message, 'success', $is_dismissible );
     35    }
     36
     37    /**
     38     * add an info notice to users notices
     39     *
     40     * @param $message
     41     * @param bool $is_dismissible
     42     */
     43    public static function add_info( $message, $is_dismissible = true ) {
     44        self::add( $message, 'info', $is_dismissible );
     45    }
     46
     47    /**
    848     * add a notice to users notices
    949     *
    1050     * @param $message
    11      * @param string $type
     51     * @param string $type (error, warning, success, or info)
    1252     * @param bool $is_dismissible
    1353     */
    14     public static function add( $message, $type = 'info', $is_dismissible = true ) {
     54    private static function add( $message, $type = 'info', $is_dismissible = true ) {
    1555
    1656        $notices = self::get_all();
     
    4181
    4282    /**
     83     * clear all users notices
     84     */
     85    public static function remove_all() {
     86
     87        self::set( false );
     88    }
     89
     90    /**
    4391     * save notices
    4492     *
    4593     * @param $notices
    4694     */
    47     public static function set( $notices ) {
     95    private static function set( $notices ) {
    4896
    4997        if ( $notices === false ) {
  • advanced-custom-post-types/trunk/admin/class-post-type.php

    r1523580 r1525061  
    33namespace Advanced_Custom_Post_Types\Admin;
    44
    5 use Advanced_Custom_Post_Types\Debug;
    65use Advanced_Custom_Post_Types\Load_Main;
    76use Advanced_Custom_Post_Types\Settings;
     
    2827    public function save( $post ) {
    2928
    30         $existing_post = get_post( $post->ID );
    31 
    3229        // get fields and pre process the data
    3330        if ( ! isset( $_POST ) || ! is_array( $_POST ) ) {
     
    4946
    5047        if ( count( $this->errors ) ) {
    51             Notices::add( implode( '<br>', $this->errors ), 'error', false );
     48            Notices::add_error( implode( '<br>', $this->errors ), false );
    5249        }
    5350
     
    113110     * @param $post_id
    114111     *
    115      * @return array
    116112     */
    117113    private function set_field_values( $post_id ) {
     
    176172    /**
    177173     * creates the register_post_type arguments from the acpt fields values
    178      *
    179      * @param $this ->field_values
    180174     *
    181175     * @return array
  • advanced-custom-post-types/trunk/readme.txt

    r1523585 r1525061  
    6767= 0.4.5 =
    6868* Fixes At a Glance dashboard issues
     69
     70= 0.5.0 =
     71* Fixes SVN merge issues, notices updates, adds warning for legacy post type data
     72
Note: See TracChangeset for help on using the changeset viewer.