-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmedia-post-permalink.php
121 lines (108 loc) · 3.25 KB
/
media-post-permalink.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
/**
* Plugin Name: Media Post Permalink
* Plugin URI: https://wordpress.org/plugins/media-post-permalink/
* Description: Media Post Permalink is simply the easiest solution to separate your media/attachment Permalinks and make it User Friendly.
* Version: 0.1
* Author: Sami Ahmed Siddiqui
* Author URI: https://www.yasglobal.com/web-design-development/wordpress/media-post-permalink/
* License: GPLv3
*
* Text Domain: media-post-permalink
* Domain Path: /languages/
*
* @package MediaPostPermalink
*/
/**
* Media Post Permalink - Separate Permalinks for Attachments Plugin
* Copyright (C) 2017-2018, Sami Ahmed Siddiqui <sami.siddiqui@yasglobal.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Make sure we don't expose any info if called directly
if ( ! defined( 'ABSPATH' ) ) {
echo 'Hi there! I\'m just a plugin, not much I can do when called directly.';
exit;
}
final class Media_Post_Permalink {
/**
* Class constructor.
*/
public function __construct() {
$this->setup_constants();
$this->includes();
}
/**
* Setup plugin constants
*
* @access private
* @since 0.2
*
* @return void
*/
private function setup_constants() {
if ( ! defined( 'MEDIA_POST_PERMALINK_FILE' ) ) {
define( 'MEDIA_POST_PERMALINK_FILE', __FILE__ );
}
if( ! defined( 'MEDIA_POST_PERMALINK_PLUGIN_VERSION' ) ) {
define( 'MEDIA_POST_PERMALINK_PLUGIN_VERSION', '0.2' );
}
if( ! defined( 'MEDIA_POST_PERMALINK_PATH' ) ) {
define( 'MEDIA_POST_PERMALINK_PATH',
plugin_dir_path( MEDIA_POST_PERMALINK_FILE )
);
}
if ( ! defined( 'MEDIA_POST_PERMALINK_BASENAME' ) ) {
define( 'MEDIA_POST_PERMALINK_BASENAME',
plugin_basename( MEDIA_POST_PERMALINK_FILE )
);
}
}
/**
* Include required files
*
* @access private
* @since 0.2
*
* @return void
*/
private function includes() {
require_once(
MEDIA_POST_PERMALINK_PATH . 'frontend/class-media-post-permalink.php'
);
$mpp_frontend = new Media_Post_Permalink_Frontend();
$mpp_frontend->init();
if ( is_admin() ) {
require_once(
MEDIA_POST_PERMALINK_PATH . 'admin/class-media-post-permalink-admin.php'
);
new Media_Post_Permalink_Admin();
add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
}
}
/**
* Loads the plugin language files
*
* @access public
* @since 0.2
*
* @return void
*/
public function load_textdomain() {
load_plugin_textdomain( 'media-post-permalink', FALSE,
basename( dirname( MEDIA_POST_PERMALINK_FILE ) ) . '/languages/'
);
}
}
new Media_Post_Permalink();