Plugin Directory

Changeset 3296568


Ignore:
Timestamp:
05/19/2025 02:47:54 PM (10 months ago)
Author:
dman25560
Message:

Version 1.1.3

Location:
mediaview/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • mediaview/trunk/mediaview.php

    r2454273 r3296568  
    33/*
    44Plugin Name: MediaView
    5 Plugin URI: http://www.dscarberry.com/mediaview/
     5Plugin URI: https://www.dscarberry.com/mediaview/
    66Description: This plugin allows you to create media galleries / slideshows containing videos and photos.
    7 Version: 1.1.2
     7Version: 1.1.3
    88Author: Dustin Scarberry
    9 Author URI: http://www.dscarberry.com/
     9Author URI: https://www.dscarberry.com/
    1010License: GPL2
    1111*/
    1212
    13 /*  2013 Dustin Scarberry
     13/*  2013 Dustin Scarberry bitsnbytes1001@gmail.com
    1414
    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.
     15This program is free software; you can redistribute it and/or modify
     16it under the terms of the GNU General Public License, version 2, as
     17published by the Free Software Foundation.
    1818
    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.
     19This program is distributed in the hope that it will be useful,
     20but WITHOUT ANY WARRANTY; without even the implied warranty of
     21MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     22GNU General Public License for more details.
    2323
    24     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
     24You should have received a copy of the GNU General Public License
     25along with this program; if not, write to the Free Software
     26Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    2727*/
    2828
    29 if(!class_exists('mediaView'))
     29namespace Dscarberry\MediaView;
     30
     31use Dscarberry\MediaView\Controller\View\DashboardController;
     32use Dscarberry\MediaView\Controller\View\AppController;
     33use Dscarberry\MediaView\Service\Maintenance;
     34
     35require(dirname(__FILE__) . '/config.php');
     36
     37class Bootstrap
    3038{
     39  private $_options;
    3140
    32     class mediaView
    33     {
     41  public function __construct()
     42  {
     43    // register autoloader
     44    spl_autoload_register([$this, 'autoloader']);
    3445
    35         private $_mvadmin, $_mvfrontend, $_options, $_dirpath;
    36         const CURRENT_VERSION = '1.1.2';
     46    // load options
     47    $this->_options = get_option('mediaview_main_opts');
    3748
    38         public function __construct()
    39         {
     49    // check for upgrade
     50    if (is_admin())
     51      $this->upgrade_check();
    4052
    41             //set dirpath
    42             $this->_dirpath = dirname(__FILE__);
     53    // load dependencies
     54    $this->load_dependencies();
    4355
    44             //load options
    45             $this->_options = get_option('mediaview_main_opts');
     56    // activation hook
     57    register_activation_hook(__FILE__, [$this, 'activate']);
     58  }
    4659
    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  }
    4968
    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){
    5273
    53             //activation hook
    54             register_activation_hook(__FILE__, array($this, 'activate'));
     74      global $wpdb;
     75      $old_blog =  $wpdb->blogid;
    5576
    56         }
     77      // get all blog ids
     78      $blogIds =  $wpdb->get_col('SELECT blog_id FROM ' .  $wpdb->blogs);
    5779
    58         //activate plugin
    59         public function activate($network)
    60         {
     80      foreach ($blogIds as $blogId)
     81      {
     82        switch_to_blog($blogId);
     83        $this->maintenance();
     84      }
    6185
    62             //multisite call
    63             if(function_exists('is_multisite') && is_multisite() && $network){
     86      switch_to_blog($old_blog);
     87    }
    6488
    65                 global $wpdb;
    66                 $old_blog =  $wpdb->blogid;
     89    // regular call
     90    $this->maintenance();
     91  }
    6792
    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  }
    7097
    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  }
    72106
    73                     switch_to_blog($blog_id);
    74                     $this->maintenance();
     107  private function load_dependencies()
     108  {
     109    load_plugin_textdomain('mvcanvas', false, '/mediaview/translations');
    75110
    76                 }
     111    // load app or dashboard
     112    if (is_admin())
     113      new DashboardController();
     114    else
     115      new AppController();
     116  }
     117}
    77118
    78                 switch_to_blog($old_blog);
     119// php version check
     120function 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}
    79124
    80             }
     125function deactivate()
     126{
     127  deactivate_plugins(plugin_basename(__FILE__));
     128}
    81129
    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 ?>
     130if (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  
    11=== MediaView ===
    22Contributors: dman25560
    3 Donate link: http://www.dscarberry.com/mediaview/
     3Donate link: htts://dscarberry.com/mediaview/
    44Tags: video, gallery, youtube, vimeo, slideshow, photo
    55Requires at least: 4.4.0
    6 Tested up to: 4.8
    7 Stable tag: 1.1.2
     6Tested up to: 4.7.3
     7Stable tag: 1.1.3
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3434= Where can I go for help using / installing this plugin? =
    3535
    36 Just send an email to bitsnbytes1001@gmail.com with a link to your problem webpage if possible.
     36For assistance with this plugin contact me at dscarberry.com
    3737
    3838= What types of media does the slider / viewer support? =
     
    4747
    4848== Changelog ==
     49
     50= 1.1.3 =
     51* Major Refactoring
     52* PHP 8 and above required
    4953
    5054= 1.1.2 =
  • mediaview/trunk/uninstall.php

    r1618960 r3296568  
    11<?php
    22
    3 if(defined('WP_UNINSTALL_PLUGIN'))
    4 {
     3if (defined('WP_UNINSTALL_PLUGIN')) {
     4  // multisite call
     5  if (function_exists('is_multisite') && is_multisite()) {
     6    global $wpdb;
     7    $old_blog =  $wpdb->blogid;
    58
    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);
    811
    9         global $wpdb;
    10         $old_blog =  $wpdb->blogid;
     12    foreach ($blogids as $blog_id) {
     13      switch_to_blog($blog_id);
     14      removeDatabaseTables();
     15    }
    1116
    12         //Get all blog ids
    13         $blogids =  $wpdb->get_col('SELECT blog_id FROM ' .  $wpdb->blogs);
     17    switch_to_blog($old_blog);
     18  }
    1419
    15         foreach($blogids as $blog_id){
     20  // regular call
     21  removeDatabaseTables();
    1622
    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');
    3325}
    3426
    35 function removePlugin() {
     27function removeDatabaseTables()
     28{
     29  global $wpdb;
    3630
    37     global $wpdb;
     31  $wpdb->query('DROP TABLE ' . $wpdb->prefix . 'mediaview_media');
     32  $wpdb->query('DROP TABLE ' . $wpdb->prefix . 'mediaview_dataset');
    3833
    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');
    4435}
    4536
    46 function rrmdir($dir) {
     37function removeFiles($dir)
     38{
     39  foreach (glob($dir . '/*') as $file) {
     40    if (is_dir($file))
     41      rrmdir($file);
     42    else
     43      unlink($file);
     44  }
    4745
    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);
    5947}
    60 
    61 ?>
Note: See TracChangeset for help on using the changeset viewer.