| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /* |
| 3 | 3 | * Plugin Name: StockPack – Stock images in WordPress |
| 4 | 4 | * Plugin URI: https://wordpress.org/plugins/stockpack/ |
| 5 | - * Description: Search and download Stock Photos without leaving WordPress | |
| 5 | + * Description: Direct image search in WordPress for Unsplash, Adobe Stock, Getty Images, iStock, Pixabay, Pexels and Deposit Photos | |
| 6 | 6 | * Author: Derikon Development |
| 7 | 7 | * Author URI: https://derikon.com/ |
| 8 | - * Version: 2.2 | |
| 8 | + * Version:3.7.0 | |
| 9 | 9 | * Text Domain: stockpack |
| 10 | 10 | * Domain Path: /languages |
| 11 | 11 | * |
| 12 | 12 | * Copyright (c) 2016 Derikon Development |
| @@ -18,9 +18,9 @@ | ||
| 18 | 18 | * |
| 19 | 19 | * This program is distributed in the hope that it will be useful, |
| 20 | 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | - * GNU General Public License for more details.xdebu | |
| 22 | + * GNU General Public License for more details | |
| 23 | 23 | * |
| 24 | 24 | * You should have received a copy of the GNU General Public License |
| 25 | 25 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 26 | 26 | */ |
| @@ -27,100 +27,158 @@ | ||
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | require( __DIR__ . '/vendor/autoload.php' ); |
| 30 | 30 | |
| 31 | +define( 'STOCKPACK_DIR', __FILE__ ); | |
| 32 | + | |
| 31 | 33 | if ( ! class_exists( 'Stockpack' ) ) { |
| 32 | - class Stockpack { | |
| 34 | + class Stockpack { | |
| 33 | 35 | |
| 34 | - /** | |
| 35 | - * @var Singleton The reference the *Singleton* instance of this class | |
| 36 | - */ | |
| 37 | - private static $instance; | |
| 36 | + /** | |
| 37 | + * @var Singleton The reference the *Singleton* instance of this class | |
| 38 | + */ | |
| 39 | + private static $instance; | |
| 38 | 40 | |
| 39 | - /** @var StockpackAdmin */ | |
| 40 | - public $admin; | |
| 41 | + /** @var StockpackAdmin */ | |
| 42 | + public $admin; | |
| 41 | 43 | |
| 42 | - /** @var StockpackMedia */ | |
| 43 | - public $media; | |
| 44 | + /** @var StockpackMedia */ | |
| 45 | + public $media; | |
| 44 | 46 | |
| 45 | - /** @var StockpackQuery */ | |
| 46 | - public $query; | |
| 47 | + /** @var StockpackQuery */ | |
| 48 | + public $query; | |
| 47 | 49 | |
| 48 | - /** | |
| 49 | - * Returns the *Singleton* instance of this class. | |
| 50 | - * | |
| 51 | - * @return Singleton The *Singleton* instance. | |
| 52 | - */ | |
| 53 | - public static function get_instance() { | |
| 54 | - if ( null === self::$instance ) { | |
| 55 | - self::$instance = new self(); | |
| 56 | - } | |
| 50 | + /** @var StockpackCaptions */ | |
| 51 | + public $captions; | |
| 57 | 52 | |
| 58 | - return self::$instance; | |
| 59 | - } | |
| 53 | + /** @var StockpackSettings */ | |
| 54 | + public $settings; | |
| 60 | 55 | |
| 61 | - /** | |
| 62 | - * Stockpack constructor. | |
| 63 | - */ | |
| 64 | - protected function __construct() { | |
| 65 | - $this->dependencies(); | |
| 66 | - add_action( 'plugins_loaded', array( $this, 'init' ) ); | |
| 67 | - } | |
| 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 | + } | |
| 68 | 65 | |
| 69 | - /** | |
| 70 | - * | |
| 71 | - */ | |
| 72 | - public function filters() { | |
| 73 | - add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( | |
| 74 | - $this, | |
| 75 | - 'plugin_action_links' | |
| 76 | - ) ); | |
| 77 | - } | |
| 66 | + return self::$instance; | |
| 67 | + } | |
| 78 | 68 | |
| 79 | - /** | |
| 80 | - * Init the plugin after plugins_loaded so environment variables are set. | |
| 81 | - */ | |
| 82 | - public function init() { | |
| 83 | - // works | |
| 84 | - load_plugin_textdomain( 'stockpack', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' ); | |
| 85 | - $this->filters(); | |
| 86 | - } | |
| 69 | + /** | |
| 70 | + * Stockpack constructor. | |
| 71 | + */ | |
| 72 | + protected function __construct() { | |
| 73 | + $this->dependencies(); | |
| 74 | + add_action( 'init', array( $this, 'init' ) ); | |
| 75 | + } | |
| 87 | 76 | |
| 88 | - /** | |
| 89 | - * | |
| 90 | - */ | |
| 91 | - public function dependencies() { | |
| 92 | - $this->admin = \StockpackAdmin::get_instance(); | |
| 93 | - $this->media = \StockpackMedia::get_instance(); | |
| 94 | - $this->query = \StockpackQuery::get_instance(); | |
| 95 | - } | |
| 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 | + } | |
| 96 | 86 | |
| 97 | - /** | |
| 98 | - * Adds plugin action links | |
| 99 | - * | |
| 100 | - * @since 1.0.0 | |
| 101 | - */ | |
| 102 | - public function plugin_action_links( $links ) { | |
| 103 | - $setting_link = $this->get_setting_link(); | |
| 104 | - $plugin_links = array( | |
| 105 | - '<a href="' . $setting_link . '">' . __( 'Settings', 'stockpack' ) . '</a>', | |
| 106 | - ); | |
| 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 | + } | |
| 107 | 95 | |
| 108 | - return array_merge( $plugin_links, $links ); | |
| 109 | - } | |
| 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 | + } | |
| 110 | 106 | |
| 111 | - /** | |
| 112 | - * Get setting link. | |
| 113 | - * | |
| 114 | - * @since 1.0.0 | |
| 115 | - * | |
| 116 | - * @return string Setting link | |
| 117 | - */ | |
| 118 | - public function get_setting_link() { | |
| 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 | + ); | |
| 119 | 117 | |
| 120 | - return admin_url( 'options-general.php?page=stockpack' ); | |
| 121 | - } | |
| 118 | + return array_merge( $plugin_links, $links ); | |
| 119 | + } | |
| 122 | 120 | |
| 123 | - } | |
| 121 | + /** | |
| 122 | + * Get setting link. | |
| 123 | + * | |
| 124 | + * @return string Setting link | |
| 125 | + * @since 1.0.0 | |
| 126 | + * | |
| 127 | + */ | |
| 128 | + public function get_setting_link() { | |
| 124 | 129 | |
| 125 | - $GLOBALS['stockpack'] = Stockpack::get_instance(); | |
| 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 | + | |
| 126 | 183 | } |
| 184 | + | |