-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from gravityview/develop
Version 1.2
- Loading branch information
Showing
5 changed files
with
251 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?php | ||
namespace GV; | ||
|
||
/** If this file is called directly, abort. */ | ||
if ( ! defined( 'GRAVITYVIEW_DIR' ) ) { | ||
die(); | ||
} | ||
|
||
/** | ||
* A-Z Entry Filter Widget Extension | ||
* | ||
* @extends \GV\Extension | ||
*/ | ||
class A_Z_Entry_Filter_Extension extends Extension { | ||
|
||
protected $_min_gravityview_version = '2.0-dev'; | ||
|
||
public function __construct() { | ||
|
||
$this->_title = 'A-Z Filters'; | ||
$this->_version = GRAVITYVIEW_AZ_FILTER_VERSION; | ||
$this->_text_domain = 'gravityview-az-filters'; | ||
$this->_path = __FILE__ ; | ||
$this->_item_id = 266; | ||
$this->plugin_file = __FILE__; | ||
$this->plugin_version = GRAVITYVIEW_AZ_FILTER_VERSION; | ||
|
||
parent::__construct(); | ||
} | ||
|
||
public function add_hooks() { | ||
|
||
// Load widget | ||
add_action( 'init', array( $this, 'register_az_entry_filter_widget' ) ); | ||
|
||
// Print Styles | ||
add_action( 'wp_enqueue_scripts', array( $this, 'print_styles' ) ); | ||
|
||
// Admin styles | ||
add_action( 'admin_enqueue_scripts', array( $this, 'print_scripts')); | ||
|
||
add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_noconflict') ); | ||
|
||
define( 'GRAVITYVIEW_AZ_FILTER_PATH', plugin_dir_path( __FILE__ ) ); | ||
|
||
define( 'GRAVITYVIEW_AZ_FILTER_URL', untrailingslashit( plugins_url( '/', __FILE__ ) ) ); | ||
} | ||
|
||
/** | ||
* Load the widget files | ||
* @return void | ||
*/ | ||
public function register_az_entry_filter_widget() { | ||
// Load widget extension | ||
include_once( GRAVITYVIEW_AZ_FILTER_PATH . 'widget/gravityview-a-z-entry-filter-widget.php' ); | ||
} | ||
|
||
/** | ||
* Enable the script in no-conflict mode | ||
* | ||
* @param array $scripts_or_styles array of scripts to be loaded | ||
* @return array Modified array | ||
*/ | ||
public function register_noconflict( $scripts_or_styles ) { | ||
$scripts_or_styles []= 'gravityview-az-filters'; | ||
return $scripts_or_styles; | ||
} | ||
|
||
/** | ||
* Output the script that dynamically loads the fields for the widget settings | ||
* @param string $hook $pagenow page name | ||
* @return void | ||
*/ | ||
public function print_scripts( $hook ) { | ||
if ( ! gravityview()->request->is_admin( $hook, 'single' ) ) { | ||
return; | ||
} | ||
|
||
$script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; | ||
|
||
wp_enqueue_script( 'gravityview-az-filters', GRAVITYVIEW_AZ_FILTER_URL . '/assets/js/az-search-widget-admin'.$script_debug.'.js', array( 'jquery' ) ); | ||
|
||
wp_localize_script( 'gravityview-az-filters', 'gvAZVar', array( | ||
'nonce' => wp_create_nonce( 'gravityview_ajaxviews') | ||
) ); | ||
} | ||
|
||
/** | ||
* Print CSS on front-end when widget is loaded | ||
* @return void | ||
*/ | ||
function print_styles() { | ||
|
||
// Need to filter the CSS to load only when required. | ||
wp_enqueue_style( 'gravityview_az_entry_filter', GRAVITYVIEW_AZ_FILTER_URL . '/assets/css/gravityview-az-filters.css' ); | ||
} | ||
|
||
} // A_Z_Entry_Filter_Extension | ||
|
||
new A_Z_Entry_Filter_Extension; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* Plugin Name: GravityView - A-Z Filters Extension | ||
* Plugin URI: https://gravityview.co/extensions/a-z-filter/ | ||
* Description: Filter your entries by letters of the alphabet. | ||
* Version: 1.1.1.1 | ||
* Version: 1.2 | ||
* Author: GravityView | ||
* Author URI: https://gravityview.co | ||
* Author Email: [email protected] | ||
|
@@ -15,130 +15,32 @@ | |
|
||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly | ||
|
||
/** @since 1.2 */ | ||
define( 'GRAVITYVIEW_AZ_FILTER_VERSION', '1.2' ); | ||
|
||
add_action( 'plugins_loaded', 'gv_extension_az_entry_filtering_load' ); | ||
|
||
/** | ||
* Wrapper function to make sure GravityView_Extension has loaded | ||
* A simple loader that works with old PHP versions. | ||
* | ||
* @return void | ||
*/ | ||
function gv_extension_az_entry_filtering_load() { | ||
|
||
if( !class_exists( 'GravityView_Extension' ) ) { | ||
|
||
if( class_exists('GravityView_Plugin') && is_callable(array('GravityView_Plugin', 'include_extension_framework')) ) { | ||
GravityView_Plugin::include_extension_framework(); | ||
} else { | ||
// We prefer to use the one bundled with GravityView, but if it doesn't exist, go here. | ||
include_once plugin_dir_path( __FILE__ ) . 'lib/class-gravityview-extension.php'; | ||
} | ||
if ( ! class_exists( '\GV\Extension' ) ) { | ||
add_action( 'admin_notices', 'gv_extension_az_entry_filtering_noload' ); | ||
return; | ||
} | ||
|
||
/** | ||
* A-Z Entry Filter Widget Extension | ||
* | ||
* @extends GravityView_Extension | ||
*/ | ||
class GravityView_A_Z_Entry_Filter_Extension extends GravityView_Extension { | ||
|
||
protected $_title = 'A-Z Filters'; | ||
|
||
protected $_version = '1.1.1.1'; | ||
|
||
protected $_item_id = 266; | ||
|
||
protected $_text_domain = 'gravityview-az-filters'; | ||
|
||
protected $_min_gravityview_version = '1.1.7'; | ||
|
||
protected $_max_gravityview_version = '1.9999'; | ||
|
||
protected $_path = __FILE__; | ||
|
||
public function add_hooks() { | ||
|
||
// Load widget | ||
add_action( 'init', array( $this, 'register_az_entry_filter_widget' ) ); | ||
|
||
// Print Styles | ||
add_action( 'wp_enqueue_scripts', array( $this, 'print_styles' ) ); | ||
|
||
// Admin styles | ||
add_action( 'admin_enqueue_scripts', array( $this, 'print_scripts')); | ||
|
||
add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_noconflict') ); | ||
|
||
define( 'GRAVITYVIEW_AZ_FILTER_PATH', plugin_dir_path( __FILE__ ) ); | ||
|
||
define( 'GRAVITYVIEW_AZ_FILTER_URL', untrailingslashit( plugins_url( '/', __FILE__ ) ) ); | ||
} | ||
|
||
/** | ||
* Load the widget files | ||
* @return void | ||
*/ | ||
public function register_az_entry_filter_widget() { | ||
|
||
// 1.7.5.1+ | ||
if( is_callable( array( 'GravityView_Plugin', 'include_widget_class' ) ) ) { | ||
GravityView_Plugin::include_widget_class(); | ||
} | ||
// 1.7.5 | ||
else if( file_exists( GRAVITYVIEW_DIR . 'includes/widgets/register-gravityview-widgets.php' ) ) { | ||
include_once( GRAVITYVIEW_DIR . 'includes/widgets/register-gravityview-widgets.php' ); | ||
} | ||
// Before 1.7.5 | ||
else { | ||
include_once( GRAVITYVIEW_DIR . 'includes/default-widgets.php' ); | ||
} | ||
|
||
// Load widget extension | ||
include_once( GRAVITYVIEW_AZ_FILTER_PATH . 'widget/gravityview-a-z-entry-filter-widget.php' ); | ||
} | ||
|
||
/** | ||
* Enable the script in no-conflict mode | ||
* | ||
* @param array $scripts_or_styles array of scripts to be loaded | ||
* @return array Modified array | ||
*/ | ||
function register_noconflict( $scripts_or_styles ) { | ||
|
||
$scripts_or_styles[] = 'gravityview-az-filters'; | ||
|
||
return $scripts_or_styles; | ||
} | ||
|
||
/** | ||
* Output the script that dynamically loads the fields for the widget settings | ||
* @param string $hook $pagenow page name | ||
* @return void | ||
*/ | ||
function print_scripts( $hook ) { | ||
|
||
if( !gravityview_is_admin_page($hook, 'single') ) { return; } | ||
|
||
$script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; | ||
|
||
wp_enqueue_script( 'gravityview-az-filters', GRAVITYVIEW_AZ_FILTER_URL . '/assets/js/az-search-widget-admin'.$script_debug.'.js', array('jquery') ); | ||
|
||
wp_localize_script( 'gravityview-az-filters', 'gvAZVar', array( | ||
'nonce' => wp_create_nonce( 'gravityview_ajaxviews') | ||
) ); | ||
|
||
} | ||
|
||
/** | ||
* Print CSS on front-end when widget is loaded | ||
* @return void | ||
*/ | ||
function print_styles() { | ||
|
||
// Need to filter the CSS to load only when required. | ||
wp_enqueue_style( 'gravityview_az_entry_filter', GRAVITYVIEW_AZ_FILTER_URL . '/assets/css/gravityview-az-filters.css' ); | ||
} | ||
|
||
} // GravityView_A_Z_Entry_Filter_Extension | ||
|
||
new GravityView_A_Z_Entry_Filter_Extension; | ||
if ( ! class_exists( '\GV\A_Z_Entry_Filter_Extension' ) ) { | ||
require plugin_dir_path( __FILE__ ) . 'gravityview-az-filters-extension.php'; | ||
} | ||
} | ||
|
||
/** | ||
* Outputs a loader warning notice. | ||
* | ||
* @return void | ||
*/ | ||
function gv_extension_az_entry_filtering_noload() { | ||
echo esc_html( 'GravityView A-Z Filters Extension was not loaded. GravityView 2.0 core files not found!' ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.