PluginProbe
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More / 2.0.12
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More v2.0.12
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.0.12, at content-control.php

152 lines 4.1 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.0.12
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: 5.6
13 * Minimum WP: 5.6
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', 'content-control' ),
32 'slug' => 'content-control',
33 'version' => '2.0.12',
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', 'content-control' ),
38 'min_php_ver' => '5.6.0',
39 'min_wp_ver' => '5.6.0',
40 'file' => __FILE__,
41 'basename' => \plugin_basename( __FILE__ ),
42 'url' => \plugin_dir_url( __FILE__ ),
43 'path' => \realpath( \plugin_dir_path( __FILE__ ) ) . \DIRECTORY_SEPARATOR,
44 'api_url' => 'https://contentcontrolplugin.com/',
45 'is_pro' => class_exists( 'ContentControlPro\Plugin\Core' ),
46 ];
47 }
48
49 /**
50 * Get config or config property.
51 *
52 * @param string|null $key Key of config item to return.
53 *
54 * @return mixed
55 */
56 function config( $key = null ) {
57 $config = get_plugin_config();
58
59 if ( ! isset( $key ) ) {
60 return $config;
61 }
62
63 return isset( $config[ $key ] ) ? $config[ $key ] : false;
64 }
65
66 /**
67 * Register autoloader.
68 */
69 require_once __DIR__ . '/classes/Plugin/Autoloader.php';
70
71 if ( ! Plugin\Autoloader::init( config( 'name' ), config( 'path' ) ) ) {
72 return;
73 }
74
75 /**
76 * Check plugin prerequisites.
77 *
78 * @return bool
79 */
80 function check_prerequisites() {
81
82 // 1.a Check Prerequisites.
83 $prerequisites = new \ContentControl\Plugin\Prerequisites( [
84 [
85 // a. PHP Min Version.
86 'type' => 'php',
87 'version' => config( 'min_php_ver' ),
88 ],
89 // a. PHP Min Version.
90 [
91 'type' => 'wp',
92 'version' => config( 'min_wp_ver' ),
93 ],
94 ] );
95
96 /**
97 * 1.b If there are missing requirements, render error messaging and return.
98 */
99 if ( $prerequisites->check() === false ) {
100 $prerequisites->setup_notices();
101
102 return false;
103 }
104
105 return true;
106 }
107
108 add_action( 'plugins_loaded', function () {
109 if ( check_prerequisites() ) {
110 plugin_instance();
111 }
112 }, 11 );
113
114 /**
115 * Initiates and/or retrieves an encapsulated container for the plugin.
116 *
117 * This kicks it all off, loads functions and initiates the plugins main class.
118 *
119 * @return \ContentControl\Plugin\Core
120 */
121 function plugin_instance() {
122 static $plugin;
123
124 if ( ! $plugin instanceof \ContentControl\Plugin\Core ) {
125 require_once __DIR__ . '/inc/functions.php';
126 require_once __DIR__ . '/inc/deprecated.php';
127 $plugin = new Plugin\Core( get_plugin_config() );
128 }
129
130 return $plugin;
131 }
132
133 /**
134 * Easy access to all plugin services from the container.
135 *
136 * @see \ContentControl\plugin_instance
137 *
138 * @param string|null $service_or_config Key of service or config to fetch.
139 * @return \ContentControl\Plugin\Core|mixed
140 */
141 function plugin( $service_or_config = null ) {
142 if ( ! isset( $service_or_config ) ) {
143 return plugin_instance();
144 }
145
146 return plugin_instance()->get( $service_or_config );
147 }
148
149 \register_activation_hook( __FILE__, '\ContentControl\Plugin\Install::activate_plugin' );
150 \register_deactivation_hook( __FILE__, '\ContentControl\Plugin\Install::deactivate_plugin' );
151 \register_uninstall_hook( __FILE__, '\ContentControl\Plugin\Install::uninstall_plugin' );
152