WordPress.org

Plugin Directory

Changeset 1744797


Ignore:
Timestamp:
10/11/2017 02:10:48 PM (18 months ago)
Author:
euthelup
Message:

update to 1.4.8

Location:
pixtypes
Files:
26 added
4 deleted
43 edited
7 copied

Legend:

Unmodified
Added
Removed
  • pixtypes/tags/1.4.8/README.md

    r1591155 r1744797  
    4949                ),
    5050                'has_archive'   => 'portfolio-archive',
    51                 'menu_icon'     => 'report.png',
     51                'menu_icon'     => 'dashicons-portfolio',
    5252                'menu_position' => null,
    5353                'hierarchical' => true,
  • pixtypes/tags/1.4.8/class-pixtypes.php

    r1728763 r1744797  
    2525     * @const   string
    2626     */
    27     protected $version = '1.4.7';
     27    protected $version;
    2828    /**
    2929     * Unique identifier for your plugin.
     
    7272     *
    7373     * @since     1.0.0
    74      */
    75     protected function __construct() {
    76 
     74     *
     75     * @param string $version
     76     */
     77    protected function __construct( $version = '1.0.0' ) {
     78        $this->version = $version;
    7779        $this->plugin_basepath = plugin_dir_path( __FILE__ );
    7880        $this->config          = self::config();
     
    8082        // Load plugin text domain
    8183        add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
    82 //      add_action( 'admin_init', array( $this, 'wpgrade_init_plugin' ) );
    8384
    8485        // Add the options page and menu item only when is needed.
     
    9293        }
    9394
    94         // Load admin style sheet and JavaScript.
     95        // Load admin stylesheet and JavaScript files.
    9596        add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
    9697        add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
    9798
    98         // Load public-facing style sheet and JavaScript.
    99 //      add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
    100 //      add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
    101 
    10299        add_action( 'plugins_loaded', array( $this, 'register_metaboxes' ), 14 );
    103100        add_action( 'init', array( $this, 'register_entities' ), 99999 );
    104101
    105         // We need this later that the default 10 so we can have things happening between the init-10 and the PixTypes config
     102        // We need this later then the default 10 priority so we can have things happening between the init-10 and the PixTypes config
    106103        add_action( 'init', array( $this, 'theme_version_check' ), 15 );
    107104
    108105        /**
    109          * Ajax Callbacks
     106         * Ajax Callbacks - only for logged in users
    110107         */
    111108        add_action( 'wp_ajax_unset_pixtypes', array( &$this, 'ajax_unset_pixtypes' ) );
    112         add_action( 'wp_ajax_nopriv_unset_pixtypes', array( &$this, 'ajax_unset_pixtypes' ) );
    113109    }
    114110
     
    118114     * @since     1.0.0
    119115     *
     116     * @param string $version The current plugin version.
    120117     * @return    object    A single instance of this class.
    121118     */
    122     public static function get_instance() {
     119    public static function get_instance( $version = '1.0.0' ) {
    123120
    124121        // If the single instance hasn't been set, set it now.
    125122        if ( null == self::$instance ) {
    126             self::$instance = new self;
     123            self::$instance = new self( $version );
    127124        }
    128125
     
    133130        // @TODO maybe check this
    134131        return include 'plugin-config.php';
    135     }
    136 
    137     public function wpgrade_init_plugin() {
    138 //      $this->plugin_textdomain();
    139 //      $this->add_wpgrade_shortcodes_button();
    140132    }
    141133
     
    184176                    if ( ! empty( $theme_types[ $current_theme ]['post_types'] ) ) {
    185177                        foreach ( $theme_types[ $current_theme ]['post_types'] as $key => $post_type ) {
    186                             $testable_slug = $is_slug_unique = '';
    187                             $testable_slug = str_replace( $theme_name . '-', '', $post_type["rewrite"]["slug"] );
     178                            $testable_slug = str_replace( $theme_name . '-', '', $post_type['rewrite']['slug'] );
    188179
    189180                            /** for our current theme we try to prioritize slugs */
    190                             if ( isset( $post_type["rewrite"] ) && self::is_custom_post_type_slug_unique( $testable_slug ) ) {
     181                            if ( isset( $post_type['rewrite'] ) && self::is_custom_post_type_slug_unique( $testable_slug ) ) {
    191182                                /** this slug is unique we can quit the theme suffix */
    192                                 $theme_types[ $current_theme ]['post_types'][ $key ]["rewrite"]["slug"] = $testable_slug;
     183                                $theme_types[ $current_theme ]['post_types'][ $key ]['rewrite']['slug'] = $testable_slug;
    193184                            }
    194185
    195186                            // process menu icon if it exists
    196187                            if ( isset( $post_type['menu_icon'] ) ) {
    197                                 $theme_types[ $current_theme ]['post_types'][ $key ]['menu_icon'] = plugins_url( 'assets/' . $post_type['menu_icon'], __FILE__ );
     188                                // If we have been given a dashicon, use it without processing
     189                                if ( false !== strpos( $post_type['menu_icon'], 'dashicon' ) ) {
     190                                    $theme_types[ $current_theme ]['post_types'][ $key ]['menu_icon'] =  $post_type['menu_icon'];
     191                                } else {
     192                                    $theme_types[ $current_theme ]['post_types'][ $key ]['menu_icon'] = plugins_url( 'assets/' . $post_type['menu_icon'], __FILE__ );
     193                                }
    198194                            }
    199195                        }
     
    203199                    if ( ! empty( $theme_types[ $current_theme ]['taxonomies'] ) ) {
    204200                        foreach ( $theme_types[ $current_theme ]['taxonomies'] as $key => $tax ) {
    205                             $testable_slug = $is_slug_unique = '';
    206                             $testable_slug = str_replace( $theme_name . '-', '', $tax["rewrite"]["slug"] );
    207                             if ( isset( $tax["rewrite"] ) && self::is_tax_slug_unique( $testable_slug ) ) {
     201                            $testable_slug = str_replace( $theme_name . '-', '', $tax['rewrite']['slug'] );
     202                            if ( isset( $tax['rewrite'] ) && self::is_tax_slug_unique( $testable_slug ) ) {
    208203                                /** this slug is unique we can quit the theme suffix */
    209                                 $theme_types[ $current_theme ]['taxonomies'][ $key ]["rewrite"]["slug"] = $testable_slug;
     204                                $theme_types[ $current_theme ]['taxonomies'][ $key ]['rewrite']['slug'] = $testable_slug;
    210205                            }
    211206                        }
     
    218213        update_option( $config['settings-key'], $types_settings );
    219214
    220 //      flush_rewrite_rules();
    221 //      global $wp_rewrite;
    222 //      $wp_rewrite->generate_rewrite_rules();
    223 //      flush_rewrite_rules();
    224 
    225215        /**
    226216         * http://wordpress.stackexchange.com/questions/36152/flush-rewrite-rules-not-working-on-plugin-deactivation-invalid-urls-not-showing
    227          * nothing from above works in plugin so ...
     217         * nothing from above works in plugins so ...
    228218         */
    229219        delete_option( 'rewrite_rules' );
     
    299289
    300290    /**
    301      * Register and enqueue public-facing style sheet.
    302      *
    303      * @since    1.0.0
    304      */
    305     function enqueue_styles() {
    306         wp_enqueue_style( $this->plugin_slug . '-plugin-styles', plugins_url( 'css/public.css', __FILE__ ), array(), $this->version );
    307     }
    308 
    309     /**
    310      * Register and enqueues public-facing JavaScript files.
    311      *
    312      * @since    1.0.0
    313      */
    314     public function enqueue_scripts() {
    315         wp_enqueue_script( $this->plugin_slug . '-plugin-script', plugins_url( 'js/public.js', __FILE__ ), array( 'jquery' ), $this->version );
    316     }
    317 
    318     /**
    319291     * Register the administration menu for this plugin into the WordPress Dashboard menu.
    320292     */
     
    322294
    323295        $this->plugin_screen_hook_suffix = add_options_page(
    324             esc_html__( 'PixTypes', $this->plugin_slug ),
    325             esc_html__( 'PixTypes', $this->plugin_slug ),
     296            esc_html__( 'PixTypes', 'pixtypes' ),
     297            esc_html__( 'PixTypes', 'pixtypes' ),
    326298            'manage_options',
    327299            $this->plugin_slug,
     
    342314     */
    343315    function add_action_links( $links ) {
    344         return array_merge( array( 'settings' => '<a href="' . admin_url( 'options-general.php?page=pixtypes' ) . '">' . esc_html__( 'Settings', $this->plugin_slug ) . '</a>' ), $links );
     316        return array_merge( array( 'settings' => '<a href="' . admin_url( 'options-general.php?page=pixtypes' ) . '">' . esc_html__( 'Settings', 'pixtypes' ) . '</a>' ), $links );
    345317    }
    346318
    347319    function register_entities() {
    348         require_once( $this->plugin_basepath . 'features/custom-entities.php' );
     320        // register post types
     321        $options = $updated_options  = apply_filters( 'pixtypes_settings_pre_register_entitites', get_option( 'pixtypes_settings' ) );
     322        $updated_options['display_settings'] = false;
     323
     324        // go through each theme and activate portfolio post types
     325        if ( empty( $options['themes'] ) || ! array( $options['themes'] ) ) {
     326            return;
     327        }
     328
     329        /** A pixelgrade theme will always have this class so we know we can import new settings **/
     330        $current_theme = false;
     331        if ( class_exists( 'wpgrade' ) ) {
     332            $current_theme = wpgrade::shortname();
     333        }
     334
     335        $theme_types = $options['themes'];
     336        foreach ( $theme_types as $key => $theme ) {
     337            // post types
     338            if ( isset( $theme['post_types'] ) && is_array( $theme['post_types'] ) ) {
     339                // Remember what post types we have removed from settings so we can skip registering their taxonomies
     340                $deleted_post_types = array();
     341                foreach ( $theme['post_types'] as $post_type => $post_type_args ) {
     342                    // First check if the post type is already registered - we bail if that is the case
     343                    if ( post_type_exists( $post_type ) ) {
     344                        continue;
     345                    }
     346
     347                    // Second, for post types not belonging to the current theme, we only register them if there are posts
     348                    if ( false !== $current_theme && $key != $current_theme ) {
     349                        // We get the posts to see if there are any - we include all post statuses (trash and auto-draft need to be specified directly)
     350                        $posts = get_posts( array( 'post_type' => $post_type, 'post_status' => array( 'any', 'trash', 'auto-draft' ), 'posts_per_page' => '1' ) );
     351                        if ( empty( $posts ) ) {
     352                            // We should also delete the post type from the settings - no worries; if the theme gets activated again, all this will come back
     353                            // This is just for auto-cleanup
     354                            unset( $updated_options['themes'][ $key ]['post_types'][ $post_type ] );
     355                            $deleted_post_types[] = $post_type;
     356                            continue;
     357                        }
     358                    }
     359
     360                    $is_jetpack_compatible = false;
     361                    if ( strpos( $post_type, 'jetpack' ) !== false ) {
     362                        ///$xxxx = str_replace(  'jetpack-', '', $post_type);
     363                        $is_jetpack_compatible = true;
     364                    }
     365
     366                    if ( $is_jetpack_compatible ) {
     367                        $post_type_key = strstr( $post_type, '-' );
     368                        $post_type_key = substr( $post_type_key, 1 );
     369                    } else {
     370                        // eliminate the theme prefix
     371                        $post_type_key = strstr( $post_type, '_' );
     372                        $post_type_key = substr( $post_type_key, 1 );
     373                    }
     374
     375                    // process menu icon if it exists
     376                    if ( isset( $post_type_args['menu_icon'] ) ) {
     377                        // If we have been given a dashicon or full URL, use it without processing
     378                        if ( false === strpos( $post_type_args['menu_icon'], 'dashicon' ) && false === filter_var( $post_type_args['menu_icon'], FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED ) ) {
     379                            $post_type_args['menu_icon'] = plugins_url( 'assets/' . $post_type_args['menu_icon'], __FILE__ );
     380                        }
     381                    }
     382
     383                    if ( isset( $options[ 'enable_' . $post_type_key ] ) ) {
     384                        $updated_options['display_settings'] = true;
     385                        if ( $options[ 'enable_' . $post_type_key ] ) {
     386                            register_post_type( $post_type, $post_type_args );
     387                        }
     388                    }
     389                }
     390            }
     391
     392            // taxonomies
     393            if ( isset( $theme['taxonomies'] ) && is_array( $theme['taxonomies'] ) ) {
     394                foreach ( $theme['taxonomies'] as $tax => $tax_args ) {
     395                    // First check if the taxonomy is already registered - we bail if that is the case
     396                    if ( taxonomy_exists( $tax ) ) {
     397                        continue;
     398                    }
     399
     400                    // If we have deleted post types settings we need to skip registering their taxonomies
     401                    if ( ! empty( $tax_args['post_types'] ) && ! empty( $deleted_post_types ) ) {
     402                        if ( ! is_array( $tax_args['post_types'] ) ) {
     403                            if ( in_array( $tax_args['post_types'], $deleted_post_types ) ) {
     404                                continue;
     405                            }
     406                        } else {
     407                            $temp = array_diff( $tax_args['post_types'], $deleted_post_types );
     408                            if ( empty( $temp ) ) {
     409                                continue;
     410                            }
     411                        }
     412                    }
     413
     414                    $tax_post_types = $tax_args['post_types'];
     415                    // remove "post_types", isn't a register_taxonomy argument we are just using it for post type linking
     416                    unset( $tax_args['post_types'] );
     417
     418                    $is_jetpack_compatible = false;
     419                    if ( strpos( $tax, 'jetpack' ) !== false ) {
     420                        ///$xxxx = str_replace(  'jetpack-', '', $tax);
     421                        $is_jetpack_compatible = true;
     422                    }
     423
     424                    if ( $is_jetpack_compatible ) {
     425                        $tax_key = strstr( $tax, '-' );
     426                        $tax_key = substr( $tax_key, 1 );
     427                    } else {
     428                        // eliminate the theme prefix
     429                        $tax_key = strstr( $tax, '_' );
     430                        $tax_key = substr( $tax_key, 1 );
     431                    }
     432
     433                    if ( isset( $options[ 'enable_' . $tax_key ] ) ) {
     434                        $updated_options['display_settings'] = true;
     435                        if ( $options[ 'enable_' . $tax_key ] ) {
     436                            register_taxonomy( $tax, $tax_post_types, $tax_args );
     437                        }
     438                    }
     439                }
     440            }
     441        }
     442
     443        // Only update if we have actually changed something
     444        if ( $options != $updated_options ) {
     445            update_option( 'pixtypes_settings', $updated_options );
     446        }
    349447    }
    350448
     
    369467            $rewrite = $post_type->rewrite;
    370468            /** if this post_type has a rewrite rule check for it */
    371             if ( ! empty( $rewrite ) && isset( $rewrite["slug"] ) && $slug == $rewrite["slug"] ) {
     469            if ( ! empty( $rewrite ) && isset( $rewrite['slug'] ) && $slug == $rewrite['slug'] ) {
    372470                $is_unique = false;
    373471            } elseif ( $slug == $key ) {
     
    388486     */
    389487    static function is_tax_slug_unique( $slug ) {
    390 
    391488        global $wp_taxonomies;
     489
     490        /** Suppose it's true */
    392491        $is_unique = true;
    393         /** Suppose it's true */
    394492
    395493        foreach ( $wp_taxonomies as $key => $tax ) {
    396494            $rewrite = $tax->rewrite;
    397495            /** if this post_type has a rewrite rule check for it */
    398             if ( ! empty( $rewrite ) && isset( $rewrite["slug"] ) && $slug == $rewrite["slug"] ) {
     496            if ( ! empty( $rewrite ) && isset( $rewrite['slug'] ) && $slug == $rewrite['slug'] ) {
    399497                $is_unique = false;
    400498            } elseif ( $slug == $key ) {
     
    433531                ),
    434532                'has_archive'   => 'portfolio-archive',
    435                 'menu_icon'     => plugins_url( 'assets/report.png', __FILE__ ),
     533                'menu_icon'     => 'dashicons-portfolio',
    436534                'supports'      => array( 'title', 'editor', 'thumbnail', 'page-attributes', 'excerpt' ),
    437535                'yarpp_support' => true,
     
    459557                'has_archive'   => 'galleries-archive',
    460558                'menu_position' => null,
     559                'menu_icon'     => 'dashicons-format-gallery',
    461560                'supports'      => array( 'title', 'thumbnail', 'page-attributes', 'excerpt' ),
    462561                'yarpp_support' => true,
     
    546645
    547646    /**
    548      * Ajax callback for unseting unneeded post types
     647     * Ajax callback for cleaning up the settings for a theme
    549648     */
    550649    function ajax_unset_pixtypes() {
     
    555654        }
    556655
    557         if ( isset( $_POST['post_type'] ) ) {
    558             $key     = $_POST['post_type'];
     656        if ( isset( $_POST['theme_slug'] ) ) {
     657            $key     = $_POST['theme_slug'];
    559658            $options = get_option( 'pixtypes_settings' );
    560659            if ( isset( $options['themes'][ $key ] ) ) {
    561660                unset( $options['themes'][ $key ] );
    562661                update_option( 'pixtypes_settings', $options );
    563                 $result['msg']     = 'Post type ' . $key . ' is gone.';
     662                $result['msg']     = 'Settings for ' . ucfirst( $key ) . ' have been cleaned up!';
    564663                $result['success'] = true;
    565664            }
     
    574673     */
    575674    function theme_version_check() {
    576 
    577         $options = get_option( 'pixtypes_settings' );
    578 
    579         if ( class_exists( 'wpgrade' ) && isset( $options['wpgrade_theme_version'] ) ) {
    580 
    581             if ( wpgrade::themeversion() != $options['wpgrade_theme_version'] ) {
     675        if ( class_exists( 'wpgrade' ) ) {
     676            // Each theme should have it's pixtypes config theme version saved
     677            $options = get_option( 'pixtypes_settings' );
     678
     679            // Make sure that we fix things just in case
     680            if ( ! isset( $options['wpgrade_theme_version'] ) ) {
     681                $options['wpgrade_theme_version'] = '0.0.1';
     682            }
     683
     684            if ( version_compare( wpgrade::themeversion(), $options['wpgrade_theme_version'], '!=' ) ) {
    582685                // here the theme is updating it's options
    583                 $test = function_exists( 'wpgrade_callback_geting_active' );
    584 
    585                 wpgrade_callback_geting_active();
    586                 // the plugin will copy these options into it's own field
    587                 self::activate( false );
    588                 // end finally merge user's settings with the theme ones
    589                 save_pixtypes_settings( $options );
    590 
     686                if ( function_exists( 'wpgrade_callback_geting_active' ) ) {
     687                    wpgrade_callback_geting_active();
     688                    // the plugin will copy these options into it's own field
     689                    self::activate( false );
     690                    // end finally merge user's settings with the theme ones
     691                    save_pixtypes_settings( $options );
     692                }
    591693            }
    592694        }
  • pixtypes/tags/1.4.8/core/classes/HTMLElement.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/tags/1.4.8/core/classes/HTMLTag.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/tags/1.4.8/core/classes/Meta.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/tags/1.4.8/core/classes/Processor.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/tags/1.4.8/core/classes/Validator.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/tags/1.4.8/core/classes/forms/Form.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/tags/1.4.8/core/classes/forms/FormField.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/tags/1.4.8/core/defaults.php

    r1591155 r1744797  
    2828        'errors' => array
    2929            (
    30                 'is_numeric' => esc_html__('Numberic value required.', pixtypes::textdomain()),
    31                 'not_empty' => esc_html__('Field is required.', pixtypes::textdomain()),
     30                'is_numeric' => esc_html__('Numberic value required.', 'pixtypes' ),
     31                'not_empty' => esc_html__('Field is required.', 'pixtypes' ),
    3232            ),
    3333
  • pixtypes/tags/1.4.8/core/interfaces/HTMLElement.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/tags/1.4.8/core/interfaces/HTMLTag.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/tags/1.4.8/core/interfaces/Meta.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/tags/1.4.8/core/interfaces/Processor.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/tags/1.4.8/core/interfaces/Validator.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/tags/1.4.8/core/interfaces/extended/Form.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/tags/1.4.8/core/interfaces/extended/FormField.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/tags/1.4.8/features/metaboxes/init.php

    r1591646 r1744797  
    10121012            // validate meta value
    10131013            if ( isset( $field['validate_func'] ) ) {
    1014                 $ok = call_user_func( array( 'cmb_Meta_Box_Validate', $field['validate_func'] ), $new );
     1014                $ok = call_user_func( $field['validate_func'], $new, $field, $post_id );
    10151015                if ( $ok === false ) { // pass away when meta value is invalid
    10161016                    continue;
  • pixtypes/tags/1.4.8/features/metaboxes/metaboxes.php

    r1728763 r1744797  
    5353
    5454        require_once 'cmb-field-select2/cmb-field-select2.php';
     55        require_once 'cmb-field-select2-v2/cmb-field-select2.php';
    5556    }
    5657
  • pixtypes/tags/1.4.8/js/admin.js

    r1115891 r1744797  
    6161        /** ajax callbacks */
    6262        $('#unset_pixypes').on('click', 'button', function(e){
    63             var response = confirm('Be sure that you don\'t need this post type anymore');
     63            var response = confirm('Make sure that you have moved the theme specific content you were interested in. If at any time you wish to access it again, reactivate that previous theme.');
    6464
    6565            if ( response == false ) {
     
    6969
    7070                var ajax_nounce = $(this).parents('ul').siblings('.unset_nonce').val();
    71                 // reload likes number
     71                // Cleanup pixtypes settings
    7272                jQuery.ajax({
    73                     type: "post",url: locals.ajax_url,data: { action: 'unset_pixtypes', _ajax_nonce: ajax_nounce, post_type: $(this).val() },
     73                    type: "post",url: locals.ajax_url,data: { action: 'unset_pixtypes', _ajax_nonce: ajax_nounce, theme_slug: $(this).val() },
    7474                    //beforeSend: function() {jQuery("#loading").show("slow");}, //show loading just when link is clicked
    7575                    //complete: function() { jQuery("#loading").hide("fast");}, //stop showing loading when the process is complete
  • pixtypes/tags/1.4.8/pixtypes.php

    r1728763 r1744797  
    11<?php
    22/*
    3 * @package   PixTypes
    4 * @author    Pixelgrade <[email protected]>
    5 * @license   GPL-2.0+
    6 * @link      https://pixelgrade.com
    7 * @copyright 2013-2017 Pixelgrade
    8 *
    9 * @wordpress-plugin
    10 Plugin Name: PixTypes
    11 Plugin URI:  https://pixelgrade.com
    12 Description: Custom post types and meta-boxes needed by your theme
    13 Version: 1.4.7
    14 Author: Pixelgrade
    15 Author URI: https://pixelgrade.com
    16 Author Email: [email protected]
    17 Text Domain: pixtypes
    18 License:     GPL-2.0+
    19 License URI: http://www.gnu.org/licenses/gpl-2.0.txt
    20 Domain Path: /lang
    21 */
     3 * Plugin Name: PixTypes
     4 * Plugin URI: https://wordpress.org/plugins/pixtypes/
     5 * Description: Custom post types and meta-boxes needed by your themes.
     6 * Version: 1.4.8
     7 * Author URI: https://pixelgrade.com
     8 * Author Email: [email protected]
     9 * License: GPL2+
     10 * Text Domain: pixtypes
     11 * Domain Path: /lang/
     12 */
    2213
    2314// If this file is called directly, abort.
     
    3425
    3526$config = include 'plugin-config' . EXT;
    36 include 'features/class-pix-query' . EXT;
    3727// set textdomain
    3828pixtypes::settextdomain( $config['textdomain'] );
     
    5646// --------------
    5747
    58 $basepath     = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
    59 $callbackpath = $basepath . 'callbacks' . DIRECTORY_SEPARATOR;
     48$basepath     = trailingslashit( dirname( __FILE__ ) );
     49$callbackpath = trailingslashit( $basepath . 'callbacks' );
    6050pixtypes::require_all( $callbackpath );
    6151
     
    6757
    6858global $pixtypes_plugin;
    69 $pixtypes_plugin = PixTypesPlugin::get_instance();
     59$pixtypes_plugin = PixTypesPlugin::get_instance( '1.4.8' );
  • pixtypes/tags/1.4.8/settings/post_types.php

    r1591155 r1744797  
    77
    88$options = get_option( 'pixtypes_settings' );
    9 // go through each theme and activate portfolio post types
    10 if ( isset( $options["themes"] ) ) {
    11     $theme_types = $options["themes"];
     9// go through each theme and activate the post types settings
     10if ( isset( $options['themes'] ) ) {
     11    $theme_types = $options['themes'];
    1212    foreach ( $theme_types as $key => $theme ) {
    1313
     
    2323            }
    2424            $display_settings = true;
    25         } else {
    26             return array( 'type' => 'hidden' );
    2725        }
    2826    }
     27}
     28
     29// Check if we have any post type that should be shown settings
     30$hide = true;
     31foreach ( $display_option as $post_type => $display ) {
     32    if ( $display ) {
     33        $hide = false;
     34        break;
     35    }
     36}
     37
     38if ( $hide ) {
     39    return array( 'type' => 'hidden' );
    2940}
    3041
  • pixtypes/tags/1.4.8/views/admin.php

    r1591155 r1744797  
    4343        <?php endif; ?>
    4444
    45         <?php echo $f = pixtypes::form( $config, $processor );
    46         echo $f->field( 'hiddens' )->render(); ?>
     45        <?php
     46        $f = pixtypes::form( $config, $processor ); ?>
     47
     48        <?php echo $f->startform() ?>
     49
     50        <?php echo $f->field( 'hiddens' )->render(); ?>
    4751
    4852        <?php echo $f->field( 'post_types' )->render(); ?>
     
    7074
    7175            <div class="handlediv" title="Click to toggle"><br></div>
    72             <h3 class="hndle"><span><?php esc_html_e( 'Danger Zone', 'pixtypes' ); ?></span></h3>
     76            <h3 class="hndle"><span><?php esc_html_e( 'Extra Careful Zone', 'pixtypes' ); ?></span></h3>
    7377
    7478            <div class="inside">
    7579
    76                 <p><?php esc_html_e( 'If you are done with copying your content from old post types to new ones, you can also get rid of the old post types.', 'pixtypes' ); ?></p>
     80                <p><?php esc_html_e( 'If you are done with copying your content from old themes to new ones, you can also get rid of the old themes settings and post types.', 'pixtypes' ); ?></p>
    7781                <form method="post" id="unset_pixypes"
    7882                      action="<?php echo admin_url( 'options-general.php?page=pixtypes' ) ?>">
     
    8387                        if ( isset( $options['themes'] ) && count( $options['themes'] ) > 1 ) {
    8488                            foreach ( $options['themes'] as $key => $theme ) {
    85                                 echo '<li><button class="button delete-action" type="submit" name="unset_pixtype" value="' . $key . '">' . esc_html__( 'Unset', 'pixtypes' ) . ' ' . $key . '</button></li>';
     89                                echo '<li><button class="button delete-action" type="submit" name="unset_pixtype" value="' . $key . '">' . esc_html__( 'Clean-up after', 'pixtypes' ) . ' ' . ucfirst( $key ) . '</button></li>';
    8690                            }
    8791                        } ?>
  • pixtypes/trunk/README.md

    r1591155 r1744797  
    4949                ),
    5050                'has_archive'   => 'portfolio-archive',
    51                 'menu_icon'     => 'report.png',
     51                'menu_icon'     => 'dashicons-portfolio',
    5252                'menu_position' => null,
    5353                'hierarchical' => true,
  • pixtypes/trunk/class-pixtypes.php

    r1728763 r1744797  
    2525     * @const   string
    2626     */
    27     protected $version = '1.4.7';
     27    protected $version;
    2828    /**
    2929     * Unique identifier for your plugin.
     
    7272     *
    7373     * @since     1.0.0
    74      */
    75     protected function __construct() {
    76 
     74     *
     75     * @param string $version
     76     */
     77    protected function __construct( $version = '1.0.0' ) {
     78        $this->version = $version;
    7779        $this->plugin_basepath = plugin_dir_path( __FILE__ );
    7880        $this->config          = self::config();
     
    8082        // Load plugin text domain
    8183        add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
    82 //      add_action( 'admin_init', array( $this, 'wpgrade_init_plugin' ) );
    8384
    8485        // Add the options page and menu item only when is needed.
     
    9293        }
    9394
    94         // Load admin style sheet and JavaScript.
     95        // Load admin stylesheet and JavaScript files.
    9596        add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
    9697        add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
    9798
    98         // Load public-facing style sheet and JavaScript.
    99 //      add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
    100 //      add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
    101 
    10299        add_action( 'plugins_loaded', array( $this, 'register_metaboxes' ), 14 );
    103100        add_action( 'init', array( $this, 'register_entities' ), 99999 );
    104101
    105         // We need this later that the default 10 so we can have things happening between the init-10 and the PixTypes config
     102        // We need this later then the default 10 priority so we can have things happening between the init-10 and the PixTypes config
    106103        add_action( 'init', array( $this, 'theme_version_check' ), 15 );
    107104
    108105        /**
    109          * Ajax Callbacks
     106         * Ajax Callbacks - only for logged in users
    110107         */
    111108        add_action( 'wp_ajax_unset_pixtypes', array( &$this, 'ajax_unset_pixtypes' ) );
    112         add_action( 'wp_ajax_nopriv_unset_pixtypes', array( &$this, 'ajax_unset_pixtypes' ) );
    113109    }
    114110
     
    118114     * @since     1.0.0
    119115     *
     116     * @param string $version The current plugin version.
    120117     * @return    object    A single instance of this class.
    121118     */
    122     public static function get_instance() {
     119    public static function get_instance( $version = '1.0.0' ) {
    123120
    124121        // If the single instance hasn't been set, set it now.
    125122        if ( null == self::$instance ) {
    126             self::$instance = new self;
     123            self::$instance = new self( $version );
    127124        }
    128125
     
    133130        // @TODO maybe check this
    134131        return include 'plugin-config.php';
    135     }
    136 
    137     public function wpgrade_init_plugin() {
    138 //      $this->plugin_textdomain();
    139 //      $this->add_wpgrade_shortcodes_button();
    140132    }
    141133
     
    184176                    if ( ! empty( $theme_types[ $current_theme ]['post_types'] ) ) {
    185177                        foreach ( $theme_types[ $current_theme ]['post_types'] as $key => $post_type ) {
    186                             $testable_slug = $is_slug_unique = '';
    187                             $testable_slug = str_replace( $theme_name . '-', '', $post_type["rewrite"]["slug"] );
     178                            $testable_slug = str_replace( $theme_name . '-', '', $post_type['rewrite']['slug'] );
    188179
    189180                            /** for our current theme we try to prioritize slugs */
    190                             if ( isset( $post_type["rewrite"] ) && self::is_custom_post_type_slug_unique( $testable_slug ) ) {
     181                            if ( isset( $post_type['rewrite'] ) && self::is_custom_post_type_slug_unique( $testable_slug ) ) {
    191182                                /** this slug is unique we can quit the theme suffix */
    192                                 $theme_types[ $current_theme ]['post_types'][ $key ]["rewrite"]["slug"] = $testable_slug;
     183                                $theme_types[ $current_theme ]['post_types'][ $key ]['rewrite']['slug'] = $testable_slug;
    193184                            }
    194185
    195186                            // process menu icon if it exists
    196187                            if ( isset( $post_type['menu_icon'] ) ) {
    197                                 $theme_types[ $current_theme ]['post_types'][ $key ]['menu_icon'] = plugins_url( 'assets/' . $post_type['menu_icon'], __FILE__ );
     188                                // If we have been given a dashicon, use it without processing
     189                                if ( false !== strpos( $post_type['menu_icon'], 'dashicon' ) ) {
     190                                    $theme_types[ $current_theme ]['post_types'][ $key ]['menu_icon'] =  $post_type['menu_icon'];
     191                                } else {
     192                                    $theme_types[ $current_theme ]['post_types'][ $key ]['menu_icon'] = plugins_url( 'assets/' . $post_type['menu_icon'], __FILE__ );
     193                                }
    198194                            }
    199195                        }
     
    203199                    if ( ! empty( $theme_types[ $current_theme ]['taxonomies'] ) ) {
    204200                        foreach ( $theme_types[ $current_theme ]['taxonomies'] as $key => $tax ) {
    205                             $testable_slug = $is_slug_unique = '';
    206                             $testable_slug = str_replace( $theme_name . '-', '', $tax["rewrite"]["slug"] );
    207                             if ( isset( $tax["rewrite"] ) && self::is_tax_slug_unique( $testable_slug ) ) {
     201                            $testable_slug = str_replace( $theme_name . '-', '', $tax['rewrite']['slug'] );
     202                            if ( isset( $tax['rewrite'] ) && self::is_tax_slug_unique( $testable_slug ) ) {
    208203                                /** this slug is unique we can quit the theme suffix */
    209                                 $theme_types[ $current_theme ]['taxonomies'][ $key ]["rewrite"]["slug"] = $testable_slug;
     204                                $theme_types[ $current_theme ]['taxonomies'][ $key ]['rewrite']['slug'] = $testable_slug;
    210205                            }
    211206                        }
     
    218213        update_option( $config['settings-key'], $types_settings );
    219214
    220 //      flush_rewrite_rules();
    221 //      global $wp_rewrite;
    222 //      $wp_rewrite->generate_rewrite_rules();
    223 //      flush_rewrite_rules();
    224 
    225215        /**
    226216         * http://wordpress.stackexchange.com/questions/36152/flush-rewrite-rules-not-working-on-plugin-deactivation-invalid-urls-not-showing
    227          * nothing from above works in plugin so ...
     217         * nothing from above works in plugins so ...
    228218         */
    229219        delete_option( 'rewrite_rules' );
     
    299289
    300290    /**
    301      * Register and enqueue public-facing style sheet.
    302      *
    303      * @since    1.0.0
    304      */
    305     function enqueue_styles() {
    306         wp_enqueue_style( $this->plugin_slug . '-plugin-styles', plugins_url( 'css/public.css', __FILE__ ), array(), $this->version );
    307     }
    308 
    309     /**
    310      * Register and enqueues public-facing JavaScript files.
    311      *
    312      * @since    1.0.0
    313      */
    314     public function enqueue_scripts() {
    315         wp_enqueue_script( $this->plugin_slug . '-plugin-script', plugins_url( 'js/public.js', __FILE__ ), array( 'jquery' ), $this->version );
    316     }
    317 
    318     /**
    319291     * Register the administration menu for this plugin into the WordPress Dashboard menu.
    320292     */
     
    322294
    323295        $this->plugin_screen_hook_suffix = add_options_page(
    324             esc_html__( 'PixTypes', $this->plugin_slug ),
    325             esc_html__( 'PixTypes', $this->plugin_slug ),
     296            esc_html__( 'PixTypes', 'pixtypes' ),
     297            esc_html__( 'PixTypes', 'pixtypes' ),
    326298            'manage_options',
    327299            $this->plugin_slug,
     
    342314     */
    343315    function add_action_links( $links ) {
    344         return array_merge( array( 'settings' => '<a href="' . admin_url( 'options-general.php?page=pixtypes' ) . '">' . esc_html__( 'Settings', $this->plugin_slug ) . '</a>' ), $links );
     316        return array_merge( array( 'settings' => '<a href="' . admin_url( 'options-general.php?page=pixtypes' ) . '">' . esc_html__( 'Settings', 'pixtypes' ) . '</a>' ), $links );
    345317    }
    346318
    347319    function register_entities() {
    348         require_once( $this->plugin_basepath . 'features/custom-entities.php' );
     320        // register post types
     321        $options = $updated_options  = apply_filters( 'pixtypes_settings_pre_register_entitites', get_option( 'pixtypes_settings' ) );
     322        $updated_options['display_settings'] = false;
     323
     324        // go through each theme and activate portfolio post types
     325        if ( empty( $options['themes'] ) || ! array( $options['themes'] ) ) {
     326            return;
     327        }
     328
     329        /** A pixelgrade theme will always have this class so we know we can import new settings **/
     330        $current_theme = false;
     331        if ( class_exists( 'wpgrade' ) ) {
     332            $current_theme = wpgrade::shortname();
     333        }
     334
     335        $theme_types = $options['themes'];
     336        foreach ( $theme_types as $key => $theme ) {
     337            // post types
     338            if ( isset( $theme['post_types'] ) && is_array( $theme['post_types'] ) ) {
     339                // Remember what post types we have removed from settings so we can skip registering their taxonomies
     340                $deleted_post_types = array();
     341                foreach ( $theme['post_types'] as $post_type => $post_type_args ) {
     342                    // First check if the post type is already registered - we bail if that is the case
     343                    if ( post_type_exists( $post_type ) ) {
     344                        continue;
     345                    }
     346
     347                    // Second, for post types not belonging to the current theme, we only register them if there are posts
     348                    if ( false !== $current_theme && $key != $current_theme ) {
     349                        // We get the posts to see if there are any - we include all post statuses (trash and auto-draft need to be specified directly)
     350                        $posts = get_posts( array( 'post_type' => $post_type, 'post_status' => array( 'any', 'trash', 'auto-draft' ), 'posts_per_page' => '1' ) );
     351                        if ( empty( $posts ) ) {
     352                            // We should also delete the post type from the settings - no worries; if the theme gets activated again, all this will come back
     353                            // This is just for auto-cleanup
     354                            unset( $updated_options['themes'][ $key ]['post_types'][ $post_type ] );
     355                            $deleted_post_types[] = $post_type;
     356                            continue;
     357                        }
     358                    }
     359
     360                    $is_jetpack_compatible = false;
     361                    if ( strpos( $post_type, 'jetpack' ) !== false ) {
     362                        ///$xxxx = str_replace(  'jetpack-', '', $post_type);
     363                        $is_jetpack_compatible = true;
     364                    }
     365
     366                    if ( $is_jetpack_compatible ) {
     367                        $post_type_key = strstr( $post_type, '-' );
     368                        $post_type_key = substr( $post_type_key, 1 );
     369                    } else {
     370                        // eliminate the theme prefix
     371                        $post_type_key = strstr( $post_type, '_' );
     372                        $post_type_key = substr( $post_type_key, 1 );
     373                    }
     374
     375                    // process menu icon if it exists
     376                    if ( isset( $post_type_args['menu_icon'] ) ) {
     377                        // If we have been given a dashicon or full URL, use it without processing
     378                        if ( false === strpos( $post_type_args['menu_icon'], 'dashicon' ) && false === filter_var( $post_type_args['menu_icon'], FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED ) ) {
     379                            $post_type_args['menu_icon'] = plugins_url( 'assets/' . $post_type_args['menu_icon'], __FILE__ );
     380                        }
     381                    }
     382
     383                    if ( isset( $options[ 'enable_' . $post_type_key ] ) ) {
     384                        $updated_options['display_settings'] = true;
     385                        if ( $options[ 'enable_' . $post_type_key ] ) {
     386                            register_post_type( $post_type, $post_type_args );
     387                        }
     388                    }
     389                }
     390            }
     391
     392            // taxonomies
     393            if ( isset( $theme['taxonomies'] ) && is_array( $theme['taxonomies'] ) ) {
     394                foreach ( $theme['taxonomies'] as $tax => $tax_args ) {
     395                    // First check if the taxonomy is already registered - we bail if that is the case
     396                    if ( taxonomy_exists( $tax ) ) {
     397                        continue;
     398                    }
     399
     400                    // If we have deleted post types settings we need to skip registering their taxonomies
     401                    if ( ! empty( $tax_args['post_types'] ) && ! empty( $deleted_post_types ) ) {
     402                        if ( ! is_array( $tax_args['post_types'] ) ) {
     403                            if ( in_array( $tax_args['post_types'], $deleted_post_types ) ) {
     404                                continue;
     405                            }
     406                        } else {
     407                            $temp = array_diff( $tax_args['post_types'], $deleted_post_types );
     408                            if ( empty( $temp ) ) {
     409                                continue;
     410                            }
     411                        }
     412                    }
     413
     414                    $tax_post_types = $tax_args['post_types'];
     415                    // remove "post_types", isn't a register_taxonomy argument we are just using it for post type linking
     416                    unset( $tax_args['post_types'] );
     417
     418                    $is_jetpack_compatible = false;
     419                    if ( strpos( $tax, 'jetpack' ) !== false ) {
     420                        ///$xxxx = str_replace(  'jetpack-', '', $tax);
     421                        $is_jetpack_compatible = true;
     422                    }
     423
     424                    if ( $is_jetpack_compatible ) {
     425                        $tax_key = strstr( $tax, '-' );
     426                        $tax_key = substr( $tax_key, 1 );
     427                    } else {
     428                        // eliminate the theme prefix
     429                        $tax_key = strstr( $tax, '_' );
     430                        $tax_key = substr( $tax_key, 1 );
     431                    }
     432
     433                    if ( isset( $options[ 'enable_' . $tax_key ] ) ) {
     434                        $updated_options['display_settings'] = true;
     435                        if ( $options[ 'enable_' . $tax_key ] ) {
     436                            register_taxonomy( $tax, $tax_post_types, $tax_args );
     437                        }
     438                    }
     439                }
     440            }
     441        }
     442
     443        // Only update if we have actually changed something
     444        if ( $options != $updated_options ) {
     445            update_option( 'pixtypes_settings', $updated_options );
     446        }
    349447    }
    350448
     
    369467            $rewrite = $post_type->rewrite;
    370468            /** if this post_type has a rewrite rule check for it */
    371             if ( ! empty( $rewrite ) && isset( $rewrite["slug"] ) && $slug == $rewrite["slug"] ) {
     469            if ( ! empty( $rewrite ) && isset( $rewrite['slug'] ) && $slug == $rewrite['slug'] ) {
    372470                $is_unique = false;
    373471            } elseif ( $slug == $key ) {
     
    388486     */
    389487    static function is_tax_slug_unique( $slug ) {
    390 
    391488        global $wp_taxonomies;
     489
     490        /** Suppose it's true */
    392491        $is_unique = true;
    393         /** Suppose it's true */
    394492
    395493        foreach ( $wp_taxonomies as $key => $tax ) {
    396494            $rewrite = $tax->rewrite;
    397495            /** if this post_type has a rewrite rule check for it */
    398             if ( ! empty( $rewrite ) && isset( $rewrite["slug"] ) && $slug == $rewrite["slug"] ) {
     496            if ( ! empty( $rewrite ) && isset( $rewrite['slug'] ) && $slug == $rewrite['slug'] ) {
    399497                $is_unique = false;
    400498            } elseif ( $slug == $key ) {
     
    433531                ),
    434532                'has_archive'   => 'portfolio-archive',
    435                 'menu_icon'     => plugins_url( 'assets/report.png', __FILE__ ),
     533                'menu_icon'     => 'dashicons-portfolio',
    436534                'supports'      => array( 'title', 'editor', 'thumbnail', 'page-attributes', 'excerpt' ),
    437535                'yarpp_support' => true,
     
    459557                'has_archive'   => 'galleries-archive',
    460558                'menu_position' => null,
     559                'menu_icon'     => 'dashicons-format-gallery',
    461560                'supports'      => array( 'title', 'thumbnail', 'page-attributes', 'excerpt' ),
    462561                'yarpp_support' => true,
     
    546645
    547646    /**
    548      * Ajax callback for unseting unneeded post types
     647     * Ajax callback for cleaning up the settings for a theme
    549648     */
    550649    function ajax_unset_pixtypes() {
     
    555654        }
    556655
    557         if ( isset( $_POST['post_type'] ) ) {
    558             $key     = $_POST['post_type'];
     656        if ( isset( $_POST['theme_slug'] ) ) {
     657            $key     = $_POST['theme_slug'];
    559658            $options = get_option( 'pixtypes_settings' );
    560659            if ( isset( $options['themes'][ $key ] ) ) {
    561660                unset( $options['themes'][ $key ] );
    562661                update_option( 'pixtypes_settings', $options );
    563                 $result['msg']     = 'Post type ' . $key . ' is gone.';
     662                $result['msg']     = 'Settings for ' . ucfirst( $key ) . ' have been cleaned up!';
    564663                $result['success'] = true;
    565664            }
     
    574673     */
    575674    function theme_version_check() {
    576 
    577         $options = get_option( 'pixtypes_settings' );
    578 
    579         if ( class_exists( 'wpgrade' ) && isset( $options['wpgrade_theme_version'] ) ) {
    580 
    581             if ( wpgrade::themeversion() != $options['wpgrade_theme_version'] ) {
     675        if ( class_exists( 'wpgrade' ) ) {
     676            // Each theme should have it's pixtypes config theme version saved
     677            $options = get_option( 'pixtypes_settings' );
     678
     679            // Make sure that we fix things just in case
     680            if ( ! isset( $options['wpgrade_theme_version'] ) ) {
     681                $options['wpgrade_theme_version'] = '0.0.1';
     682            }
     683
     684            if ( version_compare( wpgrade::themeversion(), $options['wpgrade_theme_version'], '!=' ) ) {
    582685                // here the theme is updating it's options
    583                 $test = function_exists( 'wpgrade_callback_geting_active' );
    584 
    585                 wpgrade_callback_geting_active();
    586                 // the plugin will copy these options into it's own field
    587                 self::activate( false );
    588                 // end finally merge user's settings with the theme ones
    589                 save_pixtypes_settings( $options );
    590 
     686                if ( function_exists( 'wpgrade_callback_geting_active' ) ) {
     687                    wpgrade_callback_geting_active();
     688                    // the plugin will copy these options into it's own field
     689                    self::activate( false );
     690                    // end finally merge user's settings with the theme ones
     691                    save_pixtypes_settings( $options );
     692                }
    591693            }
    592694        }
  • pixtypes/trunk/core/classes/HTMLElement.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/trunk/core/classes/HTMLTag.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/trunk/core/classes/Meta.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/trunk/core/classes/Processor.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/trunk/core/classes/Validator.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/trunk/core/classes/forms/Form.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/trunk/core/classes/forms/FormField.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/trunk/core/defaults.php

    r1591155 r1744797  
    2828        'errors' => array
    2929            (
    30                 'is_numeric' => esc_html__('Numberic value required.', pixtypes::textdomain()),
    31                 'not_empty' => esc_html__('Field is required.', pixtypes::textdomain()),
     30                'is_numeric' => esc_html__('Numberic value required.', 'pixtypes' ),
     31                'not_empty' => esc_html__('Field is required.', 'pixtypes' ),
    3232            ),
    3333
  • pixtypes/trunk/core/interfaces/HTMLElement.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/trunk/core/interfaces/HTMLTag.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/trunk/core/interfaces/Meta.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/trunk/core/interfaces/Processor.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/trunk/core/interfaces/Validator.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/trunk/core/interfaces/extended/Form.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/trunk/core/interfaces/extended/FormField.php

    r1115891 r1744797  
    11<?php defined('ABSPATH') or die;
    2 
    3 /* This file is property of Pixel Grade Media. You may NOT copy, or redistribute
    4  * it. Please see the license that came with your copy for more information.
    5  */
    62
    73/**
  • pixtypes/trunk/features/metaboxes/init.php

    r1591646 r1744797  
    10121012            // validate meta value
    10131013            if ( isset( $field['validate_func'] ) ) {
    1014                 $ok = call_user_func( array( 'cmb_Meta_Box_Validate', $field['validate_func'] ), $new );
     1014                $ok = call_user_func( $field['validate_func'], $new, $field, $post_id );
    10151015                if ( $ok === false ) { // pass away when meta value is invalid
    10161016                    continue;
  • pixtypes/trunk/features/metaboxes/metaboxes.php

    r1728763 r1744797  
    5353
    5454        require_once 'cmb-field-select2/cmb-field-select2.php';
     55        require_once 'cmb-field-select2-v2/cmb-field-select2.php';
    5556    }
    5657
  • pixtypes/trunk/js/admin.js

    r1115891 r1744797  
    6161        /** ajax callbacks */
    6262        $('#unset_pixypes').on('click', 'button', function(e){
    63             var response = confirm('Be sure that you don\'t need this post type anymore');
     63            var response = confirm('Make sure that you have moved the theme specific content you were interested in. If at any time you wish to access it again, reactivate that previous theme.');
    6464
    6565            if ( response == false ) {
     
    6969
    7070                var ajax_nounce = $(this).parents('ul').siblings('.unset_nonce').val();
    71                 // reload likes number
     71                // Cleanup pixtypes settings
    7272                jQuery.ajax({
    73                     type: "post",url: locals.ajax_url,data: { action: 'unset_pixtypes', _ajax_nonce: ajax_nounce, post_type: $(this).val() },
     73                    type: "post",url: locals.ajax_url,data: { action: 'unset_pixtypes', _ajax_nonce: ajax_nounce, theme_slug: $(this).val() },
    7474                    //beforeSend: function() {jQuery("#loading").show("slow");}, //show loading just when link is clicked
    7575                    //complete: function() { jQuery("#loading").hide("fast");}, //stop showing loading when the process is complete
  • pixtypes/trunk/pixtypes.php

    r1728763 r1744797  
    11<?php
    22/*
    3 * @package   PixTypes
    4 * @author    Pixelgrade <[email protected]>
    5 * @license   GPL-2.0+
    6 * @link      https://pixelgrade.com
    7 * @copyright 2013-2017 Pixelgrade
    8 *
    9 * @wordpress-plugin
    10 Plugin Name: PixTypes
    11 Plugin URI:  https://pixelgrade.com
    12 Description: Custom post types and meta-boxes needed by your theme
    13 Version: 1.4.7
    14 Author: Pixelgrade
    15 Author URI: https://pixelgrade.com
    16 Author Email: [email protected]
    17 Text Domain: pixtypes
    18 License:     GPL-2.0+
    19 License URI: http://www.gnu.org/licenses/gpl-2.0.txt
    20 Domain Path: /lang
    21 */
     3 * Plugin Name: PixTypes
     4 * Plugin URI: https://wordpress.org/plugins/pixtypes/
     5 * Description: Custom post types and meta-boxes needed by your themes.
     6 * Version: 1.4.8
     7 * Author URI: https://pixelgrade.com
     8 * Author Email: [email protected]
     9 * License: GPL2+
     10 * Text Domain: pixtypes
     11 * Domain Path: /lang/
     12 */
    2213
    2314// If this file is called directly, abort.
     
    3425
    3526$config = include 'plugin-config' . EXT;
    36 include 'features/class-pix-query' . EXT;
    3727// set textdomain
    3828pixtypes::settextdomain( $config['textdomain'] );
     
    5646// --------------
    5747
    58 $basepath     = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
    59 $callbackpath = $basepath . 'callbacks' . DIRECTORY_SEPARATOR;
     48$basepath     = trailingslashit( dirname( __FILE__ ) );
     49$callbackpath = trailingslashit( $basepath . 'callbacks' );
    6050pixtypes::require_all( $callbackpath );
    6151
     
    6757
    6858global $pixtypes_plugin;
    69 $pixtypes_plugin = PixTypesPlugin::get_instance();
     59$pixtypes_plugin = PixTypesPlugin::get_instance( '1.4.8' );
  • pixtypes/trunk/settings/post_types.php

    r1591155 r1744797  
    77
    88$options = get_option( 'pixtypes_settings' );
    9 // go through each theme and activate portfolio post types
    10 if ( isset( $options["themes"] ) ) {
    11     $theme_types = $options["themes"];
     9// go through each theme and activate the post types settings
     10if ( isset( $options['themes'] ) ) {
     11    $theme_types = $options['themes'];
    1212    foreach ( $theme_types as $key => $theme ) {
    1313
     
    2323            }
    2424            $display_settings = true;
    25         } else {
    26             return array( 'type' => 'hidden' );
    2725        }
    2826    }
     27}
     28
     29// Check if we have any post type that should be shown settings
     30$hide = true;
     31foreach ( $display_option as $post_type => $display ) {
     32    if ( $display ) {
     33        $hide = false;
     34        break;
     35    }
     36}
     37
     38if ( $hide ) {
     39    return array( 'type' => 'hidden' );
    2940}
    3041
  • pixtypes/trunk/views/admin.php

    r1591155 r1744797  
    4343        <?php endif; ?>
    4444
    45         <?php echo $f = pixtypes::form( $config, $processor );
    46         echo $f->field( 'hiddens' )->render(); ?>
     45        <?php
     46        $f = pixtypes::form( $config, $processor ); ?>
     47
     48        <?php echo $f->startform() ?>
     49
     50        <?php echo $f->field( 'hiddens' )->render(); ?>
    4751
    4852        <?php echo $f->field( 'post_types' )->render(); ?>
     
    7074
    7175            <div class="handlediv" title="Click to toggle"><br></div>
    72             <h3 class="hndle"><span><?php esc_html_e( 'Danger Zone', 'pixtypes' ); ?></span></h3>
     76            <h3 class="hndle"><span><?php esc_html_e( 'Extra Careful Zone', 'pixtypes' ); ?></span></h3>
    7377
    7478            <div class="inside">
    7579
    76                 <p><?php esc_html_e( 'If you are done with copying your content from old post types to new ones, you can also get rid of the old post types.', 'pixtypes' ); ?></p>
     80                <p><?php esc_html_e( 'If you are done with copying your content from old themes to new ones, you can also get rid of the old themes settings and post types.', 'pixtypes' ); ?></p>
    7781                <form method="post" id="unset_pixypes"
    7882                      action="<?php echo admin_url( 'options-general.php?page=pixtypes' ) ?>">
     
    8387                        if ( isset( $options['themes'] ) && count( $options['themes'] ) > 1 ) {
    8488                            foreach ( $options['themes'] as $key => $theme ) {
    85                                 echo '<li><button class="button delete-action" type="submit" name="unset_pixtype" value="' . $key . '">' . esc_html__( 'Unset', 'pixtypes' ) . ' ' . $key . '</button></li>';
     89                                echo '<li><button class="button delete-action" type="submit" name="unset_pixtype" value="' . $key . '">' . esc_html__( 'Clean-up after', 'pixtypes' ) . ' ' . ucfirst( $key ) . '</button></li>';
    8690                            }
    8791                        } ?>
Note: See TracChangeset for help on using the changeset viewer.