PluginProbe
Hide Posts / 2.1.2
Hide Posts v2.1.2
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.1.2, at whp-hide-posts.php

162 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Hide Posts
4 * Description: Hides posts on home page, categories, search, tags page, authors page, RSS Feed, XML sitemaps, Yoast SEO as well as hiding Woocommerce products
5 * Author: MartinCV
6 * Author URI: https://www.martincv.com
7 * Version: 2.1.2
8 * Text Domain: whp-hide-posts
9 *
10 * 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 * 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 HidePostsPlugin
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 HidePostsPlugin {
39 /**
40 * Instance of the plugin
41 *
42 * @var HidePostsPlugin
43 */
44 private static $instance;
45
46 /**
47 * Plugin version
48 *
49 * @var string
50 */
51 private $version = '2.1.2';
52
53 /**
54 * Instance of this plugin
55 *
56 * @return HidePostsPlugin
57 */
58 public static function instance() {
59 if ( ! isset( self::$instance ) && ! ( self::$instance instanceof HidePostsPlugin ) ) {
60 self::$instance = new HidePostsPlugin();
61 self::$instance->constants();
62 self::$instance->includes();
63
64 add_action( 'plugins_loaded', array( self::$instance, 'run' ) );
65 add_action( 'init', array( self::$instance, 'load_textdomain' ) );
66 }
67
68 return self::$instance;
69 }
70
71 /**
72 * 3rd party includes
73 *
74 * @return void
75 */
76 private function includes() {
77 require_once WHP_PLUGIN_DIR . 'inc/core/autoloader.php';
78 require_once WHP_PLUGIN_DIR . 'inc/core/helpers.php';
79 }
80
81 /**
82 * Define plugin constants
83 *
84 * @return void
85 */
86 private function constants() {
87 // Plugin version.
88 if ( ! defined( 'WHP_VERSION' ) ) {
89 define( 'WHP_VERSION', $this->version );
90 }
91
92 // Plugin Folder Path.
93 if ( ! defined( 'WHP_PLUGIN_DIR' ) ) {
94 define( 'WHP_PLUGIN_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
95 }
96
97 // Plugin Folder URL.
98 if ( ! defined( 'WHP_PLUGIN_URL' ) ) {
99 define( 'WHP_PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
100 }
101
102 // Plugin Root File.
103 if ( ! defined( 'WHP_PLUGIN_FILE' ) ) {
104 define( 'WHP_PLUGIN_FILE', __FILE__ );
105 }
106 }
107
108 /**
109 * Initialize classes / objects here
110 *
111 * @return void
112 */
113 public function run() {
114 \MartinCV\WHP\Zeen_Theme::get_instance();
115 \MartinCV\WHP\Core\Database::get_instance()->create_tables();
116
117 // Initialize metabox (needed for both admin and REST API/Gutenberg).
118 \MartinCV\WHP\Admin\Post_Hide_Metabox::get_instance();
119
120 // Initialize REST API for Gutenberg (custom table, no postmeta).
121 \MartinCV\WHP\REST_API::get_instance();
122
123 // Init classes if is Admin/Dashboard.
124 if ( is_admin() ) {
125 \MartinCV\WHP\Admin\Dashboard::get_instance();
126 \MartinCV\WHP\Yoast_Duplicate_Post::get_instance();
127 } else {
128 \MartinCV\WHP\Post_Hide::get_instance();
129 }
130
131 // Initialize SEO integrations (works on both frontend and admin).
132 \MartinCV\WHP\SEO_Integration::get_instance();
133
134 // Initialize cache manager.
135 \MartinCV\WHP\Cache_Manager::get_instance();
136 }
137
138 /**
139 * Register textdomain
140 *
141 * Hooked on `init` — WordPress 6.7+ warns when translations load earlier.
142 *
143 * @return void
144 */
145 public function load_textdomain() {
146 load_plugin_textdomain( 'whp-hide-posts', false, basename( dirname( __FILE__ ) ) . '/languages' );
147 }
148 }
149
150 HidePostsPlugin::instance();
151
152 if ( ! function_exists( 'whp_plugin' ) ) {
153 /**
154 * Instance of the Plugin class which holds helper functions
155 *
156 * @return \MartinCV\WHP\Core\Plugin
157 */
158 function whp_plugin() {
159 return \MartinCV\WHP\Core\Plugin::get_instance();
160 }
161 }
162