PluginProbe
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More / 2.6.2
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More v2.6.2
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.10 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 47 releases
content-control / content-control.php

content-control.php in Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More 2.6.2, at content-control.php

156 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: Content Control
4 * Plugin URI: https://contentcontrolplugin.com/?utm_campaign=plugin-info&utm_source=php-file-header&utm_medium=plugin-ui&utm_content=plugin-uri
5 * Description: Restrict content to logged in/out users or specific user roles. Restrict access to certain parts of a page/post. Control the visibility of widgets.
6 * Version: 2.6.2
7 * Author: Code Atlantic
8 * Author URI: https://code-atlantic.com/?utm_campaign=plugin-info&utm_source=php-file-header&utm_medium=plugin-ui&utm_content=author-uri
9 * Donate link: https://code-atlantic.com/donate/?utm_campaign=donations&utm_source=php-file-header&utm_medium=plugin-ui&utm_content=donate-link
10 * Text Domain: content-control
11 *
12 * Minimum PHP: 7.4
13 * Minimum WP: 6.2
14 *
15 * @package Content Control
16 * @author Code Atlantic
17 * @copyright Copyright (c) 2023, Code Atlantic LLC.
18 */
19
20 namespace ContentControl;
21
22 defined( 'ABSPATH' ) || exit;
23
24 /**
25 * Define plugin's global configuration.
26 *
27 * @return array<string,string|bool>
28 */
29 function get_plugin_config() {
30 return [
31 'name' => 'Content Control',
32 'slug' => 'content-control',
33 'version' => '2.6.2',
34 'option_prefix' => 'content_control',
35 // Maybe remove this and simply prefix `name` with `'Popup Maker'`.
36 'text_domain' => 'content-control',
37 'fullname' => 'Content Control',
38 'min_php_ver' => '7.4.0',
39 'min_wp_ver' => '6.2.0',
40 'file' => __FILE__,
41 'basename' => \plugin_basename( __FILE__ ),
42 'url' => \plugin_dir_url( __FILE__ ),
43 'path' => __DIR__ . \DIRECTORY_SEPARATOR,
44 'api_url' => 'https://contentcontrolplugin.com/',
45 ];
46 }
47
48 /**
49 * Get config or config property.
50 *
51 * @param string|null $key Key of config item to return.
52 *
53 * @return mixed
54 */
55 function config( $key = null ) {
56 $config = get_plugin_config();
57
58 if ( ! isset( $key ) ) {
59 return $config;
60 }
61
62 return isset( $config[ $key ] ) ? $config[ $key ] : false;
63 }
64
65 /**
66 * Register autoloader.
67 */
68 require_once __DIR__ . '/classes/Plugin/Autoloader.php';
69
70 if ( ! Plugin\Autoloader::init( config( 'name' ), config( 'path' ) ) ) {
71 return;
72 }
73
74 /**
75 * Check plugin prerequisites.
76 *
77 * @return bool
78 */
79 function check_prerequisites() {
80
81 // 1.a Check Prerequisites.
82 $prerequisites = new \ContentControl\Plugin\Prerequisites( [
83 [
84 // a. PHP Min Version.
85 'type' => 'php',
86 'version' => config( 'min_php_ver' ),
87 ],
88 // a. PHP Min Version.
89 [
90 'type' => 'wp',
91 'version' => config( 'min_wp_ver' ),
92 ],
93 ] );
94
95 /**
96 * 1.b If there are missing requirements, render error messaging and return.
97 */
98 if ( $prerequisites->check() === false ) {
99 $prerequisites->setup_notices();
100
101 return false;
102 }
103
104 return true;
105 }
106
107 add_action(
108 'plugins_loaded',
109 function () {
110 if ( check_prerequisites() ) {
111 plugin_instance();
112 }
113 },
114 // Core plugin loads at 11, Pro loads at 12 & addons load at 13.
115 11
116 );
117
118 /**
119 * Initiates and/or retrieves an encapsulated container for the plugin.
120 *
121 * This kicks it all off, loads functions and initiates the plugins main class.
122 *
123 * @return \ContentControl\Plugin\Core
124 */
125 function plugin_instance() {
126 static $plugin;
127
128 if ( ! $plugin instanceof \ContentControl\Plugin\Core ) {
129 require_once __DIR__ . '/inc/functions.php';
130 require_once __DIR__ . '/inc/deprecated.php';
131 $plugin = new Plugin\Core( get_plugin_config() );
132 }
133
134 return $plugin;
135 }
136
137 /**
138 * Easy access to all plugin services from the container.
139 *
140 * @see \ContentControl\plugin_instance
141 *
142 * @param string|null $service_or_config Key of service or config to fetch.
143 * @return \ContentControl\Plugin\Core|mixed
144 */
145 function plugin( $service_or_config = null ) {
146 if ( ! isset( $service_or_config ) ) {
147 return plugin_instance();
148 }
149
150 return plugin_instance()->get( $service_or_config );
151 }
152
153 \register_activation_hook( __FILE__, '\ContentControl\Plugin\Install::activate_plugin' );
154 \register_deactivation_hook( __FILE__, '\ContentControl\Plugin\Install::deactivate_plugin' );
155 \register_uninstall_hook( __FILE__, '\ContentControl\Plugin\Install::uninstall_plugin' );
156