1
|
|
|
<?php |
2
|
|
|
if ( ! class_exists( 'FooGallery_Albums_Extension' ) ) { |
3
|
|
|
|
4
|
|
|
define( 'FOOGALLERY_ALBUM_PATH', plugin_dir_path( __FILE__ ) ); |
5
|
|
|
define( 'FOOGALLERY_ALBUM_URL', plugin_dir_url( __FILE__ ) ); |
6
|
|
|
define( 'FOOGALLERY_CPT_ALBUM', 'foogallery-album' ); |
7
|
|
|
define( 'FOOGALLERY_ALBUM_META_GALLERIES', 'foogallery_album_galleries' ); |
8
|
|
|
define( 'FOOGALLERY_ALBUM_META_TEMPLATE', 'foogallery_album_template' ); |
9
|
|
|
define( 'FOOGALLERY_ALBUM_META_SORT', 'foogallery_album_sort' ); |
10
|
|
|
|
11
|
|
|
class FooGallery_Albums_Extension { |
12
|
|
|
|
13
|
|
|
function __construct() { |
14
|
|
|
$this->includes(); |
15
|
|
|
|
16
|
|
|
new FooGallery_Album_Rewrite_Rules(); |
17
|
|
|
new FooGallery_Albums_PostTypes(); |
18
|
|
|
new FooGallery_Album_Shortcodes(); |
19
|
|
|
|
20
|
|
|
if ( is_admin() ) { |
21
|
|
|
new FooGallery_Albums_Admin_Columns(); |
22
|
|
|
new FooGallery_Admin_Album_MetaBoxes(); |
23
|
|
|
|
24
|
|
|
//add language settings |
25
|
|
|
add_filter( 'foogallery_admin_settings_override', array( $this, 'include_album_language_settings' ) ); |
26
|
|
|
|
27
|
|
|
//add some global settings for albums |
28
|
|
|
add_filter( 'foogallery_admin_settings_override', array($this, 'add_album_settings' ) ); |
29
|
|
|
|
30
|
|
|
add_action( 'foogallery_uninstall', array($this, 'uninstall' ) ); |
31
|
|
|
} |
32
|
|
|
add_filter( 'foogallery_album_templates_files', array( $this, 'register_myself' ) ); |
33
|
|
|
add_filter( 'foogallery_defaults', array( $this, 'apply_album_defaults' ) ); |
34
|
|
|
add_action( 'foogallery_extension_activated-albums', array( $this, 'flush_rewrite_rules' ) ); |
35
|
|
|
add_filter( 'foogallery_alter_album_template_field', array( $this, 'alter_gallery_template_field' ), 10, 2 ); |
36
|
|
|
add_filter( 'foogallery_albums_supports_video-stack', '__return_true' ); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
function includes() { |
|
|
|
|
40
|
|
|
require_once( FOOGALLERY_ALBUM_PATH . 'functions.php' ); |
41
|
|
|
require_once( FOOGALLERY_ALBUM_PATH . 'class-posttypes.php' ); |
42
|
|
|
require_once( FOOGALLERY_ALBUM_PATH . 'class-foogallery-album.php' ); |
43
|
|
|
require_once( FOOGALLERY_ALBUM_PATH . 'public/class-rewrite-rules.php' ); |
44
|
|
|
require_once( FOOGALLERY_ALBUM_PATH . 'public/class-shortcodes.php' ); |
45
|
|
|
require_once( FOOGALLERY_ALBUM_PATH . 'public/class-foogallery-album-template-loader.php' ); |
46
|
|
|
|
47
|
|
|
if ( is_admin() ) { |
48
|
|
|
//only admin |
49
|
|
|
require_once( FOOGALLERY_ALBUM_PATH . 'admin/class-metaboxes.php' ); |
50
|
|
|
require_once( FOOGALLERY_ALBUM_PATH . 'admin/class-columns.php' ); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
function apply_album_defaults( $defaults ) { |
55
|
|
|
$defaults['album_template'] = 'default'; |
56
|
|
|
|
57
|
|
|
return $defaults; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
function register_myself( $extensions ) { |
61
|
|
|
$extensions[] = __FILE__; |
62
|
|
|
return $extensions; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
function flush_rewrite_rules() { |
66
|
|
|
$rewrite = new FooGallery_Album_Rewrite_Rules(); |
67
|
|
|
$rewrite->add_gallery_endpoint(); |
68
|
|
|
|
69
|
|
|
flush_rewrite_rules(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
function include_album_language_settings( $settings ) { |
73
|
|
|
$settings['settings'][] = array( |
74
|
|
|
'id' => 'language_back_to_album_text', |
75
|
|
|
'title' => __( 'Back To Album Text', 'foogallery' ), |
76
|
|
|
'type' => 'text', |
77
|
|
|
'default' => __( '« back to album', 'foogallery' ), |
78
|
|
|
'tab' => 'language' |
79
|
|
|
); |
80
|
|
|
|
81
|
|
|
return $settings; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
function add_album_settings( $settings ) { |
|
|
|
|
85
|
|
|
|
86
|
|
|
$settings['tabs']['albums'] = __( 'Albums', 'foogallery' ); |
87
|
|
|
|
88
|
|
|
$settings['settings'][] = array( |
89
|
|
|
'id' => 'album_gallery_slug', |
90
|
|
|
'title' => __( 'Gallery Slug', 'foogallery' ), |
91
|
|
|
'type' => 'text', |
92
|
|
|
'default' => 'gallery', |
93
|
|
|
'desc' => __( 'The slug that is used when generating gallery URL\'s for albums. PLEASE NOTE : if you change this value, you might need to save your Permalinks again.', 'foogallery' ), |
94
|
|
|
'tab' => 'albums' |
95
|
|
|
); |
96
|
|
|
|
97
|
|
|
return $settings; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
function uninstall() { |
|
|
|
|
101
|
|
|
foogallery_album_uninstall(); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|
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.