PluginProbe
Free Assets Library – Openverse/Pixabay 600+ Million Images / 2.1.3
Free Assets Library – Openverse/Pixabay 600+ Million Images v2.1.3
trunk 1.0.0 1.0.1 1.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.4.0 1.4.1 1.4.2 2.0.0 2.0.0-beta.1 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.1 2.3.0
free-images / free-images.php

free-images.php in Free Assets Library – Openverse/Pixabay 600+ Million Images 2.1.3, at free-images.php

249 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Free Assets Library Plugin.
4 *
5 * @package FAL
6 * @copyright Copyright (C) 2014-2022, Surror - admin@surror.com
7 * @link https://surror.com
8 * @since 2.0.0
9 *
10 * @wordpress-plugin
11 * Plugin Name: Free Assets Library
12 * Version: 2.1.2
13 * Plugin URI: https://surror.com/free-asset-library/
14 * Description: Stunning free images from Openverse, Pixabay for your own blog. Find suitable image as per your need from the millions royalty free images library.
15 * Author: Surror
16 * Author URI: https://surror.com/
17 * License: GPL v3
18 * License URI: https://www.gnu.org/licenses/gpl-3.0.txt
19 * Text Domain: fal
20 * Domain Path: /languages
21 */
22
23 defined( 'ABSPATH' ) || exit;
24
25 /**
26 * FAL class.
27 *
28 * @class Main class of the plugin.
29 */
30 final class FAL {
31
32 /**
33 * Plugin version.
34 *
35 * @var string
36 */
37 public $version = '2.1.3';
38
39 /**
40 * Database version.
41 *
42 * @var string
43 */
44 public $db_version = '1';
45
46 /**
47 * Minimum version of WordPress required.
48 *
49 * @var string
50 */
51 private $wordpress_version = '6.1.1';
52
53 /**
54 * Minimum version of PHP required.
55 *
56 * @var string
57 */
58 private $php_version = '7.2';
59
60 /**
61 * Holds various class instances.
62 *
63 * @var array
64 */
65 private $container = [];
66
67 /**
68 * Hold install error messages.
69 *
70 * @var bool
71 */
72 private $messages = [];
73
74 /**
75 * The single instance of the class.
76 *
77 * @var FAL
78 */
79 protected static $instance = null;
80
81 /**
82 * Magic isset to bypass referencing plugin.
83 *
84 * @param string $prop Property to check.
85 * @return bool
86 */
87 public function __isset( $prop ) {
88 return isset( $this->{$prop} ) || isset( $this->container[ $prop ] );
89 }
90
91 /**
92 * Magic getter method.
93 *
94 * @param string $prop Property to get.
95 * @return mixed Property value or NULL if it does not exists.
96 */
97 public function __get( $prop ) {
98 if ( array_key_exists( $prop, $this->container ) ) {
99 return $this->container[ $prop ];
100 }
101
102 if ( isset( $this->{$prop} ) ) {
103 return $this->{$prop};
104 }
105
106 return null;
107 }
108
109 /**
110 * Magic setter method.
111 *
112 * @param mixed $prop Property to set.
113 * @param mixed $value Value to set.
114 */
115 public function __set( $prop, $value ) {
116 if ( property_exists( $this, $prop ) ) {
117 $this->$prop = $value;
118 return;
119 }
120
121 $this->container[ $prop ] = $value;
122 }
123
124 /**
125 * Magic call method.
126 *
127 * @param string $name Method to call.
128 * @param array $arguments Arguments to pass when calling.
129 * @return mixed Return value of the callback.
130 */
131 public function __call( $name, $arguments ) {
132 $hash = [
133 'plugin_dir' => FAL_DIR,
134 'plugin_url' => FAL_URI,
135 'includes_dir' => FAL_DIR . 'includes/',
136 ];
137
138 if ( isset( $hash[ $name ] ) ) {
139 return $hash[ $name ];
140 }
141
142 return call_user_func_array( $name, $arguments );
143 }
144
145 /**
146 * Initialize.
147 */
148 public function init() {
149 }
150
151 /**
152 * Retrieve main FAL instance.
153 *
154 * Ensure only one instance is loaded or can be loaded.
155 *
156 * @see fal()
157 * @return FAL
158 */
159 public static function get() {
160 if ( is_null( self::$instance ) && ! ( self::$instance instanceof FAL ) ) {
161 self::$instance = new FAL();
162 self::$instance->setup();
163 }
164
165 return self::$instance;
166 }
167
168 /**
169 * Instantiate the plugin.
170 */
171 private function setup() {
172 // Define plugin constants.
173 $this->define_constants();
174
175 // Include required files.
176 $this->includes();
177
178 // Instantiate classes.
179 $this->instantiate();
180
181 // Loaded action.
182 do_action( 'fal/loaded' );
183 }
184
185 /**
186 * Auto-deactivate plugin if requirements are not met, and display a notice.
187 */
188 public function auto_deactivate() {
189 deactivate_plugins( plugin_basename( FAL_FILE ) );
190 if ( isset( $_GET['activate'] ) ) { // phpcs:ignore
191 unset( $_GET['activate'] ); // phpcs:ignore
192 }
193 }
194
195 /**
196 * Error notice on plugin activation.
197 */
198 public function activation_error() {
199 ?>
200 <div class="notice fal-notice notice-error">
201 <p>
202 <?php echo join( '<br>', $this->messages ); // phpcs:ignore ?>
203 </p>
204 </div>
205 <?php
206 }
207
208 /**
209 * Define the plugin constants.
210 */
211 private function define_constants() {
212 define( 'FAL_VERSION', $this->version );
213 define( 'FAL_FILE', __FILE__ );
214 define( 'FAL_BASE', plugin_basename( FAL_FILE ) );
215 define( 'FAL_DIR', plugin_dir_path( FAL_FILE ) );
216 define( 'FAL_URI', plugins_url( '/', FAL_FILE ) );
217 }
218
219 /**
220 * Include the required files.
221 */
222 private function includes() {
223 include dirname( __FILE__ ) . '/vendor/autoload.php';
224 }
225
226 /**
227 * Instantiate classes.
228 */
229 private function instantiate() {
230 new \FAL\Page();
231 new \FAL\RestAPI();
232 new \FAL\Track();
233 new \FAL\Media_Popup();
234 }
235
236 }
237
238 /**
239 * Returns the main instance of FAL to prevent the need to use globals.
240 *
241 * @return FAL
242 */
243 function fal() {
244 return FAL::get();
245 }
246
247 // Start it.
248 fal();
249