PluginProbe
Hide Posts / 2.0
Hide Posts v2.0
trunk 0.0.1 0.1.1 0.2.1 0.3.1 0.3.2 0.4.0 0.4.1 0.4.2 0.4.3 0.4.4 0.5.0 0.5.1 0.5.2 0.5.3 0.5.4 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 2.0 2.0.1 2.0.2 All 29 releases
whp-hide-posts / whp-hide-posts.php

whp-hide-posts.php in Hide Posts 2.0, at whp-hide-posts.php

149 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: WordPress Hide Posts
4 * Description: Hides posts on home page, categories, search, tags page, authors page, RSS Feed as well as hiding Woocommerce products
5 * Author: MartinCV
6 * Author URI: https://www.martincv.com
7 * Version: 2.0
8 * Text Domain: whp-hide-posts
9 *
10 * WordPress Hide Posts is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * any later version.
14 *
15 * WordPress Hide Posts is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with WordPress Hide Posts. If not, see <http://www.gnu.org/licenses/>.
22 *
23 * @package WordPressHidePosts
24 * @author MartinCV
25 * @since 0.0.1
26 * @license GPL-3.0+
27 * @copyright Copyright (c) 2022, MartinCV
28 */
29
30 // Exit if accessed directly.
31 if ( ! defined( 'ABSPATH' ) ) {
32 exit;
33 }
34
35 /**
36 * Main class
37 */
38 final class WordPressHidePosts {
39 /**
40 * Instance of the plugin
41 *
42 * @var WordPressHidePosts
43 */
44 private static $instance;
45
46 /**
47 * Plugin version
48 *
49 * @var string
50 */
51 private $version = '2.0';
52
53 /**
54 * Instance of this plugin
55 *
56 * @return WordPressHidePosts
57 */
58 public static function instance() {
59 if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WordPressHidePosts ) ) {
60 self::$instance = new WordPressHidePosts();
61 self::$instance->constants();
62 self::$instance->includes();
63
64 add_action( 'plugins_loaded', array( self::$instance, 'run' ) );
65 }
66
67 return self::$instance;
68 }
69
70 /**
71 * 3rd party includes
72 *
73 * @return void
74 */
75 private function includes() {
76 require_once WHP_PLUGIN_DIR . 'inc/core/autoloader.php';
77 require_once WHP_PLUGIN_DIR . 'inc/core/helpers.php';
78 }
79
80 /**
81 * Define plugin constants
82 *
83 * @return void
84 */
85 private function constants() {
86 // Plugin version.
87 if ( ! defined( 'WHP_VERSION' ) ) {
88 define( 'WHP_VERSION', $this->version );
89 }
90
91 // Plugin Folder Path.
92 if ( ! defined( 'WHP_PLUGIN_DIR' ) ) {
93 define( 'WHP_PLUGIN_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
94 }
95
96 // Plugin Folder URL.
97 if ( ! defined( 'WHP_PLUGIN_URL' ) ) {
98 define( 'WHP_PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
99 }
100
101 // Plugin Root File.
102 if ( ! defined( 'WHP_PLUGIN_FILE' ) ) {
103 define( 'WHP_PLUGIN_FILE', __FILE__ );
104 }
105 }
106
107 /**
108 * Initialize classes / objects here
109 *
110 * @return void
111 */
112 public function run() {
113 $this->load_textdomain();
114
115 \MartinCV\WHP\Zeen_Theme::get_instance();
116 \MartinCV\WHP\Core\Database::get_instance()->create_tables();
117
118 // Init classes if is Admin/Dashboard.
119 if ( is_admin() ) {
120 \MartinCV\WHP\Admin\Dashboard::get_instance();
121 \MartinCV\WHP\Admin\Post_Hide_Metabox::get_instance();
122 } else {
123 \MartinCV\WHP\Post_Hide::get_instance();
124 }
125 }
126
127 /**
128 * Register textdomain
129 *
130 * @return void
131 */
132 private function load_textdomain() {
133 load_plugin_textdomain( 'whp-hide-posts', false, basename( dirname( __FILE__ ) ) . '/languages' );
134 }
135 }
136
137 WordPressHidePosts::instance();
138
139 if ( ! function_exists( 'whp_plugin' ) ) {
140 /**
141 * Instance of the Plugin class which holds helper functions
142 *
143 * @return \MartinCV\WHP\Core\Plugin
144 */
145 function whp_plugin() {
146 return \MartinCV\WHP\Core\Plugin::get_instance();
147 }
148 }
149