| 1 |
<?php |
| 2 |
/* |
| 3 |
* Plugin Name: StockPack – Stock images in WordPress |
| 4 |
* Plugin URI: https://wordpress.org/plugins/stockpack/ |
| 5 |
* Description: Direct image search in WordPress for Unsplash, Adobe Stock, Getty Images, iStock, Pixabay, Pexels and Deposit Photos |
| 6 |
* Author: Derikon Development |
| 7 |
* Author URI: https://derikon.com/ |
| 8 |
* Version:3.6.1 |
| 9 |
* Text Domain: stockpack |
| 10 |
* Domain Path: /languages |
| 11 |
* |
| 12 |
* Copyright (c) 2016 Derikon Development |
| 13 |
* |
| 14 |
* This program is free software: you can redistribute it and/or modify |
| 15 |
* it under the terms of the GNU General Public License as published by |
| 16 |
* the Free Software Foundation, either version 3 of the License, or |
| 17 |
* (at your option) any later version. |
| 18 |
* |
| 19 |
* This program is distributed in the hope that it will be useful, |
| 20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
* GNU General Public License for more details |
| 23 |
* |
| 24 |
* You should have received a copy of the GNU General Public License |
| 25 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 26 |
*/ |
| 27 |
|
| 28 |
|
| 29 |
require( __DIR__ . '/vendor/autoload.php' ); |
| 30 |
|
| 31 |
define( 'STOCKPACK_DIR', __FILE__ ); |
| 32 |
|
| 33 |
if ( ! class_exists( 'Stockpack' ) ) { |
| 34 |
class Stockpack { |
| 35 |
|
| 36 |
/** |
| 37 |
* @var Singleton The reference the *Singleton* instance of this class |
| 38 |
*/ |
| 39 |
private static $instance; |
| 40 |
|
| 41 |
/** @var StockpackAdmin */ |
| 42 |
public $admin; |
| 43 |
|
| 44 |
/** @var StockpackMedia */ |
| 45 |
public $media; |
| 46 |
|
| 47 |
/** @var StockpackQuery */ |
| 48 |
public $query; |
| 49 |
|
| 50 |
/** @var StockpackCaptions */ |
| 51 |
public $captions; |
| 52 |
|
| 53 |
/** @var StockpackSettings */ |
| 54 |
public $settings; |
| 55 |
|
| 56 |
/** |
| 57 |
* Returns the *Singleton* instance of this class. |
| 58 |
* |
| 59 |
* @return Singleton The *Singleton* instance. |
| 60 |
*/ |
| 61 |
public static function get_instance() { |
| 62 |
if ( null === self::$instance ) { |
| 63 |
self::$instance = new self(); |
| 64 |
} |
| 65 |
|
| 66 |
return self::$instance; |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Stockpack constructor. |
| 71 |
*/ |
| 72 |
protected function __construct() { |
| 73 |
$this->dependencies(); |
| 74 |
add_action( 'init', array( $this, 'init' ) ); |
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* |
| 79 |
*/ |
| 80 |
public function filters() { |
| 81 |
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( |
| 82 |
$this, |
| 83 |
'plugin_action_links' |
| 84 |
) ); |
| 85 |
} |
| 86 |
|
| 87 |
/** |
| 88 |
* Init the plugin after plugins_loaded so environment variables are set. |
| 89 |
*/ |
| 90 |
public function init() { |
| 91 |
// works |
| 92 |
load_plugin_textdomain( 'stockpack', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' ); |
| 93 |
$this->filters(); |
| 94 |
} |
| 95 |
|
| 96 |
/** |
| 97 |
* |
| 98 |
*/ |
| 99 |
public function dependencies() { |
| 100 |
$this->admin = \StockpackAdmin::get_instance(); |
| 101 |
$this->media = \StockpackMedia::get_instance(); |
| 102 |
$this->query = \StockpackQuery::get_instance(); |
| 103 |
$this->captions = \StockpackCaptions::get_instance(); |
| 104 |
$this->settings = \StockpackSettings::get_instance(); |
| 105 |
} |
| 106 |
|
| 107 |
/** |
| 108 |
* Adds plugin action links |
| 109 |
* |
| 110 |
* @since 1.0.0 |
| 111 |
*/ |
| 112 |
public function plugin_action_links( $links ) { |
| 113 |
$setting_link = $this->get_setting_link(); |
| 114 |
$plugin_links = array( |
| 115 |
'<a href="' . $setting_link . '">' . __( 'Settings', 'stockpack' ) . '</a>', |
| 116 |
); |
| 117 |
|
| 118 |
return array_merge( $plugin_links, $links ); |
| 119 |
} |
| 120 |
|
| 121 |
/** |
| 122 |
* Get setting link. |
| 123 |
* |
| 124 |
* @return string Setting link |
| 125 |
* @since 1.0.0 |
| 126 |
* |
| 127 |
*/ |
| 128 |
public function get_setting_link() { |
| 129 |
|
| 130 |
return admin_url( 'options-general.php?page=stockpack' ); |
| 131 |
} |
| 132 |
|
| 133 |
} |
| 134 |
|
| 135 |
add_action( 'after_setup_theme', 'stockpack_register_plugin' ); |
| 136 |
function stockpack_register_plugin() { |
| 137 |
$load_stockpack = true; |
| 138 |
if ( ! is_admin()) { |
| 139 |
$load_stockpack = false; |
| 140 |
} |
| 141 |
|
| 142 |
$stockpack_start = apply_filters( 'load_stockpack', $load_stockpack ); |
| 143 |
if ( $stockpack_start || stockpack_frontend_load() || stockpack_cli_load() ) { |
| 144 |
$GLOBALS['stockpack'] = Stockpack::get_instance(); |
| 145 |
} |
| 146 |
} |
| 147 |
|
| 148 |
function stockpack_frontend_load() { |
| 149 |
$load = false; |
| 150 |
if ( isset( $_GET['et_fb'] ) || isset ( $_GET['bricks'] ) || isset ( $_GET['ct_builder'] ) || (isset( $_GET['fl_builder']) && !isset($_GET['fl_builder_ui_iframe']) ) || isset( $_GET['fb-edit'] ) || isset( $_GET['brizy-edit-iframe'] ) ) { |
| 151 |
$load = true; |
| 152 |
} |
| 153 |
|
| 154 |
return apply_filters( 'frontend_load_stockpack', $load ); |
| 155 |
} |
| 156 |
|
| 157 |
function stockpack_early_admin_enqueue(){ |
| 158 |
return isset($_GET['breakdance_wpuiforbuilder_media']); |
| 159 |
} |
| 160 |
|
| 161 |
function stockpack_cli_load() { |
| 162 |
$load = false; |
| 163 |
if ( defined( 'WP_CLI' ) && WP_CLI ) { |
| 164 |
WP_CLI::add_command( 'stockpack', 'StockpackCLI' ); |
| 165 |
$load = true; |
| 166 |
} |
| 167 |
|
| 168 |
return apply_filters( 'cli_load_stockpack', $load ); |
| 169 |
} |
| 170 |
|
| 171 |
function stockpack_late_init() { |
| 172 |
global $stockpack; |
| 173 |
// if loaded bail |
| 174 |
if ( $stockpack ) { |
| 175 |
return false; |
| 176 |
} |
| 177 |
stockpack_register_plugin(); |
| 178 |
|
| 179 |
} |
| 180 |
|
| 181 |
add_action( 'get_header', 'stockpack_late_init' ); |
| 182 |
|
| 183 |
} |
| 184 |
|
| 185 |
|