Changeset 3296568
- Timestamp:
- 05/19/2025 02:47:54 PM (10 months ago)
- Location:
- mediaview/trunk
- Files:
-
- 3 edited
-
mediaview.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
-
uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
mediaview/trunk/mediaview.php
r2454273 r3296568 3 3 /* 4 4 Plugin Name: MediaView 5 Plugin URI: http ://www.dscarberry.com/mediaview/5 Plugin URI: https://www.dscarberry.com/mediaview/ 6 6 Description: This plugin allows you to create media galleries / slideshows containing videos and photos. 7 Version: 1.1. 27 Version: 1.1.3 8 8 Author: Dustin Scarberry 9 Author URI: http ://www.dscarberry.com/9 Author URI: https://www.dscarberry.com/ 10 10 License: GPL2 11 11 */ 12 12 13 /* 2013 Dustin Scarberry 13 /* 2013 Dustin Scarberry bitsnbytes1001@gmail.com 14 14 15 This program is free software; you can redistribute it and/or modify16 it under the terms of the GNU General Public License, version 2, as17 published by the Free Software Foundation.15 This program is free software; you can redistribute it and/or modify 16 it under the terms of the GNU General Public License, version 2, as 17 published by the Free Software Foundation. 18 18 19 This program is distributed in the hope that it will be useful,20 but WITHOUT ANY WARRANTY; without even the implied warranty of21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the22 GNU General Public License for more details.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 23 24 You should have received a copy of the GNU General Public License25 along with this program; if not, write to the Free Software26 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA24 You should have received a copy of the GNU General Public License 25 along with this program; if not, write to the Free Software 26 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 27 27 */ 28 28 29 if(!class_exists('mediaView')) 29 namespace Dscarberry\MediaView; 30 31 use Dscarberry\MediaView\Controller\View\DashboardController; 32 use Dscarberry\MediaView\Controller\View\AppController; 33 use Dscarberry\MediaView\Service\Maintenance; 34 35 require(dirname(__FILE__) . '/config.php'); 36 37 class Bootstrap 30 38 { 39 private $_options; 31 40 32 class mediaView 33 { 41 public function __construct() 42 { 43 // register autoloader 44 spl_autoload_register([$this, 'autoloader']); 34 45 35 private $_mvadmin, $_mvfrontend, $_options, $_dirpath; 36 const CURRENT_VERSION = '1.1.2';46 // load options 47 $this->_options = get_option('mediaview_main_opts'); 37 48 38 public function __construct() 39 { 49 // check for upgrade 50 if (is_admin()) 51 $this->upgrade_check(); 40 52 41 //set dirpath 42 $this->_dirpath = dirname(__FILE__);53 // load dependencies 54 $this->load_dependencies(); 43 55 44 //load options 45 $this->_options = get_option('mediaview_main_opts'); 56 // activation hook 57 register_activation_hook(__FILE__, [$this, 'activate']); 58 } 46 59 47 //check for upgrade 48 $this->upgrade_check(); 60 public function autoloader($className) 61 { 62 if (strpos($className, 'Dscarberry\MediaView') !== false) { 63 $className = str_replace('\\', '/', $className); 64 $className = str_replace('Dscarberry/MediaView/', '', $className); 65 require_once('src/' . $className . '.php'); 66 } 67 } 49 68 50 //load external files 51 $this->load_dependencies(); 69 public function activate($network) 70 { 71 // multisite call 72 if (function_exists('is_multisite') && is_multisite() && $network){ 52 73 53 //activation hook 54 register_activation_hook(__FILE__, array($this, 'activate'));74 global $wpdb; 75 $old_blog = $wpdb->blogid; 55 76 56 } 77 // get all blog ids 78 $blogIds = $wpdb->get_col('SELECT blog_id FROM ' . $wpdb->blogs); 57 79 58 //activate plugin 59 public function activate($network) 60 { 80 foreach ($blogIds as $blogId) 81 { 82 switch_to_blog($blogId); 83 $this->maintenance(); 84 } 61 85 62 //multisite call 63 if(function_exists('is_multisite') && is_multisite() && $network){ 86 switch_to_blog($old_blog); 87 } 64 88 65 global $wpdb; 66 $old_blog = $wpdb->blogid; 89 // regular call 90 $this->maintenance(); 91 } 67 92 68 //Get all blog ids 69 $blogids = $wpdb->get_col('SELECT blog_id FROM ' . $wpdb->blogs); 93 private function maintenance() 94 { 95 new Maintenance(); 96 } 70 97 71 foreach($blogids as $blog_id){ 98 private function upgrade_check() 99 { 100 if (!isset($this->_options['version']) || $this->_options['version'] < DS_MEDIAVIEW_VERSION) { 101 $this->maintenance(); 102 $this->_options['version'] = DS_MEDIAVIEW_VERSION; 103 update_option('mediaview_main_opts', $this->options); 104 } 105 } 72 106 73 switch_to_blog($blog_id); 74 $this->maintenance(); 107 private function load_dependencies() 108 { 109 load_plugin_textdomain('mvcanvas', false, '/mediaview/translations'); 75 110 76 } 111 // load app or dashboard 112 if (is_admin()) 113 new DashboardController(); 114 else 115 new AppController(); 116 } 117 } 77 118 78 switch_to_blog($old_blog); 119 // php version check 120 function showNotice() 121 { 122 echo '<div class="error e-message"><p>MediaView - PHP version ' . DS_MEDIAVIEW_MIN_PHP_VERSION . ' or greater required. You currently have version ' . phpversion() . '</p></div>'; 123 } 79 124 80 } 125 function deactivate() 126 { 127 deactivate_plugins(plugin_basename(__FILE__)); 128 } 81 129 82 //regular call 83 $this->maintenance(); 84 85 } 86 87 private function maintenance() 88 { 89 90 /*//php version check - to implement later 91 $requiredPHPVersion = '5.5'; 92 93 if(version_compare(PHP_VERSION, $requiredPHPVersion, '<')){ 94 95 deactivate_plugins( basename( __FILE__ ) ); 96 wp_die('<p><strong>MediaView</strong> requires PHP version ' . $requiredPHPVersion . ' or greater.</p>', 'Plugin Activation Error'); 97 98 }*/ 99 100 //set up globals 101 global $wpdb; 102 103 //create database tables for plugin 104 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 105 106 $tbname[0] = $wpdb->prefix . 'mediaview_dataset'; 107 $tbname[1] = $wpdb->prefix . 'mediaview_media'; 108 109 $sql = "CREATE TABLE $tbname[0] ( 110 DATA_ID int(11) NOT NULL AUTO_INCREMENT, 111 DATA_NAME varchar(40) NOT NULL, 112 DATA_DISPLAYHEIGHT int(11) NOT NULL, 113 DATA_CANVASCOLOR varchar(10) NOT NULL, 114 DATA_CAPTIONCOLOR varchar(10) NOT NULL, 115 DATA_UPDATEDATE int(11) NOT NULL, 116 DATA_MEDIACOUNT int(4) DEFAULT '0' NOT NULL, 117 UNIQUE KEY DATA_ID (DATA_ID) 118 ); 119 CREATE TABLE $tbname[1] ( 120 MEDIA_ID int(11) NOT NULL AUTO_INCREMENT, 121 MEDIA_VALUE longtext NOT NULL, 122 MEDIA_TYPE varchar(40) NOT NULL, 123 MEDIA_CAPTION varchar(60), 124 MEDIA_POS int(11) DEFAULT '0' NOT NULL, 125 MEDIA_UPDATEDATE int(11) NOT NULL, 126 DATA_ID int(11) NOT NULL, 127 UNIQUE KEY MEDIA_ID (MEDIA_ID) 128 );"; 129 130 dbDelta($sql); 131 132 if(empty($this->_options)) 133 $this->_options = array(); 134 135 $dft['ytHideControls'] = 'yes'; 136 $dft['ytProgressColor'] = 'white'; 137 $dft['vimeoControlColor'] = '#00adef'; 138 $dft['version'] = self::CURRENT_VERSION; 139 140 $this->_options = $this->_options + $dft; 141 142 update_option('mediaview_main_opts', $this->_options); 143 144 //create photo cache directory if needed 145 $dir = wp_upload_dir(); 146 $dir = $dir['basedir']; 147 148 wp_mkdir_p($dir . '/mediaview-cache'); 149 150 } 151 152 private function upgrade_check() 153 { 154 155 if(!isset($this->_options['version']) || $this->_options['version'] < self::CURRENT_VERSION){ 156 157 $this->_options['version'] = self::CURRENT_VERSION; 158 $this->maintenance(); 159 160 } 161 162 } 163 164 //load dependencies for plugin 165 private function load_dependencies() 166 { 167 168 load_plugin_textdomain('mvcanvas', false, 'mediaview/language'); 169 170 //load backend or frontend dependencies 171 if(is_admin()) 172 { 173 174 require ($this->_dirpath . '/admin.php'); 175 $this->_mvadmin = new mediaViewAdmin(self::CURRENT_VERSION); 176 177 } 178 else 179 { 180 181 require ($this->_dirpath . '/frontend.php'); 182 $this->_mvfrontend = new mediaViewFrontend(self::CURRENT_VERSION); 183 184 } 185 186 } 187 188 } 189 190 $mediaview = new mediaView(); 191 192 } 193 ?> 130 if (strnatcmp(phpversion(), DS_MEDIAVIEW_MIN_PHP_VERSION) < 0) { 131 add_action('admin_notices', 'Dscarberry\MediaView\showNotice'); 132 add_action('admin_notices', 'Dscarberry\MediaView\deactivate'); 133 } else 134 new Bootstrap(); -
mediaview/trunk/readme.txt
r2454273 r3296568 1 1 === MediaView === 2 2 Contributors: dman25560 3 Donate link: htt p://www.dscarberry.com/mediaview/3 Donate link: htts://dscarberry.com/mediaview/ 4 4 Tags: video, gallery, youtube, vimeo, slideshow, photo 5 5 Requires at least: 4.4.0 6 Tested up to: 4. 87 Stable tag: 1.1. 26 Tested up to: 4.7.3 7 Stable tag: 1.1.3 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 34 34 = Where can I go for help using / installing this plugin? = 35 35 36 Just send an email to bitsnbytes1001@gmail.com with a link to your problem webpage if possible. 36 For assistance with this plugin contact me at dscarberry.com 37 37 38 38 = What types of media does the slider / viewer support? = … … 47 47 48 48 == Changelog == 49 50 = 1.1.3 = 51 * Major Refactoring 52 * PHP 8 and above required 49 53 50 54 = 1.1.2 = -
mediaview/trunk/uninstall.php
r1618960 r3296568 1 1 <?php 2 2 3 if(defined('WP_UNINSTALL_PLUGIN')) 4 { 3 if (defined('WP_UNINSTALL_PLUGIN')) { 4 // multisite call 5 if (function_exists('is_multisite') && is_multisite()) { 6 global $wpdb; 7 $old_blog = $wpdb->blogid; 5 8 6 //multisite call 7 if(function_exists('is_multisite') && is_multisite()){ 9 // get all blog ids 10 $blogids = $wpdb->get_col('SELECT blog_id FROM ' . $wpdb->blogs); 8 11 9 global $wpdb; 10 $old_blog = $wpdb->blogid; 12 foreach ($blogids as $blog_id) { 13 switch_to_blog($blog_id); 14 removeDatabaseTables(); 15 } 11 16 12 //Get all blog ids 13 $blogids = $wpdb->get_col('SELECT blog_id FROM ' . $wpdb->blogs); 17 switch_to_blog($old_blog); 18 } 14 19 15 foreach($blogids as $blog_id){ 20 // regular call 21 removeDatabaseTables(); 16 22 17 switch_to_blog($blog_id); 18 removePlugin(); 19 20 } 21 22 switch_to_blog($old_blog); 23 24 } 25 26 //regular call 27 removePlugin(); 28 29 //remove file directories 30 $dir = wp_upload_dir(); 31 rrmdir($dir['basedir'] . '/mediaview-cache'); 32 23 // remove file directories 24 removeFiles((wp_upload_dir())['basedir'] . '/mediaview-cache'); 33 25 } 34 26 35 function removePlugin() { 27 function removeDatabaseTables() 28 { 29 global $wpdb; 36 30 37 global $wpdb; 31 $wpdb->query('DROP TABLE ' . $wpdb->prefix . 'mediaview_media'); 32 $wpdb->query('DROP TABLE ' . $wpdb->prefix . 'mediaview_dataset'); 38 33 39 $wpdb->query('DROP TABLE ' . $wpdb->prefix . 'mediaview_media'); 40 $wpdb->query('DROP TABLE ' . $wpdb->prefix . 'mediaview_dataset'); 41 42 delete_option('mediaview_main_opts'); 43 34 delete_option('mediaview_main_opts'); 44 35 } 45 36 46 function rrmdir($dir) { 37 function removeFiles($dir) 38 { 39 foreach (glob($dir . '/*') as $file) { 40 if (is_dir($file)) 41 rrmdir($file); 42 else 43 unlink($file); 44 } 47 45 48 foreach(glob($dir . '/*') as $file) 49 { 50 51 if(is_dir($file)) 52 rrmdir($file); 53 else 54 unlink($file); 55 56 } 57 58 rmdir($dir); 46 rmdir($dir); 59 47 } 60 61 ?>
Note: See TracChangeset
for help on using the changeset viewer.