|
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
|
|
|
|
|
19
|
|
|
if ( is_admin() ) { |
|
20
|
|
|
new FooGallery_Albums_Admin_Columns(); |
|
21
|
|
|
new FooGallery_Admin_Album_MetaBoxes(); |
|
22
|
|
|
|
|
23
|
|
|
//add language settings |
|
24
|
|
|
add_filter( 'foogallery_admin_settings_override', array( $this, 'include_album_language_settings' ) ); |
|
25
|
|
|
|
|
26
|
|
|
//add some global settings for albums |
|
27
|
|
|
add_filter( 'foogallery_admin_settings_override', array($this, 'add_album_settings' ) ); |
|
28
|
|
|
|
|
29
|
|
|
add_action( 'foogallery_uninstall', array($this, 'uninstall' ) ); |
|
30
|
|
|
|
|
31
|
|
|
} else { |
|
32
|
|
|
|
|
33
|
|
|
new FooGallery_Album_Template_Loader(); |
|
34
|
|
|
new FooGallery_Album_Shortcodes(); |
|
35
|
|
|
} |
|
36
|
|
|
add_filter( 'foogallery_album_templates_files', array( $this, 'register_myself' ) ); |
|
37
|
|
|
add_filter( 'foogallery_defaults', array( $this, 'apply_album_defaults' ) ); |
|
38
|
|
|
add_action( 'foogallery_extension_activated-albums', array( $this, 'flush_rewrite_rules' ) ); |
|
39
|
|
|
add_filter( 'foogallery_alter_album_template_field', array( $this, 'alter_gallery_template_field' ), 10, 2 ); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
function includes() { |
|
43
|
|
|
require_once( FOOGALLERY_ALBUM_PATH . 'functions.php' ); |
|
44
|
|
|
require_once( FOOGALLERY_ALBUM_PATH . 'class-posttypes.php' ); |
|
45
|
|
|
require_once( FOOGALLERY_ALBUM_PATH . 'class-foogallery-album.php' ); |
|
46
|
|
|
require_once( FOOGALLERY_ALBUM_PATH . 'public/class-rewrite-rules.php' ); |
|
47
|
|
|
|
|
48
|
|
|
if ( is_admin() ) { |
|
49
|
|
|
//only admin |
|
50
|
|
|
require_once( FOOGALLERY_ALBUM_PATH . 'admin/class-metaboxes.php' ); |
|
51
|
|
|
require_once( FOOGALLERY_ALBUM_PATH . 'admin/class-columns.php' ); |
|
52
|
|
|
} else { |
|
53
|
|
|
//only front-end |
|
54
|
|
|
require_once( FOOGALLERY_ALBUM_PATH . 'public/class-shortcodes.php' ); |
|
55
|
|
|
|
|
56
|
|
|
//load Template \ Loader files |
|
57
|
|
|
require_once( FOOGALLERY_ALBUM_PATH . 'public/class-foogallery-album-template-loader.php' ); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
function apply_album_defaults( $defaults ) { |
|
62
|
|
|
$defaults['album_template'] = 'default'; |
|
63
|
|
|
|
|
64
|
|
|
return $defaults; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
function register_myself( $extensions ) { |
|
68
|
|
|
$extensions[] = __FILE__; |
|
69
|
|
|
return $extensions; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
function flush_rewrite_rules() { |
|
73
|
|
|
$rewrite = new FooGallery_Album_Rewrite_Rules(); |
|
74
|
|
|
$rewrite->add_gallery_endpoint(); |
|
75
|
|
|
|
|
76
|
|
|
flush_rewrite_rules(); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
function include_album_language_settings( $settings ) { |
|
80
|
|
|
$settings['settings'][] = array( |
|
81
|
|
|
'id' => 'language_back_to_album_text', |
|
82
|
|
|
'title' => __( 'Back To Album Text', 'foogallery' ), |
|
83
|
|
|
'type' => 'text', |
|
84
|
|
|
'default' => __( '« back to album', 'foogallery' ), |
|
85
|
|
|
'tab' => 'language' |
|
86
|
|
|
); |
|
87
|
|
|
|
|
88
|
|
|
return $settings; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
function add_album_settings( $settings ) { |
|
|
|
|
|
|
92
|
|
|
|
|
93
|
|
|
$settings['tabs']['albums'] = __( 'Albums', 'foogallery' ); |
|
94
|
|
|
|
|
95
|
|
|
$settings['settings'][] = array( |
|
96
|
|
|
'id' => 'album_gallery_slug', |
|
97
|
|
|
'title' => __( 'Gallery Slug', 'foogallery' ), |
|
98
|
|
|
'type' => 'text', |
|
99
|
|
|
'default' => 'gallery', |
|
100
|
|
|
'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' ), |
|
101
|
|
|
'tab' => 'albums' |
|
102
|
|
|
); |
|
103
|
|
|
|
|
104
|
|
|
return $settings; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
function uninstall() { |
|
|
|
|
|
|
108
|
|
|
foogallery_album_uninstall(); |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|
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.