| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Plugin Name: Gmedia Photo Gallery |
| 5 |
* Plugin URI: http://wordpress.org/extend/plugins/grand-media/ |
| 6 |
* Description: Gmedia Gallery - powerful media library plugin for creating beautiful galleries and managing files. |
| 7 |
* Version: 1.25.1 |
| 8 |
* Author: Rattus |
| 9 |
* Author URI: https://codeasily.com/ |
| 10 |
* Requires at least: 5.4.0 |
| 11 |
* Tested up to: 7.1 |
| 12 |
* Stable tag: 1.25.1 |
| 13 |
* License: GPLv2 or later |
| 14 |
* Text Domain: grand-media |
| 15 |
* Domain Path: /lang |
| 16 |
*/ |
| 17 |
/* |
| 18 |
Copyright (C) 2011 Rattus (email : gmediafolder@gmail.com) |
| 19 |
|
| 20 |
This program is free software; you can redistribute it and/or |
| 21 |
modify it under the terms of the GNU General Public License |
| 22 |
as published by the Free Software Foundation; either version 2 |
| 23 |
of the License, or (at your option) any later version. |
| 24 |
|
| 25 |
This program is distributed in the hope that it will be useful, |
| 26 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 27 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 28 |
GNU General Public License for more details. |
| 29 |
|
| 30 |
You should have received a copy of the GNU General Public License |
| 31 |
along with this program; if not, write to the Free Software |
| 32 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 33 |
*/ |
| 34 |
// Stop direct call. |
| 35 |
defined( 'ABSPATH' ) || die( 'No script kiddies please!' ); |
| 36 |
// Create a helper function for easy SDK access. |
| 37 |
if ( !function_exists( 'gmg_fs' ) ) { |
| 38 |
function gmg_fs() { |
| 39 |
global $gmg_fs; |
| 40 |
if ( !isset( $gmg_fs ) ) { |
| 41 |
// Include Freemius SDK. |
| 42 |
require_once dirname( __FILE__ ) . '/vendor/freemius/start.php'; |
| 43 |
$gmg_fs = fs_dynamic_init( array( |
| 44 |
'id' => '20980', |
| 45 |
'slug' => 'grand-media', |
| 46 |
'type' => 'plugin', |
| 47 |
'public_key' => 'pk_377df98aab7989cdb496abbd72dea', |
| 48 |
'is_premium' => false, |
| 49 |
'premium_suffix' => 'Premium', |
| 50 |
'has_addons' => false, |
| 51 |
'has_paid_plans' => true, |
| 52 |
'menu' => array( |
| 53 |
'slug' => 'GrandMedia', |
| 54 |
'contact' => false, |
| 55 |
'support' => false, |
| 56 |
), |
| 57 |
'is_live' => true, |
| 58 |
'is_org_compliant' => true, |
| 59 |
) ); |
| 60 |
} |
| 61 |
return $gmg_fs; |
| 62 |
} |
| 63 |
|
| 64 |
// Init Freemius. |
| 65 |
gmg_fs(); |
| 66 |
// Signal that SDK was initiated. |
| 67 |
do_action( 'gmg_fs_loaded' ); |
| 68 |
gmg_fs()->add_action( 'after_uninstall', 'gmg_fs_uninstall_cleanup' ); |
| 69 |
} |
| 70 |
/** |
| 71 |
* Freemius uninstall cleanup |
| 72 |
*/ |
| 73 |
function gmg_fs_uninstall_cleanup() { |
| 74 |
if ( !function_exists( 'gmedia_uninstall' ) ) { |
| 75 |
require_once dirname( __FILE__ ) . '/inc/functions.php'; |
| 76 |
} |
| 77 |
if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
| 78 |
global $wpdb; |
| 79 |
$blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A ); |
| 80 |
if ( $blogs ) { |
| 81 |
foreach ( $blogs as $blog ) { |
| 82 |
switch_to_blog( $blog['blog_id'] ); |
| 83 |
gmedia_uninstall(); |
| 84 |
restore_current_blog(); |
| 85 |
} |
| 86 |
} |
| 87 |
} else { |
| 88 |
gmedia_uninstall(); |
| 89 |
} |
| 90 |
} |
| 91 |
|
| 92 |
if ( !class_exists( 'Gmedia' ) ) { |
| 93 |
/** |
| 94 |
* Class Gmedia |
| 95 |
*/ |
| 96 |
class Gmedia { |
| 97 |
public $version = '1.25.1'; |
| 98 |
|
| 99 |
public $dbversion = '1.8.0'; |
| 100 |
|
| 101 |
public $minium_WP = '5.3'; |
| 102 |
|
| 103 |
public $options = ''; |
| 104 |
|
| 105 |
public $do_module = array(); |
| 106 |
|
| 107 |
public $import_styles = array(); |
| 108 |
|
| 109 |
public $shortcode = array(); |
| 110 |
|
| 111 |
public $plugin_name = ''; |
| 112 |
|
| 113 |
public function __construct() { |
| 114 |
// Stop the plugin if we missed the requirements. |
| 115 |
if ( !$this->required_version() ) { |
| 116 |
return; |
| 117 |
} |
| 118 |
// Get some constants first. |
| 119 |
include_once dirname( __FILE__ ) . '/config.php'; |
| 120 |
$this->load_options(); |
| 121 |
$this->define_constant(); |
| 122 |
$this->define_tables(); |
| 123 |
// Load global libraries. |
| 124 |
require_once dirname( __FILE__ ) . '/inc/core.php'; |
| 125 |
require_once dirname( __FILE__ ) . '/inc/db.connect.php'; |
| 126 |
require_once dirname( __FILE__ ) . '/inc/permalinks.php'; |
| 127 |
//if ( $this->options['debug_mode'] ) { |
| 128 |
// @ini_set( 'display_errors', true ); |
| 129 |
// error_reporting( E_ALL ); |
| 130 |
//} else { |
| 131 |
// @ini_set( 'display_errors', true ); //Ensure that Fatal errors are displayed. |
| 132 |
// error_reporting( E_CORE_ERROR | E_COMPILE_ERROR | E_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR ); |
| 133 |
//} |
| 134 |
$this->plugin_name = plugin_basename( __FILE__ ); |
| 135 |
add_filter( 'cron_schedules', array(&$this, 'gmedia_cron_schedules') ); |
| 136 |
// Init options & tables during activation & deregister init option. |
| 137 |
register_activation_hook( $this->plugin_name, array(&$this, 'activate') ); |
| 138 |
register_deactivation_hook( $this->plugin_name, array(&$this, 'deactivate') ); |
| 139 |
add_action( 'wp_enqueue_scripts', array(&$this, 'register_scripts_frontend'), 20 ); |
| 140 |
add_action( 'admin_enqueue_scripts', array(&$this, 'register_scripts_backend'), 8 ); |
| 141 |
add_action( |
| 142 |
'wpmu_new_blog', |
| 143 |
array(&$this, 'new_blog'), |
| 144 |
10, |
| 145 |
6 |
| 146 |
); |
| 147 |
// Start this plugin once all other plugins are fully loaded. |
| 148 |
add_action( 'plugins_loaded', array(&$this, 'start_plugin') ); |
| 149 |
add_action( |
| 150 |
'deleted_user', |
| 151 |
array(&$this, 'reassign_media'), |
| 152 |
10, |
| 153 |
2 |
| 154 |
); |
| 155 |
add_action( 'init', array(&$this, 'gmedia_post_type'), 0 ); |
| 156 |
add_action( 'init', array(&$this, 'compatibility'), 11 ); |
| 157 |
//add_action('init', array(&$this, 'gm_schedule_update_checks'), 0); |
| 158 |
// register widget. |
| 159 |
add_action( 'widgets_init', array(&$this, 'register_gmedia_widget') ); |
| 160 |
add_action( 'gmedia_app_cronjob', array(&$this, 'gmedia_app_cronjob') ); |
| 161 |
add_action( 'gmedia_modules_update', array(&$this, 'gmedia_modules_update') ); |
| 162 |
//Add some message on the plugins page. |
| 163 |
//add_action( 'after_plugin_row', array(&$this, 'check_message_version') ); |
| 164 |
//Add some links on the plugins page. |
| 165 |
add_filter( |
| 166 |
'plugin_row_meta', |
| 167 |
array(&$this, 'add_plugin_links'), |
| 168 |
10, |
| 169 |
2 |
| 170 |
); |
| 171 |
} |
| 172 |
|
| 173 |
public function start_plugin() { |
| 174 |
$this->load_dependencies(); |
| 175 |
// Load the language file. |
| 176 |
$this->load_textdomain(); |
| 177 |
require_once dirname( __FILE__ ) . '/inc/functions.php'; |
| 178 |
// Check for upgrade. |
| 179 |
$this->upgrade(); |
| 180 |
require_once dirname( __FILE__ ) . '/inc/hashids.php'; |
| 181 |
require_once dirname( __FILE__ ) . '/inc/shortcodes.php'; |
| 182 |
// Load the admin panel or the frontend functions. |
| 183 |
if ( is_admin() ) { |
| 184 |
// Pass the init check or show a message. |
| 185 |
if ( get_option( 'gmediaActivated' ) ) { |
| 186 |
add_action( 'init', array(&$this, 'gmedia_after_activation') ); |
| 187 |
} |
| 188 |
// Pass the init check or show a message. |
| 189 |
if ( get_option( 'gmediaInitCheck' ) ) { |
| 190 |
add_action( 'admin_notices', array(&$this, 'admin_notices') ); |
| 191 |
} |
| 192 |
require_once dirname( __FILE__ ) . '/admin/functions.php'; |
| 193 |
require_once dirname( __FILE__ ) . '/admin/class.processor.php'; |
| 194 |
} else { |
| 195 |
// Add the script and style files. |
| 196 |
//add_action('wp_enqueue_scripts', array(&$this, 'load_scripts'), 4); |
| 197 |
require_once dirname( __FILE__ ) . '/inc/frontend.filters.php'; |
| 198 |
// Add a version number to the header. |
| 199 |
add_action( 'wp_head', array(&$this, 'gmedia_head_meta') ); |
| 200 |
add_action( 'wp_footer', array(&$this, 'load_module_scripts') ); |
| 201 |
} |
| 202 |
add_action( 'gmedia_head', array(&$this, 'gmedia_head_meta') ); |
| 203 |
add_action( 'gmedia_head', array(&$this, 'load_scripts'), 2 ); |
| 204 |
add_action( 'gmedia_head', 'wp_print_head_scripts', 9 ); |
| 205 |
add_action( 'gmedia_enqueue_scripts', array(&$this, 'load_module_scripts') ); |
| 206 |
add_action( 'gmedia_head', array(&$this, 'print_import_styles') ); |
| 207 |
add_action( 'gmedia_footer', array(&$this, 'print_import_styles') ); |
| 208 |
} |
| 209 |
|
| 210 |
public function gmedia_head_meta() { |
| 211 |
$lk = strtolower( $this->options['license_key'] ); |
| 212 |
$db_version = get_option( 'gmediaDbVersion' ); |
| 213 |
echo "\n" . '<!-- <meta name="GmediaGallery" version="' . esc_attr( $this->version . '/' . $db_version ) . '" license="' . esc_attr( $lk ) . '" /> -->' . "\n"; |
| 214 |
} |
| 215 |
|
| 216 |
public function admin_notices() { |
| 217 |
echo '<div id="message" class="error"><p><strong>' . esc_html( get_option( 'gmediaInitCheck' ) ) . '</strong></p></div>'; |
| 218 |
delete_option( 'gmediaInitCheck' ); |
| 219 |
} |
| 220 |
|
| 221 |
/** |
| 222 |
* @return bool |
| 223 |
*/ |
| 224 |
public function required_version() { |
| 225 |
global $wp_version; |
| 226 |
// Check for WP version installation. |
| 227 |
if ( version_compare( $wp_version, $this->minium_WP, '<' ) ) { |
| 228 |
// translators: version. |
| 229 |
$note = sprintf( __( 'Sorry, Gmedia Gallery works only under WordPress %s or higher', 'grand-media' ), $this->minium_WP ); |
| 230 |
update_option( 'gmediaInitCheck', $note ); |
| 231 |
add_action( 'admin_notices', array(&$this, 'admin_notices') ); |
| 232 |
return false; |
| 233 |
} |
| 234 |
if ( version_compare( '5.3', phpversion(), '>' ) ) { |
| 235 |
// translators: version. |
| 236 |
$note = sprintf( __( 'Attention! Your server php version is: %s. Gmedia Gallery requires php version 5.3+ in order to run properly. Please upgrade your server!', 'grand-media' ), phpversion() ); |
| 237 |
update_option( 'gmediaInitCheck', $note ); |
| 238 |
add_action( 'admin_notices', array(&$this, 'admin_notices') ); |
| 239 |
return false; |
| 240 |
} |
| 241 |
return true; |
| 242 |
} |
| 243 |
|
| 244 |
/** |
| 245 |
* Called via Setup and register_activate hook after gmedia_install() function |
| 246 |
*/ |
| 247 |
public function gmedia_after_activation() { |
| 248 |
global $gmCore; |
| 249 |
delete_option( 'gmediaActivated' ); |
| 250 |
flush_rewrite_rules( false ); |
| 251 |
if ( (int) $this->options['mobile_app'] ) { |
| 252 |
wp_clear_scheduled_hook( 'gmedia_app_cronjob' ); |
| 253 |
wp_schedule_event( time(), 'gmedia_app', 'gmedia_app_cronjob' ); |
| 254 |
$gmCore->app_service( 'app_activateplugin' ); |
| 255 |
} |
| 256 |
$wp_installing = defined( 'WP_INSTALLING' ) && WP_INSTALLING; |
| 257 |
if ( !wp_next_scheduled( 'gmedia_modules_update' ) && !$wp_installing ) { |
| 258 |
wp_schedule_event( time(), 'daily', 'gmedia_modules_update' ); |
| 259 |
} |
| 260 |
} |
| 261 |
|
| 262 |
public function upgrade() { |
| 263 |
// Queue upgrades. |
| 264 |
$current_version = get_option( 'gmediaVersion', null ); |
| 265 |
$current_db_version = get_option( 'gmediaDbVersion', null ); |
| 266 |
if ( null === $current_db_version ) { |
| 267 |
add_option( 'gmediaDbVersion', GMEDIA_DBVERSION ); |
| 268 |
} elseif ( version_compare( $current_db_version, GMEDIA_DBVERSION, '<' ) ) { |
| 269 |
require_once dirname( __FILE__ ) . '/config/update.php'; |
| 270 |
if ( get_transient( 'gmediaUpgrade' ) || isset( $_GET['do_update'] ) && 'gmedia' === $_GET['do_update'] ) { |
| 271 |
add_action( 'admin_notices', 'gmedia_upgrade_process_admin_notice' ); |
| 272 |
} else { |
| 273 |
add_action( 'admin_notices', 'gmedia_upgrade_required_admin_notice' ); |
| 274 |
} |
| 275 |
} |
| 276 |
if ( null === $current_version ) { |
| 277 |
require_once dirname( __FILE__ ) . '/config/update.php'; |
| 278 |
add_option( 'gmediaVersion', GMEDIA_VERSION ); |
| 279 |
add_action( 'init', 'gmedia_flush_rewrite_rules', 1000 ); |
| 280 |
} elseif ( version_compare( $current_version, GMEDIA_VERSION, '<' ) ) { |
| 281 |
require_once dirname( __FILE__ ) . '/config/update.php'; |
| 282 |
gmedia_quite_update(); |
| 283 |
gmedia_delete_transients( 'gm_cache' ); |
| 284 |
add_action( 'init', 'gmedia_flush_rewrite_rules', 1000 ); |
| 285 |
if ( (int) $this->options['mobile_app'] ) { |
| 286 |
if ( !wp_get_schedule( 'gmedia_app_cronjob' ) ) { |
| 287 |
wp_schedule_event( time(), 'gmedia_app', 'gmedia_app_cronjob' ); |
| 288 |
} |
| 289 |
global $gmCore; |
| 290 |
$gmCore->app_service( 'app_updatecron' ); |
| 291 |
} |
| 292 |
} |
| 293 |
} |
| 294 |
|
| 295 |
public function define_tables() { |
| 296 |
global $wpdb; |
| 297 |
// add database pointer. |
| 298 |
$wpdb->gmedia = $wpdb->prefix . 'gmedia'; |
| 299 |
$wpdb->gmedia_meta = $wpdb->prefix . 'gmedia_meta'; |
| 300 |
$wpdb->gmedia_term = $wpdb->prefix . 'gmedia_term'; |
| 301 |
$wpdb->gmedia_term_meta = $wpdb->prefix . 'gmedia_term_meta'; |
| 302 |
$wpdb->gmedia_term_relationships = $wpdb->prefix . 'gmedia_term_relationships'; |
| 303 |
} |
| 304 |
|
| 305 |
public function define_constant() { |
| 306 |
define( 'GMEDIA_VERSION', $this->version ); |
| 307 |
// Minimum required database version. |
| 308 |
define( 'GMEDIA_DBVERSION', $this->dbversion ); |
| 309 |
} |
| 310 |
|
| 311 |
public function load_options() { |
| 312 |
include_once dirname( __FILE__ ) . '/config/setup.php'; |
| 313 |
// Load the options. |
| 314 |
$default_options = gmedia_default_options(); |
| 315 |
$db_options = get_option( 'gmediaOptions' ); |
| 316 |
if ( !is_array( $db_options ) ) { |
| 317 |
$db_options = array(); |
| 318 |
} |
| 319 |
$this->options = array_merge( $default_options, $db_options ); |
| 320 |
if ( function_exists( 'gmg_fs' ) ) { |
| 321 |
$fs = gmg_fs(); |
| 322 |
if ( $fs->has_active_valid_license() ) { |
| 323 |
$this->options['license_key'] = 'freemius'; |
| 324 |
$this->options['license_key2'] = 'freemius'; |
| 325 |
} |
| 326 |
} |
| 327 |
} |
| 328 |
|
| 329 |
public function load_dependencies() { |
| 330 |
// We didn't need all stuff during an AJAX operation. |
| 331 |
if ( defined( 'DOING_AJAX' ) ) { |
| 332 |
require_once dirname( __FILE__ ) . '/admin/ajax.php'; |
| 333 |
} else { |
| 334 |
// Load backend libraries. |
| 335 |
if ( is_admin() ) { |
| 336 |
require_once dirname( __FILE__ ) . '/inc/media-upload.php'; |
| 337 |
require_once dirname( __FILE__ ) . '/inc/post-metabox.php'; |
| 338 |
require_once dirname( __FILE__ ) . '/admin/admin.php'; |
| 339 |
// Load frontend libraries. |
| 340 |
} |
| 341 |
$current_plugins = get_option( 'active_plugins' ); |
| 342 |
if ( in_array( 'wordpress-seo/wp-seo.php', $current_plugins, true ) ) { |
| 343 |
require_once dirname( __FILE__ ) . '/inc/sitemap.php'; |
| 344 |
} |
| 345 |
} |
| 346 |
} |
| 347 |
|
| 348 |
public function compatibility() { |
| 349 |
global $allowedposttags, $gm_allowed_tags; |
| 350 |
require_once dirname( __FILE__ ) . '/inc/compatibility.php'; |
| 351 |
$allowed_tags = $allowedposttags; |
| 352 |
$allowed_tags['template'] = array( |
| 353 |
'data-gmedia' => array(), |
| 354 |
); |
| 355 |
$gm_allowed_tags = wp_kses_allowed_html( $allowed_tags ); |
| 356 |
} |
| 357 |
|
| 358 |
public function load_textdomain() { |
| 359 |
load_plugin_textdomain( 'grand-media', false, GMEDIA_FOLDER . '/lang/' ); |
| 360 |
} |
| 361 |
|
| 362 |
public function register_scripts_backend() { |
| 363 |
global $gmCore; |
| 364 |
wp_register_script( |
| 365 |
'gmedia-global-backend', |
| 366 |
$gmCore->gmedia_url . '/admin/assets/js/gmedia.global.js', |
| 367 |
array('jquery', 'underscore'), |
| 368 |
'1.13.0', |
| 369 |
true |
| 370 |
); |
| 371 |
wp_localize_script( 'gmedia-global-backend', 'GmediaGallery', array( |
| 372 |
'ajaxurl' => admin_url( 'admin-ajax.php' ), |
| 373 |
'_wpnonce' => wp_create_nonce( 'GmediaGallery' ), |
| 374 |
'upload_dirurl' => $gmCore->upload['url'], |
| 375 |
'plugin_dirurl' => $gmCore->gmedia_url, |
| 376 |
'google_api_key' => $this->options['google_api_key'], |
| 377 |
) ); |
| 378 |
wp_register_style( |
| 379 |
'fontawesome', |
| 380 |
$gmCore->gmedia_url . '/assets/fontawesome/css/all.min.css', |
| 381 |
array(), |
| 382 |
'6.1.1' |
| 383 |
); |
| 384 |
wp_register_style( |
| 385 |
'gmedia-bootstrap', |
| 386 |
$gmCore->gmedia_url . '/assets/bootstrap/css/bootstrap.min.css', |
| 387 |
array(), |
| 388 |
'5.1.3' |
| 389 |
); |
| 390 |
wp_register_script( |
| 391 |
'gmedia-bootstrap', |
| 392 |
$gmCore->gmedia_url . '/assets/bootstrap/js/bootstrap.bundle.min.js', |
| 393 |
array('jquery'), |
| 394 |
'5.1.3', |
| 395 |
true |
| 396 |
); |
| 397 |
wp_register_style( |
| 398 |
'grand-media', |
| 399 |
$gmCore->gmedia_url . '/admin/assets/css/gmedia.admin.css', |
| 400 |
array('gmedia-bootstrap', 'fontawesome'), |
| 401 |
$this->version |
| 402 |
); |
| 403 |
wp_register_script( |
| 404 |
'grand-media', |
| 405 |
$gmCore->gmedia_url . '/admin/assets/js/gmedia.admin.js', |
| 406 |
array('jquery', 'gmedia-bootstrap', 'gmedia-global-backend'), |
| 407 |
$this->version, |
| 408 |
true |
| 409 |
); |
| 410 |
wp_localize_script( 'grand-media', 'grandMedia', array( |
| 411 |
'error3' => __( 'Disable your Popup Blocker and try again.', 'grand-media' ), |
| 412 |
'download' => __( 'downloading...', 'grand-media' ), |
| 413 |
'wait' => __( 'Working. Wait please.', 'grand-media' ), |
| 414 |
'_wpnonce' => wp_create_nonce( 'GmediaGallery' ), |
| 415 |
) ); |
| 416 |
wp_register_script( |
| 417 |
'outside-events', |
| 418 |
$gmCore->gmedia_url . '/assets/jq-plugins/outside-events.js', |
| 419 |
array('jquery'), |
| 420 |
'1.1', |
| 421 |
true |
| 422 |
); |
| 423 |
} |
| 424 |
|
| 425 |
public function register_scripts_frontend() { |
| 426 |
global $gmCore, $wp_scripts; |
| 427 |
wp_register_style( |
| 428 |
'gmedia-global-frontend', |
| 429 |
$gmCore->gmedia_url . '/assets/gmedia.global.front.css', |
| 430 |
array(), |
| 431 |
'1.15.0' |
| 432 |
); |
| 433 |
wp_register_script( |
| 434 |
'gmedia-global-frontend', |
| 435 |
$gmCore->gmedia_url . '/assets/gmedia.global.front.js', |
| 436 |
array('jquery'), |
| 437 |
'1.13.0', |
| 438 |
true |
| 439 |
); |
| 440 |
wp_localize_script( 'gmedia-global-frontend', 'GmediaGallery', array( |
| 441 |
'ajaxurl' => admin_url( 'admin-ajax.php' ), |
| 442 |
'nonce' => wp_create_nonce( 'GmediaGallery' ), |
| 443 |
'upload_dirurl' => $gmCore->upload['url'], |
| 444 |
'plugin_dirurl' => $gmCore->upload['url'], |
| 445 |
'license' => strtolower( $this->options['license_key'] ), |
| 446 |
'license2' => $this->options['license_key2'], |
| 447 |
'google_api_key' => $this->options['google_api_key'], |
| 448 |
) ); |
| 449 |
if ( !wp_script_is( 'velocity', 'registered' ) || version_compare( $wp_scripts->registered['velocity']->ver, '1.4.1', '<' ) ) { |
| 450 |
wp_deregister_script( 'velocity' ); |
| 451 |
wp_register_script( |
| 452 |
'velocity', |
| 453 |
$gmCore->gmedia_url . '/assets/velocity/velocity.min.js', |
| 454 |
array('jquery'), |
| 455 |
'1.4.1', |
| 456 |
true |
| 457 |
); |
| 458 |
} |
| 459 |
if ( !wp_script_is( 'wavesurfer', 'registered' ) ) { |
| 460 |
wp_register_script( |
| 461 |
'wavesurfer', |
| 462 |
$gmCore->gmedia_url . '/assets/wavesurfer/wavesurfer.min.js', |
| 463 |
array('jquery'), |
| 464 |
'1.2.8', |
| 465 |
true |
| 466 |
); |
| 467 |
} |
| 468 |
if ( !wp_script_is( 'swiper', 'registered' ) ) { |
| 469 |
wp_register_script( |
| 470 |
'swiper', |
| 471 |
$gmCore->gmedia_url . '/assets/swiper/swiper.min.js', |
| 472 |
array('jquery'), |
| 473 |
'5.3.6', |
| 474 |
true |
| 475 |
); |
| 476 |
} |
| 477 |
if ( !wp_style_is( 'swiper', 'registered' ) ) { |
| 478 |
wp_register_style( |
| 479 |
'swiper', |
| 480 |
$gmCore->gmedia_url . '/assets/swiper/swiper.min.css', |
| 481 |
array(), |
| 482 |
'5.3.6', |
| 483 |
'screen' |
| 484 |
); |
| 485 |
} |
| 486 |
if ( !wp_script_is( 'photoswipe', 'registered' ) || version_compare( $wp_scripts->registered['photoswipe']->ver, '3.0.5', '<=' ) ) { |
| 487 |
wp_deregister_style( 'photoswipe' ); |
| 488 |
wp_deregister_script( 'photoswipe' ); |
| 489 |
wp_register_style( |
| 490 |
'photoswipe', |
| 491 |
$gmCore->gmedia_url . '/assets/photoswipe/photoswipe.css', |
| 492 |
array(), |
| 493 |
GMEDIA_VERSION, |
| 494 |
'screen' |
| 495 |
); |
| 496 |
wp_register_script( |
| 497 |
'photoswipe', |
| 498 |
$gmCore->gmedia_url . '/assets/photoswipe/photoswipe.jquery.min.js', |
| 499 |
array('jquery'), |
| 500 |
'3.0.5', |
| 501 |
true |
| 502 |
); |
| 503 |
} |
| 504 |
if ( !wp_script_is( 'easing', 'registered' ) || false !== $wp_scripts->registered['easing']->ver && version_compare( $wp_scripts->registered['easing']->ver, '1.3.0', '<' ) ) { |
| 505 |
wp_deregister_script( 'easing' ); |
| 506 |
wp_register_script( |
| 507 |
'easing', |
| 508 |
$gmCore->gmedia_url . '/assets/jq-plugins/jquery.easing.js', |
| 509 |
array('jquery'), |
| 510 |
'1.3.0', |
| 511 |
true |
| 512 |
); |
| 513 |
} |
| 514 |
if ( !wp_script_is( 'fancybox', 'registered' ) || false !== $wp_scripts->registered['fancybox']->ver && version_compare( $wp_scripts->registered['fancybox']->ver, '1.3.4', '<' ) ) { |
| 515 |
if ( !defined( 'FANCYBOX_VERSION' ) ) { |
| 516 |
wp_deregister_style( 'fancybox' ); |
| 517 |
wp_register_style( |
| 518 |
'fancybox', |
| 519 |
$gmCore->gmedia_url . '/assets/fancybox/jquery.fancybox-1.3.4.css', |
| 520 |
array(), |
| 521 |
'1.3.4' |
| 522 |
); |
| 523 |
} |
| 524 |
wp_deregister_script( 'fancybox' ); |
| 525 |
wp_register_script( |
| 526 |
'fancybox', |
| 527 |
$gmCore->gmedia_url . '/assets/fancybox/jquery.fancybox-1.3.4.pack.js', |
| 528 |
array('jquery', 'easing'), |
| 529 |
'1.3.4', |
| 530 |
true |
| 531 |
); |
| 532 |
} |
| 533 |
if ( !wp_script_is( 'jplayer', 'registered' ) || version_compare( $wp_scripts->registered['jplayer']->ver, '2.6.4', '<' ) ) { |
| 534 |
wp_deregister_script( 'jplayer' ); |
| 535 |
wp_register_script( |
| 536 |
'jplayer', |
| 537 |
$gmCore->gmedia_url . '/assets/jplayer/jquery.jplayer.min.js', |
| 538 |
array('jquery'), |
| 539 |
'2.6.4', |
| 540 |
true |
| 541 |
); |
| 542 |
} |
| 543 |
wp_register_script( |
| 544 |
'mousetrap', |
| 545 |
$gmCore->gmedia_url . '/assets/mousetrap/mousetrap.min.js', |
| 546 |
array(), |
| 547 |
'1.5.2', |
| 548 |
true |
| 549 |
); |
| 550 |
$this->load_scripts(); |
| 551 |
} |
| 552 |
|
| 553 |
public function load_scripts() { |
| 554 |
wp_enqueue_script( 'jquery' ); |
| 555 |
wp_enqueue_style( 'gmedia-global-frontend' ); |
| 556 |
wp_enqueue_script( 'gmedia-global-frontend' ); |
| 557 |
} |
| 558 |
|
| 559 |
public function load_module_scripts() { |
| 560 |
global $wp_styles; |
| 561 |
$deps = array(); |
| 562 |
$xmlhttprequest = isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && 'xmlhttprequest' === strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ); |
| 563 |
foreach ( $this->do_module as $m => $module ) { |
| 564 |
$deps = array_merge( $deps, explode( ',', $module['info']['dependencies'] ) ); |
| 565 |
$deps = apply_filters( 'gmedia_module_js_dependencies', $deps, $m ); |
| 566 |
$deps = array_filter( array_unique( $deps ) ); |
| 567 |
foreach ( $deps as $handle ) { |
| 568 |
if ( wp_script_is( $handle, 'registered' ) ) { |
| 569 |
wp_enqueue_script( |
| 570 |
$handle, |
| 571 |
false, |
| 572 |
array('jquery'), |
| 573 |
$this->version, |
| 574 |
true |
| 575 |
); |
| 576 |
if ( $xmlhttprequest ) { |
| 577 |
wp_print_scripts( $handle ); |
| 578 |
} |
| 579 |
} |
| 580 |
if ( wp_style_is( $handle, 'registered' ) ) { |
| 581 |
//wp_print_styles($handle); |
| 582 |
$this->import_styles[$handle] = $wp_styles->registered[$handle]->src; |
| 583 |
} |
| 584 |
} |
| 585 |
//$files = glob($module['path'] . '/css/*.css', GLOB_NOSORT); |
| 586 |
//if(!empty($files)){ |
| 587 |
// $files = array_map('basename', $files); |
| 588 |
// foreach($files as $file){ |
| 589 |
// $this->import_styles[] = "{$module['url']}/css/{$file}"; |
| 590 |
// } |
| 591 |
//} |
| 592 |
$files = glob( $module['path'] . '/js/*.js', GLOB_NOSORT ); |
| 593 |
if ( !empty( $files ) ) { |
| 594 |
$files = array_map( 'basename', $files ); |
| 595 |
$files_deps = array_merge( array('jquery'), $deps ); |
| 596 |
foreach ( $files as $file ) { |
| 597 |
$_ver = ( isset( $module['info']['version'] ) ? $module['info']['version'] : false ); |
| 598 |
$handle = "{$module['name']}_{$file}"; |
| 599 |
wp_enqueue_script( |
| 600 |
$handle, |
| 601 |
"{$module['url']}/js/{$file}", |
| 602 |
$files_deps, |
| 603 |
$_ver, |
| 604 |
[ |
| 605 |
'strategy' => 'defer', |
| 606 |
'in_footer' => true, |
| 607 |
] |
| 608 |
); |
| 609 |
if ( $xmlhttprequest ) { |
| 610 |
wp_print_scripts( $handle ); |
| 611 |
} |
| 612 |
} |
| 613 |
} |
| 614 |
} |
| 615 |
$this->do_module = array(); |
| 616 |
if ( !empty( $this->import_styles ) ) { |
| 617 |
add_action( 'wp_print_head_scripts', array(&$this, 'print_import_styles'), 1 ); |
| 618 |
add_action( 'wp_print_footer_scripts', array(&$this, 'print_import_styles'), 1 ); |
| 619 |
} |
| 620 |
if ( $xmlhttprequest ) { |
| 621 |
$this->print_import_styles(); |
| 622 |
} |
| 623 |
} |
| 624 |
|
| 625 |
/** |
| 626 |
* Return module styles like <style>@import(...)</style> |
| 627 |
* |
| 628 |
* @param array $module |
| 629 |
* |
| 630 |
* @return string |
| 631 |
*/ |
| 632 |
public function load_module_styles( $module ) { |
| 633 |
$module_styles = ''; |
| 634 |
$files = glob( $module['path'] . '/css/*.css', GLOB_NOSORT ); |
| 635 |
if ( !empty( $files ) ) { |
| 636 |
$_ver = ( isset( $module['info']['version'] ) ? $module['info']['version'] . '-' . GMEDIA_VERSION : GMEDIA_VERSION ); |
| 637 |
$files = array_map( 'basename', $files ); |
| 638 |
foreach ( $files as $file ) { |
| 639 |
$src = "{$module['url']}/css/{$file}"; |
| 640 |
if ( 'http' !== substr( $src, 0, 4 ) ) { |
| 641 |
$src = site_url( $src ); |
| 642 |
} |
| 643 |
$src = add_query_arg( array( |
| 644 |
'v' => $_ver, |
| 645 |
), $src ); |
| 646 |
$module_styles .= "@import url('{$src}') all;"; |
| 647 |
} |
| 648 |
} |
| 649 |
return $module_styles; |
| 650 |
} |
| 651 |
|
| 652 |
public function print_import_styles() { |
| 653 |
if ( !empty( $this->import_styles ) ) { |
| 654 |
echo "\n<style class='gmedia_assets_style_import'>"; |
| 655 |
foreach ( $this->import_styles as $src ) { |
| 656 |
if ( 'http' !== substr( $src, 0, 4 ) ) { |
| 657 |
$src = site_url( $src ); |
| 658 |
} |
| 659 |
echo "\n@import url('" . esc_url( $src ) . "') all;"; |
| 660 |
} |
| 661 |
echo "\n</style>\n"; |
| 662 |
$this->import_styles = array(); |
| 663 |
} |
| 664 |
} |
| 665 |
|
| 666 |
/** |
| 667 |
* Call user function to all blogs in network |
| 668 |
* called during register_activation hook |
| 669 |
* |
| 670 |
* @param string $pfunction UserFunction name. |
| 671 |
* @param bool $networkwide Check if plugin has been activated for the entire blog network. |
| 672 |
* |
| 673 |
* @return void |
| 674 |
*/ |
| 675 |
public static function network_propagate( $pfunction, $networkwide ) { |
| 676 |
include_once dirname( __FILE__ ) . '/config/setup.php'; |
| 677 |
if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
| 678 |
// check if it is a network activation - if so, run the activation function. |
| 679 |
// for each blog id. |
| 680 |
if ( $networkwide ) { |
| 681 |
global $wpdb; |
| 682 |
//$old_blog = $wpdb->blogid; |
| 683 |
// Get all blog ids. |
| 684 |
$blogids = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" ); |
| 685 |
foreach ( $blogids as $blog_id ) { |
| 686 |
switch_to_blog( $blog_id ); |
| 687 |
call_user_func( $pfunction ); |
| 688 |
} |
| 689 |
//switch_to_blog($old_blog); |
| 690 |
restore_current_blog(); |
| 691 |
return; |
| 692 |
} |
| 693 |
} |
| 694 |
call_user_func( $pfunction ); |
| 695 |
} |
| 696 |
|
| 697 |
/** |
| 698 |
* @param $networkwide |
| 699 |
*/ |
| 700 |
public function activate( $networkwide ) { |
| 701 |
$this->network_propagate( 'gmedia_install', $networkwide ); |
| 702 |
} |
| 703 |
|
| 704 |
/** |
| 705 |
* @param $networkwide |
| 706 |
*/ |
| 707 |
public function deactivate( $networkwide ) { |
| 708 |
$this->network_propagate( 'gmedia_deactivate', $networkwide ); |
| 709 |
} |
| 710 |
|
| 711 |
/* |
| 712 |
public static function uninstall($networkwide) { |
| 713 |
//wp_die( '<h1>This is run on <code>init</code> during uninstallation</h1>', 'Uninstallation hook example' ); |
| 714 |
Gmedia::network_propagate('gmedia_uninstall', $networkwide); |
| 715 |
} |
| 716 |
*/ |
| 717 |
/** |
| 718 |
* @param $blog_id |
| 719 |
* @param $user_id |
| 720 |
* @param $domain |
| 721 |
* @param $path |
| 722 |
* @param $site_id |
| 723 |
* @param $meta |
| 724 |
*/ |
| 725 |
public function new_blog( |
| 726 |
$blog_id, |
| 727 |
$user_id, |
| 728 |
$domain, |
| 729 |
$path, |
| 730 |
$site_id, |
| 731 |
$meta |
| 732 |
) { |
| 733 |
if ( is_plugin_active_for_network( GMEDIA_FOLDER . '/grand-media.php' ) ) { |
| 734 |
include_once dirname( __FILE__ ) . '/config/setup.php'; |
| 735 |
switch_to_blog( $blog_id ); |
| 736 |
gmedia_install(); |
| 737 |
restore_current_blog(); |
| 738 |
} |
| 739 |
} |
| 740 |
|
| 741 |
/** |
| 742 |
* @param $user_id |
| 743 |
* @param $reassign |
| 744 |
*/ |
| 745 |
public function reassign_media( $user_id, $reassign ) { |
| 746 |
global $gmDB; |
| 747 |
$gmDB->reassign_media( $user_id, $reassign ); |
| 748 |
} |
| 749 |
|
| 750 |
/** |
| 751 |
* Register Gmedia Post Types |
| 752 |
*/ |
| 753 |
public function gmedia_post_type() { |
| 754 |
$args = array( |
| 755 |
'label' => __( 'Gmedia Posts', 'grand-media' ), |
| 756 |
'supports' => array('comments'), |
| 757 |
'hierarchical' => false, |
| 758 |
'public' => true, |
| 759 |
'show_ui' => false, |
| 760 |
'show_in_menu' => false, |
| 761 |
'show_in_admin_bar' => false, |
| 762 |
'show_in_nav_menus' => false, |
| 763 |
'can_export' => false, |
| 764 |
'has_archive' => (bool) (int) $this->options['gmedia_has_archive'], |
| 765 |
'publicly_queryable' => true, |
| 766 |
'exclude_from_search' => (bool) (int) $this->options['gmedia_exclude_from_search'], |
| 767 |
'rewrite' => array( |
| 768 |
'slug' => $this->options['gmedia_post_slug'], |
| 769 |
), |
| 770 |
'map_meta_cap' => true, |
| 771 |
'capabilities' => array( |
| 772 |
'read_private_posts' => 'read_private_gmedia_posts', |
| 773 |
'create_posts' => false, |
| 774 |
), |
| 775 |
); |
| 776 |
register_post_type( 'gmedia', $args ); |
| 777 |
$args['label'] = __( 'Gmedia Albums', 'grand-media' ); |
| 778 |
$args['show_in_nav_menus'] = true; |
| 779 |
$args['hierarchical'] = true; |
| 780 |
$args['has_archive'] = (bool) (int) $this->options['gmedia_album_has_archive']; |
| 781 |
$args['exclude_from_search'] = (bool) (int) $this->options['gmedia_album_exclude_from_search']; |
| 782 |
$args['rewrite'] = array( |
| 783 |
'slug' => $this->options['gmedia_album_post_slug'], |
| 784 |
); |
| 785 |
register_post_type( 'gmedia_album', $args ); |
| 786 |
$args['label'] = __( 'Gmedia Galleries', 'grand-media' ); |
| 787 |
$args['has_archive'] = (bool) (int) $this->options['gmedia_gallery_has_archive']; |
| 788 |
$args['exclude_from_search'] = (bool) (int) $this->options['gmedia_gallery_exclude_from_search']; |
| 789 |
$args['rewrite'] = array( |
| 790 |
'slug' => $this->options['gmedia_gallery_post_slug'], |
| 791 |
); |
| 792 |
register_post_type( 'gmedia_gallery', $args ); |
| 793 |
add_filter( |
| 794 |
'get_gmedia_metadata', |
| 795 |
array($this, 'get_gmedia_metadata'), |
| 796 |
10, |
| 797 |
4 |
| 798 |
); |
| 799 |
add_filter( |
| 800 |
'get_gmedia_term_metadata', |
| 801 |
array($this, 'get_gmedia_term_metadata'), |
| 802 |
10, |
| 803 |
4 |
| 804 |
); |
| 805 |
add_filter( |
| 806 |
'get_edit_post_link', |
| 807 |
array($this, 'gmedia_post_type_edit_link'), |
| 808 |
10, |
| 809 |
3 |
| 810 |
); |
| 811 |
$args = array( |
| 812 |
'hierarchical' => false, |
| 813 |
'public' => true, |
| 814 |
'show_ui' => false, |
| 815 |
'show_admin_column' => false, |
| 816 |
'show_in_nav_menus' => false, |
| 817 |
'show_tagcloud' => false, |
| 818 |
'rewrite' => array( |
| 819 |
'slug' => 'gmedia-category', |
| 820 |
), |
| 821 |
); |
| 822 |
$args['labels'] = array( |
| 823 |
'name' => _x( 'Gmedia Categories', 'Taxonomy General Name', 'grand-media' ), |
| 824 |
'singular_name' => _x( 'Gmedia Category', 'Taxonomy Singular Name', 'grand-media' ), |
| 825 |
'menu_name' => __( 'Gmedia Categories', 'grand-media' ), |
| 826 |
); |
| 827 |
register_taxonomy( 'gmedia_category', null, $args ); |
| 828 |
$args['rewrite'] = array( |
| 829 |
'slug' => 'gmedia-tag', |
| 830 |
); |
| 831 |
$args['labels'] = array( |
| 832 |
'name' => _x( 'Gmedia Tags', 'Taxonomy General Name', 'grand-media' ), |
| 833 |
'singular_name' => _x( 'Gmedia Tag', 'Taxonomy Singular Name', 'grand-media' ), |
| 834 |
'menu_name' => __( 'Gmedia Tags', 'grand-media' ), |
| 835 |
); |
| 836 |
register_taxonomy( 'gmedia_tag', null, $args ); |
| 837 |
add_filter( 'wp_link_query_args', array($this, 'exclude_gmedia_from_link_query') ); |
| 838 |
if ( !empty( $this->options['flush_rewrite_rules'] ) ) { |
| 839 |
unset($this->options['flush_rewrite_rules']); |
| 840 |
update_option( 'gmediaOptions', $this->options ); |
| 841 |
flush_rewrite_rules( false ); |
| 842 |
} |
| 843 |
} |
| 844 |
|
| 845 |
/** |
| 846 |
* Get gmedia metadata |
| 847 |
* |
| 848 |
* @param $meta |
| 849 |
* @param $post_ID |
| 850 |
* @param $meta_key |
| 851 |
* @param $single |
| 852 |
* |
| 853 |
* @return array|string |
| 854 |
*/ |
| 855 |
public function get_gmedia_metadata( |
| 856 |
$meta, |
| 857 |
$post_ID, |
| 858 |
$meta_key, |
| 859 |
$single |
| 860 |
) { |
| 861 |
global $gmDB; |
| 862 |
$gmedia_id = get_post_meta( $post_ID, '_gmedia_ID', true ); |
| 863 |
$meta = $gmDB->get_metadata( |
| 864 |
'gmedia', |
| 865 |
$gmedia_id, |
| 866 |
$meta_key, |
| 867 |
$single |
| 868 |
); |
| 869 |
return $meta; |
| 870 |
} |
| 871 |
|
| 872 |
/** |
| 873 |
* Get gmedia term metadata |
| 874 |
* |
| 875 |
* @param $meta |
| 876 |
* @param $post_ID |
| 877 |
* @param $meta_key |
| 878 |
* @param $single |
| 879 |
* |
| 880 |
* @return array|string |
| 881 |
*/ |
| 882 |
public function get_gmedia_term_metadata( |
| 883 |
$meta, |
| 884 |
$post_ID, |
| 885 |
$meta_key, |
| 886 |
$single |
| 887 |
) { |
| 888 |
global $gmDB; |
| 889 |
$gmedia_term_id = get_post_meta( $post_ID, '_gmedia_term_ID', true ); |
| 890 |
$meta = $gmDB->get_metadata( |
| 891 |
'gmedia_term', |
| 892 |
$gmedia_term_id, |
| 893 |
$meta_key, |
| 894 |
$single |
| 895 |
); |
| 896 |
return $meta; |
| 897 |
} |
| 898 |
|
| 899 |
/** |
| 900 |
* Edit link for gmedia |
| 901 |
* |
| 902 |
* @param $link |
| 903 |
* @param $post_ID |
| 904 |
* @param $context |
| 905 |
* |
| 906 |
* @return string|void |
| 907 |
*/ |
| 908 |
public function gmedia_post_type_edit_link( $link, $post_ID, $context ) { |
| 909 |
$post = get_post( $post_ID ); |
| 910 |
if ( isset( $post->ID ) && 'gmedia' === substr( $post->post_type, 0, 6 ) ) { |
| 911 |
global $gmDB; |
| 912 |
if ( 'gmedia' === $post->post_type ) { |
| 913 |
$gmedia_id = get_post_meta( $post->ID, '_gmedia_ID', true ); |
| 914 |
$gmedia = $gmDB->get_gmedia( $gmedia_id ); |
| 915 |
if ( $gmedia ) { |
| 916 |
$link = admin_url( "admin.php?page=GrandMedia&mode=edit&gmedia__in={$gmedia->ID}" ); |
| 917 |
} else { |
| 918 |
wp_delete_post( $post->ID, true ); |
| 919 |
$link = '#'; |
| 920 |
} |
| 921 |
} else { |
| 922 |
$term_id = get_post_meta( $post->ID, '_gmedia_term_ID', true ); |
| 923 |
$term = $gmDB->get_term( $term_id ); |
| 924 |
if ( $term ) { |
| 925 |
if ( 'gmedia_album' === $term->taxonomy ) { |
| 926 |
$link = admin_url( "admin.php?page=GrandMedia_Albums&edit_term={$term->term_id}" ); |
| 927 |
} elseif ( 'gmedia_gallery' === $term->taxonomy ) { |
| 928 |
$link = admin_url( "admin.php?page=GrandMedia_Galleries&edit_term={$term->term_id}" ); |
| 929 |
} |
| 930 |
} else { |
| 931 |
wp_delete_post( $post->ID, true ); |
| 932 |
$link = '#'; |
| 933 |
} |
| 934 |
} |
| 935 |
} |
| 936 |
return $link; |
| 937 |
} |
| 938 |
|
| 939 |
public function register_gmedia_widget() { |
| 940 |
require_once dirname( __FILE__ ) . '/inc/widget.php'; |
| 941 |
register_widget( 'GrandMedia_Gallery_Widget' ); |
| 942 |
register_widget( 'GrandMedia_Album_Widget' ); |
| 943 |
} |
| 944 |
|
| 945 |
/** |
| 946 |
* @param $query |
| 947 |
* |
| 948 |
* @return mixed |
| 949 |
*/ |
| 950 |
public function exclude_gmedia_from_link_query( $query ) { |
| 951 |
$key = array_search( 'gmedia', $query['post_type'], true ); |
| 952 |
if ( false !== $key ) { |
| 953 |
unset($query['post_type'][$key]); |
| 954 |
} |
| 955 |
return $query; |
| 956 |
} |
| 957 |
|
| 958 |
/** |
| 959 |
* @param $shedules |
| 960 |
* |
| 961 |
* @return array |
| 962 |
*/ |
| 963 |
public function gmedia_cron_schedules( $shedules ) { |
| 964 |
$gmedia_shedules = array( |
| 965 |
'gmedia_app' => array( |
| 966 |
'interval' => 5 * DAY_IN_SECONDS, |
| 967 |
'display' => __( 'Gmedia App Defined', 'grand-media' ), |
| 968 |
), |
| 969 |
); |
| 970 |
$shedules = array_merge( $shedules, $gmedia_shedules ); |
| 971 |
return $shedules; |
| 972 |
} |
| 973 |
|
| 974 |
public function gmedia_app_cronjob() { |
| 975 |
global $gmCore; |
| 976 |
$gmCore->app_service( 'app_updatecron' ); |
| 977 |
} |
| 978 |
|
| 979 |
public function gmedia_modules_update() { |
| 980 |
global $gmCore; |
| 981 |
$gmCore->modules_update(); |
| 982 |
} |
| 983 |
|
| 984 |
/* |
| 985 |
// PLUGIN MESSAGE ON PLUGINS PAGE. |
| 986 |
public function check_message_version( $file ) { |
| 987 |
static $this_plugin; |
| 988 |
if ( ! $this_plugin ) { |
| 989 |
$this_plugin = GMEDIA_FOLDER; |
| 990 |
} |
| 991 |
|
| 992 |
if ( $file === $this_plugin ) { |
| 993 |
$checkfile = 'https://codeasily.com/grand-flam.chk'; |
| 994 |
|
| 995 |
$message = wp_remote_fopen( $checkfile ); |
| 996 |
|
| 997 |
if ( $message ) { |
| 998 |
preg_match( '|grand' . str_replace( '.', '', GMEDIA_VERSION ) . ':(.*)$|mi', $message, $theMessage ); |
| 999 |
$columns = 5; |
| 1000 |
if ( ! empty( $theMessage ) ) { |
| 1001 |
$theMessage = trim( $theMessage[1] ); |
| 1002 |
echo '<td colspan="' . intval( $columns ) . '" class="plugin-update" style="line-height:1.2em; font-size:11px; padding:1px;"><div id="flag-update-msg" style="padding-bottom:1px;" >' . wp_kses_post( $theMessage ) . '</div></td>'; |
| 1003 |
} else { |
| 1004 |
return; |
| 1005 |
} |
| 1006 |
} |
| 1007 |
} |
| 1008 |
} |
| 1009 |
*/ |
| 1010 |
public function add_plugin_links( $links, $file ) { |
| 1011 |
if ( plugin_basename( __FILE__ ) === $file ) { |
| 1012 |
$links[] = '<a href="admin.php?page=GrandMedia_Settings">' . esc_html__( 'Settings', 'grand-media' ) . '</a>'; |
| 1013 |
$links[] = '<a href="admin.php?page=GrandMedia_Modules">' . esc_html__( 'Modules', 'grand-media' ) . '</a>'; |
| 1014 |
$links[] = '<a href="admin.php?page=GrandMedia-pricing">' . esc_html__( 'Get Premium', 'grand-media' ) . '</a>'; |
| 1015 |
$links[] = '<a href="https://codeasily.com/donate/">' . esc_html__( 'Donate', 'grand-media' ) . '</a>'; |
| 1016 |
} |
| 1017 |
return $links; |
| 1018 |
} |
| 1019 |
|
| 1020 |
} |
| 1021 |
|
| 1022 |
// Let's start the holy plugin. |
| 1023 |
global $gmGallery; |
| 1024 |
$gmGallery = new Gmedia(); |
| 1025 |
} |