| 1 |
<?php |
| 2 |
/* |
| 3 |
* Plugin Name: StockPack – Stock images in WordPress |
| 4 |
* Plugin URI: https://wordpress.org/plugins/stockpack/ |
| 5 |
* Description: Search and download stock images without leaving WordPress |
| 6 |
* Author: Derikon Development |
| 7 |
* Author URI: https://derikon.com/ |
| 8 |
* Version: 2.3 |
| 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.xdebu |
| 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 |
if ( ! class_exists( 'Stockpack' ) ) { |
| 32 |
class Stockpack { |
| 33 |
|
| 34 |
/** |
| 35 |
* @var Singleton The reference the *Singleton* instance of this class |
| 36 |
*/ |
| 37 |
private static $instance; |
| 38 |
|
| 39 |
/** @var StockpackAdmin */ |
| 40 |
public $admin; |
| 41 |
|
| 42 |
/** @var StockpackMedia */ |
| 43 |
public $media; |
| 44 |
|
| 45 |
/** @var StockpackQuery */ |
| 46 |
public $query; |
| 47 |
|
| 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 |
} |
| 57 |
|
| 58 |
return self::$instance; |
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* Stockpack constructor. |
| 63 |
*/ |
| 64 |
protected function __construct() { |
| 65 |
$this->dependencies(); |
| 66 |
add_action( 'plugins_loaded', array( $this, 'init' ) ); |
| 67 |
} |
| 68 |
|
| 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 |
} |
| 78 |
|
| 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 |
} |
| 87 |
|
| 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 |
} |
| 96 |
|
| 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 |
); |
| 107 |
|
| 108 |
return array_merge( $plugin_links, $links ); |
| 109 |
} |
| 110 |
|
| 111 |
/** |
| 112 |
* Get setting link. |
| 113 |
* |
| 114 |
* @since 1.0.0 |
| 115 |
* |
| 116 |
* @return string Setting link |
| 117 |
*/ |
| 118 |
public function get_setting_link() { |
| 119 |
|
| 120 |
return admin_url( 'options-general.php?page=stockpack' ); |
| 121 |
} |
| 122 |
|
| 123 |
} |
| 124 |
|
| 125 |
$GLOBALS['stockpack'] = Stockpack::get_instance(); |
| 126 |
} |
| 127 |
|