PluginProbe
WP Ultimate Post Grid / 3.8.0
WP Ultimate Post Grid v3.8.0
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
← All changes | wp-ultimate-post-grid.php +64 -226 2.6.03.8.0 View file →
@@ -1,234 +1,72 @@
1 1 <?php
2 -/*
3 -Plugin Name: WP Ultimate Post Grid
4 -Plugin URI: http://bootstrapped.ventures/wp-ultimate-post-grid/
5 -Description: Easily create filterable responsive grids for your posts, pages or custom post types
6 -Version: 2.6.0
7 -Author: Bootstrapped Ventures
8 -Author URI: http://bootstrapped.ventures
9 -License: GPLv3
10 -Text Domain: wp-ultimate-post-grid
11 -Domain Path: /lang
12 -*/
13 -define( 'WPUPG_VERSION', '2.6.0' );
14 -define( 'WPUPG_POST_TYPE', 'wpupg_grid' );
2 +/**
3 + * The plugin bootstrap file
4 + *
5 + * This file is read by WordPress to generate the plugin information in the plugin
6 + * admin area. This file also includes all of the dependencies used by the plugin,
7 + * registers the activation and deactivation functions, and defines a function
8 + * that starts the plugin.
9 + *
10 + * @link https://bootstrapped.ventures/
11 + * @since 3.0.0
12 + * @package WP_Ultimate_Post_Grid
13 + *
14 + * @wordpress-plugin
15 + * Plugin Name: WP Ultimate Post Grid
16 + * Plugin URI: https://bootstrapped.ventures/wp-ultimate-post-grid/
17 + * Description: Easily create filterable responsive grids for your posts, pages or custom post types.
18 + * Version: 3.8.0
19 + * Author: Bootstrapped Ventures
20 + * Author URI: https://bootstrapped.ventures/
21 + * License: GPL-2.0+
22 + * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
23 + * Text Domain: wp-ultimate-post-grid
24 + * Domain Path: /languages
25 + */
15 26
16 -class WPUltimatePostGrid {
27 +// If this file is called directly, abort.
28 +if ( ! defined( 'WPINC' ) ) {
29 + die;
30 +}
17 31
18 - private static $instance;
19 - private static $instantiated_by_premium;
20 - private static $addons = array();
32 +/**
33 + * The code that runs during plugin activation.
34 + * This action is documented in includes/class-wpupg-activator.php
35 + */
36 +function activate_wp_ultimate_post_grid() {
37 + require_once plugin_dir_path( __FILE__ ) . 'includes/class-wpupg-activator.php';
38 + WPUPG_Activator::activate();
39 +}
21 40
22 - /**
23 - * Return instance of self
24 - */
25 - public static function get( $instantiated_by_premium = false )
26 - {
27 - // Instantiate self only once
28 - if( is_null( self::$instance ) ) {
29 - self::$instantiated_by_premium = $instantiated_by_premium;
30 - self::$instance = new self;
31 - self::$instance->init();
32 - }
41 +/**
42 + * The code that runs during plugin deactivation.
43 + * This action is documented in includes/class-wpupg-deactivator.php
44 + */
45 +function deactivate_wp_ultimate_post_grid() {
46 + require_once plugin_dir_path( __FILE__ ) . 'includes/class-wpupg-deactivator.php';
47 + WPUPG_Deactivator::deactivate();
48 +}
33 49
34 - return self::$instance;
35 - }
50 +register_activation_hook( __FILE__, 'activate_wp_ultimate_post_grid' );
51 +register_deactivation_hook( __FILE__, 'deactivate_wp_ultimate_post_grid' );
36 52
37 - /**
38 - * Returns true if we are using the Premium version
39 - */
40 - public static function is_premium_active()
41 - {
42 - return self::$instantiated_by_premium;
43 - }
53 +/**
54 + * The core plugin class that is used to define internationalization,
55 + * admin-specific hooks, and public-facing site hooks.
56 + */
57 +require plugin_dir_path( __FILE__ ) . 'includes/class-wp-ultimate-post-grid.php';
44 58
45 - /**
46 - * Add loaded addon to array of loaded addons
47 - */
48 - public static function loaded_addon( $addon, $instance )
49 - {
50 - if( !array_key_exists( $addon, self::$addons ) ) {
51 - self::$addons[$addon] = $instance;
52 - }
53 - }
54 -
55 - /**
56 - * Returns true if the specified addon has been loaded
57 - */
58 - public static function is_addon_active( $addon )
59 - {
60 - return array_key_exists( $addon, self::$addons );
61 - }
62 -
63 - public static function addon( $addon )
64 - {
65 - if( isset( self::$addons[$addon] ) ) {
66 - return self::$addons[$addon];
67 - }
68 -
69 - return false;
70 - }
71 -
72 - /**
73 - * Access a VafPress option with optional default value
74 - */
75 - public static function option( $name, $default = null )
76 - {
77 - $option = vp_option( 'wpupg_option.' . $name );
78 -
79 - return is_null( $option ) ? $default : $option;
80 - }
81 -
82 -
83 - public $pluginName = 'wp-ultimate-post-grid';
84 - public $coreDir;
85 - public $corePath;
86 - public $coreUrl;
87 - public $pluginFile;
88 -
89 - protected $helper_dirs = array();
90 - protected $helpers = array();
91 -
92 - /**
93 - * Initialize
94 - */
95 - public function init()
96 - {
97 - // Load external libraries
98 - if( !class_exists( 'VP_AutoLoader' ) ) {
99 - require_once( 'vendor/vafpress/bootstrap.php' );
100 - }
101 -
102 - // Update plugin version
103 - update_option( $this->pluginName . '_version', WPUPG_VERSION );
104 -
105 - // Set core directory, URL and main plugin file
106 - $this->corePath = str_replace( '/wp-ultimate-post-grid.php', '', plugin_basename( __FILE__ ) );
107 - $this->coreDir = apply_filters( 'wpupg_core_dir', WP_PLUGIN_DIR . '/' . $this->corePath );
108 - $this->coreUrl = apply_filters( 'wpupg_core_url', plugins_url() . '/' . $this->corePath );
109 - $this->pluginFile = apply_filters( 'wpupg_plugin_file', __FILE__ );
110 -
111 - // Load textdomain
112 - if( !self::is_premium_active() ) {
113 - $domain = 'wp-ultimate-post-grid';
114 - $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
115 -
116 - load_textdomain( $domain, WP_LANG_DIR.'/'.$domain.'/'.$domain.'-'.$locale.'.mo' );
117 - load_plugin_textdomain( $domain, false, $this->corePath . '/lang/' );
118 - }
119 -
120 - // Add core helper directory
121 - $this->add_helper_directory( $this->coreDir . '/helpers' );
122 -
123 - // Migrate first if needed
124 - $this->helper( 'migration' );
125 -
126 - // Load required helpers
127 - $this->helper( 'activate' );
128 - $this->helper( 'ajax' );
129 - $this->helper( 'content' );
130 - $this->helper( 'css' );
131 - $this->helper( 'faq' );
132 - $this->helper( 'giveaway' );
133 - $this->helper( 'grid_cache' );
134 - $this->helper( 'grid_save' );
135 - $this->helper( 'meta_box' );
136 - $this->helper( 'meta_box_post' );
137 - $this->helper( 'notices' );
138 - $this->helper( 'pagination' );
139 - $this->helper( 'plugin_action_link' );
140 - $this->helper( 'post_save' );
141 - $this->helper( 'post_type' );
142 - $this->helper( 'support_tab' );
143 - $this->helper( 'vafpress_menu' );
144 - $this->helper( 'vafpress_shortcode' );
145 - $this->helper( 'shortcodes/filter_shortcode' );
146 - $this->helper( 'shortcodes/grid_shortcode' );
147 -
148 - // Include required helpers but don't instantiate
149 - $this->include_helper( 'addons/addon' );
150 - $this->include_helper( 'addons/premium_addon' );
151 - $this->include_helper( 'models/grid' );
152 -
153 - // Load core addons
154 - $this->helper( 'addon_loader' )->load_addons( $this->coreDir . '/addons' );
155 -
156 - // Load default assets
157 - $this->helper( 'assets' );
158 - }
159 -
160 - /**
161 - * Access a helper. Will instantiate if helper hasn't been loaded before.
162 - */
163 - public function helper( $helper )
164 - {
165 - // Lazy instantiate helper
166 - if( !isset( $this->helpers[$helper] ) ) {
167 - $this->include_helper( $helper );
168 -
169 - // Get class name from filename
170 - $class_name = 'WPUPG';
171 -
172 - $dirs = explode( '/', $helper );
173 - $file = end( $dirs );
174 - $name_parts = explode( '_', $file );
175 - foreach( $name_parts as $name_part ) {
176 - $class_name .= '_' . ucfirst( $name_part );
177 - }
178 -
179 - // Instantiate class if exists
180 - if( class_exists( $class_name ) ) {
181 - $this->helpers[$helper] = new $class_name();
182 - }
183 - }
184 -
185 - // Return helper instance
186 - return $this->helpers[$helper];
187 - }
188 -
189 - /**
190 - * Include a helper. Looks through all helper directories that have been added.
191 - */
192 - public function include_helper( $helper )
193 - {
194 - foreach( $this->helper_dirs as $dir )
195 - {
196 - $file = $dir . '/'.$helper.'.php';
197 -
198 - if( file_exists( $file ) ) {
199 - require_once( $file );
200 - }
201 - }
202 - }
203 -
204 - /**
205 - * Add a directory to look for helpers.
206 - */
207 - public function add_helper_directory( $dir )
208 - {
209 - if( is_dir( $dir ) ) {
210 - $this->helper_dirs[] = $dir;
211 - }
212 - }
213 -
214 - /*
215 - * Quick access functions
216 - */
217 -
218 - public function template( $template )
219 - {
220 - return $this->addon( 'custom-templates' )->get_template( $template );
221 - }
59 +/**
60 + * Begins execution of the plugin.
61 + *
62 + * Since everything within the plugin is registered via hooks,
63 + * then kicking off the plugin from this point in the file does
64 + * not affect the page life cycle.
65 + *
66 + * @since 3.0.0
67 + */
68 +function run_wp_ultimate_post_grid() {
69 + $plugin = new WP_Ultimate_Post_Grid();
70 + add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ) , array( $plugin, 'plugin_action_links' ), 1 );
222 71 }
223 -
224 -// Backward compatibility for older versions of WordPress
225 -if( !function_exists( 'get_term_meta' ) ) {
226 - function get_term_meta ( $term_id = 0, $key = '', $single = false ) {
227 - return '';
228 - }
229 -}
230 -
231 -// Premium version is responsible for instantiating if available
232 -if( !class_exists( 'WPUltimatePostGridPremium' ) ) {
233 - WPUltimatePostGrid::get();
234 -}
72 +run_wp_ultimate_post_grid();