5 if ( ! defined(
'GRAVITYVIEW_DIR' ) ) {
22 protected $_title = NULL;
27 protected $_version = NULL;
33 protected $_item_id = NULL;
38 protected $_text_domain =
'gravityview';
43 protected $_min_gravityview_version =
'2.0-dev';
48 protected $_max_gravityview_version = null;
53 protected $_min_php_version =
'5.6.4';
58 protected $_author =
'Katz Web Services, Inc.';
63 protected $_path =
'';
68 static protected $admin_notices = array();
74 static public $is_compatible = array();
80 if (
false === $this->is_extension_supported() ) {
84 if ( ! $this->_path ) {
85 $this->_path = __FILE__;
88 add_action(
'init', array( $this,
'load_plugin_textdomain' ) );
90 add_action(
'admin_notices', array( $this,
'admin_notice' ), 100 );
93 add_action(
'save_post', array( $this,
'save_post' ), 14 );
95 add_action(
'gravityview/metaboxes/before_render', array( $this,
'add_metabox_tab' ) );
97 add_filter(
'gravityview/metaboxes/tooltips', array( $this,
'tooltips' ) );
112 if ( empty( $this->_text_domain ) ) {
113 gravityview()->log->debug(
'Extension translation cannot be loaded; the `_text_domain` variable is not defined', array(
'data' => $this ) );
118 $path = isset( $this->_path ) ? $this->_path : ( isset( $this->plugin_file ) ? $this->plugin_file :
'' );
121 $lang_dir = dirname( plugin_basename( $path ) ) .
'/languages/';
123 $locale = get_locale();
125 if ( function_exists(
'get_user_locale') && is_admin() ) {
126 $locale = get_user_locale();
130 $locale = apply_filters(
'plugin_locale', $locale, $this->_text_domain );
132 $mofile = sprintf(
'%1$s-%2$s.mo', $this->_text_domain, $locale );
135 $mofile_local = $lang_dir . $mofile;
136 $mofile_global = WP_LANG_DIR .
'/' . $this->_text_domain .
'/' . $mofile;
138 if ( file_exists( $mofile_global ) ) {
140 load_textdomain( $this->_text_domain, $mofile_global );
141 } elseif ( file_exists( $mofile_local ) ) {
143 load_textdomain( $this->_text_domain, $mofile_local );
146 load_plugin_textdomain( $this->_text_domain,
false, $lang_dir );
207 $tab_settings = $this->tab_settings();
210 if ( empty( $tab_settings ) ) {
214 $tab_defaults = array(
220 'callback_args' =>
'',
222 'priority' =>
'default',
225 $tab = wp_parse_args( $tab_settings, $tab_defaults );
228 $tab[
'screen'] =
'gravityview';
230 if ( class_exists(
'GravityView_Metabox_Tab' ) ) {
231 $metabox = new \GravityView_Metabox_Tab( $tab[
'id'], $tab[
'title'], $tab[
'file'], $tab[
'icon-class'], $tab[
'callback'], $tab[
'callback_args'] );
234 add_meta_box(
'gravityview_' . $tab[
'id'], $tab[
'title'], $tab[
'callback'], $tab[
'screen'], $tab[
'context'], $tab[
'priority'] );
244 return Utils::get( self::$is_compatible, get_called_class(), null );
259 self::$is_compatible = is_array( self::$is_compatible ) ? self::$is_compatible : array( get_called_class() => (
bool) self::$is_compatible );
261 if ( ! function_exists(
'gravityview' ) ) {
262 $message = sprintf( __(
'Could not activate the %s Extension; GravityView is not active.',
'gk-gravityview' ), esc_html( $this->_title ) );
263 }
else if (
false === version_compare( Plugin::$version, $this->_min_gravityview_version ,
">=" ) ) {
264 $message = sprintf( __(
'The %s Extension requires GravityView Version %s or newer.',
'gk-gravityview' ), esc_html( $this->_title ),
'<tt>'.$this->_min_gravityview_version.
'</tt>' );
265 }
else if ( isset( $this->_min_php_version ) &&
false === version_compare( phpversion(), $this->_min_php_version ,
">=" ) ) {
266 $message = sprintf( __(
'The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.',
'gk-gravityview' ), esc_html( $this->_title ),
'<tt>'.$this->_min_php_version.
'</tt>' );
267 }
else if ( ! empty( $this->_max_gravityview_version ) &&
false === version_compare( $this->_max_gravityview_version, Plugin::$version,
">" ) ) {
268 $message = sprintf( __(
'The %s Extension is not compatible with this version of GravityView. Please update the Extension to the latest version.',
'gk-gravityview' ), esc_html( $this->_title ) );
271 self::$is_compatible[ get_called_class() ] =
gravityview()->plugin->is_compatible();
274 if ( ! empty( $message ) ) {
275 self::add_notice( $message );
276 self::$is_compatible[ get_called_class() ] =
false;
277 gravityview()->log->error(
'{message}', array(
'message' => $message ) );
280 return self::is_compatible();
292 if ( is_array( $notice ) && empty( $notice[
'message'] ) ) {
293 gravityview()->log->error(
'Notice not set', array(
'data' => $notice ) );
295 }
else if ( is_string( $notice ) ) {
296 $notice = array(
'message' => $notice );
299 $notice[
'class'] = empty( $notice[
'class'] ) ?
'error' : $notice[
'class'];
301 self::$admin_notices []= $notice;
310 if ( empty( self::$admin_notices ) ) {
314 foreach ( self::$admin_notices as $key => $notice ) {
315 echo
'<div id="message" class="'. esc_attr( $notice[
'class'] ).
'">';
316 echo wpautop( $notice[
'message'] );
317 echo
'<div class="clear"></div>';
322 self::$admin_notices = array();
If this file is called directly, abort.
save_post( $post_id)
Save extra view configuration.
static add_notice( $notice=array())
Add a notice to be displayed in the admin.
static is_compatible()
Is this extension even compatible?
is_extension_supported()
Check whether the extension is supported:
load_plugin_textdomain()
Load translations for the extension.
tab_settings()
Add a tab to GravityView Edit View tabbed metabox.
add_hooks()
Extensions should override this hook to add their hooks.
gravityview()
The main GravityView wrapper function.
__construct()
Generic initialization.
add_metabox_tab()
If Extension overrides tab_settings() and passes its own tab, add it to the tabbed settings metabox...
admin_notice()
Outputs the admin notices generated by the all plugins.
tooltips( $tooltips=array())
Add tooltips for the extension.