|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* FooGallery Pro Paging Class |
|
4
|
|
|
*/ |
|
5
|
|
|
if ( ! class_exists( 'FooGallery_Pro_Paging' ) ) { |
|
6
|
|
|
|
|
7
|
|
|
class FooGallery_Pro_Paging { |
|
8
|
|
|
|
|
9
|
|
|
function __construct() { |
|
|
|
|
|
|
10
|
|
|
add_filter( 'foogallery_gallery_template_paging_type_choices', array( $this, 'add_pro_paging_choices' ) ); |
|
11
|
|
|
|
|
12
|
|
|
if ( is_admin() ) { |
|
13
|
|
|
//add a global setting to change the All filter |
|
14
|
|
|
add_filter( 'foogallery_admin_settings_override', array( $this, 'add_language_settings' ) ); |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
//add the paging attributes to the gallery container |
|
18
|
|
|
add_filter( 'foogallery_build_container_data_options', array( $this, 'add_paging_data_options' ), 10, 3 ); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Adds the presets that are available in the PRO version |
|
23
|
|
|
* |
|
24
|
|
|
* @param $choices |
|
25
|
|
|
* |
|
26
|
|
|
* @return mixed |
|
27
|
|
|
*/ |
|
28
|
|
|
function add_pro_paging_choices( $choices ) { |
|
|
|
|
|
|
29
|
|
|
$choices['pagination'] = __( 'Pagination', 'foogallery' ); |
|
30
|
|
|
$choices['infinite'] = __( 'Infinite Scroll', 'foogallery' ); |
|
31
|
|
|
$choices['loadMore'] = __( 'Load More', 'foogallery' ); |
|
32
|
|
|
return $choices; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Add global setting to override the "All" text used in the filtering |
|
37
|
|
|
* @param $settings |
|
38
|
|
|
* |
|
39
|
|
|
* @return mixed |
|
40
|
|
|
*/ |
|
41
|
|
|
public function add_language_settings( $settings ) { |
|
42
|
|
|
|
|
43
|
|
|
$settings['settings'][] = array( |
|
44
|
|
|
'id' => 'language_paging_loadmore_text', |
|
45
|
|
|
'title' => __( 'Paging Load More Text', 'foogallery' ), |
|
46
|
|
|
'type' => 'text', |
|
47
|
|
|
'default' => __( 'Load More', 'foogallery' ), |
|
48
|
|
|
'tab' => 'language' |
|
49
|
|
|
); |
|
50
|
|
|
|
|
51
|
|
|
return $settings; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Add the required paging data options if needed |
|
56
|
|
|
* |
|
57
|
|
|
* @param $attributes array |
|
58
|
|
|
* @param $gallery FooGallery |
|
59
|
|
|
* |
|
60
|
|
|
* @return array |
|
61
|
|
|
*/ |
|
62
|
|
|
function add_paging_data_options( $options, $gallery, $attributes ) { |
|
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
$paging_loadmore_text_default = __( 'Load More', 'foogallery' ); |
|
65
|
|
|
$paging_loadmore_text = foogallery_get_setting( 'language_paging_loadmore_text', $paging_loadmore_text_default ); |
|
66
|
|
|
if ( empty( $paging_loadmore_text ) ) { |
|
67
|
|
|
$paging_loadmore_text = $paging_loadmore_text_default; |
|
68
|
|
|
} |
|
69
|
|
|
if ( $paging_loadmore_text_default !== $paging_loadmore_text ) { |
|
70
|
|
|
if ( !array_key_exists( 'il8n', $options ) ) { |
|
71
|
|
|
$options['il8n'] = array(); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
$options['il8n']['paging'] = array( |
|
75
|
|
|
'button' => $paging_loadmore_text |
|
76
|
|
|
); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
return $options; |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
} |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.