1 | <?php |
||
30 | class Auto_Load_Next_Post { |
||
31 | |||
32 | /** |
||
33 | * @var Auto_Load_Next_Post - The single instance of the class |
||
34 | * |
||
35 | * @access protected |
||
36 | * @static |
||
37 | * @since 1.0.0 |
||
38 | */ |
||
39 | protected static $_instance = null; |
||
40 | |||
41 | /** |
||
42 | * Plugin Version |
||
43 | * |
||
44 | * @access public |
||
45 | * @static |
||
46 | * @since 1.5.0 |
||
47 | */ |
||
48 | public static $version = '1.6.0-beta.1'; |
||
49 | |||
50 | /** |
||
51 | * Main Auto Load Next Post Instance |
||
52 | * |
||
53 | * Ensures only one instance of Auto Load Next Post is loaded or can be loaded. |
||
54 | * |
||
55 | * @access public |
||
56 | * @since 1.0.0 |
||
57 | * @static |
||
58 | * @see Auto_Load_Next_Post() |
||
59 | * @return Auto_Load_Next_Post Single instance. |
||
60 | */ |
||
61 | public static function instance() { |
||
67 | |||
68 | /** |
||
69 | * Cloning is forbidden. |
||
70 | * |
||
71 | * @access public |
||
72 | * @since 1.0.0 |
||
73 | * @return void |
||
74 | */ |
||
75 | public function __clone() { |
||
79 | |||
80 | /** |
||
81 | * Unserializing instances of this class is forbidden. |
||
82 | * |
||
83 | * @access public |
||
84 | * @since 1.0.0 |
||
85 | * @return void |
||
86 | */ |
||
87 | public function __wakeup() { |
||
90 | |||
91 | /** |
||
92 | * Auto_Load_Next_Post Constructor |
||
93 | * |
||
94 | * @access public |
||
95 | * @since 1.0.0 |
||
96 | * @version 1.5.0 |
||
97 | */ |
||
98 | public function __construct() { |
||
99 | $this->setup_constants(); |
||
100 | $this->includes(); |
||
101 | $this->init_hooks(); |
||
102 | |||
103 | // Auto Load Next Post is fully loaded. |
||
104 | do_action( 'auto_load_next_post_loaded' ); |
||
105 | } // END __construct() |
||
106 | |||
107 | /** |
||
108 | * Hooks into action hooks. |
||
109 | * |
||
110 | * @access public |
||
111 | * @since 1.5.0 |
||
112 | */ |
||
113 | public function init_hooks() { |
||
114 | // Load translation files. |
||
115 | add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); |
||
116 | |||
117 | // Load Auto Load Next Post scripts on the frontend. |
||
118 | add_action( 'wp_enqueue_scripts', array( $this, 'alnp_enqueue_scripts' ) ); |
||
119 | } // END init_hooks() |
||
120 | |||
121 | /** |
||
122 | * Setup Constants |
||
123 | * |
||
124 | * @access private |
||
125 | * @since 1.4.3 |
||
126 | * @version 1.5.12 |
||
127 | */ |
||
128 | private function setup_constants() { |
||
129 | $this->define('AUTO_LOAD_NEXT_POST_VERSION', self::$version); |
||
130 | $this->define('AUTO_LOAD_NEXT_POST_FILE', __FILE__); |
||
131 | $this->define('AUTO_LOAD_NEXT_POST_SLUG', 'auto-load-next-post'); |
||
132 | |||
133 | $this->define('AUTO_LOAD_NEXT_POST_URL_PATH', untrailingslashit( plugins_url( '/', __FILE__ ) ) ); |
||
134 | $this->define('AUTO_LOAD_NEXT_POST_FILE_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); |
||
135 | $this->define('AUTO_LOAD_NEXT_POST_TEMPLATE_PATH', 'auto-load-next-post/'); |
||
136 | $this->define('AUTO_LOAD_NEXT_POST_3RD_PARTY', AUTO_LOAD_NEXT_POST_FILE_PATH . '/includes/3rd-party/'); |
||
137 | |||
138 | $this->define('AUTO_LOAD_NEXT_POST_WP_VERSION_REQUIRE', '4.4'); |
||
139 | |||
140 | $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
||
141 | $debug_suffix = defined('ALNP_DEV_DEBUG') && ALNP_DEV_DEBUG ? '.dev' : ''; |
||
142 | |||
143 | $this->define('AUTO_LOAD_NEXT_POST_SCRIPT_MODE', $suffix); |
||
144 | $this->define('AUTO_LOAD_NEXT_POST_DEBUG_MODE', $debug_suffix); |
||
145 | |||
146 | $this->define('AUTO_LOAD_NEXT_POST_STORE_URL', 'https://autoloadnextpost.com/'); |
||
147 | $this->define('AUTO_LOAD_NEXT_POST_PLUGIN_URL', 'https://wordpress.org/plugins/auto-load-next-post/'); |
||
148 | $this->define('AUTO_LOAD_NEXT_POST_SUPPORT_URL', 'https://wordpress.org/support/plugin/auto-load-next-post'); |
||
149 | $this->define('AUTO_LOAD_NEXT_POST_REVIEW_URL', 'https://wordpress.org/support/plugin/auto-load-next-post/reviews/'); |
||
150 | $this->define('AUTO_LOAD_NEXT_POST_DOCUMENTATION_URL', 'https://github.com/autoloadnextpost/alnp-documentation/tree/master/en_US#the-manual'); |
||
151 | } // END setup_constants() |
||
152 | |||
153 | /** |
||
154 | * Define constant if not already set. |
||
155 | * |
||
156 | * @access private |
||
157 | * @since 1.4.3 |
||
158 | * @param string $name |
||
159 | * @param string|bool $value |
||
160 | */ |
||
161 | private function define( $name, $value ) { |
||
166 | |||
167 | /** |
||
168 | * Include required core files used in admin and on the frontend. |
||
169 | * |
||
170 | * @access public |
||
171 | * @since 1.0.0 |
||
172 | * @version 1.6.0 |
||
173 | * @return void |
||
174 | */ |
||
175 | public function includes() { |
||
206 | |||
207 | /** |
||
208 | * Make the plugin translation ready. |
||
209 | * |
||
210 | * Translations should be added in the WordPress language directory: |
||
211 | * - WP_LANG_DIR/plugins/auto-load-next-post-LOCALE.mo |
||
212 | * |
||
213 | * @access public |
||
214 | * @since 1.0.0 |
||
215 | * @version 1.4.10 |
||
216 | * @return void |
||
217 | */ |
||
218 | public function load_plugin_textdomain() { |
||
221 | |||
222 | /** |
||
223 | * Registers and enqueues stylesheets and javascripts for the front of the site. |
||
224 | * |
||
225 | * @access public |
||
226 | * @since 1.3.2 |
||
227 | * @version 1.6.0 |
||
228 | */ |
||
229 | public function alnp_enqueue_scripts() { |
||
270 | |||
271 | /** |
||
272 | * Checks if we are using the theme customizer. |
||
273 | * |
||
274 | * @access public |
||
275 | * @since 1.5.0 |
||
276 | * @static |
||
277 | * @return string|bool |
||
278 | */ |
||
279 | public static function is_alnp_using_customizer() { |
||
286 | |||
287 | /** |
||
288 | * Check if the site is viewed on a mobile device. |
||
289 | * |
||
290 | * @access public |
||
291 | * @since 1.6.0 |
||
292 | * @static |
||
293 | * @return string|bool |
||
294 | */ |
||
295 | public static function is_mobile() { |
||
302 | |||
303 | /** |
||
304 | * Helper function for registering and enqueueing scripts and styles. |
||
305 | * |
||
306 | * @access public |
||
307 | * @since 1.0.0 |
||
308 | * @version 1.5.0 |
||
309 | * @static |
||
310 | * @param string $name The ID to register with WordPress. |
||
311 | * @param string $file_path The path to the actual file. |
||
312 | * @param bool $is_script Optional, argument for if the incoming file_path is a JavaScript source file. |
||
313 | * @param array $support Optional, for requiring other javascripts for the source file you are calling. |
||
314 | * @param string $version Optional, can match the version of the plugin or version of the source file. |
||
315 | * @param bool $footer Optional, can set the JavaScript to load in the footer instead. |
||
316 | */ |
||
317 | public static function load_file( $name, $file_path, $is_script = false, $support = array(), $version = '', $footer = false ) { |
||
335 | |||
336 | } // END Auto_Load_Next_Post() |
||
337 | |||
341 |