ee
Showing
81 changed files
with
4749 additions
and
4 deletions
This diff is collapsed.
Click to expand it.
| 1 | # Enable Media Replace | ||
| 2 | |||
| 3 | This plugin allows you to replace a file in your media library by uploading a new file in its place. No more deleting, renaming and re-uploading files! | ||
| 4 | |||
| 5 | ## A real timesaver | ||
| 6 | |||
| 7 | Don't you find it tedious and complicated to have to first delete a file and then upload one with the exact same name every time you want to update an image or any uploaded file inside the WordPress media library? | ||
| 8 | |||
| 9 | Well, no longer! | ||
| 10 | |||
| 11 | Now you'll be able to replace any uploaded file from the media "edit" view, where it should be. Media replacement can be done in one of two ways: | ||
| 12 | |||
| 13 | ## It's simple to replace a file | ||
| 14 | |||
| 15 | 1. Just replace the file. This option requires you to upload a file of the same type as the one you are replacing. The name of the attachment will stay the same no matter what the file you upload is called. | ||
| 16 | 1. Replace the file, use new file name and update all links. If you check this option, the name and type of the file you are about to upload will replace the old file. All links pointing to the current file will be updated to point to the new file name. | ||
| 17 | |||
| 18 | This plugin is very powerful and a must-have for any larger sites built with WordPress. | ||
| 19 | |||
| 20 | ## Display file modification time | ||
| 21 | |||
| 22 | There is a shortcode available which picks up the file modification date and displays it in a post or a page. The code is: | ||
| 23 | `[file_modified id=XX format=XXXX]` where the "id" is required and the "format" is optional and defaults to your current WordPress settings for date and time format. | ||
| 24 | |||
| 25 | So `[file_modified id=870]` would display the last time the file with ID 870 was updated on your site. To get the ID for a file, check the URL when editing a file in the media library (see screenshot #4) | ||
| 26 | |||
| 27 | If you want more control over the format used to display the time, you can use the format option, so `[file_modified id=870 format=Y-m-d]` would display the file modification date but not the time. The format string uses [standard PHP date() formatting tags](http://php.net/manual/en/function.date.php). | ||
| 28 | |||
| 29 | *** | ||
| 30 | |||
| 31 | See [Enable Media Replace](http://wordpress.org/plugins/enable-media-replace/) at WordPress.org for more information. |
| 1 | <?php | ||
| 2 | namespace EnableMediaReplace\Build; | ||
| 3 | |||
| 4 | class PackageLoader | ||
| 5 | { | ||
| 6 | public $dir; | ||
| 7 | public $composerFile = false; | ||
| 8 | |||
| 9 | public function __construct() | ||
| 10 | { | ||
| 11 | |||
| 12 | } | ||
| 13 | |||
| 14 | public function setComposerFile($filePath) | ||
| 15 | { | ||
| 16 | $this->composerFile = json_decode(file_get_contents($filePath),1); | ||
| 17 | } | ||
| 18 | |||
| 19 | public function getComposerFile($filePath = false ) | ||
| 20 | { | ||
| 21 | if (! $this->composerFile) | ||
| 22 | $this->composerFile = json_decode(file_get_contents($this->dir."/composer.json"), 1); | ||
| 23 | |||
| 24 | return $this->composerFile; | ||
| 25 | } | ||
| 26 | |||
| 27 | public function load($dir) | ||
| 28 | { | ||
| 29 | $this->dir = $dir; | ||
| 30 | $composer = $this->getComposerFile(); | ||
| 31 | |||
| 32 | |||
| 33 | if(isset($composer["autoload"]["psr-4"])){ | ||
| 34 | $this->loadPSR4($composer['autoload']['psr-4']); | ||
| 35 | } | ||
| 36 | if(isset($composer["autoload"]["psr-0"])){ | ||
| 37 | $this->loadPSR0($composer['autoload']['psr-0']); | ||
| 38 | } | ||
| 39 | if(isset($composer["autoload"]["files"])){ | ||
| 40 | $this->loadFiles($composer["autoload"]["files"]); | ||
| 41 | } | ||
| 42 | } | ||
| 43 | |||
| 44 | public function loadFiles($files){ | ||
| 45 | foreach($files as $file){ | ||
| 46 | $fullpath = $this->dir."/".$file; | ||
| 47 | if(file_exists($fullpath)){ | ||
| 48 | include_once($fullpath); | ||
| 49 | } | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | public function loadPSR4($namespaces) | ||
| 54 | { | ||
| 55 | $this->loadPSR($namespaces, true); | ||
| 56 | } | ||
| 57 | |||
| 58 | public function loadPSR0($namespaces) | ||
| 59 | { | ||
| 60 | $this->loadPSR($namespaces, false); | ||
| 61 | } | ||
| 62 | |||
| 63 | public function loadPSR($namespaces, $psr4) | ||
| 64 | { | ||
| 65 | $dir = $this->dir; | ||
| 66 | // Foreach namespace specified in the composer, load the given classes | ||
| 67 | foreach ($namespaces as $namespace => $classpaths) { | ||
| 68 | if (!is_array($classpaths)) { | ||
| 69 | $classpaths = array($classpaths); | ||
| 70 | } | ||
| 71 | spl_autoload_register(function ($classname) use ($namespace, $classpaths, $dir, $psr4) { | ||
| 72 | // Check if the namespace matches the class we are looking for | ||
| 73 | if (preg_match("#^".preg_quote($namespace)."#", $classname)) { | ||
| 74 | // Remove the namespace from the file path since it's psr4 | ||
| 75 | if ($psr4) { | ||
| 76 | $classname = str_replace($namespace, "", $classname); | ||
| 77 | } | ||
| 78 | |||
| 79 | // $filename = preg_replace("#\\\\#", "", $classname).".php"; | ||
| 80 | // This is fix for nested classes which were losing a / | ||
| 81 | $filename = ltrim($classname .'.php', '\\'); | ||
| 82 | $filename = str_replace('\\','/', $filename); | ||
| 83 | |||
| 84 | foreach ($classpaths as $classpath) { | ||
| 85 | $fullpath = trailingslashit($dir) . trailingslashit($classpath) .$filename; | ||
| 86 | if (file_exists($fullpath)) { | ||
| 87 | include_once $fullpath; | ||
| 88 | } | ||
| 89 | } | ||
| 90 | } | ||
| 91 | }); | ||
| 92 | } | ||
| 93 | } | ||
| 94 | } |
| 1 | {"name":"EnableMediaReplace\/shortpixelmodules","description":"ShortPixel submodules","type":"function","autoload":{"psr-4":{"EnableMediaReplace\\ShortPixelLogger":"log\/src","EnableMediaReplace\\Notices":"notices\/src"}}} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | { | ||
| 2 | "name": "shortpixel/log", | ||
| 3 | "description": "ShortPixel Logging", | ||
| 4 | "version": "1.1.3", | ||
| 5 | "type": "library", | ||
| 6 | "license": "MIT", | ||
| 7 | "authors": [ | ||
| 8 | { | ||
| 9 | "name": "Bas", | ||
| 10 | "email": "bas@weblogmechanic.com" | ||
| 11 | } | ||
| 12 | ], | ||
| 13 | "minimum-stability": "dev", | ||
| 14 | "require": {}, | ||
| 15 | "autoload": { | ||
| 16 | "psr-4": { "ShortPixel\\ShortPixelLogger\\" : "src" } | ||
| 17 | } | ||
| 18 | } |
| 1 | <?php | ||
| 2 | // The data models. | ||
| 3 | namespace EnableMediaReplace\ShortPixelLogger; | ||
| 4 | |||
| 5 | |||
| 6 | class DebugItem | ||
| 7 | { | ||
| 8 | protected $time; | ||
| 9 | protected $level; | ||
| 10 | protected $message; | ||
| 11 | protected $data = array(); | ||
| 12 | protected $caller = false; // array when filled | ||
| 13 | |||
| 14 | protected $model; | ||
| 15 | |||
| 16 | const LEVEL_ERROR = 1; | ||
| 17 | const LEVEL_WARN = 2; | ||
| 18 | const LEVEL_INFO = 3; | ||
| 19 | const LEVEL_DEBUG = 4; | ||
| 20 | |||
| 21 | public function __construct($message, $args) | ||
| 22 | { | ||
| 23 | $this->level = $args['level']; | ||
| 24 | $data = $args['data']; | ||
| 25 | |||
| 26 | $this->message = $message; | ||
| 27 | $this->time = microtime(true); | ||
| 28 | |||
| 29 | $this->setCaller(); | ||
| 30 | |||
| 31 | // Add message to data if it seems to be some debug variable. | ||
| 32 | if (is_object($this->message) || is_array($this->message)) | ||
| 33 | { | ||
| 34 | $data[] = $this->message; | ||
| 35 | $this->message = __('[Data]'); | ||
| 36 | } | ||
| 37 | if (is_array($data) && count($data) > 0) | ||
| 38 | { | ||
| 39 | $dataType = $this->getDataType($data); | ||
| 40 | if ($dataType == 1) // singular | ||
| 41 | { | ||
| 42 | $this->data[] = print_r($data, true); | ||
| 43 | } | ||
| 44 | if ($dataType == 2) //array | ||
| 45 | { | ||
| 46 | foreach($data as $index => $item) | ||
| 47 | { | ||
| 48 | if (is_object($item) || is_array($item)) | ||
| 49 | { | ||
| 50 | $this->data[] = print_r($item, true); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | } | ||
| 54 | } // if | ||
| 55 | elseif (! is_array($data)) // this leaves out empty default arrays | ||
| 56 | { | ||
| 57 | $this->data[] = print_r($data, true); | ||
| 58 | } | ||
| 59 | } | ||
| 60 | |||
| 61 | public function getData() | ||
| 62 | { | ||
| 63 | return array('time' => $this->time, 'level' => $this->level, 'message' => $this->message, 'data' => $this->data, 'caller' => $this->caller); | ||
| 64 | } | ||
| 65 | |||
| 66 | /** Test Data Array for possible values | ||
| 67 | * | ||
| 68 | * Data can be a collection of several debug vars, a single var, or just an normal array. Test if array has single types, | ||
| 69 | * which is a sign the array is not a collection. | ||
| 70 | */ | ||
| 71 | protected function getDataType($data) | ||
| 72 | { | ||
| 73 | $single_type = array('integer', 'boolean', 'string'); | ||
| 74 | if (in_array(gettype(reset($data)), $single_type)) | ||
| 75 | { | ||
| 76 | return 1; | ||
| 77 | } | ||
| 78 | else | ||
| 79 | { | ||
| 80 | return 2; | ||
| 81 | } | ||
| 82 | } | ||
| 83 | |||
| 84 | public function getForFormat() | ||
| 85 | { | ||
| 86 | $data = $this->getData(); | ||
| 87 | switch($this->level) | ||
| 88 | { | ||
| 89 | case self::LEVEL_ERROR: | ||
| 90 | $level = 'ERR'; | ||
| 91 | $color = "\033[31m"; | ||
| 92 | break; | ||
| 93 | case self::LEVEL_WARN: | ||
| 94 | $level = 'WRN'; | ||
| 95 | $color = "\033[33m"; | ||
| 96 | break; | ||
| 97 | case self::LEVEL_INFO: | ||
| 98 | $level = 'INF'; | ||
| 99 | $color = "\033[37m"; | ||
| 100 | break; | ||
| 101 | case self::LEVEL_DEBUG: | ||
| 102 | $level = 'DBG'; | ||
| 103 | $color = "\033[37m"; | ||
| 104 | break; | ||
| 105 | |||
| 106 | } | ||
| 107 | $color_end = "\033[0m"; | ||
| 108 | |||
| 109 | $data['color'] = $color; | ||
| 110 | $data['color_end'] = $color_end; | ||
| 111 | $data['level'] = $level; | ||
| 112 | |||
| 113 | return $data; | ||
| 114 | |||
| 115 | //return array('time' => $this->time, 'level' => $level, 'message' => $this->message, 'data' => $this->data, 'color' => $color, 'color_end' => $color_end, 'caller' => $this->caller); | ||
| 116 | |||
| 117 | } | ||
| 118 | |||
| 119 | protected function setCaller() | ||
| 120 | { | ||
| 121 | if(PHP_VERSION_ID < 50400) { | ||
| 122 | $debug=debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); | ||
| 123 | } else { | ||
| 124 | $debug=debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS,5); | ||
| 125 | } | ||
| 126 | |||
| 127 | $i = 4; | ||
| 128 | if (isset($debug[$i])) | ||
| 129 | { | ||
| 130 | $info = $debug[$i]; | ||
| 131 | $line = isset($info['line']) ? $info['line'] : 'Line unknown'; | ||
| 132 | $file = isset($info['file']) ? basename($info['file']) : 'File not set'; | ||
| 133 | |||
| 134 | $this->caller = array('line' => $line, 'file' => $file, 'function' => $info['function']); | ||
| 135 | } | ||
| 136 | |||
| 137 | |||
| 138 | } | ||
| 139 | |||
| 140 | |||
| 141 | } |
| 1 | <?php | ||
| 2 | namespace EnableMediaReplace\ShortPixelLogger; | ||
| 3 | |||
| 4 | /*** Logger class | ||
| 5 | * | ||
| 6 | * Class uses the debug data model for keeping log entries. | ||
| 7 | * Logger should not be called before init hook! | ||
| 8 | */ | ||
| 9 | class ShortPixelLogger | ||
| 10 | { | ||
| 11 | static protected $instance = null; | ||
| 12 | protected $start_time; | ||
| 13 | |||
| 14 | protected $is_active = false; | ||
| 15 | protected $is_manual_request = false; | ||
| 16 | protected $show_debug_view = false; | ||
| 17 | |||
| 18 | protected $items = array(); | ||
| 19 | protected $logPath = false; | ||
| 20 | protected $logMode = FILE_APPEND; | ||
| 21 | |||
| 22 | protected $logLevel; | ||
| 23 | protected $format = "[ %%time%% ] %%color%% %%level%% %%color_end%% \t %%message%% \t %%caller%% ( %%time_passed%% )"; | ||
| 24 | protected $format_data = "\t %%data%% "; | ||
| 25 | |||
| 26 | protected $hooks = array(); | ||
| 27 | /* protected $hooks = array( | ||
| 28 | 'shortpixel_image_exists' => array('numargs' => 3), | ||
| 29 | 'shortpixel_webp_image_base' => array('numargs' => 2), | ||
| 30 | 'shortpixel_image_urls' => array('numargs' => 2), | ||
| 31 | ); // @todo monitor hooks, but this should be more dynamic. Do when moving to module via config. | ||
| 32 | */ | ||
| 33 | |||
| 34 | // utility | ||
| 35 | private $namespace; | ||
| 36 | private $view; | ||
| 37 | |||
| 38 | protected $template = 'view-debug-box'; | ||
| 39 | |||
| 40 | /** Debugger constructor | ||
| 41 | * Two ways to activate the debugger. 1) Define SHORTPIXEL_DEBUG in wp-config.php. Either must be true or a number corresponding to required LogLevel | ||
| 42 | * 2) Put SHORTPIXEL_DEBUG in the request. Either true or number. | ||
| 43 | */ | ||
| 44 | public function __construct() | ||
| 45 | { | ||
| 46 | $this->start_time = microtime(true); | ||
| 47 | $this->logLevel = DebugItem::LEVEL_WARN; | ||
| 48 | |||
| 49 | $ns = __NAMESPACE__; | ||
| 50 | $this->namespace = substr($ns, 0, strpos($ns, '\\')); // try to get first part of namespace | ||
| 51 | |||
| 52 | if (isset($_REQUEST['SHORTPIXEL_DEBUG'])) // manual takes precedence over constants | ||
| 53 | { | ||
| 54 | $this->is_manual_request = true; | ||
| 55 | $this->is_active = true; | ||
| 56 | |||
| 57 | if ($_REQUEST['SHORTPIXEL_DEBUG'] === 'true') | ||
| 58 | { | ||
| 59 | $this->logLevel = DebugItem::LEVEL_INFO; | ||
| 60 | } | ||
| 61 | else { | ||
| 62 | $this->logLevel = intval($_REQUEST['SHORTPIXEL_DEBUG']); | ||
| 63 | } | ||
| 64 | |||
| 65 | } | ||
| 66 | else if ( (defined('SHORTPIXEL_DEBUG') && SHORTPIXEL_DEBUG > 0) ) | ||
| 67 | { | ||
| 68 | $this->is_active = true; | ||
| 69 | if (SHORTPIXEL_DEBUG === true) | ||
| 70 | $this->logLevel = DebugItem::LEVEL_INFO; | ||
| 71 | else { | ||
| 72 | $this->logLevel = intval(SHORTPIXEL_DEBUG); | ||
| 73 | } | ||
| 74 | } | ||
| 75 | |||
| 76 | if (defined('SHORTPIXEL_DEBUG_TARGET') && SHORTPIXEL_DEBUG_TARGET || $this->is_manual_request) | ||
| 77 | { | ||
| 78 | //$this->logPath = SHORTPIXEL_BACKUP_FOLDER . "/shortpixel_log"; | ||
| 79 | //$this->logMode = defined('SHORTPIXEL_LOG_OVERWRITE') ? 0 : FILE_APPEND; | ||
| 80 | if (defined('SHORTPIXEL_LOG_OVERWRITE')) // if overwrite, do this on init once. | ||
| 81 | file_put_contents($this->logPath,'-- Log Reset -- ' .PHP_EOL); | ||
| 82 | |||
| 83 | } | ||
| 84 | |||
| 85 | if ($this->is_active) | ||
| 86 | { | ||
| 87 | /* On Early init, this function might not exist, then queue it when needed */ | ||
| 88 | if (! function_exists('wp_get_current_user')) | ||
| 89 | add_action('init', array($this, 'initView')); | ||
| 90 | else | ||
| 91 | $this->initView(); | ||
| 92 | } | ||
| 93 | |||
| 94 | if ($this->is_active && count($this->hooks) > 0) | ||
| 95 | $this->monitorHooks(); | ||
| 96 | } | ||
| 97 | |||
| 98 | /** Init the view when needed. Private function ( public because of WP_HOOK ) | ||
| 99 | * Never call directly */ | ||
| 100 | public function initView() | ||
| 101 | { | ||
| 102 | $user_is_administrator = (current_user_can('manage_options')) ? true : false; | ||
| 103 | |||
| 104 | if ($this->is_active && $this->is_manual_request && $user_is_administrator ) | ||
| 105 | { | ||
| 106 | $content_url = content_url(); | ||
| 107 | $logPath = $this->logPath; | ||
| 108 | $pathpos = strpos($logPath, 'wp-content') + strlen('wp-content'); | ||
| 109 | $logPart = substr($logPath, $pathpos); | ||
| 110 | $logLink = $content_url . $logPart; | ||
| 111 | |||
| 112 | $this->view = new \stdClass; | ||
| 113 | $this->view->logLink = $logLink; | ||
| 114 | add_action('admin_footer', array($this, 'loadView')); | ||
| 115 | } | ||
| 116 | } | ||
| 117 | |||
| 118 | public static function getInstance() | ||
| 119 | { | ||
| 120 | if ( self::$instance === null) | ||
| 121 | { | ||
| 122 | self::$instance = new ShortPixelLogger(); | ||
| 123 | } | ||
| 124 | return self::$instance; | ||
| 125 | } | ||
| 126 | |||
| 127 | public function setLogPath($logPath) | ||
| 128 | { | ||
| 129 | $this->logPath = $logPath; | ||
| 130 | } | ||
| 131 | protected function addLog($message, $level, $data = array()) | ||
| 132 | { | ||
| 133 | // $log = self::getInstance(); | ||
| 134 | |||
| 135 | // don't log anything too low or when not active. | ||
| 136 | if ($this->logLevel < $level || ! $this->is_active) | ||
| 137 | { | ||
| 138 | return; | ||
| 139 | } | ||
| 140 | |||
| 141 | // Force administrator on manuals. | ||
| 142 | if ( $this->is_manual_request ) | ||
| 143 | { | ||
| 144 | if (! function_exists('wp_get_current_user')) // not loaded yet | ||
| 145 | return false; | ||
| 146 | |||
| 147 | $user_is_administrator = (current_user_can('manage_options')) ? true : false; | ||
| 148 | if (! $user_is_administrator) | ||
| 149 | return false; | ||
| 150 | } | ||
| 151 | |||
| 152 | // Check where to log to. | ||
| 153 | if ($this->logPath === false) | ||
| 154 | { | ||
| 155 | $upload_dir = wp_upload_dir(null,false,false); | ||
| 156 | $this->logPath = $this->setLogPath($upload_dir['basedir'] . '/' . $this->namespace . ".log"); | ||
| 157 | } | ||
| 158 | |||
| 159 | $arg = array(); | ||
| 160 | $args['level'] = $level; | ||
| 161 | $args['data'] = $data; | ||
| 162 | |||
| 163 | $newItem = new DebugItem($message, $args); | ||
| 164 | $this->items[] = $newItem; | ||
| 165 | |||
| 166 | if ($this->is_active) | ||
| 167 | { | ||
| 168 | $this->write($newItem); | ||
| 169 | } | ||
| 170 | } | ||
| 171 | |||
| 172 | /** Writes to log File. */ | ||
| 173 | protected function write($debugItem, $mode = 'file') | ||
| 174 | { | ||
| 175 | $items = $debugItem->getForFormat(); | ||
| 176 | $items['time_passed'] = round ( ($items['time'] - $this->start_time), 5); | ||
| 177 | $items['time'] = date('Y-m-d H:i:s', $items['time'] ); | ||
| 178 | |||
| 179 | if ( ($items['caller']) && is_array($items['caller']) && count($items['caller']) > 0) | ||
| 180 | { | ||
| 181 | $caller = $items['caller']; | ||
| 182 | $items['caller'] = $caller['file'] . ' in ' . $caller['function'] . '(' . $caller['line'] . ')'; | ||
| 183 | } | ||
| 184 | |||
| 185 | $line = $this->formatLine($items); | ||
| 186 | |||
| 187 | // try to write to file. Don't write if directory doesn't exists (leads to notices) | ||
| 188 | if ($this->logPath && is_dir(dirname($this->logPath)) ) | ||
| 189 | { | ||
| 190 | file_put_contents($this->logPath,$line, FILE_APPEND); | ||
| 191 | } | ||
| 192 | else { | ||
| 193 | error_log($line); | ||
| 194 | } | ||
| 195 | } | ||
| 196 | |||
| 197 | protected function formatLine($args = array() ) | ||
| 198 | { | ||
| 199 | $line= $this->format; | ||
| 200 | foreach($args as $key => $value) | ||
| 201 | { | ||
| 202 | if (! is_array($value) && ! is_object($value)) | ||
| 203 | $line = str_replace('%%' . $key . '%%', $value, $line); | ||
| 204 | } | ||
| 205 | |||
| 206 | $line .= PHP_EOL; | ||
| 207 | |||
| 208 | if (isset($args['data'])) | ||
| 209 | { | ||
| 210 | $data = array_filter($args['data']); | ||
| 211 | if (count($data) > 0) | ||
| 212 | { | ||
| 213 | foreach($data as $item) | ||
| 214 | { | ||
| 215 | $line .= $item . PHP_EOL; | ||
| 216 | } | ||
| 217 | } | ||
| 218 | } | ||
| 219 | |||
| 220 | return $line; | ||
| 221 | } | ||
| 222 | |||
| 223 | protected function setLogLevel($level) | ||
| 224 | { | ||
| 225 | $this->logLevel = $level; | ||
| 226 | } | ||
| 227 | |||
| 228 | protected function getEnv($name) | ||
| 229 | { | ||
| 230 | if (isset($this->{$name})) | ||
| 231 | { | ||
| 232 | return $this->{$name}; | ||
| 233 | } | ||
| 234 | else { | ||
| 235 | return false; | ||
| 236 | } | ||
| 237 | } | ||
| 238 | |||
| 239 | public static function addError($message, $args = array()) | ||
| 240 | { | ||
| 241 | $level = DebugItem::LEVEL_ERROR; | ||
| 242 | $log = self::getInstance(); | ||
| 243 | $log->addLog($message, $level, $args); | ||
| 244 | } | ||
| 245 | public static function addWarn($message, $args = array()) | ||
| 246 | { | ||
| 247 | $level = DebugItem::LEVEL_WARN; | ||
| 248 | $log = self::getInstance(); | ||
| 249 | $log->addLog($message, $level, $args); | ||
| 250 | } | ||
| 251 | // Alias, since it goes wrong so often. | ||
| 252 | public static function addWarning($message, $args = array()) | ||
| 253 | { | ||
| 254 | self::addWarn($message, $args); | ||
| 255 | } | ||
| 256 | public static function addInfo($message, $args = array()) | ||
| 257 | { | ||
| 258 | $level = DebugItem::LEVEL_INFO; | ||
| 259 | $log = self::getInstance(); | ||
| 260 | $log->addLog($message, $level, $args); | ||
| 261 | } | ||
| 262 | public static function addDebug($message, $args = array()) | ||
| 263 | { | ||
| 264 | $level = DebugItem::LEVEL_DEBUG; | ||
| 265 | $log = self::getInstance(); | ||
| 266 | $log->addLog($message, $level, $args); | ||
| 267 | } | ||
| 268 | |||
| 269 | /** These should be removed every release. They are temporary only for d'bugging the current release */ | ||
| 270 | public static function addTemp($message, $args = array()) | ||
| 271 | { | ||
| 272 | self::addDebug($message, $args); | ||
| 273 | } | ||
| 274 | |||
| 275 | public static function logLevel($level) | ||
| 276 | { | ||
| 277 | $log = self::getInstance(); | ||
| 278 | static::addInfo('Changing Log level' . $level); | ||
| 279 | $log->setLogLevel($level); | ||
| 280 | } | ||
| 281 | |||
| 282 | public static function getLogLevel() | ||
| 283 | { | ||
| 284 | $log = self::getInstance(); | ||
| 285 | return $log->getEnv('logLevel'); | ||
| 286 | } | ||
| 287 | |||
| 288 | public static function isManualDebug() | ||
| 289 | { | ||
| 290 | $log = self::getInstance(); | ||
| 291 | return $log->getEnv('is_manual_request'); | ||
| 292 | } | ||
| 293 | |||
| 294 | public static function getLogPath() | ||
| 295 | { | ||
| 296 | $log = self::getInstance(); | ||
| 297 | return $log->getEnv('logPath'); | ||
| 298 | } | ||
| 299 | |||
| 300 | /** Function to test if the debugger is active | ||
| 301 | * @return boolean true when active. | ||
| 302 | */ | ||
| 303 | public static function debugIsActive() | ||
| 304 | { | ||
| 305 | $log = self::getInstance(); | ||
| 306 | return $log->getEnv('is_active'); | ||
| 307 | } | ||
| 308 | |||
| 309 | protected function monitorHooks() | ||
| 310 | { | ||
| 311 | |||
| 312 | foreach($this->hooks as $hook => $data) | ||
| 313 | { | ||
| 314 | $numargs = isset($data['numargs']) ? $data['numargs'] : 1; | ||
| 315 | $prio = isset($data['priority']) ? $data['priority'] : 10; | ||
| 316 | |||
| 317 | add_filter($hook, function($value) use ($hook) { | ||
| 318 | $args = func_get_args(); | ||
| 319 | return $this->logHook($hook, $value, $args); }, $prio, $numargs); | ||
| 320 | } | ||
| 321 | } | ||
| 322 | |||
| 323 | public function logHook($hook, $value, $args) | ||
| 324 | { | ||
| 325 | array_shift($args); | ||
| 326 | self::addInfo('[Hook] - ' . $hook . ' with ' . var_export($value,true), $args); | ||
| 327 | return $value; | ||
| 328 | } | ||
| 329 | |||
| 330 | public function loadView() | ||
| 331 | { | ||
| 332 | // load either param or class template. | ||
| 333 | $template = $this->template; | ||
| 334 | |||
| 335 | $view = $this->view; | ||
| 336 | $view->namespace = $this->namespace; | ||
| 337 | $controller = $this; | ||
| 338 | |||
| 339 | $template_path = __DIR__ . '/' . $this->template . '.php'; | ||
| 340 | // var_dump( $template_path); | ||
| 341 | if (file_exists($template_path)) | ||
| 342 | { | ||
| 343 | |||
| 344 | include($template_path); | ||
| 345 | } | ||
| 346 | else { | ||
| 347 | self::addError("View $template could not be found in " . $template_path, | ||
| 348 | array('class' => get_class($this), 'req' => $_REQUEST)); | ||
| 349 | } | ||
| 350 | } | ||
| 351 | |||
| 352 | |||
| 353 | } // class debugController |
| 1 | <?php | ||
| 2 | // Debug Box to load Log File | ||
| 3 | namespace EnableMediaReplace\ShortPixelLogger; | ||
| 4 | wp_enqueue_script( 'jquery-ui-draggable' ); | ||
| 5 | |||
| 6 | ?> | ||
| 7 | |||
| 8 | <style> | ||
| 9 | .sp_debug_wrap | ||
| 10 | { | ||
| 11 | position: relative; | ||
| 12 | clear: both; | ||
| 13 | } | ||
| 14 | .sp_debug_box | ||
| 15 | { | ||
| 16 | position: absolute; | ||
| 17 | right: 0px; | ||
| 18 | top: 50px; | ||
| 19 | background-color: #fff; | ||
| 20 | width: 150px; | ||
| 21 | z-index: 1000000; | ||
| 22 | border: 1px solid #000; | ||
| 23 | |||
| 24 | } | ||
| 25 | .sp_debug_box .header | ||
| 26 | { | ||
| 27 | min-height: 10px; | ||
| 28 | background: #000; | ||
| 29 | color: #fff; | ||
| 30 | padding: 8px | ||
| 31 | } | ||
| 32 | .sp_debug_box .content_box | ||
| 33 | { | ||
| 34 | background: #ccc; | ||
| 35 | } | ||
| 36 | .content_box | ||
| 37 | { | ||
| 38 | padding: 8px; | ||
| 39 | } | ||
| 40 | </style> | ||
| 41 | |||
| 42 | <script language='javascript'> | ||
| 43 | jQuery(document).ready(function($) | ||
| 44 | { | ||
| 45 | $( ".sp_debug_box" ).draggable(); | ||
| 46 | |||
| 47 | }); | ||
| 48 | </script> | ||
| 49 | |||
| 50 | |||
| 51 | <div class='sp_debug_box'> | ||
| 52 | <div class='header'><?php echo $view->namespace ?> Debug Box </div> | ||
| 53 | <a target="_blank" href='<?php echo $view->logLink ?>'>Logfile</a> | ||
| 54 | <div class='content_box'> | ||
| 55 | |||
| 56 | </div> | ||
| 57 | </div> |
| 1 | { | ||
| 2 | "name": "shortpixel/notices", | ||
| 3 | "description": "ShortPixel WordPress Notice System", | ||
| 4 | "version": "1.5", | ||
| 5 | "type": "library", | ||
| 6 | "license": "MIT", | ||
| 7 | "authors": [ | ||
| 8 | { | ||
| 9 | "name": "Bas", | ||
| 10 | "email": "bas@weblogmechanic.com" | ||
| 11 | } | ||
| 12 | ], | ||
| 13 | "minimum-stability": "dev", | ||
| 14 | "require": { | ||
| 15 | "shortpixel/log" : "1.1.*" | ||
| 16 | }, | ||
| 17 | "repositories": [ | ||
| 18 | { | ||
| 19 | "packagist.org": false, | ||
| 20 | "type": "path", | ||
| 21 | "url": "../modules/", | ||
| 22 | "options": { | ||
| 23 | "symlink": true | ||
| 24 | } | ||
| 25 | } | ||
| 26 | ], | ||
| 27 | |||
| 28 | "autoload": { | ||
| 29 | "psr-4": { "ShortPixel\\Notices\\" : "src" } | ||
| 30 | } | ||
| 31 | } |
wp-content/plugins/enable-media-replace/build/shortpixel/notices/src/NoticeController.php
0 → 100644
| 1 | <?php | ||
| 2 | namespace EnableMediaReplace\Notices; | ||
| 3 | use EnableMediaReplace\ShortPixelLogger\ShortPixelLogger as Log; | ||
| 4 | |||
| 5 | class NoticeController //extends ShortPixelController | ||
| 6 | { | ||
| 7 | protected static $notices = array(); | ||
| 8 | protected static $instance = null; | ||
| 9 | protected static $cssHookLoaded = false; // prevent css output more than once. | ||
| 10 | |||
| 11 | protected $notice_displayed = array(); | ||
| 12 | |||
| 13 | public $notice_count = 0; | ||
| 14 | |||
| 15 | protected $has_stored = false; | ||
| 16 | |||
| 17 | protected $notice_option = ''; // The wp_options name for notices here. | ||
| 18 | |||
| 19 | /** For backward compat. Never call constructor directly. */ | ||
| 20 | public function __construct() | ||
| 21 | { | ||
| 22 | $ns = __NAMESPACE__; | ||
| 23 | $ns = substr($ns, 0, strpos($ns, '\\')); // try to get first part of namespace | ||
| 24 | $this->notice_option = $ns . '-notices'; | ||
| 25 | |||
| 26 | add_action('wp_ajax_' . $this->notice_option, array($this, 'ajax_action')); | ||
| 27 | |||
| 28 | $this->loadNotices(); | ||
| 29 | //$this->loadConfig(); | ||
| 30 | } | ||
| 31 | |||
| 32 | public static function getInstance() | ||
| 33 | { | ||
| 34 | if ( self::$instance === null) | ||
| 35 | { | ||
| 36 | self::$instance = new NoticeController(); | ||
| 37 | } | ||
| 38 | |||
| 39 | return self::$instance; | ||
| 40 | } | ||
| 41 | |||
| 42 | /** Reset all notices, before loading them, to ensure on updates / activations one starts fresh */ | ||
| 43 | public static function resetNotices() | ||
| 44 | { | ||
| 45 | $ns = __NAMESPACE__; | ||
| 46 | $ns = substr($ns, 0, strpos($ns, '\\')); // try to get first part of namespace | ||
| 47 | $result = delete_option($ns . '-notices'); | ||
| 48 | } | ||
| 49 | |||
| 50 | /** Load Notices Config File, if any | ||
| 51 | * | ||
| 52 | * [ Future Use ] | ||
| 53 | */ | ||
| 54 | public function loadConfig() | ||
| 55 | { | ||
| 56 | return; | ||
| 57 | if (file_exists('../notice_config.json')) | ||
| 58 | { | ||
| 59 | $config = file_get_contents('../notice_config.json'); | ||
| 60 | $json_config = json_decode($config); | ||
| 61 | } | ||
| 62 | } | ||
| 63 | |||
| 64 | public function loadIcons($icons) | ||
| 65 | { | ||
| 66 | foreach($icons as $name => $icon) | ||
| 67 | NoticeModel::setIcon($name, $icon); | ||
| 68 | } | ||
| 69 | |||
| 70 | |||
| 71 | protected function loadNotices() | ||
| 72 | { | ||
| 73 | $notices = get_option($this->notice_option, false); | ||
| 74 | $cnotice = (is_array($notices)) ? count($notices) : 0; | ||
| 75 | |||
| 76 | if ($notices !== false && is_array($notices)) | ||
| 77 | { | ||
| 78 | $checked = array(); | ||
| 79 | foreach($notices as $noticeObj) | ||
| 80 | { | ||
| 81 | if (is_object($noticeObj) && $noticeObj instanceOf NoticeModel) | ||
| 82 | { | ||
| 83 | $checked[] = $noticeObj; | ||
| 84 | } | ||
| 85 | } | ||
| 86 | self::$notices = $checked; | ||
| 87 | $this->has_stored = true; | ||
| 88 | } | ||
| 89 | else { | ||
| 90 | self::$notices = array(); | ||
| 91 | $this->has_stored = false; | ||
| 92 | } | ||
| 93 | $this->countNotices(); | ||
| 94 | } | ||
| 95 | |||
| 96 | |||
| 97 | protected function addNotice($message, $code, $unique) | ||
| 98 | { | ||
| 99 | $notice = new NoticeModel($message, $code); | ||
| 100 | |||
| 101 | if ($unique) | ||
| 102 | { | ||
| 103 | foreach(self::$notices as $nitem) | ||
| 104 | { | ||
| 105 | if ($nitem->message == $notice->message && $nitem->code == $notice->code) // same message. | ||
| 106 | return $nitem; // return the notice with the same message. | ||
| 107 | } | ||
| 108 | } | ||
| 109 | self::$notices[] = $notice; | ||
| 110 | $this->countNotices(); | ||
| 111 | Log::addDebug('Adding notice - ', $notice); | ||
| 112 | $this->update(); | ||
| 113 | return $notice; | ||
| 114 | } | ||
| 115 | |||
| 116 | /** Update the notices to store, check what to remove, returns count. */ | ||
| 117 | public function update() | ||
| 118 | { | ||
| 119 | if (! is_array(self::$notices) || count(self::$notices) == 0) | ||
| 120 | { | ||
| 121 | if ($this->has_stored) | ||
| 122 | delete_option($this->notice_option); | ||
| 123 | |||
| 124 | return 0; | ||
| 125 | } | ||
| 126 | |||
| 127 | $new_notices = array(); | ||
| 128 | foreach(self::$notices as $item) | ||
| 129 | { | ||
| 130 | if (! $item->isDone() ) | ||
| 131 | { | ||
| 132 | $new_notices[] = $item; | ||
| 133 | } | ||
| 134 | } | ||
| 135 | |||
| 136 | update_option($this->notice_option, $new_notices); | ||
| 137 | self::$notices = $new_notices; | ||
| 138 | |||
| 139 | return $this->countNotices(); | ||
| 140 | } | ||
| 141 | |||
| 142 | public function countNotices() | ||
| 143 | { | ||
| 144 | $this->notice_count = count(self::$notices); | ||
| 145 | return $this->notice_count; | ||
| 146 | } | ||
| 147 | |||
| 148 | |||
| 149 | public function getNotices() | ||
| 150 | { | ||
| 151 | return self::$notices; | ||
| 152 | } | ||
| 153 | |||
| 154 | public function getNoticesForDisplay() | ||
| 155 | { | ||
| 156 | $newNotices = array(); | ||
| 157 | |||
| 158 | foreach(self::$notices as $notice) | ||
| 159 | { | ||
| 160 | if ($notice->isDismissed()) // dismissed never displays. | ||
| 161 | continue; | ||
| 162 | |||
| 163 | if ($notice->isPersistent()) | ||
| 164 | { | ||
| 165 | $id = $notice->getID(); | ||
| 166 | if (! is_null($id) && ! in_array($id, $this->notice_displayed)) | ||
| 167 | { | ||
| 168 | $notice->notice_action = $this->notice_option; | ||
| 169 | $newNotices[] = $notice; | ||
| 170 | $this->notice_displayed[] = $id; | ||
| 171 | } | ||
| 172 | |||
| 173 | } | ||
| 174 | else | ||
| 175 | $newNotices[] = $notice; | ||
| 176 | |||
| 177 | |||
| 178 | } | ||
| 179 | return $newNotices; | ||
| 180 | } | ||
| 181 | |||
| 182 | |||
| 183 | public function getNoticeByID($id) | ||
| 184 | { | ||
| 185 | foreach(self::$notices as $notice) | ||
| 186 | { | ||
| 187 | if ($notice->getID() == $id) | ||
| 188 | return $notice; | ||
| 189 | } | ||
| 190 | |||
| 191 | return false; | ||
| 192 | } | ||
| 193 | |||
| 194 | public static function removeNoticeByID($id) | ||
| 195 | { | ||
| 196 | $noticeController = self::getInstance(); | ||
| 197 | |||
| 198 | for($i = 0; $i < count(self::$notices); $i++) | ||
| 199 | { | ||
| 200 | $item = self::$notices[$i]; | ||
| 201 | if (is_object($item) && $item->getID() == $id) | ||
| 202 | { | ||
| 203 | Log::addDebug('Removing notice with ID ' . $id); | ||
| 204 | unset(self::$notices[$i]); | ||
| 205 | } | ||
| 206 | //if ($notice_item ) | ||
| 207 | } | ||
| 208 | $noticeController->update(); | ||
| 209 | } | ||
| 210 | |||
| 211 | public function ajax_action() | ||
| 212 | { | ||
| 213 | $response = array('result' => false, 'reason' => ''); | ||
| 214 | |||
| 215 | if ( wp_verify_nonce( $_POST['nonce'], 'dismiss') ) | ||
| 216 | { | ||
| 217 | if ($_POST['plugin_action'] == 'dismiss') | ||
| 218 | { | ||
| 219 | $id = sanitize_text_field($_POST['id']); | ||
| 220 | $notice = $this->getNoticeByID($id); | ||
| 221 | |||
| 222 | if($notice) | ||
| 223 | { | ||
| 224 | $notice->dismiss(); | ||
| 225 | $this->update(); | ||
| 226 | $response['result'] = true; | ||
| 227 | } | ||
| 228 | else | ||
| 229 | { | ||
| 230 | Log::addError('Notice not found when dismissing -> ' . $id, self::$notices); | ||
| 231 | $response['result'] = ' Notice ' . $id . ' not found. '; | ||
| 232 | } | ||
| 233 | |||
| 234 | } | ||
| 235 | |||
| 236 | } | ||
| 237 | else | ||
| 238 | { | ||
| 239 | Log::addError('Wrong Nonce when dismissed notice. '); | ||
| 240 | $response['reason'] = 'wrong nonce'; | ||
| 241 | } | ||
| 242 | wp_send_json($response); | ||
| 243 | } | ||
| 244 | |||
| 245 | /** Adds a notice, quick and fast method | ||
| 246 | * @param String $message The Message you want to notify | ||
| 247 | * @param Boolean $unique If unique, check to not repeat notice exact same text in notices. Discard if so | ||
| 248 | * @param int $code A value of messageType as defined in model | ||
| 249 | * @returm Object Instance of noticeModel | ||
| 250 | */ | ||
| 251 | |||
| 252 | public static function addNormal($message, $unique = false) | ||
| 253 | { | ||
| 254 | $noticeController = self::getInstance(); | ||
| 255 | $notice = $noticeController->addNotice($message, NoticeModel::NOTICE_NORMAL, $unique); | ||
| 256 | return $notice; | ||
| 257 | |||
| 258 | } | ||
| 259 | |||
| 260 | public static function addError($message, $unique = false) | ||
| 261 | { | ||
| 262 | $noticeController = self::getInstance(); | ||
| 263 | $notice = $noticeController->addNotice($message, NoticeModel::NOTICE_ERROR, $unique); | ||
| 264 | return $notice; | ||
| 265 | |||
| 266 | } | ||
| 267 | |||
| 268 | public static function addWarning($message, $unique = false) | ||
| 269 | { | ||
| 270 | $noticeController = self::getInstance(); | ||
| 271 | $notice = $noticeController->addNotice($message, NoticeModel::NOTICE_WARNING, $unique); | ||
| 272 | return $notice; | ||
| 273 | } | ||
| 274 | |||
| 275 | public static function addSuccess($message, $unique = false) | ||
| 276 | { | ||
| 277 | $noticeController = self::getInstance(); | ||
| 278 | $notice = $noticeController->addNotice($message, NoticeModel::NOTICE_SUCCESS, $unique); | ||
| 279 | return $notice; | ||
| 280 | |||
| 281 | } | ||
| 282 | |||
| 283 | public static function addDetail($notice, $detail) | ||
| 284 | { | ||
| 285 | $noticeController = self::getInstance(); | ||
| 286 | $notice->addDetail($detail); | ||
| 287 | |||
| 288 | // $notice_id = spl_object_id($notice); | ||
| 289 | |||
| 290 | $noticeController->update(); | ||
| 291 | } | ||
| 292 | |||
| 293 | /** Make a regular notice persistent across multiple page loads | ||
| 294 | * @param $notice NoticeModel The Notice to make Persistent | ||
| 295 | * @param $key String Identifier of the persistent notice. | ||
| 296 | * @param $suppress Int When dismissed, time to stay dismissed | ||
| 297 | * @param $callback Function Callable function | ||
| 298 | */ | ||
| 299 | public static function makePersistent($notice, $key, $suppress = -1, $callback = null) | ||
| 300 | { | ||
| 301 | $noticeController = self::getInstance(); | ||
| 302 | $existing = $noticeController->getNoticeByID($key); | ||
| 303 | |||
| 304 | // if this key already exists, don't allow the new notice to be entered into the array. Remove it since it's already created. | ||
| 305 | if ($existing) | ||
| 306 | { | ||
| 307 | for($i = 0; $i < count(self::$notices); $i++) | ||
| 308 | { | ||
| 309 | $item = self::$notices[$i]; | ||
| 310 | |||
| 311 | if ($item->message == $notice->message && $item->getID() == null) | ||
| 312 | { | ||
| 313 | if ($item->message != $existing->message) // allow the persistent message to be updated, if something else is served on this ID | ||
| 314 | { | ||
| 315 | $existing->message = $item->message; | ||
| 316 | } | ||
| 317 | unset(self::$notices[$i]); | ||
| 318 | } | ||
| 319 | //if ($notice_item ) | ||
| 320 | } | ||
| 321 | } | ||
| 322 | else | ||
| 323 | { | ||
| 324 | $notice->setPersistent($key, $suppress, $callback); // set this notice persistent. | ||
| 325 | } | ||
| 326 | |||
| 327 | $noticeController->update(); | ||
| 328 | } | ||
| 329 | |||
| 330 | public function admin_notices() | ||
| 331 | { | ||
| 332 | if ($this->countNotices() > 0) | ||
| 333 | { | ||
| 334 | if (! self::$cssHookLoaded) | ||
| 335 | { | ||
| 336 | add_action('admin_print_footer_scripts', array($this, 'printNoticeStyle')); | ||
| 337 | self::$cssHookLoaded = true; | ||
| 338 | } | ||
| 339 | foreach($this->getNoticesForDisplay() as $notice) | ||
| 340 | { | ||
| 341 | echo $notice->getForDisplay(); | ||
| 342 | } | ||
| 343 | } | ||
| 344 | $this->update(); // puts views, and updates | ||
| 345 | } | ||
| 346 | |||
| 347 | |||
| 348 | public function printNoticeStyle() | ||
| 349 | { | ||
| 350 | if (file_exists(__DIR__ . '/css/notices.css')) | ||
| 351 | { | ||
| 352 | echo '<style>' . file_get_contents(__DIR__ . '/css/notices.css') . '</style>'; | ||
| 353 | } | ||
| 354 | else { | ||
| 355 | Log::addDebug('Notices : css/notices.css could not be loaded'); | ||
| 356 | } | ||
| 357 | } | ||
| 358 | |||
| 359 | |||
| 360 | |||
| 361 | |||
| 362 | } |
| 1 | <?php | ||
| 2 | namespace EnableMediaReplace\Notices; | ||
| 3 | |||
| 4 | class NoticeModel //extends ShortPixelModel | ||
| 5 | { | ||
| 6 | public $message; // The message we want to convey. | ||
| 7 | public $details = array(); // extra details, like the files involved. Something could be hideable in the future. | ||
| 8 | public $code; | ||
| 9 | |||
| 10 | private $id = null; // used for persistent messages. | ||
| 11 | protected $viewed = false; // was this notice viewed? | ||
| 12 | protected $is_persistent = false; // This is a fatal issue, display until something was fixed. | ||
| 13 | protected $is_dismissed = false; // for persistent notices, | ||
| 14 | protected $suppress_until = null; | ||
| 15 | protected $suppress_period = -1; | ||
| 16 | public $is_removable = true; // if removable, display a notice dialog with red X or so. | ||
| 17 | public $messageType = self::NOTICE_NORMAL; | ||
| 18 | |||
| 19 | public $notice_action; // empty unless for display. Ajax action to talk back to controller. | ||
| 20 | protected $callback; // empty unless callback is needed | ||
| 21 | |||
| 22 | public static $icons = array(); | ||
| 23 | |||
| 24 | const NOTICE_NORMAL = 1; | ||
| 25 | const NOTICE_ERROR = 2; | ||
| 26 | const NOTICE_SUCCESS = 3; | ||
| 27 | const NOTICE_WARNING = 4; | ||
| 28 | |||
| 29 | /** Use this model in conjunction with NoticeController, do not call directly */ | ||
| 30 | public function __construct($message, $messageType = self::NOTICE_NORMAL) | ||
| 31 | { | ||
| 32 | $this->message = $message; | ||
| 33 | $this->messageType = $messageType; | ||
| 34 | |||
| 35 | } | ||
| 36 | |||
| 37 | public function isDone() | ||
| 38 | { | ||
| 39 | // check suppressed | ||
| 40 | if ($this->is_dismissed && ! is_null($this->suppress_until)) | ||
| 41 | { | ||
| 42 | if (time() >= $this->suppress_until) | ||
| 43 | { | ||
| 44 | //Log::addDebug('') | ||
| 45 | $this->is_persistent = false; // unpersist, so it will be cleaned and dropped. | ||
| 46 | |||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | if ($this->viewed && ! $this->is_persistent) | ||
| 51 | return true; | ||
| 52 | else | ||
| 53 | return false; | ||
| 54 | } | ||
| 55 | |||
| 56 | public function getID() | ||
| 57 | { | ||
| 58 | return $this->id; | ||
| 59 | } | ||
| 60 | |||
| 61 | public function isPersistent() | ||
| 62 | { | ||
| 63 | return $this->is_persistent; | ||
| 64 | } | ||
| 65 | |||
| 66 | public function isDismissed() | ||
| 67 | { | ||
| 68 | return $this->is_dismissed; | ||
| 69 | } | ||
| 70 | |||
| 71 | public function dismiss() | ||
| 72 | { | ||
| 73 | $this->is_dismissed = true; | ||
| 74 | $this->suppress_until = time() + $this->suppress_period; | ||
| 75 | } | ||
| 76 | |||
| 77 | public function unDismiss() | ||
| 78 | { | ||
| 79 | $this->is_dismissed = false; | ||
| 80 | } | ||
| 81 | |||
| 82 | public function setDismissedUntil($timestamp) | ||
| 83 | { | ||
| 84 | $this->suppress_until = $timestamp; | ||
| 85 | } | ||
| 86 | |||
| 87 | /** Support for extra information beyond the message. | ||
| 88 | * Can help to not overwhelm users w/ the same message but different file /circumstances. | ||
| 89 | */ | ||
| 90 | public function addDetail($detail, $clean = false) | ||
| 91 | { | ||
| 92 | if ($clean) | ||
| 93 | $this->details = array(); | ||
| 94 | |||
| 95 | if (! in_array($detail, $this->details) ) | ||
| 96 | $this->details[] = $detail; | ||
| 97 | } | ||
| 98 | |||
| 99 | |||
| 100 | |||
| 101 | /** Set a notice persistent. Meaning it shows every page load until dismissed. | ||
| 102 | * @param $key Unique Key of this message. Required | ||
| 103 | * @param $suppress When dismissed do not show this message again for X amount of time. When -1 it will just be dropped from the Notices and not suppressed | ||
| 104 | */ | ||
| 105 | public function setPersistent($key, $suppress = -1, $callback = null) | ||
| 106 | { | ||
| 107 | $this->id = $key; | ||
| 108 | $this->is_persistent = true; | ||
| 109 | $this->suppress_period = $suppress; | ||
| 110 | if ( ! is_null($callback) && is_callable($callback)) | ||
| 111 | { | ||
| 112 | $this->callback = $callback; | ||
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 116 | public static function setIcon($notice_type, $icon) | ||
| 117 | { | ||
| 118 | switch($notice_type) | ||
| 119 | { | ||
| 120 | case 'error': | ||
| 121 | $type = self::NOTICE_ERROR; | ||
| 122 | break; | ||
| 123 | case 'success': | ||
| 124 | $type = self::NOTICE_SUCCESS; | ||
| 125 | break; | ||
| 126 | case 'warning': | ||
| 127 | $type = self::NOTICE_WARNING; | ||
| 128 | break; | ||
| 129 | case 'normal': | ||
| 130 | default: | ||
| 131 | $type = self::NOTICE_NORMAL; | ||
| 132 | break; | ||
| 133 | } | ||
| 134 | self::$icons[$type] = $icon; | ||
| 135 | } | ||
| 136 | |||
| 137 | private function checkIncomplete($var) | ||
| 138 | { | ||
| 139 | return ($var instanceof \__PHP_Incomplete_Class); | ||
| 140 | } | ||
| 141 | |||
| 142 | public function getForDisplay() | ||
| 143 | { | ||
| 144 | $this->viewed = true; | ||
| 145 | $class = 'shortpixel notice '; | ||
| 146 | |||
| 147 | $icon = ''; | ||
| 148 | |||
| 149 | if ($this->callback) | ||
| 150 | { | ||
| 151 | if (is_array($this->callback)) | ||
| 152 | { | ||
| 153 | foreach($this->callback as $part) | ||
| 154 | { | ||
| 155 | if ($this->checkIncomplete($part) === true) | ||
| 156 | { | ||
| 157 | return false; | ||
| 158 | } | ||
| 159 | } | ||
| 160 | } elseif (is_object($this->callback)) | ||
| 161 | { | ||
| 162 | if ($this->checkIncomplete($part) === true) | ||
| 163 | return false; | ||
| 164 | } | ||
| 165 | |||
| 166 | $return = call_user_func($this->callback, $this); | ||
| 167 | if ($return === false) // don't display is callback returns false explicitly. | ||
| 168 | return; | ||
| 169 | } | ||
| 170 | |||
| 171 | switch($this->messageType) | ||
| 172 | { | ||
| 173 | case self::NOTICE_ERROR: | ||
| 174 | $class .= 'notice-error '; | ||
| 175 | $icon = isset(self::$icons[self::NOTICE_ERROR]) ? self::$icons[self::NOTICE_ERROR] : ''; | ||
| 176 | //$icon = 'scared'; | ||
| 177 | break; | ||
| 178 | case self::NOTICE_SUCCESS: | ||
| 179 | $class .= 'notice-success '; | ||
| 180 | $icon = isset(self::$icons[self::NOTICE_SUCCESS]) ? self::$icons[self::NOTICE_SUCCESS] : ''; | ||
| 181 | break; | ||
| 182 | case self::NOTICE_WARNING: | ||
| 183 | $class .= 'notice-warning '; | ||
| 184 | $icon = isset(self::$icons[self::NOTICE_WARNING]) ? self::$icons[self::NOTICE_WARNING] : ''; | ||
| 185 | break; | ||
| 186 | case self::NOTICE_NORMAL: | ||
| 187 | $class .= 'notice-info '; | ||
| 188 | $icon = isset(self::$icons[self::NOTICE_NORMAL]) ? self::$icons[self::NOTICE_NORMAL] : ''; | ||
| 189 | break; | ||
| 190 | default: | ||
| 191 | $class .= 'notice-info '; | ||
| 192 | $icon = ''; | ||
| 193 | break; | ||
| 194 | } | ||
| 195 | |||
| 196 | |||
| 197 | if ($this->is_removable) | ||
| 198 | { | ||
| 199 | $class .= 'is-dismissible '; | ||
| 200 | } | ||
| 201 | |||
| 202 | if ($this->is_persistent) | ||
| 203 | { | ||
| 204 | $class .= 'is-persistent '; | ||
| 205 | } | ||
| 206 | |||
| 207 | $id = ! is_null($this->id) ? $this->id : uniqid(); | ||
| 208 | //'id="' . $this->id . '"' | ||
| 209 | $output = "<div id='$id' class='$class'><span class='icon'> " . $icon . "</span> <span class='content'>" . $this->message; | ||
| 210 | if ($this->hasDetails()) | ||
| 211 | { | ||
| 212 | $output .= '<div class="details-wrapper"> | ||
| 213 | <input type="checkbox" name="detailhider" id="check-' . $id .'"> | ||
| 214 | <label for="check-' . $id . '" class="show-details"><span>' . __('See Details', 'shortpixel-image-optimiser') . '</span> | ||
| 215 | </label>'; | ||
| 216 | |||
| 217 | $output .= "<div class='detail-content-wrapper'><p class='detail-content'>" . $this->parseDetails() . "</p></div>"; | ||
| 218 | $output .= '<label for="check-' . $id . '" class="hide-details"><span>' . __('Hide Details', 'shortpixel-image-optimiser') . '</span></label>'; | ||
| 219 | |||
| 220 | $output .= '</div>'; // detail rapper | ||
| 221 | |||
| 222 | } | ||
| 223 | $output .= "</span></div>"; | ||
| 224 | |||
| 225 | if ($this->is_persistent && $this->is_removable) | ||
| 226 | { | ||
| 227 | $output .= "<script type='text/javascript'>\n" . $this->getDismissJS() . "\n</script>"; | ||
| 228 | } | ||
| 229 | return $output; | ||
| 230 | |||
| 231 | } | ||
| 232 | |||
| 233 | protected function hasDetails() | ||
| 234 | { | ||
| 235 | if (is_array($this->details) && count($this->details) > 0) | ||
| 236 | return true; | ||
| 237 | else | ||
| 238 | return false; | ||
| 239 | } | ||
| 240 | |||
| 241 | protected function parseDetails() | ||
| 242 | { | ||
| 243 | return implode('<BR>', $this->details); | ||
| 244 | } | ||
| 245 | |||
| 246 | private function getDismissJS() | ||
| 247 | { | ||
| 248 | $url = wp_json_encode(admin_url('admin-ajax.php')); | ||
| 249 | // $action = 'dismiss'; | ||
| 250 | $nonce = wp_create_nonce('dismiss'); | ||
| 251 | |||
| 252 | $data = wp_json_encode(array('action' => $this->notice_action, 'plugin_action' => 'dismiss', 'nonce' => $nonce, 'id' => $this->id, 'time' => $this->suppress_period)); | ||
| 253 | |||
| 254 | // $data_string = "{action:'$this->notice_action'}"; | ||
| 255 | |||
| 256 | $js = "jQuery(document).on('click','#$this->id button.notice-dismiss', | ||
| 257 | function() { | ||
| 258 | var data = $data; | ||
| 259 | var url = $url; | ||
| 260 | jQuery.post(url, data); } | ||
| 261 | );"; | ||
| 262 | return "\n jQuery(document).ready(function(){ \n" . $js . "\n});"; | ||
| 263 | } | ||
| 264 | |||
| 265 | } |
| 1 | .shortpixel.notice { | ||
| 2 | padding: 8px; } | ||
| 3 | .shortpixel.notice img { | ||
| 4 | display: inline-block; | ||
| 5 | margin: 0 25px 0 0; | ||
| 6 | max-height: 50px; } | ||
| 7 | .shortpixel.notice .notice-dismiss { | ||
| 8 | margin-top: 10px; } | ||
| 9 | |||
| 10 | /* In-view notice ( not on top, between the options ) - styled after WP notice */ | ||
| 11 | .view-notice { | ||
| 12 | box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1); | ||
| 13 | border: 4px solid #fff; | ||
| 14 | padding: 1px 12px; } | ||
| 15 | .view-notice p { | ||
| 16 | margin: 1em 0 !important; } | ||
| 17 | .view-notice.warning { | ||
| 18 | border-left-color: #ffb900; } | ||
| 19 | |||
| 20 | .view-notice-row { | ||
| 21 | display: none; } |
| 1 | |||
| 2 | .shortpixel.notice | ||
| 3 | { | ||
| 4 | //padding: 18px; | ||
| 5 | //min-height: 50px; | ||
| 6 | padding: 8px; | ||
| 7 | img | ||
| 8 | { | ||
| 9 | display:inline-block; | ||
| 10 | margin: 0 25px 0 0; | ||
| 11 | max-height: 50px; | ||
| 12 | } | ||
| 13 | .notice-dismiss | ||
| 14 | { | ||
| 15 | margin-top: 10px; | ||
| 16 | } | ||
| 17 | } | ||
| 18 | |||
| 19 | /* In-view notice ( not on top, between the options ) - styled after WP notice */ | ||
| 20 | .view-notice | ||
| 21 | { | ||
| 22 | |||
| 23 | box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 ); | ||
| 24 | border: 4px solid #fff; | ||
| 25 | |||
| 26 | padding: 1px 12px; | ||
| 27 | p { | ||
| 28 | margin: 1em 0 !important; | ||
| 29 | } | ||
| 30 | &.warning | ||
| 31 | { | ||
| 32 | border-left-color: #ffb900; | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | .view-notice-row | ||
| 37 | { | ||
| 38 | display: none; | ||
| 39 | } |
| 1 | <?php | ||
| 2 | namespace EnableMediaReplace; | ||
| 3 | |||
| 4 | use EnableMediaReplace\ShortPixelLogger\ShortPixelLogger as Log; | ||
| 5 | |||
| 6 | class emrCache | ||
| 7 | { | ||
| 8 | protected $has_supercache = false; // supercache seems to replace quite fine, without our help. @todo Test if this is needed | ||
| 9 | protected $has_w3tc = false; | ||
| 10 | protected $has_wpengine = false; | ||
| 11 | protected $has_fastestcache = false; | ||
| 12 | protected $has_siteground = false; | ||
| 13 | protected $has_litespeed = false; | ||
| 14 | |||
| 15 | public function __construct() | ||
| 16 | { | ||
| 17 | |||
| 18 | } | ||
| 19 | |||
| 20 | /** Checks which cache plugins are active on the moment a flush is needed */ | ||
| 21 | public function checkCaches() | ||
| 22 | { | ||
| 23 | if ( function_exists( 'w3tc_pgcache_flush' ) ) | ||
| 24 | $this->has_w3tc = true; | ||
| 25 | |||
| 26 | if ( function_exists('wp_cache_clean_cache') ) | ||
| 27 | $this->has_supercache = true; | ||
| 28 | |||
| 29 | if ( class_exists( 'WpeCommon' ) ) | ||
| 30 | $this->has_wpengine = true; | ||
| 31 | |||
| 32 | global $wp_fastest_cache; | ||
| 33 | if ( method_exists( 'WpFastestCache', 'deleteCache' ) && !empty( $wp_fastest_cache ) ) | ||
| 34 | $this->has_fastestcache = true; | ||
| 35 | |||
| 36 | // SG SuperCacher | ||
| 37 | if (function_exists('sg_cachepress_purge_cache')) { | ||
| 38 | $this->has_siteground = true; | ||
| 39 | } | ||
| 40 | |||
| 41 | if (defined( 'LSCWP_DIR' )) | ||
| 42 | { | ||
| 43 | $this->has_litespeed = true; | ||
| 44 | } | ||
| 45 | |||
| 46 | // @todo WpRocket? | ||
| 47 | // @todo BlueHost Caching? | ||
| 48 | } | ||
| 49 | |||
| 50 | /* Tries to flush cache there were we have issues | ||
| 51 | * | ||
| 52 | * @param Array $args Argument Array to provide data. | ||
| 53 | */ | ||
| 54 | public function flushCache($args) | ||
| 55 | { | ||
| 56 | $defaults = array( | ||
| 57 | 'flush_mode' => 'post', | ||
| 58 | 'post_id' => 0, | ||
| 59 | ); | ||
| 60 | |||
| 61 | $args = wp_parse_args($args, $defaults); | ||
| 62 | $post_id = $args['post_id']; // can be zero! | ||
| 63 | |||
| 64 | // important - first check the available cache plugins | ||
| 65 | $this->checkCaches(); | ||
| 66 | |||
| 67 | // general WP | ||
| 68 | if ($post_id > 0) | ||
| 69 | clean_post_cache($post_id); | ||
| 70 | else | ||
| 71 | wp_cache_flush(); | ||
| 72 | |||
| 73 | /* Verified working without. | ||
| 74 | if ($this->has_supercache) | ||
| 75 | $this->removeSuperCache(); | ||
| 76 | */ | ||
| 77 | if ($this->has_w3tc) | ||
| 78 | $this->removeW3tcCache(); | ||
| 79 | |||
| 80 | if ($this->has_wpengine) | ||
| 81 | $this->removeWpeCache(); | ||
| 82 | |||
| 83 | if ($this->has_siteground) | ||
| 84 | $this->removeSiteGround(); | ||
| 85 | |||
| 86 | if ($this->has_fastestcache) | ||
| 87 | $this->removeFastestCache(); | ||
| 88 | |||
| 89 | if ($this->has_litespeed) | ||
| 90 | $this->litespeedReset($post_id); | ||
| 91 | |||
| 92 | do_action('emr/cache/flush', $post_id); | ||
| 93 | } | ||
| 94 | |||
| 95 | protected function removeSuperCache() | ||
| 96 | { | ||
| 97 | global $file_prefix, $supercachedir; | ||
| 98 | if ( empty( $supercachedir ) && function_exists( 'get_supercache_dir' ) ) { | ||
| 99 | $supercachedir = get_supercache_dir(); | ||
| 100 | } | ||
| 101 | wp_cache_clean_cache( $file_prefix ); | ||
| 102 | } | ||
| 103 | |||
| 104 | protected function removeW3tcCache() | ||
| 105 | { | ||
| 106 | w3tc_pgcache_flush(); | ||
| 107 | } | ||
| 108 | |||
| 109 | protected function removeWpeCache() | ||
| 110 | { | ||
| 111 | if ( method_exists( 'WpeCommon', 'purge_memcached' ) ) { | ||
| 112 | \WpeCommon::purge_memcached(); | ||
| 113 | } | ||
| 114 | if ( method_exists( 'WpeCommon', 'clear_maxcdn_cache' ) ) { | ||
| 115 | \WpeCommon::clear_maxcdn_cache(); | ||
| 116 | } | ||
| 117 | if ( method_exists( 'WpeCommon', 'purge_varnish_cache' ) ) { | ||
| 118 | \WpeCommon::purge_varnish_cache(); | ||
| 119 | } | ||
| 120 | } | ||
| 121 | |||
| 122 | protected function removeFastestCache() | ||
| 123 | { | ||
| 124 | global $wp_fastest_cache; | ||
| 125 | $wp_fastest_cache->deleteCache(); | ||
| 126 | } | ||
| 127 | |||
| 128 | protected function removeSiteGround() | ||
| 129 | { | ||
| 130 | sg_cachepress_purge_cache(); | ||
| 131 | } | ||
| 132 | |||
| 133 | protected function litespeedReset($post_id) | ||
| 134 | { | ||
| 135 | do_action('litespeed_media_reset', $post_id); | ||
| 136 | } | ||
| 137 | |||
| 138 | } |
| 1 | <?php | ||
| 2 | |||
| 3 | // Compatibility functions for old version of WordPress / PHP / Other | ||
| 4 | |||
| 5 | |||
| 6 | /* | ||
| 7 | * Introduced in WP 4.9.7 - https://developer.wordpress.org/reference/functions/wp_delete_attachment_files/ | ||
| 8 | * Compat for previous versions. | ||
| 9 | */ | ||
| 10 | if (! function_exists('wp_delete_attachment_files')) | ||
| 11 | { | ||
| 12 | function wp_delete_attachment_files($post_id, $meta, $backup_sizes, $file ) | ||
| 13 | { | ||
| 14 | global $wpdb; | ||
| 15 | $uploadpath = wp_get_upload_dir(); | ||
| 16 | $deleted = true; | ||
| 17 | |||
| 18 | if ( ! empty( $meta['thumb'] ) ) { | ||
| 19 | // Don't delete the thumb if another attachment uses it. | ||
| 20 | if ( ! $wpdb->get_row( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE %s AND post_id <> %d", '%' . $wpdb->esc_like( $meta['thumb'] ) . '%', $post_id ) ) ) { | ||
| 21 | $thumbfile = str_replace( wp_basename( $file ), $meta['thumb'], $file ); | ||
| 22 | if ( ! empty( $thumbfile ) ) { | ||
| 23 | $thumbfile = path_join( $uploadpath['basedir'], $thumbfile ); | ||
| 24 | $thumbdir = path_join( $uploadpath['basedir'], dirname( $file ) ); | ||
| 25 | |||
| 26 | if ( ! wp_delete_file_from_directory( $thumbfile, $thumbdir ) ) { | ||
| 27 | $deleted = false; | ||
| 28 | } | ||
| 29 | } | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | // Remove intermediate and backup images if there are any. | ||
| 34 | if ( isset( $meta['sizes'] ) && is_array( $meta['sizes'] ) ) { | ||
| 35 | $intermediate_dir = path_join( $uploadpath['basedir'], dirname( $file ) ); | ||
| 36 | foreach ( $meta['sizes'] as $size => $sizeinfo ) { | ||
| 37 | $intermediate_file = str_replace( wp_basename( $file ), $sizeinfo['file'], $file ); | ||
| 38 | if ( ! empty( $intermediate_file ) ) { | ||
| 39 | $intermediate_file = path_join( $uploadpath['basedir'], $intermediate_file ); | ||
| 40 | |||
| 41 | if ( ! wp_delete_file_from_directory( $intermediate_file, $intermediate_dir ) ) { | ||
| 42 | $deleted = false; | ||
| 43 | } | ||
| 44 | } | ||
| 45 | } | ||
| 46 | } | ||
| 47 | |||
| 48 | if ( is_array( $backup_sizes ) ) { | ||
| 49 | $del_dir = path_join( $uploadpath['basedir'], dirname( $meta['file'] ) ); | ||
| 50 | foreach ( $backup_sizes as $size ) { | ||
| 51 | $del_file = path_join( dirname( $meta['file'] ), $size['file'] ); | ||
| 52 | if ( ! empty( $del_file ) ) { | ||
| 53 | $del_file = path_join( $uploadpath['basedir'], $del_file ); | ||
| 54 | |||
| 55 | if ( ! wp_delete_file_from_directory( $del_file, $del_dir ) ) { | ||
| 56 | $deleted = false; | ||
| 57 | } | ||
| 58 | } | ||
| 59 | } | ||
| 60 | } | ||
| 61 | |||
| 62 | if ( ! wp_delete_file_from_directory( $file, $uploadpath['basedir'] ) ) { | ||
| 63 | $deleted = false; | ||
| 64 | } | ||
| 65 | |||
| 66 | return $deleted; | ||
| 67 | |||
| 68 | } | ||
| 69 | } // end function | ||
| 70 | |||
| 71 | |||
| 72 | /* | ||
| 73 | * Introduced in WP 4.9.7 - https://developer.wordpress.org/reference/functions/wp_delete_attachment_files/ | ||
| 74 | * Compat for previous versions. | ||
| 75 | */ | ||
| 76 | if (! function_exists('wp_delete_file_from_directory')) | ||
| 77 | { | ||
| 78 | function wp_delete_file_from_directory( $file, $directory ) { | ||
| 79 | if ( wp_is_stream( $file ) ) { | ||
| 80 | $real_file = wp_normalize_path( $file ); | ||
| 81 | $real_directory = wp_normalize_path( $directory ); | ||
| 82 | } else { | ||
| 83 | $real_file = realpath( wp_normalize_path( $file ) ); | ||
| 84 | $real_directory = realpath( wp_normalize_path( $directory ) ); | ||
| 85 | } | ||
| 86 | |||
| 87 | if ( false === $real_file || false === $real_directory || strpos( $real_file, trailingslashit( $real_directory ) ) !== 0 ) { | ||
| 88 | return false; | ||
| 89 | } | ||
| 90 | |||
| 91 | wp_delete_file( $file ); | ||
| 92 | |||
| 93 | return true; | ||
| 94 | } | ||
| 95 | |||
| 96 | } // end function | ||
| 97 | |||
| 98 | |||
| 99 | /* | ||
| 100 | * Introduced in WP 4.5.0 - needed for compat function of wp_delete_attachment_files | ||
| 101 | */ | ||
| 102 | if (! function_exists('wp_get_upload_dir')) | ||
| 103 | { | ||
| 104 | function wp_get_upload_dir() { | ||
| 105 | return wp_upload_dir( null, false ); | ||
| 106 | } | ||
| 107 | } |
This diff is collapsed.
Click to expand it.
| 1 | <?php | ||
| 2 | namespace EnableMediaReplace\Externals; | ||
| 3 | |||
| 4 | class Elementor | ||
| 5 | { | ||
| 6 | private static $instance; | ||
| 7 | |||
| 8 | protected $queryKey = 'elementor'; | ||
| 9 | |||
| 10 | public static function getInstance() | ||
| 11 | { | ||
| 12 | if (is_null(self::$instance)) | ||
| 13 | self::$instance = new Elementor(); | ||
| 14 | |||
| 15 | return self::$instance; | ||
| 16 | } | ||
| 17 | |||
| 18 | public function __construct() | ||
| 19 | { | ||
| 20 | if ($this->elementor_is_active()) // elementor is active | ||
| 21 | { | ||
| 22 | add_filter('emr/replacer/custom_replace_query', array($this, 'addElementor'), 10, 4); // custom query for elementor \ // problem | ||
| 23 | add_action('enable-media-replace-upload-done', array($this, 'removeCache') ); | ||
| 24 | } | ||
| 25 | } | ||
| 26 | |||
| 27 | public function addElementor($items, $base_url, $search_urls, $replace_urls) | ||
| 28 | { | ||
| 29 | $base_url = $this->addSlash($base_url); | ||
| 30 | $el_search_urls = $search_urls; //array_map(array($this, 'addslash'), $search_urls); | ||
| 31 | $el_replace_urls = $replace_urls; //array_map(array($this, 'addslash'), $replace_urls); | ||
| 32 | $items[$this->queryKey] = array('base_url' => $base_url, 'search_urls' => $el_search_urls, 'replace_urls' => $el_replace_urls); | ||
| 33 | return $items; | ||
| 34 | } | ||
| 35 | |||
| 36 | public function addSlash($value) | ||
| 37 | { | ||
| 38 | global $wpdb; | ||
| 39 | $value= ltrim($value, '/'); // for some reason the left / isn't picked up by Mysql. | ||
| 40 | $value= str_replace('/', '\/', $value); | ||
| 41 | $value = $wpdb->esc_like(($value)); //(wp_slash) / str_replace('/', '\/', $value); | ||
| 42 | |||
| 43 | return $value; | ||
| 44 | } | ||
| 45 | |||
| 46 | protected function elementor_is_active() | ||
| 47 | { | ||
| 48 | $bool = false; | ||
| 49 | |||
| 50 | if (defined('ELEMENTOR_VERSION')) | ||
| 51 | $bool = true; | ||
| 52 | |||
| 53 | return apply_filters('emr/externals/elementor_is_active', $bool); // manual override | ||
| 54 | } | ||
| 55 | |||
| 56 | public function removeCache() | ||
| 57 | { | ||
| 58 | \Elementor\Plugin::$instance->files_manager->clear_cache(); | ||
| 59 | } | ||
| 60 | } |
| 1 | <?php | ||
| 2 | |||
| 3 | |||
| 4 | /** | ||
| 5 | * Skin class. | ||
| 6 | * | ||
| 7 | * @since 1.0.0 | ||
| 8 | * | ||
| 9 | * @package Envira_Gallery | ||
| 10 | * @author Envira Team | ||
| 11 | */ | ||
| 12 | class EMR_Envira_Gallery_Skin extends WP_Upgrader_Skin { | ||
| 13 | |||
| 14 | /** | ||
| 15 | * Primary class constructor. | ||
| 16 | * | ||
| 17 | * @since 1.0.0 | ||
| 18 | * | ||
| 19 | * @param array $args Empty array of args (we will use defaults). | ||
| 20 | */ | ||
| 21 | public function __construct( $args = array() ) { | ||
| 22 | |||
| 23 | parent::__construct(); | ||
| 24 | |||
| 25 | } | ||
| 26 | |||
| 27 | /** | ||
| 28 | * Set the upgrader object and store it as a property in the parent class. | ||
| 29 | * | ||
| 30 | * @since 1.0.0 | ||
| 31 | * | ||
| 32 | * @param object $upgrader The upgrader object (passed by reference). | ||
| 33 | */ | ||
| 34 | public function set_upgrader( &$upgrader ) { | ||
| 35 | |||
| 36 | if ( is_object( $upgrader ) ) { | ||
| 37 | $this->upgrader =& $upgrader; | ||
| 38 | } | ||
| 39 | |||
| 40 | } | ||
| 41 | |||
| 42 | /** | ||
| 43 | * Set the upgrader result and store it as a property in the parent class. | ||
| 44 | * | ||
| 45 | * @since 1.0.0 | ||
| 46 | * | ||
| 47 | * @param object $result The result of the install process. | ||
| 48 | */ | ||
| 49 | public function set_result( $result ) { | ||
| 50 | |||
| 51 | $this->result = $result; | ||
| 52 | |||
| 53 | } | ||
| 54 | |||
| 55 | /** | ||
| 56 | * Empty out the header of its HTML content and only check to see if it has | ||
| 57 | * been performed or not. | ||
| 58 | * | ||
| 59 | * @since 1.0.0 | ||
| 60 | */ | ||
| 61 | public function header() {} | ||
| 62 | |||
| 63 | /** | ||
| 64 | * Empty out the footer of its HTML contents. | ||
| 65 | * | ||
| 66 | * @since 1.0.0 | ||
| 67 | */ | ||
| 68 | public function footer() {} | ||
| 69 | |||
| 70 | /** | ||
| 71 | * Instead of outputting HTML for errors, json_encode the errors and send them | ||
| 72 | * back to the Ajax script for processing. | ||
| 73 | * | ||
| 74 | * @since 1.0.0 | ||
| 75 | * | ||
| 76 | * @param array $errors Array of errors with the install process. | ||
| 77 | */ | ||
| 78 | public function error( $errors ) { | ||
| 79 | |||
| 80 | if ( ! empty( $errors ) ) { | ||
| 81 | echo wp_json_encode( array( 'error' => __( 'There was an error installing the addon. Please try again.', 'envira-gallery' ) ) ); | ||
| 82 | /* log this for API issues */ | ||
| 83 | |||
| 84 | error_log( 'Envira: There was an error installing the addon' ); | ||
| 85 | error_log( print_r( $errors, true ) ); | ||
| 86 | |||
| 87 | die; | ||
| 88 | } | ||
| 89 | |||
| 90 | } | ||
| 91 | |||
| 92 | /** | ||
| 93 | * Empty out the feedback method to prevent outputting HTML strings as the install | ||
| 94 | * is progressing. | ||
| 95 | * | ||
| 96 | * @since 1.0.0 | ||
| 97 | * | ||
| 98 | * @param string $string The feedback string. | ||
| 99 | * @param array ...$args The args. | ||
| 100 | */ | ||
| 101 | public function feedback( $string, ...$args ) {} | ||
| 102 | |||
| 103 | } |
| 1 | <?php | ||
| 2 | |||
| 3 | add_action( 'wp_ajax_emr_plugin_install', 'emr_plugin_install' ); | ||
| 4 | |||
| 5 | function emr_plugin_install() { | ||
| 6 | |||
| 7 | // Run a security check first. | ||
| 8 | check_admin_referer( 'emr-plugin-install', 'nonce' ); | ||
| 9 | |||
| 10 | $plugin = isset($_POST['plugin']) ? sanitize_text_field($_POST['plugin']) : null; | ||
| 11 | |||
| 12 | switch($plugin) | ||
| 13 | { | ||
| 14 | case "envira": | ||
| 15 | $download_url = 'https://downloads.wordpress.org/plugin/envira-gallery-lite.zip'; | ||
| 16 | break; | ||
| 17 | case 'spio': | ||
| 18 | $download_url = 'https://downloads.wordpress.org/plugin/shortpixel-image-optimiser.zip'; | ||
| 19 | break; | ||
| 20 | case 'spai': | ||
| 21 | $download_url = 'https://downloads.wordpress.org/plugin/shortpixel-adaptive-images.zip'; | ||
| 22 | break; | ||
| 23 | } | ||
| 24 | |||
| 25 | // Install the addon. | ||
| 26 | if ( ! is_null($download_url ) ) { | ||
| 27 | |||
| 28 | //$download_url = esc_url_raw( wp_unslash( $_POST['plugin'] ) ); | ||
| 29 | global $hook_suffix; | ||
| 30 | |||
| 31 | // Set the current screen to avoid undefined notices. | ||
| 32 | set_current_screen(); | ||
| 33 | |||
| 34 | // Prepare variables. | ||
| 35 | $method = ''; | ||
| 36 | $url = add_query_arg( | ||
| 37 | array( | ||
| 38 | // 'page' => 'envira-gallery-settings', | ||
| 39 | ), | ||
| 40 | admin_url( 'admin.php' ) | ||
| 41 | ); | ||
| 42 | $url = esc_url( $url ); | ||
| 43 | |||
| 44 | // Start output bufferring to catch the filesystem form if credentials are needed. | ||
| 45 | ob_start(); | ||
| 46 | $creds = request_filesystem_credentials( $url, $method, false, false, null ); | ||
| 47 | if ( false === $creds ) { | ||
| 48 | $form = ob_get_clean(); | ||
| 49 | echo wp_json_encode( array( 'form' => $form ) ); | ||
| 50 | die; | ||
| 51 | } | ||
| 52 | |||
| 53 | // If we are not authenticated, make it happen now. | ||
| 54 | if ( ! WP_Filesystem( $creds ) ) { | ||
| 55 | ob_start(); | ||
| 56 | request_filesystem_credentials( $url, $method, true, false, null ); | ||
| 57 | $form = ob_get_clean(); | ||
| 58 | echo wp_json_encode( array( 'form' => $form ) ); | ||
| 59 | die; | ||
| 60 | } | ||
| 61 | |||
| 62 | // We do not need any extra credentials if we have gotten this far, so let's install the plugin. | ||
| 63 | require_once (ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'); | ||
| 64 | require_once (plugin_dir_path( EMR_ROOT_FILE ) . 'classes/external/upgrader_skin.php'); | ||
| 65 | |||
| 66 | // Create the plugin upgrader with our custom skin. | ||
| 67 | $skin = new EMR_Envira_Gallery_Skin(); | ||
| 68 | $installer = new Plugin_Upgrader( $skin ); | ||
| 69 | $installer->install( $download_url ); | ||
| 70 | |||
| 71 | // Flush the cache and return the newly installed plugin basename. | ||
| 72 | wp_cache_flush(); | ||
| 73 | |||
| 74 | if ( $installer->plugin_info() ) { | ||
| 75 | $plugin_basename = $installer->plugin_info(); | ||
| 76 | |||
| 77 | ob_clean(); | ||
| 78 | |||
| 79 | |||
| 80 | wp_send_json_success( array( 'plugin' => $plugin_basename ) ); | ||
| 81 | |||
| 82 | die(); | ||
| 83 | } | ||
| 84 | } | ||
| 85 | |||
| 86 | // Send back a response. | ||
| 87 | wp_send_json(array('result'=> false)); | ||
| 88 | die; | ||
| 89 | |||
| 90 | } | ||
| 91 | |||
| 92 | add_action( 'wp_ajax_emr_plugin_activate', 'emr_activate' ); | ||
| 93 | |||
| 94 | /** | ||
| 95 | * Activates an Envira addon. | ||
| 96 | * | ||
| 97 | * @since 1.0.0 | ||
| 98 | */ | ||
| 99 | function emr_activate() { | ||
| 100 | |||
| 101 | // Run a security check first. | ||
| 102 | check_admin_referer( 'emr-plugin-activate', 'nonce' ); | ||
| 103 | |||
| 104 | $plugin = isset($_POST['plugin']) ? sanitize_text_field($_POST['plugin']) : null; | ||
| 105 | |||
| 106 | switch($plugin) | ||
| 107 | { | ||
| 108 | case "envira": | ||
| 109 | $plugin = 'envira-gallery-lite/envira-gallery-lite.php'; | ||
| 110 | break; | ||
| 111 | case 'spio': | ||
| 112 | $plugin = 'shortpixel-image-optimiser/wp-shortpixel.php'; | ||
| 113 | break; | ||
| 114 | case 'spai': | ||
| 115 | $plugin = 'shortpixel-adaptive-images/short-pixel-ai.php'; | ||
| 116 | break; | ||
| 117 | } | ||
| 118 | |||
| 119 | // Activate the addon. | ||
| 120 | if ( ! is_null($plugin) ) { | ||
| 121 | $activate = activate_plugin( $plugin ); | ||
| 122 | if ( is_wp_error( $activate ) ) { | ||
| 123 | echo json_encode( array( 'error' => $activate->get_error_message() ) ); | ||
| 124 | die; | ||
| 125 | } | ||
| 126 | } | ||
| 127 | |||
| 128 | echo json_encode( true ); | ||
| 129 | die; | ||
| 130 | |||
| 131 | } |
| 1 | <?php | ||
| 2 | namespace EnableMediaReplace\Externals; | ||
| 3 | |||
| 4 | |||
| 5 | // Note! This class doubles as integration for both Visual Composer *and* WP Bakery. They both need URLENCODE. | ||
| 6 | class WpBakery | ||
| 7 | { | ||
| 8 | private static $instance; | ||
| 9 | |||
| 10 | protected $queryKey = 'wpbakery'; | ||
| 11 | |||
| 12 | public static function getInstance() | ||
| 13 | { | ||
| 14 | if (is_null(self::$instance)) | ||
| 15 | self::$instance = new WpBakery(); | ||
| 16 | |||
| 17 | return self::$instance; | ||
| 18 | } | ||
| 19 | |||
| 20 | public function __construct() | ||
| 21 | { | ||
| 22 | if ($this->bakery_is_active()) // elementor is active | ||
| 23 | { | ||
| 24 | add_filter('emr/replacer/custom_replace_query', array($this, 'addURLEncoded'), 10, 4); // custom query for elementor \ // problem | ||
| 25 | } | ||
| 26 | } | ||
| 27 | |||
| 28 | public function addUrlEncoded($items, $base_url, $search_urls, $replace_urls) | ||
| 29 | { | ||
| 30 | $base_url = $this->addEncode($base_url); | ||
| 31 | $el_search_urls = array_map(array($this, 'addEncode'), $search_urls); | ||
| 32 | $el_replace_urls = array_map(array($this, 'addEncode'), $replace_urls); | ||
| 33 | $items[$this->queryKey] = array('base_url' => $base_url, 'search_urls' => $el_search_urls, 'replace_urls' => $el_replace_urls); | ||
| 34 | return $items; | ||
| 35 | } | ||
| 36 | |||
| 37 | public function addEncode($value) | ||
| 38 | { | ||
| 39 | return urlencode($value); | ||
| 40 | } | ||
| 41 | |||
| 42 | protected function bakery_is_active() | ||
| 43 | { | ||
| 44 | $bool = false; | ||
| 45 | |||
| 46 | // did_action -> wpbakery , VCV_version -> detect Visual Composer | ||
| 47 | if (did_action('vc_plugins_loaded') || defined('VCV_VERSION')) | ||
| 48 | $bool = true; | ||
| 49 | |||
| 50 | return apply_filters('emr/externals/urlencode_is_active', $bool); // manual override | ||
| 51 | } | ||
| 52 | } |
| 1 | <?php | ||
| 2 | namespace EnableMediaReplace; | ||
| 3 | use EnableMediaReplace\ShortPixelLogger\ShortPixelLogger as Log; | ||
| 4 | use EnableMediaReplace\Notices\NoticeController as Notices; | ||
| 5 | |||
| 6 | use EnableMediaReplace\Externals\Elementor as Elementor; | ||
| 7 | use EnableMediaReplace\Externals\WpBakery as WpBakery; | ||
| 8 | |||
| 9 | class Externals | ||
| 10 | { | ||
| 11 | protected $replaceType = null; | ||
| 12 | protected $replaceSearchType = null; | ||
| 13 | |||
| 14 | protected $messages = array(); | ||
| 15 | |||
| 16 | public function __construct() | ||
| 17 | { | ||
| 18 | // These hooks prevent loading of options when plugin conflicts arise. | ||
| 19 | add_filter('emr_display_replace_type_options', array($this, 'get_replace_type')); | ||
| 20 | add_filter('emr_enable_replace_and_search', array($this, 'get_replacesearch_type')); | ||
| 21 | add_action('emr_after_replace_type_options', array($this, 'get_messages')); | ||
| 22 | |||
| 23 | $this->check(); | ||
| 24 | |||
| 25 | // integrations | ||
| 26 | $this->loadElementor(); | ||
| 27 | $this->loadBakery(); // in case of urlencoded issues, this class should be used probably. | ||
| 28 | } | ||
| 29 | |||
| 30 | protected function check() // check if any of the options should be disabled due to conflicts | ||
| 31 | { | ||
| 32 | /*if (class_exists('FLBuilder')) | ||
| 33 | { | ||
| 34 | $this->replaceSearchType = false; | ||
| 35 | $this->messages[] = __('Replace and Search feature is not compatible with Beaver Builder.', 'enable-media-replace'); | ||
| 36 | } */ | ||
| 37 | } | ||
| 38 | |||
| 39 | public function get_replace_type($bool) | ||
| 40 | { | ||
| 41 | if ($this->replaceType === null) | ||
| 42 | return $bool; | ||
| 43 | |||
| 44 | return $this->replaceType; | ||
| 45 | } | ||
| 46 | |||
| 47 | public function get_replacesearch_type($bool) | ||
| 48 | { | ||
| 49 | if ($this->replaceSearchType === null) | ||
| 50 | return $bool; | ||
| 51 | |||
| 52 | return $this->replaceSearchType; | ||
| 53 | } | ||
| 54 | |||
| 55 | public function get_messages() | ||
| 56 | { | ||
| 57 | foreach($this->messages as $message) | ||
| 58 | { | ||
| 59 | echo '<span class="nofeature-notice"><p>'. $message . '</p></span>'; | ||
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 63 | public function loadElementor() | ||
| 64 | { | ||
| 65 | Elementor::getInstance(); | ||
| 66 | } | ||
| 67 | |||
| 68 | public function loadBakery() | ||
| 69 | { | ||
| 70 | WpBakery::getInstance(); | ||
| 71 | } | ||
| 72 | |||
| 73 | } // class |
| 1 | <?php | ||
| 2 | namespace EnableMediaReplace; | ||
| 3 | |||
| 4 | use EnableMediaReplace\ShortPixelLogger\ShortPixelLogger as Log; | ||
| 5 | use EnableMediaReplace\Notices\NoticeController as Notices; | ||
| 6 | |||
| 7 | class emrFile | ||
| 8 | { | ||
| 9 | |||
| 10 | protected $file; // the full file w/ path. | ||
| 11 | protected $extension; | ||
| 12 | protected $fileName; | ||
| 13 | protected $filePath; // with trailing slash! not the image name. | ||
| 14 | protected $fileURL; | ||
| 15 | protected $fileMime; | ||
| 16 | protected $permissions = 0; | ||
| 17 | |||
| 18 | protected $exists = false; | ||
| 19 | |||
| 20 | public function __construct($file) | ||
| 21 | { | ||
| 22 | clearstatcache($file); | ||
| 23 | // file can not exist i.e. crashed files replacement and the lot. | ||
| 24 | if ( file_exists($file)) | ||
| 25 | { | ||
| 26 | $this->exists = true; | ||
| 27 | } | ||
| 28 | |||
| 29 | $this->file = $file; | ||
| 30 | $fileparts = pathinfo($file); | ||
| 31 | |||
| 32 | $this->fileName = isset($fileparts['basename']) ? $fileparts['basename'] : ''; | ||
| 33 | $this->filePath = isset($fileparts['dirname']) ? trailingslashit($fileparts['dirname']) : ''; | ||
| 34 | $this->extension = isset($fileparts['extension']) ? $fileparts['extension'] : ''; | ||
| 35 | if ($this->exists) // doesn't have to be. | ||
| 36 | $this->permissions = fileperms($file) & 0777; | ||
| 37 | |||
| 38 | $filedata = wp_check_filetype_and_ext($this->file, $this->fileName); | ||
| 39 | // This will *not* be checked, is not meant for permission of validation! | ||
| 40 | // Note: this function will work on non-existing file, but not on existing files containing wrong mime in file. | ||
| 41 | $this->fileMime = (isset($filedata['type']) && strlen($filedata['type']) > 0) ? $filedata['type'] : false; | ||
| 42 | |||
| 43 | if ($this->fileMime == false && strlen($this->file) > 0 && function_exists('mime_content_type') && $this->exists) | ||
| 44 | { | ||
| 45 | // If it's not a registered mimetype | ||
| 46 | $this->fileMime = mime_content_type($this->file); | ||
| 47 | } | ||
| 48 | |||
| 49 | } | ||
| 50 | |||
| 51 | public function checkAndCreateFolder() | ||
| 52 | { | ||
| 53 | $path = $this->getFilePath(); | ||
| 54 | if (! is_dir($path) && ! file_exists($path)) | ||
| 55 | { | ||
| 56 | return wp_mkdir_p($path); | ||
| 57 | } | ||
| 58 | } | ||
| 59 | |||
| 60 | public function getFullFilePath() | ||
| 61 | { | ||
| 62 | return $this->file; | ||
| 63 | } | ||
| 64 | |||
| 65 | public function getPermissions() | ||
| 66 | { | ||
| 67 | return $this->permissions; | ||
| 68 | } | ||
| 69 | |||
| 70 | public function setPermissions($permissions) | ||
| 71 | { | ||
| 72 | @chmod($this->file, $permissions); | ||
| 73 | } | ||
| 74 | |||
| 75 | public function getFileSize() | ||
| 76 | { | ||
| 77 | return filesize($this->file); | ||
| 78 | } | ||
| 79 | |||
| 80 | public function getFilePath() | ||
| 81 | { | ||
| 82 | return $this->filePath; | ||
| 83 | } | ||
| 84 | |||
| 85 | public function getFileName() | ||
| 86 | { | ||
| 87 | return $this->fileName; | ||
| 88 | } | ||
| 89 | |||
| 90 | public function getFileExtension() | ||
| 91 | { | ||
| 92 | return $this->extension; | ||
| 93 | } | ||
| 94 | |||
| 95 | public function getFileMime() | ||
| 96 | { | ||
| 97 | return $this->fileMime; | ||
| 98 | } | ||
| 99 | |||
| 100 | public function exists() | ||
| 101 | { | ||
| 102 | return $this->exists; | ||
| 103 | } | ||
| 104 | } |
| 1 | <?php | ||
| 2 | namespace EnableMediaReplace; | ||
| 3 | |||
| 4 | // Legacy functions. | ||
| 5 | |||
| 6 | /** | ||
| 7 | * Maybe remove query string from URL. | ||
| 8 | * | ||
| 9 | * @param string $url | ||
| 10 | * | ||
| 11 | * @return string | ||
| 12 | */ | ||
| 13 | |||
| 14 | function emr_maybe_remove_query_string( $url ) { | ||
| 15 | $parts = explode( '?', $url ); | ||
| 16 | |||
| 17 | return reset( $parts ); | ||
| 18 | } | ||
| 19 | |||
| 20 | /** | ||
| 21 | * Remove scheme from URL. | ||
| 22 | * | ||
| 23 | * @param string $url | ||
| 24 | * | ||
| 25 | * @return string | ||
| 26 | */ | ||
| 27 | function emr_remove_scheme( $url ) { | ||
| 28 | return preg_replace( '/^(?:http|https):/', '', $url ); | ||
| 29 | } | ||
| 30 | |||
| 31 | /** | ||
| 32 | * Remove size from filename (image[-100x100].jpeg). | ||
| 33 | * | ||
| 34 | * @param string $url | ||
| 35 | * @param bool $remove_extension | ||
| 36 | * | ||
| 37 | * @return string | ||
| 38 | */ | ||
| 39 | function emr_remove_size_from_filename( $url, $remove_extension = false ) { | ||
| 40 | $url = preg_replace( '/^(\S+)-[0-9]{1,4}x[0-9]{1,4}(\.[a-zA-Z0-9\.]{2,})?/', '$1$2', $url ); | ||
| 41 | |||
| 42 | if ( $remove_extension ) { | ||
| 43 | $ext = pathinfo( $url, PATHINFO_EXTENSION ); | ||
| 44 | $url = str_replace( ".$ext", '', $url ); | ||
| 45 | } | ||
| 46 | |||
| 47 | return $url; | ||
| 48 | } | ||
| 49 | |||
| 50 | /** | ||
| 51 | * Strip an image URL down to bare minimum for matching. | ||
| 52 | * | ||
| 53 | * @param string $url | ||
| 54 | * | ||
| 55 | * @return string | ||
| 56 | */ | ||
| 57 | function emr_get_match_url($url) { | ||
| 58 | $url = emr_remove_scheme($url); | ||
| 59 | $url = emr_maybe_remove_query_string($url); | ||
| 60 | $url = emr_remove_size_from_filename($url, true); // and extension is removed. | ||
| 61 | $url = emr_remove_domain_from_filename($url); | ||
| 62 | return $url; | ||
| 63 | } | ||
| 64 | |||
| 65 | |||
| 66 | function emr_remove_domain_from_filename($url) { | ||
| 67 | // Holding place for possible future function | ||
| 68 | $url = str_replace(emr_remove_scheme(get_bloginfo('url')), '', $url); | ||
| 69 | return $url; | ||
| 70 | } | ||
| 71 | |||
| 72 | /** | ||
| 73 | * Build an array of search or replace URLs for given attachment GUID and its metadata. | ||
| 74 | * | ||
| 75 | * @param string $guid | ||
| 76 | * @param array $metadata | ||
| 77 | * | ||
| 78 | * @return array | ||
| 79 | */ | ||
| 80 | function emr_get_file_urls( $guid, $metadata ) { | ||
| 81 | $urls = array(); | ||
| 82 | |||
| 83 | $guid = emr_remove_scheme( $guid ); | ||
| 84 | $guid= emr_remove_domain_from_filename($guid); | ||
| 85 | |||
| 86 | $urls['guid'] = $guid; | ||
| 87 | |||
| 88 | if ( empty( $metadata ) ) { | ||
| 89 | return $urls; | ||
| 90 | } | ||
| 91 | |||
| 92 | $base_url = dirname( $guid ); | ||
| 93 | |||
| 94 | if ( ! empty( $metadata['file'] ) ) { | ||
| 95 | $urls['file'] = trailingslashit( $base_url ) . wp_basename( $metadata['file'] ); | ||
| 96 | } | ||
| 97 | |||
| 98 | if ( ! empty( $metadata['sizes'] ) ) { | ||
| 99 | foreach ( $metadata['sizes'] as $key => $value ) { | ||
| 100 | $urls[ $key ] = trailingslashit( $base_url ) . wp_basename( $value['file'] ); | ||
| 101 | } | ||
| 102 | } | ||
| 103 | |||
| 104 | return $urls; | ||
| 105 | } | ||
| 106 | |||
| 107 | /** | ||
| 108 | * Ensure new search URLs cover known sizes for old attachment. | ||
| 109 | * Falls back to full URL if size not covered (srcset or width/height attributes should compensate). | ||
| 110 | * | ||
| 111 | * @param array $old | ||
| 112 | * @param array $new | ||
| 113 | * | ||
| 114 | * @return array | ||
| 115 | */ | ||
| 116 | function emr_normalize_file_urls( $old, $new ) { | ||
| 117 | $result = array(); | ||
| 118 | |||
| 119 | if ( empty( $new['guid'] ) ) { | ||
| 120 | return $result; | ||
| 121 | } | ||
| 122 | |||
| 123 | $guid = $new['guid']; | ||
| 124 | |||
| 125 | foreach ( $old as $key => $value ) { | ||
| 126 | $result[ $key ] = empty( $new[ $key ] ) ? $guid : $new[ $key ]; | ||
| 127 | } | ||
| 128 | |||
| 129 | return $result; | ||
| 130 | } |
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
| 1 | {"version":3,"sourceRoot":"","sources":["../scss/_datepicker.scss","../scss/admin.scss"],"names":[],"mappings":"AAEA;EACC;EACA;EACA;;;AAID;EACC;EACA;EACA;EACA;EACA;;;AAED;EACC;EACA;EACA;;;AAED;EACC;EACA;;;AAED;AAAA;EAEC;EACA;EACA;EACA;;;AAED;AAAA;EAEC;;;AAED;EACC;;;AAED;EACC;;;AAED;EACC;;;AAED;EACC;;;AAED;AAAA;EAEC;EACA;EACA;EACA;EACA;EACA;;;AAED;EACC;EACA;EACA;;;AAED;EACC;EACA;;;AAED;AAAA;EAEC;;;AAED;EACC;EACA;EACA;EACA;;;AAED;EACC;EACA;EACA;EACA;;;AAED;EACC;EACA;;;AAED;AAAA;EAEC;EACA;EACA;EACA;;;AAED;EACC;EACA;EACA;EACA;EACA;EACA;;;AAED;EACC;EACA;EACA;EACA;EACA;EACA;;;AAED;EACC;;;AAGD;AACA;EACC;;;AAED;EACC;;;AAED;EACC;EACA;;;AAED;EACC;;;AAED;EACC;;;AAED;EACC;;;AAED;AAAA;EAEC;;;AAED;EACC;;;AAED;EACC;EACA;EACA;;;AAGD;AACA;EACC;;;AAED;EACC;EACA;;;AAED;EACC;EACA;;;AAED;EACC;EACA;;;AAED;EACC;EACA;;;AAED;EACC;;;AAED;EACC;;;AAED;AAAA;EAEC;;;AAED;AAAA;EAEC;EACA;;;AAGD;AACA;EACC;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;EACA;;;AAED;AAAA;EAEC;;;AAED;EACC;;;AAED;AAAA;AAAA;AAAA;EAIC;;;AAED;AAAA;EAEC;;;AAED;AAAA;EAEC;;;AAGD;AACA;EAAiB;;;AACjB;EAAqB;;;AACrB;EAAsB;;;AACtB;EAAqB;;;AACrB;EAAsB;;;AACtB;EAAqB;;;AACrB;EAAsB;;;AACtB;EAAqB;;;AACrB;EAAsB;;;AACtB;EAAuB;;;AACvB;EAAuB;;;AACvB;EAAwB;;;AACxB;EAAyB;;;AACzB;EAAwB;;;AACxB;EAAyB;;;AACzB;EAAwB;;;AACxB;EAAyB;;;AACzB;EAAwB;;;AACxB;EAAyB;;;AACzB;EAA0B;;;AAC1B;EAA0B;;;AAC1B;EAAqB;;;AACrB;EAAsB;;;AACtB;EAAqB;;;AACrB;EAAsB;;;AACtB;EAAqB;;;AACrB;EAAsB;;;AACtB;EAAqB;;;AACrB;EAAsB;;;AACtB;EAAuB;;;AACvB;EAAyB;;;AACzB;EAAuB;;;AACvB;EAAyB;;;AACzB;EAAyB;;;AACzB;EAAyB;;;AACzB;EAAyB;;;AACzB;EAAyB;;;AACzB;EAA0B;;;AAC1B;EAA2B;;;AAC3B;EAA0B;;;AAC1B;EAA2B;;;AAC3B;EAA0B;;;AAC1B;EAA2B;;;AAC3B;EAA0B;;;AAC1B;EAA2B;;;AAC3B;EAA4B;;;AAC5B;EAA8B;;;AAC9B;EAA4B;;;AAC5B;EAA8B;;;AAC9B;EAA8B;;;AAC9B;EAA8B;;;AAC9B;EAA8B;;;AAC9B;EAA8B;;;AAC9B;EAAgC;;;AAChC;EAAgC;;;AAChC;EAAgC;;;AAChC;EAAgC;;;AAChC;EAA2B;;;AAC3B;EAA2B;;;AAC3B;EAA2B;;;AAC3B;EAA2B;;;AAC3B;EAA4B;;;AAC5B;EAA4B;;;AAC5B;EAA4B;;;AAC5B;EAA4B;;;AAC5B;EAAmB;;;AACnB;EAAwB;;;AACxB;EAAmB;;;AACnB;EAAkB;;;AAClB;EAAmB;;;AACnB;EAAmB;;;AACnB;EAAwB;;;AACxB;EAA6B;;;AAC7B;EAA4B;;;AAC5B;EAAuB;;;AACvB;EAAoB;;;AACpB;EAAsB;;;AACtB;EAAgB;;;AAChB;EAAuB;;;AACvB;EAAqB;;;AACrB;EAAoB;;;AACpB;EAAmB;;;AACnB;EAAkB;;;AAClB;EAAiB;;;AACjB;EAAiB;;;AACjB;EAAkB;;;AAClB;EAAoB;;;AACpB;EAAoB;;;AACpB;EAAe;;;AACf;EAAgB;;;AAChB;EAAgB;;;AAChB;EAAoB;;;AACpB;EAAgB;;;AAChB;EAAkB;;;AAClB;EAAiB;;;AACjB;EAAgB;;;AAChB;EAAsB;;;AACtB;EAAkB;;;AAClB;EAAmB;;;AACnB;EAAkB;;;AAClB;EAAkB;;;AAClB;EAAgB;;;AAChB;EAAiB;;;AACjB;EAAgB;;;AAChB;EAAgB;;;AAChB;EAAkB;;;AAClB;EAAgB;;;AAChB;EAAqB;;;AACrB;EAAiB;;;AACjB;EAAsB;;;AACtB;EAAiB;;;AACjB;EAAsB;;;AACtB;EAAe;;;AACf;EAAqB;;;AACrB;EAAoB;;;AACpB;EAAqB;;;AACrB;EAAgB;;;AAChB;EAAmB;;;AACnB;EAAiB;;;AACjB;EAAiB;;;AACjB;EAAkB;;;AAClB;EAAiB;;;AACjB;EAAgB;;;AAChB;EAAkB;;;AAClB;EAAgB;;;AAChB;EAAiB;;;AACjB;EAAkB;;;AAClB;EAAoB;;;AACpB;EAAqB;;;AACrB;EAAiB;;;AACjB;EAAiB;;;AACjB;EAAgB;;;AAChB;EAAiB;;;AACjB;EAAqB;;;AACrB;EAAqB;;;AACrB;EAAoB;;;AACpB;EAAsB;;;AACtB;AACA;EAAsB;;;AACtB;EAAgB;;;AAChB;EAAiB;;;AACjB;EAAsB;;;AACtB;EAAqB;;;AACrB;EAAiB;;;AACjB;EAAuB;;;AACvB;EAAkB;;;AAClB;EAAqB;;;AACrB;EAAqB;;;AACrB;EAAqB;;;AACrB;EAAqB;;;AACrB;EAAuB;;;AACvB;EAAwB;;;AACxB;EAAwB;;;AACxB;EAA6B;;;AAC7B;EAA6B;;;AAC7B;EAA6B;;;AAC7B;EAA6B;;;AAC7B;EAA0B;;;AAC1B;EAA0B;;;AAC1B;EAA0B;;;AAC1B;EAA0B;;;AAC1B;EAAyB;;;AACzB;EAA0B;;;AAC1B;EAAwB;;;AACxB;EAA4B;;;AAC5B;EAA6B;;;AAC7B;EAA6B;;;AAC7B;EAA4B;;;AAC5B;EAA6B;;;AAC7B;EAA6B;;;AAC7B;EAAgC;;;AAChC;EAAkC;;;AAClC;EAA+B;;;AAC/B;EAAiC;;;AACjC;EAAiC;;;AACjC;EAA4B;;;AAE5B;AACA;AAAA;AAAA;AAAA;EAIC;;;AAED;AAAA;AAAA;AAAA;EAIC;;;AAED;AAAA;AAAA;AAAA;EAIC;;;AAED;AAAA;AAAA;AAAA;EAIC;;;AC/ZC;EAEE;;AACA;EAEE;;AAIJ;EAGE;EACA;;AAEA;EAEE;EAEA;EACA;EACA;;AAIJ;EAEE;;AAEA;EAEE;EACA;EACA;EACA;EACA;;AACA;EAAK;;AACL;EAEE;;AAGF;EAEI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEF;EAAgB;;AAGtB;EAEE;;AACA;EAEE;EACA;EACA;EACA;EACA;EACA;EACA;;AACA;EAEE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGF;EAEE;EACA;EACA;EACA;EACA;EACA;EACA;;AAGF;EAEG;EACA;EACA;EACA;;AAID;EAAiC;;AAMjC;EAAM;;AACN;EAAa;;AAEX;EACE;EACA;EACA;;AASZ;EAEE;EACA;EACA;EAEA;EACA;;AACA;EACI;EACA;EACA;;AAIN;EAEE;;AAGF;EAEE;;AAGF;EAEE;EACA;EACA;;AACA;EAEE;EACA;;AAKA;EAEE;;AAEF;EAEE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AACA;EACE;EACA;EACA;;AAOR;EAEE;EACA;EACA;EACA;;AAGE;EACE;;AAEF;EAEE;;AAGN;EAEE;;AACA;EACC;EACA;;AAOG;EAEE;;AAMJ;EAAQ;;AAEV;EAEE;EACA;EACA;;AAEF;EAEE;EACA;EACA;;AACA;EACE;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;;AACA;EAEE;EACA;EACA;;AAIN;EAEE;EACA;;AACA;EAEE;EACA;;AAKN;EAEE;EACA;EACA;EACA;;AACA;EAEE;EACA;;AAIJ;EAEG;;AAEH;EAEE;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACF;;AACE;EACE;EACA;EACA;EACA;EACA;;AAEJ;EAEE;EACA;;AAEF;EAAO;;AACP;EAAQ;;AACR;EAAQ;;AACR;EAAS;;AACR;EACE;;AAED;EAEE;EACA;;AACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACJ;;AAGF;EAAU;;AAER;EAEE;EACA;;AACA;EAAM;EAAkB;EAAmB;;AAS/C;EAEE;;AAIF;EAEI;IAEG;;EAEH;IACE;;EACA;IACE;;;AAGR;EAEE;IAAkB;;;AAErB;EAEE;IACE;IACA;IACA;;EAIA;IACE;IACD","file":"admin.css"} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
This diff is collapsed.
Click to expand it.
| 1 | /* Styling for the edit attachment screen */ | ||
| 2 | #emr-replace-box .previewwrapper, #emr-showthumbs-box .previewwrapper { | ||
| 3 | display: inline-block; | ||
| 4 | position: relative; | ||
| 5 | clear: both; | ||
| 6 | margin: 3px 0; | ||
| 7 | } | ||
| 8 | #emr-replace-box .previewwrapper img, #emr-showthumbs-box .previewwrapper img { | ||
| 9 | max-width: 100%; | ||
| 10 | } | ||
| 11 | #emr-replace-box .previewwrapper span.label, #emr-showthumbs-box .previewwrapper span.label { | ||
| 12 | font-size: 14px; | ||
| 13 | color: #fff; | ||
| 14 | position: absolute; | ||
| 15 | line-height: 16px; | ||
| 16 | margin-top: -8px; | ||
| 17 | top: 50%; | ||
| 18 | left: 0; | ||
| 19 | right: 0; | ||
| 20 | background: rgba(0, 0, 0, 0.5); | ||
| 21 | text-align: center; | ||
| 22 | padding: 4px 0; | ||
| 23 | } | ||
| 24 | |||
| 25 | /*# sourceMappingURL=edit_attachment.css.map */ |
| 1 | {"version":3,"sourceRoot":"","sources":["../scss/edit_attachment.scss"],"names":[],"mappings":"AACA;AAGE;EAEE;EACA;EACA;EACA;;AAEA;EAAM;;AACN;EAEE;EACA;EACA;EACA;EACA;EACA;EACA;EAAS;EACT;EACA;EACA","file":"edit_attachment.css"} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /** | ||
| 3 | * Plugin Name: Enable Media Replace | ||
| 4 | * Plugin URI: https://wordpress.org/plugins/enable-media-replace/ | ||
| 5 | * Description: Enable replacing media files by uploading a new file in the "Edit Media" section of the WordPress Media Library. | ||
| 6 | * Version: 3.6.3 | ||
| 7 | * Author: ShortPixel | ||
| 8 | * Author URI: https://shortpixel.com | ||
| 9 | * GitHub Plugin URI: https://github.com/short-pixel-optimizer/enable-media-replace | ||
| 10 | * Text Domain: enable-media-replace | ||
| 11 | * Domain Path: /languages | ||
| 12 | * Dual licensed under the MIT and GPL licenses: | ||
| 13 | * License URI: http://www.opensource.org/licenses/mit-license.php | ||
| 14 | * License URI: http://www.gnu.org/licenses/gpl.html | ||
| 15 | */ | ||
| 16 | |||
| 17 | /** | ||
| 18 | * Main Plugin file | ||
| 19 | * Set action hooks and add shortcode | ||
| 20 | * | ||
| 21 | * @author ShortPixel <https://shortpixel.com> | ||
| 22 | * @copyright ShortPixel 2018-2020 | ||
| 23 | * @package wordpress | ||
| 24 | * @subpackage enable-media-replace | ||
| 25 | * | ||
| 26 | */ | ||
| 27 | |||
| 28 | namespace EnableMediaReplace; | ||
| 29 | |||
| 30 | define('EMR_VERSION', '3.6.3'); | ||
| 31 | |||
| 32 | if ( ! defined( 'ABSPATH' ) ) { | ||
| 33 | exit; // Exit if accessed directly. | ||
| 34 | } | ||
| 35 | |||
| 36 | /* Not sure why we define this? | ||
| 37 | if(!defined("S3_UPLOADS_AUTOENABLE")) { | ||
| 38 | define('S3_UPLOADS_AUTOENABLE', true); | ||
| 39 | } */ | ||
| 40 | |||
| 41 | if (! defined("EMR_ROOT_FILE")) { | ||
| 42 | define("EMR_ROOT_FILE", __FILE__); | ||
| 43 | } | ||
| 44 | |||
| 45 | if(!defined("SHORTPIXEL_AFFILIATE_CODE")) { | ||
| 46 | define("SHORTPIXEL_AFFILIATE_CODE", 'VKG6LYN28044'); | ||
| 47 | } | ||
| 48 | |||
| 49 | /** Usage: | ||
| 50 | * Define in wp-config.php | ||
| 51 | * // User must have this capability to replace all | ||
| 52 | * define('EMR_CAPABILITY' ,'edit_upload_all' ); | ||
| 53 | * // User must have first capability to replace all OR second capability to replace only own files | ||
| 54 | * define('EMR_CAPABILITY' ,array('edit_upload_all', 'edit_upload_user') ); | ||
| 55 | * | ||
| 56 | * | ||
| 57 | **/ | ||
| 58 | if (! defined('EMR_CAPABILITY')) | ||
| 59 | define('EMR_CAPABILITY', false); | ||
| 60 | |||
| 61 | /* if (! defined('EMR_CAPABILITY_USERONLY')) | ||
| 62 | define('EMR_CAPABILITY_USERONLY', false); */ | ||
| 63 | |||
| 64 | $plugin_path = plugin_dir_path(EMR_ROOT_FILE); | ||
| 65 | |||
| 66 | require_once($plugin_path . 'build/shortpixel/autoload.php'); | ||
| 67 | require_once($plugin_path . 'classes/compat.php'); | ||
| 68 | require_once($plugin_path . 'classes/functions.php'); | ||
| 69 | require_once($plugin_path . 'classes/replacer.php'); | ||
| 70 | require_once($plugin_path . 'classes/uihelper.php'); | ||
| 71 | require_once($plugin_path . 'classes/file.php'); | ||
| 72 | require_once($plugin_path . 'classes/cache.php'); | ||
| 73 | require_once($plugin_path . 'classes/emr-plugin.php'); | ||
| 74 | require_once($plugin_path . 'classes/externals.php'); | ||
| 75 | require_once($plugin_path . 'classes/external/elementor.php'); | ||
| 76 | require_once($plugin_path . 'classes/external/wpbakery.php'); | ||
| 77 | require_once($plugin_path . 'classes/external/upsell_installer.php'); | ||
| 78 | require_once($plugin_path . 'thumbnail_updater.php'); | ||
| 79 | |||
| 80 | $emr_plugin = EnableMediaReplacePlugin::get(); | ||
| 81 | |||
| 82 | register_uninstall_hook(__FILE__, '\EnableMediaReplace\emr_uninstall'); | ||
| 83 | |||
| 84 | function emr_uninstall() | ||
| 85 | { | ||
| 86 | delete_option('enable_media_replace'); | ||
| 87 | delete_option('emr_news'); | ||
| 88 | } |
10.5 KB
| 1 | <?php // Silence is golden | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
6.83 KB
6.82 KB
7.72 KB
| 1 | <?php // Silence is golden | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
This diff is collapsed.
Click to expand it.
| 1 | jQuery(document).ready(function($) | ||
| 2 | { | ||
| 3 | $('.emr-installer').on('click', function(e){ | ||
| 4 | e.preventDefault(); | ||
| 5 | // var $this = $(this); | ||
| 6 | var button = $(this); | ||
| 7 | var plugin = button.data('plugin'); | ||
| 8 | var nonce = $('#upsell-nonce').val(); | ||
| 9 | |||
| 10 | button.text(emr_upsell.installing); | ||
| 11 | |||
| 12 | var enr_eg_opts = { | ||
| 13 | url: emr_upsell.ajax, | ||
| 14 | type: 'post', | ||
| 15 | async: true, | ||
| 16 | cache: false, | ||
| 17 | dataType: 'json', | ||
| 18 | data: { | ||
| 19 | action: 'emr_plugin_install', | ||
| 20 | nonce: nonce, | ||
| 21 | plugin: plugin //'https://downloads.wordpress.org/plugin/envira-gallery-lite.zip', | ||
| 22 | }, | ||
| 23 | success: function(response) { | ||
| 24 | $(button).addClass('hidden'); | ||
| 25 | |||
| 26 | $('.emr-activate[data-plugin="' + plugin + '"]').removeClass('hidden'); | ||
| 27 | |||
| 28 | }, | ||
| 29 | error: function(xhr, textStatus, e) { | ||
| 30 | }, | ||
| 31 | }; | ||
| 32 | |||
| 33 | $.ajax(enr_eg_opts); | ||
| 34 | }); | ||
| 35 | |||
| 36 | $('.emr-activate').on('click', function(e){ | ||
| 37 | e.preventDefault(); | ||
| 38 | |||
| 39 | var button = $(this); | ||
| 40 | var plugin = button.data('plugin'); | ||
| 41 | var nonce = $('#upsell-nonce-activate').val(); | ||
| 42 | |||
| 43 | var enr_eg_opts = { | ||
| 44 | url: emr_upsell.ajax, | ||
| 45 | type: 'post', | ||
| 46 | async: true, | ||
| 47 | cache: false, | ||
| 48 | dataType: 'json', | ||
| 49 | data: { | ||
| 50 | action: 'emr_plugin_activate', | ||
| 51 | nonce: nonce, | ||
| 52 | plugin: plugin, | ||
| 53 | }, | ||
| 54 | success: function(response) { | ||
| 55 | $(button).addClass('hidden') | ||
| 56 | $('.emr-activate-done[data-plugin="' + plugin + '"]').removeClass('hidden'); | ||
| 57 | |||
| 58 | }, | ||
| 59 | error: function(xhr, textStatus, e) { | ||
| 60 | }, | ||
| 61 | }; | ||
| 62 | $.ajax(enr_eg_opts); | ||
| 63 | }); | ||
| 64 | |||
| 65 | }); |
No preview for this file type
| 1 | msgid "" | ||
| 2 | msgstr "" | ||
| 3 | "Project-Id-Version: enable-media-replace\n" | ||
| 4 | "Report-Msgid-Bugs-To: \n" | ||
| 5 | "POT-Creation-Date: 2010-09-13 14:57+0100\n" | ||
| 6 | "PO-Revision-Date: \n" | ||
| 7 | "Last-Translator: Michael Bering Petersen <michaelbering@gmail.com>\n" | ||
| 8 | "Language-Team: \n" | ||
| 9 | "MIME-Version: 1.0\n" | ||
| 10 | "Content-Type: text/plain; charset=UTF-8\n" | ||
| 11 | "Content-Transfer-Encoding: 8bit\n" | ||
| 12 | "X-Poedit-KeywordsList: __;_e\n" | ||
| 13 | "X-Poedit-Basepath: .\n" | ||
| 14 | "X-Poedit-SearchPath-0: .\n" | ||
| 15 | |||
| 16 | #: enable-media-replace.php:40 | ||
| 17 | #: enable-media-replace.php:68 | ||
| 18 | msgid "Replace media" | ||
| 19 | msgstr "Udskift media" | ||
| 20 | |||
| 21 | #: enable-media-replace.php:68 | ||
| 22 | msgid "Upload a new file" | ||
| 23 | msgstr "Upload en ny fil" | ||
| 24 | |||
| 25 | #: enable-media-replace.php:68 | ||
| 26 | msgid "To replace the current file, click the link and upload a replacement." | ||
| 27 | msgstr "Hvis du ønsker at udskifte den aktuelle fil - klik på linket og upload den nye fil." | ||
| 28 | |||
| 29 | #: popup.php:14 | ||
| 30 | #: upload.php:21 | ||
| 31 | msgid "You do not have permission to upload files." | ||
| 32 | msgstr "Du har ikke tilladelse til at uploade filer." | ||
| 33 | |||
| 34 | #: popup.php:30 | ||
| 35 | msgid "Replace Media Upload" | ||
| 36 | msgstr "Replace Media Upload" | ||
| 37 | |||
| 38 | #: popup.php:41 | ||
| 39 | msgid "NOTE: You are about to replace the media file" | ||
| 40 | msgstr "OBS: Du er nu ved at overskrive filen," | ||
| 41 | |||
| 42 | #: popup.php:41 | ||
| 43 | msgid "There is no undo. Think about it!" | ||
| 44 | msgstr "Der er ingen mulighed for at fortryde, så tænkt dig godt om inden du accepterer." | ||
| 45 | |||
| 46 | #: popup.php:43 | ||
| 47 | msgid "Choose a file to upload from your computer" | ||
| 48 | msgstr "Vælg den fil du ønsker at uploade fra din computer." | ||
| 49 | |||
| 50 | #: popup.php:47 | ||
| 51 | msgid "Select media replacement type:" | ||
| 52 | msgstr "Vælg media type:" | ||
| 53 | |||
| 54 | #: popup.php:49 | ||
| 55 | msgid "Just replace the file" | ||
| 56 | msgstr "Udskift filen" | ||
| 57 | |||
| 58 | #: popup.php:50 | ||
| 59 | msgid "Note: This option requires you to upload a file of the same type (" | ||
| 60 | msgstr "OBS: Denne mulighed kræver at du uploader en fil af samme type (" | ||
| 61 | |||
| 62 | #: popup.php:50 | ||
| 63 | msgid ") as the one you are replacing. The name of the attachment will stay the same (" | ||
| 64 | msgstr ") som den du overskriver. Navnet på filen vil forblive det samme (" | ||
| 65 | |||
| 66 | #: popup.php:50 | ||
| 67 | msgid ") no matter what the file you upload is called." | ||
| 68 | msgstr ") uanset hvad den fil du uploader hedder." | ||
| 69 | |||
| 70 | #: popup.php:52 | ||
| 71 | msgid "Replace the file, use new file name and update all links" | ||
| 72 | msgstr "Overskriv filen, brug det nye fil navn og opdater alle links-" | ||
| 73 | |||
| 74 | #: popup.php:53 | ||
| 75 | msgid "Note: If you check this option, the name and type of the file you are about to upload will replace the old file. All links pointing to the current file (" | ||
| 76 | msgstr "OBS: Hvis du vælger denne mulighed - vil filnavnet og filtypen som du er ved at uploade overskrive den gamle fil. Alle links der peger på den nuværende fil (" | ||
| 77 | |||
| 78 | #: popup.php:53 | ||
| 79 | msgid ") will be updated to point to the new file name." | ||
| 80 | msgstr ") vil blive opdateret så de peger på den nye fil." | ||
| 81 | |||
| 82 | #: popup.php:55 | ||
| 83 | msgid "Upload" | ||
| 84 | msgstr "Upload" | ||
| 85 | |||
| 86 | #: popup.php:55 | ||
| 87 | msgid "Cancel" | ||
| 88 | msgstr "Fortryd" | ||
| 89 |
No preview for this file type
| 1 | msgid "" | ||
| 2 | msgstr "" | ||
| 3 | "Project-Id-Version: enable-media-replace\n" | ||
| 4 | "Report-Msgid-Bugs-To: \n" | ||
| 5 | "POT-Creation-Date: 2010-09-13 14:57+0100\n" | ||
| 6 | "PO-Revision-Date: \n" | ||
| 7 | "Last-Translator: Martin Lettner <m.lettner@gmail.com>\n" | ||
| 8 | "Language-Team: \n" | ||
| 9 | "MIME-Version: 1.0\n" | ||
| 10 | "Content-Type: text/plain; charset=UTF-8\n" | ||
| 11 | "Content-Transfer-Encoding: 8bit\n" | ||
| 12 | "X-Poedit-KeywordsList: __;_e\n" | ||
| 13 | "X-Poedit-Basepath: .\n" | ||
| 14 | "X-Poedit-SearchPath-0: .\n" | ||
| 15 | |||
| 16 | #: enable-media-replace.php:40 | ||
| 17 | #: enable-media-replace.php:68 | ||
| 18 | msgid "Replace media" | ||
| 19 | msgstr "Datei ersetzen" | ||
| 20 | |||
| 21 | #: enable-media-replace.php:68 | ||
| 22 | msgid "Upload a new file" | ||
| 23 | msgstr "Eine neue Datei hochladen" | ||
| 24 | |||
| 25 | #: enable-media-replace.php:68 | ||
| 26 | msgid "To replace the current file, click the link and upload a replacement." | ||
| 27 | msgstr "Eine neue Datei hochladen, die die aktuelle ersetzen soll." | ||
| 28 | |||
| 29 | #: popup.php:14 | ||
| 30 | #: upload.php:21 | ||
| 31 | msgid "You do not have permission to upload files." | ||
| 32 | msgstr "Sie haben nicht die benötigten Rechte um Dateien hochzuladen." | ||
| 33 | |||
| 34 | #: popup.php:30 | ||
| 35 | msgid "Replace Media Upload" | ||
| 36 | msgstr "Medien-Datei ersetzen" | ||
| 37 | |||
| 38 | #: popup.php:41 | ||
| 39 | msgid "NOTE: You are about to replace the media file" | ||
| 40 | msgstr "HINWEIS: Sie sind dabei, eine Datei in der Mediathek zu ersetzen" | ||
| 41 | |||
| 42 | #: popup.php:41 | ||
| 43 | msgid "There is no undo. Think about it!" | ||
| 44 | msgstr "Diese Aktion kann nicht rückgängig gemacht werden!" | ||
| 45 | |||
| 46 | #: popup.php:43 | ||
| 47 | msgid "Choose a file to upload from your computer" | ||
| 48 | msgstr "Datei vom Computer auswählen:" | ||
| 49 | |||
| 50 | #: popup.php:47 | ||
| 51 | msgid "Select media replacement type:" | ||
| 52 | msgstr "Wählen Sie die gewünschte Aktion:" | ||
| 53 | |||
| 54 | #: popup.php:49 | ||
| 55 | msgid "Just replace the file" | ||
| 56 | msgstr "Datei einfach ersetzen" | ||
| 57 | |||
| 58 | #: popup.php:50 | ||
| 59 | msgid "Note: This option requires you to upload a file of the same type (" | ||
| 60 | msgstr "Hinweis: Die Datei muss vom selben Dateityp sein (" | ||
| 61 | |||
| 62 | #: popup.php:50 | ||
| 63 | msgid ") as the one you are replacing. The name of the attachment will stay the same (" | ||
| 64 | msgstr ") wie die Datei, die Sie ersetzen. Der Name der der Datei bleibt erhalten (" | ||
| 65 | |||
| 66 | #: popup.php:50 | ||
| 67 | msgid ") no matter what the file you upload is called." | ||
| 68 | msgstr "), ganz egal wie die neue Datei heißt." | ||
| 69 | |||
| 70 | #: popup.php:52 | ||
| 71 | msgid "Replace the file, use new file name and update all links" | ||
| 72 | msgstr "Datei ersetzen, aber neuen Dateinamen verwenden und alle Links automatisch aktualisieren" | ||
| 73 | |||
| 74 | #: popup.php:53 | ||
| 75 | msgid "Note: If you check this option, the name and type of the file you are about to upload will replace the old file. All links pointing to the current file (" | ||
| 76 | msgstr "Hinweis: Der Name der neuen Datei wird die alte ersetzen. Alle Verweise auf die aktuelle Datei (" | ||
| 77 | |||
| 78 | #: popup.php:53 | ||
| 79 | msgid ") will be updated to point to the new file name." | ||
| 80 | msgstr ") werden auf die neue aktualisiert." | ||
| 81 | |||
| 82 | #: popup.php:55 | ||
| 83 | msgid "Upload" | ||
| 84 | msgstr "Hochladen" | ||
| 85 | |||
| 86 | #: popup.php:55 | ||
| 87 | msgid "Cancel" | ||
| 88 | msgstr "Abbrechen" | ||
| 89 |
No preview for this file type
| 1 | msgid "" | ||
| 2 | msgstr "" | ||
| 3 | "Project-Id-Version: Enable Media Replace\n" | ||
| 4 | "Report-Msgid-Bugs-To: \n" | ||
| 5 | "POT-Creation-Date: 2011-03-24 10:57+0100\n" | ||
| 6 | "PO-Revision-Date: 2011-03-24 11:41+0100\n" | ||
| 7 | "Last-Translator: François Collette <francois.collette@gmail.com>\n" | ||
| 8 | "Language-Team: \n" | ||
| 9 | "MIME-Version: 1.0\n" | ||
| 10 | "Content-Type: text/plain; charset=UTF-8\n" | ||
| 11 | "Content-Transfer-Encoding: 8bit\n" | ||
| 12 | "X-Poedit-KeywordsList: _e;__\n" | ||
| 13 | "X-Poedit-Basepath: .\n" | ||
| 14 | "X-Poedit-SearchPath-0: .\n" | ||
| 15 | |||
| 16 | #: enable-media-replace.php:39 | ||
| 17 | #: enable-media-replace.php:67 | ||
| 18 | msgid "Replace media" | ||
| 19 | msgstr "Remplacer le média" | ||
| 20 | |||
| 21 | #: enable-media-replace.php:67 | ||
| 22 | msgid "Upload a new file" | ||
| 23 | msgstr "Choisir le nouveau fichier" | ||
| 24 | |||
| 25 | #: enable-media-replace.php:67 | ||
| 26 | msgid "To replace the current file, click the link and upload a replacement." | ||
| 27 | msgstr "Pour remplacer le fichier actuel, cliquez ci-dessus et choisissez le nouveau fichier." | ||
| 28 | |||
| 29 | #: popup.php:14 | ||
| 30 | #: upload.php:3 | ||
| 31 | msgid "You do not have permission to upload files." | ||
| 32 | msgstr "Vous n'avez pas la permission d'envoyer des fichiers." | ||
| 33 | |||
| 34 | #: popup.php:30 | ||
| 35 | msgid "Replace Media Upload" | ||
| 36 | msgstr "Remplacement de média" | ||
| 37 | |||
| 38 | #: popup.php:46 | ||
| 39 | msgid "NOTE: You are about to replace the media file" | ||
| 40 | msgstr "ATTENTION : vous vous apprêtez à remplacer le fichier" | ||
| 41 | |||
| 42 | #: popup.php:46 | ||
| 43 | msgid "There is no undo. Think about it!" | ||
| 44 | msgstr "Cette opération est irréversible. Soyez sûr(e) de vous !" | ||
| 45 | |||
| 46 | #: popup.php:48 | ||
| 47 | msgid "Choose a file to upload from your computer" | ||
| 48 | msgstr "Envoyez un fichier depuis votre ordinateur :" | ||
| 49 | |||
| 50 | #: popup.php:52 | ||
| 51 | msgid "Select media replacement type:" | ||
| 52 | msgstr "Choisissez la méthode de remplacement :" | ||
| 53 | |||
| 54 | #: popup.php:54 | ||
| 55 | msgid "Just replace the file" | ||
| 56 | msgstr "Remplacer le fichier seulement" | ||
| 57 | |||
| 58 | #: popup.php:55 | ||
| 59 | msgid "Note: This option requires you to upload a file of the same type (" | ||
| 60 | msgstr "Avec cette option, vous devez choisir un fichier du même type (" | ||
| 61 | |||
| 62 | #: popup.php:55 | ||
| 63 | msgid ") as the one you are replacing. The name of the attachment will stay the same (" | ||
| 64 | msgstr ") que le précédent. Le nom du fichier actuel (" | ||
| 65 | |||
| 66 | #: popup.php:55 | ||
| 67 | msgid ") no matter what the file you upload is called." | ||
| 68 | msgstr ") sera conservé, quel que soit le nom de votre nouveau fichier." | ||
| 69 | |||
| 70 | #: popup.php:57 | ||
| 71 | msgid "Replace the file, use new file name and update all links" | ||
| 72 | msgstr "Remplacer le fichier, utiliser le nouveau nom de fichier et mettre à jour tous les liens" | ||
| 73 | |||
| 74 | #: popup.php:58 | ||
| 75 | msgid "Note: If you check this option, the name and type of the file you are about to upload will replace the old file. All links pointing to the current file (" | ||
| 76 | msgstr "Avec cette option, le nom et le type de votre nouveau fichier vont remplacer ceux du fichier actuel. Tous les liens vers celui-ci (" | ||
| 77 | |||
| 78 | #: popup.php:58 | ||
| 79 | msgid ") will be updated to point to the new file name." | ||
| 80 | msgstr ") seront mis à jour selon le nouveau nom du fichier." | ||
| 81 | |||
| 82 | #: popup.php:60 | ||
| 83 | msgid "Upload" | ||
| 84 | msgstr "Envoyer" | ||
| 85 | |||
| 86 | #: popup.php:60 | ||
| 87 | msgid "Cancel" | ||
| 88 | msgstr "Annuler" | ||
| 89 | |||
| 90 | #: upload.php:35 | ||
| 91 | msgid "File type does not meet security guidelines. Try another." | ||
| 92 | msgstr "Ce type de fichier est incompatible avec les règles de sécurité. Essayez-en un autre." | ||
| 93 |
No preview for this file type
| 1 | msgid "" | ||
| 2 | msgstr "" | ||
| 3 | "Project-Id-Version: Enable Media Replace\n" | ||
| 4 | "Report-Msgid-Bugs-To: \n" | ||
| 5 | "POT-Creation-Date: 2011-03-24 10:57+0100\n" | ||
| 6 | "PO-Revision-Date: 2012-11-27 12:03+0100\n" | ||
| 7 | "Last-Translator: Marco <marco@blackstudio.it>\n" | ||
| 8 | "Language-Team: Black Studio <info@blackstudio.it>\n" | ||
| 9 | "MIME-Version: 1.0\n" | ||
| 10 | "Content-Type: text/plain; charset=UTF-8\n" | ||
| 11 | "Content-Transfer-Encoding: 8bit\n" | ||
| 12 | "X-Poedit-KeywordsList: _e;__\n" | ||
| 13 | "X-Poedit-Basepath: .\n" | ||
| 14 | "X-Poedit-Language: Italian\n" | ||
| 15 | "X-Poedit-Country: ITALY\n" | ||
| 16 | "X-Poedit-SearchPath-0: .\n" | ||
| 17 | |||
| 18 | #: enable-media-replace.php:39 | ||
| 19 | #: enable-media-replace.php:67 | ||
| 20 | msgid "Replace media" | ||
| 21 | msgstr "Sostituisci file" | ||
| 22 | |||
| 23 | #: enable-media-replace.php:67 | ||
| 24 | msgid "Upload a new file" | ||
| 25 | msgstr "Carica un nuovo file" | ||
| 26 | |||
| 27 | #: enable-media-replace.php:67 | ||
| 28 | msgid "To replace the current file, click the link and upload a replacement." | ||
| 29 | msgstr "Per sostituire il file corrente, clicca il link e carica un file sostitutivo." | ||
| 30 | |||
| 31 | #: popup.php:14 | ||
| 32 | #: upload.php:3 | ||
| 33 | msgid "You do not have permission to upload files." | ||
| 34 | msgstr "Non hai sufficienti permessi per caricare file." | ||
| 35 | |||
| 36 | #: popup.php:30 | ||
| 37 | msgid "Replace Media Upload" | ||
| 38 | msgstr "Caricamento file sostitutivo" | ||
| 39 | |||
| 40 | #: popup.php:46 | ||
| 41 | msgid "NOTE: You are about to replace the media file" | ||
| 42 | msgstr "NOTA: Stai per sostituire il file" | ||
| 43 | |||
| 44 | #: popup.php:46 | ||
| 45 | msgid "There is no undo. Think about it!" | ||
| 46 | msgstr "Questa operazione non è reversibile. Fai attenzione!" | ||
| 47 | |||
| 48 | #: popup.php:48 | ||
| 49 | msgid "Choose a file to upload from your computer" | ||
| 50 | msgstr "Seleziona un file da caricare dal tuo computer" | ||
| 51 | |||
| 52 | #: popup.php:52 | ||
| 53 | msgid "Select media replacement type:" | ||
| 54 | msgstr "Seleziona il tipo di sostituzione:" | ||
| 55 | |||
| 56 | #: popup.php:54 | ||
| 57 | msgid "Just replace the file" | ||
| 58 | msgstr "Sostituire semplicemente il file" | ||
| 59 | |||
| 60 | #: popup.php:55 | ||
| 61 | msgid "Note: This option requires you to upload a file of the same type (" | ||
| 62 | msgstr "Nota: Questa opzione richiede il caricamento di un file dello stesso tipo (" | ||
| 63 | |||
| 64 | #: popup.php:55 | ||
| 65 | msgid ") as the one you are replacing. The name of the attachment will stay the same (" | ||
| 66 | msgstr ") di quello sostituito. Il nome dell'allegato rimarrà invariato (" | ||
| 67 | |||
| 68 | #: popup.php:55 | ||
| 69 | msgid ") no matter what the file you upload is called." | ||
| 70 | msgstr ") indipendentemente dal nome del file caricato." | ||
| 71 | |||
| 72 | #: popup.php:57 | ||
| 73 | msgid "Replace the file, use new file name and update all links" | ||
| 74 | msgstr "Sostituire il file, usare il nome del nuovo file ed aggiornare tutti i collegamenti" | ||
| 75 | |||
| 76 | #: popup.php:58 | ||
| 77 | msgid "Note: If you check this option, the name and type of the file you are about to upload will replace the old file. All links pointing to the current file (" | ||
| 78 | msgstr "Nota: Se selezioni questa opzione, il nome ed il tipo di file che stai per caricare sostituiranno quelli del file precedente. Tutti i collegamenti che puntavano al file precedente (" | ||
| 79 | |||
| 80 | #: popup.php:58 | ||
| 81 | msgid ") will be updated to point to the new file name." | ||
| 82 | msgstr ") saranno aggiornati per puntare al nuovo file." | ||
| 83 | |||
| 84 | #: popup.php:60 | ||
| 85 | msgid "Upload" | ||
| 86 | msgstr "Carica" | ||
| 87 | |||
| 88 | #: popup.php:60 | ||
| 89 | msgid "Cancel" | ||
| 90 | msgstr "Annulla" | ||
| 91 | |||
| 92 | #: upload.php:35 | ||
| 93 | msgid "File type does not meet security guidelines. Try another." | ||
| 94 | msgstr "Il tipo di file non rispetta le restrizioni di sicurezza. Riprova con un altro tipo." | ||
| 95 |
No preview for this file type
| 1 | msgid "" | ||
| 2 | msgstr "" | ||
| 3 | "Project-Id-Version: enable-media-replace\n" | ||
| 4 | "Report-Msgid-Bugs-To: \n" | ||
| 5 | "POT-Creation-Date: 2015-01-19 09:00+0900\n" | ||
| 6 | "PO-Revision-Date: \n" | ||
| 7 | "Last-Translator: chacomv\n" | ||
| 8 | "Language-Team: \n" | ||
| 9 | "MIME-Version: 1.0\n" | ||
| 10 | "Content-Type: text/plain; charset=UTF-8\n" | ||
| 11 | "Content-Transfer-Encoding: 8bit\n" | ||
| 12 | "X-Poedit-KeywordsList: __;_e\n" | ||
| 13 | "X-Poedit-Basepath: .\n" | ||
| 14 | "X-Generator: Poedit 1.5.7\n" | ||
| 15 | "X-Poedit-SearchPath-0: .\n" | ||
| 16 | |||
| 17 | #: enable-media-replace.php:40 enable-media-replace.php:79 | ||
| 18 | #: enable-media-replace.php:120 | ||
| 19 | msgid "Replace media" | ||
| 20 | msgstr "メディアを置換" | ||
| 21 | |||
| 22 | #: enable-media-replace.php:79 | ||
| 23 | msgid "Upload a new file" | ||
| 24 | msgstr "新しいファイルをアップロード" | ||
| 25 | |||
| 26 | #: enable-media-replace.php:79 | ||
| 27 | msgid "To replace the current file, click the link and upload a replacement." | ||
| 28 | msgstr "" | ||
| 29 | "現在のファイルを置換するには、このリンクをクリックしてアップロードします。" | ||
| 30 | |||
| 31 | #: enable-media-replace.php:168 | ||
| 32 | msgid "Revised" | ||
| 33 | msgstr "変更されました" | ||
| 34 | |||
| 35 | #: popup.php:14 upload.php:3 | ||
| 36 | msgid "You do not have permission to upload files." | ||
| 37 | msgstr "ファイルをアップロードする権限がありません。" | ||
| 38 | |||
| 39 | #: popup.php:30 | ||
| 40 | msgid "Replace Media Upload" | ||
| 41 | msgstr "新しいメディアファイルをアップロード" | ||
| 42 | |||
| 43 | #: popup.php:46 | ||
| 44 | msgid "NOTE: You are about to replace the media file" | ||
| 45 | msgstr "※ このメディアを置き換えようとしています。" | ||
| 46 | |||
| 47 | #: popup.php:46 | ||
| 48 | msgid "There is no undo. Think about it!" | ||
| 49 | msgstr "元に戻せませんのでご注意ください。" | ||
| 50 | |||
| 51 | #: popup.php:48 | ||
| 52 | msgid "Choose a file to upload from your computer" | ||
| 53 | msgstr "コンピューターからアップロードするファイルを選択" | ||
| 54 | |||
| 55 | #: popup.php:52 | ||
| 56 | msgid "Select media replacement type:" | ||
| 57 | msgstr "メディアを置換する方式を選択:" | ||
| 58 | |||
| 59 | #: popup.php:54 | ||
| 60 | msgid "Just replace the file" | ||
| 61 | msgstr "ファイルの置換のみ" | ||
| 62 | |||
| 63 | #: popup.php:55 | ||
| 64 | msgid "Note: This option requires you to upload a file of the same type (" | ||
| 65 | msgstr "" | ||
| 66 | "※ このオプションは、元のファイルと同じファイル形式でアップロードする必要があ" | ||
| 67 | "ります。(" | ||
| 68 | |||
| 69 | #: popup.php:55 | ||
| 70 | msgid "" | ||
| 71 | ") as the one you are replacing. The name of the attachment will stay the " | ||
| 72 | "same (" | ||
| 73 | msgstr ") ファイル名は同じになります。(" | ||
| 74 | |||
| 75 | #: popup.php:55 | ||
| 76 | msgid ") no matter what the file you upload is called." | ||
| 77 | msgstr ")" | ||
| 78 | |||
| 79 | #: popup.php:57 | ||
| 80 | msgid "Replace the file, use new file name and update all links" | ||
| 81 | msgstr "ファイルを置換して新しいファイル名で全てのリンクを更新する" | ||
| 82 | |||
| 83 | #: popup.php:58 | ||
| 84 | msgid "" | ||
| 85 | "Note: If you check this option, the name and type of the file you are about " | ||
| 86 | "to upload will replace the old file. All links pointing to the current file (" | ||
| 87 | msgstr "" | ||
| 88 | "※ このオプションをチェックすると、アップロードしたファイルの名称と形式に置換" | ||
| 89 | "されます。現在のファイル名(" | ||
| 90 | |||
| 91 | #: popup.php:58 | ||
| 92 | msgid ") will be updated to point to the new file name." | ||
| 93 | msgstr ")へのリンクが全て新しいファイル名に更新されます。" | ||
| 94 | |||
| 95 | #: popup.php:60 | ||
| 96 | msgid "Upload" | ||
| 97 | msgstr "アップロード" | ||
| 98 | |||
| 99 | #: popup.php:60 | ||
| 100 | msgid "Cancel" | ||
| 101 | msgstr "キャンセル" | ||
| 102 | |||
| 103 | #: upload.php:33 | ||
| 104 | msgid "File type does not meet security guidelines. Try another." | ||
| 105 | msgstr "" | ||
| 106 | "ファイル形式がセキュリティ的に許可されません。他の形式をお試しください。" | ||
| 107 | |||
| 108 | #: popup.php:63 | ||
| 109 | msgid "" | ||
| 110 | "Please note that if you upload a new image, only embeds/links of the " | ||
| 111 | "original size image will be replaced in your posts." | ||
| 112 | msgstr "" | ||
| 113 | "新しいファイルをアップロードすると、元のサイズの画像へのリンクや埋め込みのみ" | ||
| 114 | "が置換されますのでご注意ください。" |
No preview for this file type
| 1 | msgid "" | ||
| 2 | msgstr "" | ||
| 3 | "Project-Id-Version: enable-media-replace\n" | ||
| 4 | "Report-Msgid-Bugs-To: \n" | ||
| 5 | "POT-Creation-Date: 2010-09-10 20:53+0100\n" | ||
| 6 | "PO-Revision-Date: \n" | ||
| 7 | "Last-Translator: WarmStal D!sign | Ben ter Stal <mail@warmstal.nl>\n" | ||
| 8 | "Language-Team: \n" | ||
| 9 | "MIME-Version: 1.0\n" | ||
| 10 | "Content-Type: text/plain; charset=UTF-8\n" | ||
| 11 | "Content-Transfer-Encoding: 8bit\n" | ||
| 12 | "X-Poedit-KeywordsList: __;_e\n" | ||
| 13 | "X-Poedit-Basepath: .\n" | ||
| 14 | "X-Poedit-SearchPath-0: .\n" | ||
| 15 | |||
| 16 | #: enable-media-replace.php:26 | ||
| 17 | #: enable-media-replace.php:45 | ||
| 18 | msgid "Replace media" | ||
| 19 | msgstr "Vervangen media" | ||
| 20 | |||
| 21 | #: enable-media-replace.php:45 | ||
| 22 | msgid "Upload a new file" | ||
| 23 | msgstr "Uploaden nieuw bestand" | ||
| 24 | |||
| 25 | #: enable-media-replace.php:45 | ||
| 26 | msgid "To replace the current file, click the link and upload a replacement." | ||
| 27 | msgstr "Klik om het bestaande bestand te vervangen door een nieuw te uploaden bestand." | ||
| 28 | |||
| 29 | #: popup.php:7 | ||
| 30 | #: upload.php:10 | ||
| 31 | msgid "You do not have permission to upload files." | ||
| 32 | msgstr "U heeft geen rechten om bestanden te uplaoden" | ||
| 33 | |||
| 34 | #: popup.php:23 | ||
| 35 | msgid "Replace Media Upload" | ||
| 36 | msgstr "Replace Media Upload" | ||
| 37 | |||
| 38 | #: popup.php:34 | ||
| 39 | msgid "NOTE: You are about to replace the media file" | ||
| 40 | msgstr "Opmerking: U staat op het punt het media bestand" | ||
| 41 | |||
| 42 | #: popup.php:34 | ||
| 43 | msgid "There is no undo. Think about it!" | ||
| 44 | msgstr "Deze bewerking kan niet ongedaan worden gemaakt!" | ||
| 45 | |||
| 46 | #: popup.php:36 | ||
| 47 | msgid "Choose a file to upload from your computer" | ||
| 48 | msgstr "Selecteer een bestand op de PC om te uploaden" | ||
| 49 | |||
| 50 | #: popup.php:40 | ||
| 51 | msgid "Select media replacement type:" | ||
| 52 | msgstr "Selecteer de wijze van vervanging" | ||
| 53 | |||
| 54 | #: popup.php:42 | ||
| 55 | msgid "Just replace the file" | ||
| 56 | msgstr "Vervang alleen het bestand" | ||
| 57 | |||
| 58 | #: popup.php:43 | ||
| 59 | msgid "Note: This option requires you to upload a file of the same type (" | ||
| 60 | msgstr "Opmerking: voor deze optie moet u een bestand van hetzelfde type uploaden (" | ||
| 61 | |||
| 62 | #: popup.php:43 | ||
| 63 | msgid ") as the one you are replacing. The name of the attachment will stay the same (" | ||
| 64 | msgstr ") De naam in de media bibliotheek blijft hetzelfde (" | ||
| 65 | |||
| 66 | #: popup.php:43 | ||
| 67 | msgid ") no matter what the file you upload is called." | ||
| 68 | msgstr ") onafhankelijk van de naam van het nieuwe bestand." | ||
| 69 | |||
| 70 | #: popup.php:45 | ||
| 71 | msgid "Replace the file, use new file name and update all links" | ||
| 72 | msgstr "Vervang het bestand, gebruik de nieuwe naam en werk alle links bij." | ||
| 73 | |||
| 74 | #: popup.php:46 | ||
| 75 | msgid "Note: If you check this option, the name and type of the file you are about to upload will replace the old file. All links pointing to the current file (" | ||
| 76 | msgstr "Opmerking: bij deze keuze wordt het bestand volledig vervangen. Alle links naar het huidige bestand (" | ||
| 77 | |||
| 78 | #: popup.php:46 | ||
| 79 | msgid ") will be updated to point to the new file name." | ||
| 80 | msgstr ") worden bijgewerkt naar het nieuwe bestand." | ||
| 81 | |||
| 82 | #: popup.php:48 | ||
| 83 | msgid "Upload" | ||
| 84 | msgstr "Uploaden" | ||
| 85 | |||
| 86 | #: popup.php:48 | ||
| 87 | msgid "Cancel" | ||
| 88 | msgstr "Annuleren" | ||
| 89 |
No preview for this file type
| 1 | msgid "" | ||
| 2 | msgstr "" | ||
| 3 | "Project-Id-Version: enable-media-replace\n" | ||
| 4 | "Report-Msgid-Bugs-To: \n" | ||
| 5 | "POT-Creation-Date: 2010-09-13 14:57+0100\n" | ||
| 6 | "PO-Revision-Date: \n" | ||
| 7 | "Last-Translator: Roger <rogerhnn@hotmail.com>\n" | ||
| 8 | "Language-Team: Roger Nobrega <rogerhnn@hotmail.com>\n" | ||
| 9 | "MIME-Version: 1.0\n" | ||
| 10 | "Content-Type: text/plain; charset=UTF-8\n" | ||
| 11 | "Content-Transfer-Encoding: 8bit\n" | ||
| 12 | "X-Poedit-KeywordsList: __;_e\n" | ||
| 13 | "X-Poedit-Basepath: .\n" | ||
| 14 | "X-Generator: Poedit 1.5.4\n" | ||
| 15 | "Language: Português - Brasil\n" | ||
| 16 | "X-Poedit-SourceCharset: UTF-8\n" | ||
| 17 | "X-Poedit-SearchPath-0: .\n" | ||
| 18 | |||
| 19 | #: enable-media-replace.php:40 enable-media-replace.php:68 | ||
| 20 | msgid "Replace media" | ||
| 21 | msgstr "Substituir mídia" | ||
| 22 | |||
| 23 | #: enable-media-replace.php:68 | ||
| 24 | msgid "Upload a new file" | ||
| 25 | msgstr "Enviar novo arquivo" | ||
| 26 | |||
| 27 | #: enable-media-replace.php:68 | ||
| 28 | msgid "To replace the current file, click the link and upload a replacement." | ||
| 29 | msgstr "" | ||
| 30 | "Para subtituir o arquivo atual, clique no link e carregue um substituto" | ||
| 31 | |||
| 32 | #: popup.php:14 upload.php:21 | ||
| 33 | msgid "You do not have permission to upload files." | ||
| 34 | msgstr "Você não tem permissões para enviar arquivos." | ||
| 35 | |||
| 36 | #: popup.php:30 | ||
| 37 | msgid "Replace Media Upload" | ||
| 38 | msgstr "Enviar Mídia Substituta" | ||
| 39 | |||
| 40 | #: popup.php:41 | ||
| 41 | msgid "NOTE: You are about to replace the media file" | ||
| 42 | msgstr "NOTA: Você irá substituir o arquivo de mídia" | ||
| 43 | |||
| 44 | #: popup.php:41 | ||
| 45 | msgid "There is no undo. Think about it!" | ||
| 46 | msgstr "Não é possível cancelar esta ação." | ||
| 47 | |||
| 48 | #: popup.php:43 | ||
| 49 | msgid "Choose a file to upload from your computer" | ||
| 50 | msgstr "Escolha um arquivo para enviar do seu computador" | ||
| 51 | |||
| 52 | #: popup.php:47 | ||
| 53 | msgid "Select media replacement type:" | ||
| 54 | msgstr "Selecione o tipo de substituição" | ||
| 55 | |||
| 56 | #: popup.php:49 | ||
| 57 | msgid "Just replace the file" | ||
| 58 | msgstr "Apenas substituir arquivo" | ||
| 59 | |||
| 60 | #: popup.php:50 | ||
| 61 | msgid "Note: This option requires you to upload a file of the same type (" | ||
| 62 | msgstr "Nota: Esta opção requer o carregamento de um arquivo do mesmo tipo (" | ||
| 63 | |||
| 64 | #: popup.php:50 | ||
| 65 | msgid "" | ||
| 66 | ") as the one you are replacing. The name of the attachment will stay the " | ||
| 67 | "same (" | ||
| 68 | msgstr "" | ||
| 69 | ") do que está sendo substituído. O nome do arquivo permanecerá o mesmo(" | ||
| 70 | |||
| 71 | #: popup.php:50 | ||
| 72 | msgid ") no matter what the file you upload is called." | ||
| 73 | msgstr "), independente do nome do arquivo enviado." | ||
| 74 | |||
| 75 | #: popup.php:52 | ||
| 76 | msgid "Replace the file, use new file name and update all links" | ||
| 77 | msgstr "" | ||
| 78 | "Substituir o arquivo, usar o novo nome de arquivo, e atualizar todos os links" | ||
| 79 | |||
| 80 | #: popup.php:53 | ||
| 81 | msgid "" | ||
| 82 | "Note: If you check this option, the name and type of the file you are about " | ||
| 83 | "to upload will replace the old file. All links pointing to the current file (" | ||
| 84 | msgstr "" | ||
| 85 | "Nota: Se selecionar esta opção, o nome e tipo do arquivo que você enviar irá " | ||
| 86 | "substituir os do arquivo antigo. Todos os links do arquivo atual (" | ||
| 87 | |||
| 88 | #: popup.php:53 | ||
| 89 | msgid ") will be updated to point to the new file name." | ||
| 90 | msgstr ") serão atualizados para o novo arquivo." | ||
| 91 | |||
| 92 | #: popup.php:55 | ||
| 93 | msgid "Upload" | ||
| 94 | msgstr "Enviar" | ||
| 95 | |||
| 96 | #: popup.php:55 | ||
| 97 | msgid "Cancel" | ||
| 98 | msgstr "Cancelar" |
No preview for this file type
| 1 | msgid "" | ||
| 2 | msgstr "" | ||
| 3 | "Project-Id-Version: enable-media-replace\n" | ||
| 4 | "Report-Msgid-Bugs-To: \n" | ||
| 5 | "POT-Creation-Date: 2017-02-10 08:48+0000\n" | ||
| 6 | "PO-Revision-Date: \n" | ||
| 7 | "Last-Translator: Pedro Mendonça <ped.gaspar@gmail.com>\n" | ||
| 8 | "Language-Team: Pedro Mendonça <ped.gaspar@gmail.com>\n" | ||
| 9 | "Language: pt_PT\n" | ||
| 10 | "MIME-Version: 1.0\n" | ||
| 11 | "Content-Type: text/plain; charset=UTF-8\n" | ||
| 12 | "Content-Transfer-Encoding: 8bit\n" | ||
| 13 | "X-Poedit-KeywordsList: __;_e\n" | ||
| 14 | "X-Poedit-Basepath: ..\n" | ||
| 15 | "X-Generator: Poedit 1.8.11\n" | ||
| 16 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
| 17 | "X-Poedit-SourceCharset: UTF-8\n" | ||
| 18 | "X-Poedit-WPHeader: enable-media-replace.php\n" | ||
| 19 | "X-Poedit-SearchPath-0: .\n" | ||
| 20 | |||
| 21 | #: enable-media-replace.php:38 enable-media-replace.php:64 | ||
| 22 | #: enable-media-replace.php:105 | ||
| 23 | msgid "Replace media" | ||
| 24 | msgstr "Substituir multimédia" | ||
| 25 | |||
| 26 | #: enable-media-replace.php:64 | ||
| 27 | msgid "Upload a new file" | ||
| 28 | msgstr "Carregar novo ficheiro" | ||
| 29 | |||
| 30 | #: enable-media-replace.php:64 | ||
| 31 | msgid "To replace the current file, click the link and upload a replacement." | ||
| 32 | msgstr "" | ||
| 33 | "Para subtituir o ficheiro actual, clique na ligação e carregue um substituto." | ||
| 34 | |||
| 35 | #: enable-media-replace.php:156 | ||
| 36 | msgid "Revised" | ||
| 37 | msgstr "Revisto" | ||
| 38 | |||
| 39 | #: popup.php:14 upload.php:3 | ||
| 40 | msgid "You do not have permission to upload files." | ||
| 41 | msgstr "Não tem permissão para carregar ficheiros." | ||
| 42 | |||
| 43 | #: popup.php:29 | ||
| 44 | msgid "Replace Media Upload" | ||
| 45 | msgstr "Carregar multimédia de substituição" | ||
| 46 | |||
| 47 | #: popup.php:45 | ||
| 48 | #, php-format | ||
| 49 | msgid "" | ||
| 50 | "NOTE: You are about to replace the media file \"%s\". There is no undo. " | ||
| 51 | "Think about it!" | ||
| 52 | msgstr "" | ||
| 53 | "NOTA: Está prestes a substituir o ficheiro multimédia \"%s\". Não será " | ||
| 54 | "possível voltar a trás!" | ||
| 55 | |||
| 56 | #: popup.php:47 | ||
| 57 | msgid "Choose a file to upload from your computer" | ||
| 58 | msgstr "Escolher um ficheiro para carregar a partir do computador" | ||
| 59 | |||
| 60 | #: popup.php:54 | ||
| 61 | msgid "Select media replacement type:" | ||
| 62 | msgstr "Seleccione o tipo de substituição de multimédia:" | ||
| 63 | |||
| 64 | #: popup.php:56 | ||
| 65 | msgid "Just replace the file" | ||
| 66 | msgstr "Apenas substituir o ficheiro" | ||
| 67 | |||
| 68 | #: popup.php:57 | ||
| 69 | #, php-format | ||
| 70 | msgid "" | ||
| 71 | "Note: This option requires you to upload a file of the same type (%s) as the " | ||
| 72 | "one you are replacing. The name of the attachment will stay the same (%s) no " | ||
| 73 | "matter what the file you upload is called." | ||
| 74 | msgstr "" | ||
| 75 | "Nota: Esta opção requer o carregamento de um ficheiro do mesmo tipo (%s) " | ||
| 76 | "daquele a substituir. O nome do ficheiro permanecerá o mesmo (%s), " | ||
| 77 | "independentemente do nome do ficheiro carregado." | ||
| 78 | |||
| 79 | #: popup.php:60 | ||
| 80 | msgid "Replace the file, use new file name and update all links" | ||
| 81 | msgstr "" | ||
| 82 | "Substituir o ficheiro, usar o novo nome de ficheiro e actualizar todas as " | ||
| 83 | "ligações" | ||
| 84 | |||
| 85 | #: popup.php:61 | ||
| 86 | #, php-format | ||
| 87 | msgid "" | ||
| 88 | "Note: If you check this option, the name and type of the file you are about " | ||
| 89 | "to upload will replace the old file. All links pointing to the current file " | ||
| 90 | "(%s) will be updated to point to the new file name." | ||
| 91 | msgstr "" | ||
| 92 | "Nota: Se seleccionar esta opção, o nome e tipo do ficheiro que está prestes " | ||
| 93 | "a carregar irá substituir os do ficheiro antigo. Todas as ligações que " | ||
| 94 | "referenciam o ficheiro actual (%s) serão actualizadas de modo a referenciar " | ||
| 95 | "o novo nome de ficheiro." | ||
| 96 | |||
| 97 | #: popup.php:62 | ||
| 98 | msgid "" | ||
| 99 | "Please note that if you upload a new image, only embeds/links of the " | ||
| 100 | "original size image will be replaced in your posts." | ||
| 101 | msgstr "" | ||
| 102 | "Por favor tenha em atenção que se carregar uma nova imagem, apenas as " | ||
| 103 | "imagens incorporadas e ligações com o tamanho original serão substituídas " | ||
| 104 | "nos seus artigos." | ||
| 105 | |||
| 106 | #: popup.php:67 | ||
| 107 | msgid "Upload" | ||
| 108 | msgstr "Carregar" | ||
| 109 | |||
| 110 | #: popup.php:67 | ||
| 111 | msgid "Cancel" | ||
| 112 | msgstr "Cancelar" | ||
| 113 | |||
| 114 | #: upload.php:26 | ||
| 115 | #, php-format | ||
| 116 | msgid "" | ||
| 117 | "The file %1$s can not be deleted by the web server, most likely because the " | ||
| 118 | "permissions on the file are wrong." | ||
| 119 | msgstr "" | ||
| 120 | "O ficheiro %1$s não pode ser apagado pelo servidor web, provavelmente porque " | ||
| 121 | "as permissões do ficheiro estão incorrectas." | ||
| 122 | |||
| 123 | #: upload.php:84 | ||
| 124 | msgid "File type does not meet security guidelines. Try another." | ||
| 125 | msgstr "" | ||
| 126 | "O tipo de ficheiro não está de acordo com os padrões de segurança. Tente " | ||
| 127 | "outro." | ||
| 128 | |||
| 129 | #. Plugin Name of the plugin/theme | ||
| 130 | msgid "Enable Media Replace" | ||
| 131 | msgstr "Enable Media Replace" | ||
| 132 | |||
| 133 | #. Plugin URI of the plugin/theme | ||
| 134 | msgid "http://www.mansjonasson.se/enable-media-replace" | ||
| 135 | msgstr "http://www.mansjonasson.se/enable-media-replace" | ||
| 136 | |||
| 137 | #. Description of the plugin/theme | ||
| 138 | msgid "" | ||
| 139 | "Enable replacing media files by uploading a new file in the \"Edit Media\" " | ||
| 140 | "section of the WordPress Media Library." | ||
| 141 | msgstr "" | ||
| 142 | "Permite substituir ficheiros multimédia através de carregar um novo ficheiro " | ||
| 143 | "na secção \"Editar multimédia\" da biblioteca multimédia do WordPress." | ||
| 144 | |||
| 145 | #. Author of the plugin/theme | ||
| 146 | msgid "Måns Jonasson" | ||
| 147 | msgstr "Måns Jonasson" | ||
| 148 | |||
| 149 | #. Author URI of the plugin/theme | ||
| 150 | msgid "http://www.mansjonasson.se" | ||
| 151 | msgstr "http://www.mansjonasson.se" |
No preview for this file type
| 1 | msgid "" | ||
| 2 | msgstr "" | ||
| 3 | "Project-Id-Version: enable-media-replace\n" | ||
| 4 | "Report-Msgid-Bugs-To: \n" | ||
| 5 | "POT-Creation-Date: 2010-09-13 14:57+0100\n" | ||
| 6 | "PO-Revision-Date: 2013-01-18 14:58+0400\n" | ||
| 7 | "Last-Translator: Vladislav (me@dsigh.ru)\n" | ||
| 8 | "Language-Team: DigitalSigh\n" | ||
| 9 | "MIME-Version: 1.0\n" | ||
| 10 | "Content-Type: text/plain; charset=UTF-8\n" | ||
| 11 | "Content-Transfer-Encoding: 8bit\n" | ||
| 12 | "X-Poedit-KeywordsList: __;_e\n" | ||
| 13 | "X-Poedit-Basepath: .\n" | ||
| 14 | "X-Poedit-Language: Russian\n" | ||
| 15 | "X-Poedit-Country: RUSSIAN FEDERATION\n" | ||
| 16 | "X-Poedit-SourceCharset: utf-8\n" | ||
| 17 | "X-Poedit-SearchPath-0: .\n" | ||
| 18 | "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11) ? 0 : ((n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20)) ? 1 : 2)\n" | ||
| 19 | |||
| 20 | #: enable-media-replace.php:40 | ||
| 21 | #: enable-media-replace.php:68 | ||
| 22 | msgid "Replace media" | ||
| 23 | msgstr "Заменить" | ||
| 24 | |||
| 25 | #: enable-media-replace.php:68 | ||
| 26 | msgid "Upload a new file" | ||
| 27 | msgstr "Загрузить новый файл" | ||
| 28 | |||
| 29 | #: enable-media-replace.php:68 | ||
| 30 | msgid "To replace the current file, click the link and upload a replacement." | ||
| 31 | msgstr "Для того, чтобы заменить текущий файл, нажмите на ссылку и загрузите замену." | ||
| 32 | |||
| 33 | #: popup.php:14 | ||
| 34 | #: upload.php:21 | ||
| 35 | msgid "You do not have permission to upload files." | ||
| 36 | msgstr "У вас нет прав для загрузки файлов." | ||
| 37 | |||
| 38 | #: popup.php:30 | ||
| 39 | msgid "Replace Media Upload" | ||
| 40 | msgstr "Загрузка файла для замены" | ||
| 41 | |||
| 42 | #: popup.php:41 | ||
| 43 | msgid "NOTE: You are about to replace the media file" | ||
| 44 | msgstr "ПРИМЕЧАНИЕ: Вы собираетесь заменить медиафайл" | ||
| 45 | |||
| 46 | #: popup.php:41 | ||
| 47 | msgid "There is no undo. Think about it!" | ||
| 48 | msgstr "Данную операцию нельзя отменить. Учтите это!" | ||
| 49 | |||
| 50 | #: popup.php:43 | ||
| 51 | msgid "Choose a file to upload from your computer" | ||
| 52 | msgstr "Выберите файл для загрузки с вашего компьютера:" | ||
| 53 | |||
| 54 | #: popup.php:47 | ||
| 55 | msgid "Select media replacement type:" | ||
| 56 | msgstr "Выберите тип замены:" | ||
| 57 | |||
| 58 | #: popup.php:49 | ||
| 59 | msgid "Just replace the file" | ||
| 60 | msgstr "Только заменить файл" | ||
| 61 | |||
| 62 | #: popup.php:50 | ||
| 63 | msgid "Note: This option requires you to upload a file of the same type (" | ||
| 64 | msgstr "Этот вариант требуется, если нужно загрузить файл того же типа (" | ||
| 65 | |||
| 66 | #: popup.php:50 | ||
| 67 | msgid ") as the one you are replacing. The name of the attachment will stay the same (" | ||
| 68 | msgstr "), как оригинальный. Имя вложения останется тем же (" | ||
| 69 | |||
| 70 | #: popup.php:50 | ||
| 71 | msgid ") no matter what the file you upload is called." | ||
| 72 | msgstr ") не зависимо от того, как называется загружаемый файл." | ||
| 73 | |||
| 74 | #: popup.php:52 | ||
| 75 | msgid "Replace the file, use new file name and update all links" | ||
| 76 | msgstr "Заменить файл, использовать новое имя и обновить все ссылки" | ||
| 77 | |||
| 78 | #: popup.php:53 | ||
| 79 | msgid "Note: If you check this option, the name and type of the file you are about to upload will replace the old file. All links pointing to the current file (" | ||
| 80 | msgstr "Если выбрать этот вариант, то имя и тип файла, который вы собираетесь загрузить, заменят старые. Все ссылки, указывающие на текущий файл (" | ||
| 81 | |||
| 82 | #: popup.php:53 | ||
| 83 | msgid ") will be updated to point to the new file name." | ||
| 84 | msgstr ") будут обновлены новыми." | ||
| 85 | |||
| 86 | #: popup.php:55 | ||
| 87 | msgid "Upload" | ||
| 88 | msgstr "Загрузить" | ||
| 89 | |||
| 90 | #: popup.php:55 | ||
| 91 | msgid "Cancel" | ||
| 92 | msgstr "Отмена" | ||
| 93 | |||
| 94 | #~ msgid "Replace media upload" | ||
| 95 | #~ msgstr "Загрузка файла для замены" |
No preview for this file type
| 1 | msgid "" | ||
| 2 | msgstr "" | ||
| 3 | "Project-Id-Version: enable-media-replace\n" | ||
| 4 | "Report-Msgid-Bugs-To: \n" | ||
| 5 | "POT-Creation-Date: 2015-01-16 15:55+0100\n" | ||
| 6 | "PO-Revision-Date: \n" | ||
| 7 | "Last-Translator: Måns Jonasson <mans@thejonassons.com>\n" | ||
| 8 | "Language-Team: \n" | ||
| 9 | "MIME-Version: 1.0\n" | ||
| 10 | "Content-Type: text/plain; charset=UTF-8\n" | ||
| 11 | "Content-Transfer-Encoding: 8bit\n" | ||
| 12 | "X-Poedit-KeywordsList: __;_e\n" | ||
| 13 | "X-Poedit-Basepath: .\n" | ||
| 14 | "X-Generator: Poedit 1.5.5\n" | ||
| 15 | "X-Poedit-SearchPath-0: ..\n" | ||
| 16 | |||
| 17 | #: ../enable-media-replace.php:40 ../enable-media-replace.php:79 | ||
| 18 | #: ../enable-media-replace.php:120 | ||
| 19 | msgid "Replace media" | ||
| 20 | msgstr "Ersätt media" | ||
| 21 | |||
| 22 | #: ../enable-media-replace.php:79 | ||
| 23 | msgid "Upload a new file" | ||
| 24 | msgstr "Ladda upp en ny fil" | ||
| 25 | |||
| 26 | #: ../enable-media-replace.php:79 | ||
| 27 | msgid "To replace the current file, click the link and upload a replacement." | ||
| 28 | msgstr "" | ||
| 29 | "För att ersätta den nuvarande filen, klicka på länken och ladda upp en ny " | ||
| 30 | "fil." | ||
| 31 | |||
| 32 | #: ../enable-media-replace.php:161 | ||
| 33 | msgid "Revised" | ||
| 34 | msgstr "Uppdaterad" | ||
| 35 | |||
| 36 | #: ../popup.php:14 ../upload.php:3 | ||
| 37 | msgid "You do not have permission to upload files." | ||
| 38 | msgstr "Du har inte tillåtelse att ladda upp filer." | ||
| 39 | |||
| 40 | #: ../popup.php:30 | ||
| 41 | msgid "Replace Media Upload" | ||
| 42 | msgstr "Ladda upp ny fil" | ||
| 43 | |||
| 44 | #: ../popup.php:46 | ||
| 45 | msgid "NOTE: You are about to replace the media file" | ||
| 46 | msgstr "OBS: Du är på väg att ersätta filen" | ||
| 47 | |||
| 48 | #: ../popup.php:46 | ||
| 49 | msgid "There is no undo. Think about it!" | ||
| 50 | msgstr "Det finns inget sätt att ångra. Tänk efter först!" | ||
| 51 | |||
| 52 | #: ../popup.php:48 | ||
| 53 | msgid "Choose a file to upload from your computer" | ||
| 54 | msgstr "Välj en fil att ladda upp från din dator" | ||
| 55 | |||
| 56 | #: ../popup.php:55 | ||
| 57 | msgid "Select media replacement type:" | ||
| 58 | msgstr "Välj ersättningsform:" | ||
| 59 | |||
| 60 | #: ../popup.php:57 | ||
| 61 | msgid "Just replace the file" | ||
| 62 | msgstr "Ersätt bara filen" | ||
| 63 | |||
| 64 | #: ../popup.php:58 | ||
| 65 | msgid "Note: This option requires you to upload a file of the same type (" | ||
| 66 | msgstr "Detta val kräver att du laddar upp en fil av exakt samma typ (" | ||
| 67 | |||
| 68 | #: ../popup.php:58 | ||
| 69 | msgid "" | ||
| 70 | ") as the one you are replacing. The name of the attachment will stay the " | ||
| 71 | "same (" | ||
| 72 | msgstr ") som den du ersätter. Namnet på filen kommer att behållas (" | ||
| 73 | |||
| 74 | #: ../popup.php:58 | ||
| 75 | msgid ") no matter what the file you upload is called." | ||
| 76 | msgstr ") oavsett vad filen du laddar upp heter på din dator." | ||
| 77 | |||
| 78 | #: ../popup.php:61 | ||
| 79 | msgid "Replace the file, use new file name and update all links" | ||
| 80 | msgstr "Ersätt filen, använd det nya filnamnet och uppdatera alla länkar" | ||
| 81 | |||
| 82 | #: ../popup.php:62 | ||
| 83 | msgid "" | ||
| 84 | "Note: If you check this option, the name and type of the file you are about " | ||
| 85 | "to upload will replace the old file. All links pointing to the current file (" | ||
| 86 | msgstr "" | ||
| 87 | "Om du klickar i den här rutan kommer den även namnet och typen på den nya " | ||
| 88 | "filen du laddar upp helt att ersätta den gamla. Alla länkar som pekar på den " | ||
| 89 | "gamla filen (" | ||
| 90 | |||
| 91 | #: ../popup.php:62 | ||
| 92 | msgid ") will be updated to point to the new file name." | ||
| 93 | msgstr ") kommer att uppdateras så att de pekar på det nya filnamnet." | ||
| 94 | |||
| 95 | #: ../popup.php:63 | ||
| 96 | msgid "" | ||
| 97 | "Please note that if you upload a new image, only embeds/links of the " | ||
| 98 | "original size image will be replaced in your posts." | ||
| 99 | msgstr "" | ||
| 100 | "Notera att om du laddar upp en ny bild kommer endast inbäddningar/länkar " | ||
| 101 | "till originalstorleken att bytas ut i dina poster." | ||
| 102 | |||
| 103 | #: ../popup.php:68 | ||
| 104 | msgid "Upload" | ||
| 105 | msgstr "Ladda upp" | ||
| 106 | |||
| 107 | #: ../popup.php:68 | ||
| 108 | msgid "Cancel" | ||
| 109 | msgstr "Avbryt" | ||
| 110 | |||
| 111 | #: ../upload.php:26 | ||
| 112 | #, php-format | ||
| 113 | msgid "" | ||
| 114 | "The file %1$s can not be deleted by the web server, most likely because the " | ||
| 115 | "permissions on the file are wrong." | ||
| 116 | msgstr "" | ||
| 117 | "Filen %1$s kan inte raderas av webbservern, troligen på grund av " | ||
| 118 | "filrättigheterna." | ||
| 119 | |||
| 120 | #: ../upload.php:84 | ||
| 121 | msgid "File type does not meet security guidelines. Try another." | ||
| 122 | msgstr "" | ||
| 123 | "Den här filen är inte tillåten enligt WordPress säkerhetsinställningar. " | ||
| 124 | |||
| 125 | #~ msgid "Enable Media Replace" | ||
| 126 | #~ msgstr "Ladda upp ny fil" | ||
| 127 | |||
| 128 | #~ msgid "" | ||
| 129 | #~ "This plugin allows you to replace any uploaded media file by uploading a " | ||
| 130 | #~ "new one." | ||
| 131 | #~ msgstr "" | ||
| 132 | #~ "Detta plugin låter dig ersätta en fil i mediebiblioteket genom att ladda " | ||
| 133 | #~ "upp en ny." | ||
| 134 | |||
| 135 | #~ msgid "First, locate the uploaded file you want to replace, using the" | ||
| 136 | #~ msgstr "Hitta först den fil du vill ersätta genom att bläddra i " | ||
| 137 | |||
| 138 | #~ msgid "media library browser" | ||
| 139 | #~ msgstr "mediebiblioteket" | ||
| 140 | |||
| 141 | #~ msgid "Click the \"Edit\" link" | ||
| 142 | #~ msgstr "Tryck på \"Redigera\"-länken" | ||
| 143 | |||
| 144 | #~ msgid "" | ||
| 145 | #~ "Second, click the link \"Upload a new file\" and follow the instructions." | ||
| 146 | #~ msgstr "Tryck sen på länken \"Ladda upp ny fil\" och följ instruktionerna." | ||
| 147 | |||
| 148 | #~ msgid "Replace media upload" | ||
| 149 | #~ msgstr "Ladda upp ny fil" |
No preview for this file type
| 1 | msgid "" | ||
| 2 | msgstr "" | ||
| 3 | "Project-Id-Version: Enable Media Replace v2.6\n" | ||
| 4 | "Report-Msgid-Bugs-To: \n" | ||
| 5 | "POT-Creation-Date: \n" | ||
| 6 | "PO-Revision-Date: 2012-09-18 07:29:17+0000\n" | ||
| 7 | "Last-Translator: Tunghsiao Liu <info@sparanoid.com>\n" | ||
| 8 | "Language-Team: \n" | ||
| 9 | "MIME-Version: 1.0\n" | ||
| 10 | "Content-Type: text/plain; charset=UTF-8\n" | ||
| 11 | "Content-Transfer-Encoding: 8bit\n" | ||
| 12 | "Plural-Forms: nplurals=2; plural=n != 1;\n" | ||
| 13 | "X-Poedit-Language: Chinese\n" | ||
| 14 | "X-Poedit-Country: PEOPLE'S REPUBLIC OF CHINA\n" | ||
| 15 | "X-Poedit-SourceCharset: utf-8\n" | ||
| 16 | "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n" | ||
| 17 | "X-Poedit-Basepath: \n" | ||
| 18 | "X-Poedit-Bookmarks: \n" | ||
| 19 | "X-Poedit-SearchPath-0: .\n" | ||
| 20 | "X-Textdomain-Support: yes" | ||
| 21 | |||
| 22 | #: enable-media-replace.php:39 | ||
| 23 | #: enable-media-replace.php:67 | ||
| 24 | #@ enable-media-replace | ||
| 25 | msgid "Replace media" | ||
| 26 | msgstr "替换媒体" | ||
| 27 | |||
| 28 | #: enable-media-replace.php:67 | ||
| 29 | #@ enable-media-replace | ||
| 30 | msgid "Upload a new file" | ||
| 31 | msgstr "上传新文件" | ||
| 32 | |||
| 33 | #: enable-media-replace.php:67 | ||
| 34 | #@ enable-media-replace | ||
| 35 | msgid "To replace the current file, click the link and upload a replacement." | ||
| 36 | msgstr "想要替换当前文件,点击上述链接并上传新文件" | ||
| 37 | |||
| 38 | #: popup.php:14 | ||
| 39 | #: upload.php:3 | ||
| 40 | #@ enable-media-replace | ||
| 41 | #@ default | ||
| 42 | msgid "You do not have permission to upload files." | ||
| 43 | msgstr "您没有权限上传文件" | ||
| 44 | |||
| 45 | #: popup.php:30 | ||
| 46 | #@ enable-media-replace | ||
| 47 | msgid "Replace Media Upload" | ||
| 48 | msgstr "替换媒体文件" | ||
| 49 | |||
| 50 | #: popup.php:46 | ||
| 51 | #@ enable-media-replace | ||
| 52 | msgid "NOTE: You are about to replace the media file" | ||
| 53 | msgstr "注意:您将要替换媒体文件" | ||
| 54 | |||
| 55 | #: popup.php:46 | ||
| 56 | #@ enable-media-replace | ||
| 57 | msgid "There is no undo. Think about it!" | ||
| 58 | msgstr "此操作无法撤销。" | ||
| 59 | |||
| 60 | #: popup.php:48 | ||
| 61 | #@ enable-media-replace | ||
| 62 | msgid "Choose a file to upload from your computer" | ||
| 63 | msgstr "从计算机中选择文件上传" | ||
| 64 | |||
| 65 | #: popup.php:52 | ||
| 66 | #@ enable-media-replace | ||
| 67 | msgid "Select media replacement type:" | ||
| 68 | msgstr "选择媒体替换类型" | ||
| 69 | |||
| 70 | #: popup.php:54 | ||
| 71 | #@ enable-media-replace | ||
| 72 | msgid "Just replace the file" | ||
| 73 | msgstr "仅替换文件" | ||
| 74 | |||
| 75 | #: popup.php:55 | ||
| 76 | #@ enable-media-replace | ||
| 77 | msgid "Note: This option requires you to upload a file of the same type (" | ||
| 78 | msgstr "说明:此选项要求您上传与之前文件相同的文件类型(" | ||
| 79 | |||
| 80 | #: popup.php:55 | ||
| 81 | #@ enable-media-replace | ||
| 82 | msgid ") as the one you are replacing. The name of the attachment will stay the same (" | ||
| 83 | msgstr "),替换后,无论您上传的文件名是什么,上传后的媒体文件名称与地址都会保持不变(" | ||
| 84 | |||
| 85 | #: popup.php:55 | ||
| 86 | #@ enable-media-replace | ||
| 87 | msgid ") no matter what the file you upload is called." | ||
| 88 | msgstr ")。" | ||
| 89 | |||
| 90 | #: popup.php:57 | ||
| 91 | #@ enable-media-replace | ||
| 92 | msgid "Replace the file, use new file name and update all links" | ||
| 93 | msgstr "替换文件,使用新文件名并更新所有链接" | ||
| 94 | |||
| 95 | #: popup.php:58 | ||
| 96 | #@ enable-media-replace | ||
| 97 | msgid "Note: If you check this option, the name and type of the file you are about to upload will replace the old file. All links pointing to the current file (" | ||
| 98 | msgstr "说明:使用此选项,将会使用新文件的文件名及文件类型,所有包含文件名(" | ||
| 99 | |||
| 100 | #: popup.php:58 | ||
| 101 | #@ enable-media-replace | ||
| 102 | msgid ") will be updated to point to the new file name." | ||
| 103 | msgstr ")的链接也将会被替换成新文件名。" | ||
| 104 | |||
| 105 | #: popup.php:60 | ||
| 106 | #@ enable-media-replace | ||
| 107 | msgid "Upload" | ||
| 108 | msgstr "上传" | ||
| 109 | |||
| 110 | #: popup.php:60 | ||
| 111 | #@ enable-media-replace | ||
| 112 | msgid "Cancel" | ||
| 113 | msgstr "取消" | ||
| 114 | |||
| 115 | #: upload.php:33 | ||
| 116 | #@ default | ||
| 117 | msgid "File type does not meet security guidelines. Try another." | ||
| 118 | msgstr "文件类型不符合安全规范,请尝试其他文件。" | ||
| 119 |
No preview for this file type
| 1 | msgid "" | ||
| 2 | msgstr "" | ||
| 3 | "Project-Id-Version: enable-media-replace\n" | ||
| 4 | "Report-Msgid-Bugs-To: \n" | ||
| 5 | "POT-Creation-Date: 2015-01-16 17:42-0000\n" | ||
| 6 | "PO-Revision-Date: \n" | ||
| 7 | "Last-Translator: Pedro Mendonça <ped.gaspar@gmail.com>\n" | ||
| 8 | "Language-Team: \n" | ||
| 9 | "MIME-Version: 1.0\n" | ||
| 10 | "Content-Type: text/plain; charset=UTF-8\n" | ||
| 11 | "Content-Transfer-Encoding: 8bit\n" | ||
| 12 | "X-Poedit-KeywordsList: __;_e\n" | ||
| 13 | "X-Poedit-Basepath: .\n" | ||
| 14 | "X-Generator: Poedit 1.7.1\n" | ||
| 15 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
| 16 | "X-Poedit-SourceCharset: UTF-8\n" | ||
| 17 | "Language: en\n" | ||
| 18 | "X-Poedit-SearchPath-0: .\n" | ||
| 19 | "X-Poedit-SearchPath-1: ..\n" | ||
| 20 | |||
| 21 | #: ../enable-media-replace.php:40 ../enable-media-replace.php:79 | ||
| 22 | #: ../enable-media-replace.php:120 | ||
| 23 | msgid "Replace media" | ||
| 24 | msgstr "" | ||
| 25 | |||
| 26 | #: ../enable-media-replace.php:79 | ||
| 27 | msgid "Upload a new file" | ||
| 28 | msgstr "" | ||
| 29 | |||
| 30 | #: ../enable-media-replace.php:79 | ||
| 31 | msgid "To replace the current file, click the link and upload a replacement." | ||
| 32 | msgstr "" | ||
| 33 | |||
| 34 | #: ../enable-media-replace.php:161 | ||
| 35 | msgid "Revised" | ||
| 36 | msgstr "" | ||
| 37 | |||
| 38 | #: ../popup.php:14 ../upload.php:3 | ||
| 39 | msgid "You do not have permission to upload files." | ||
| 40 | msgstr "" | ||
| 41 | |||
| 42 | #: ../popup.php:30 | ||
| 43 | msgid "Replace Media Upload" | ||
| 44 | msgstr "" | ||
| 45 | |||
| 46 | #: ../popup.php:46 | ||
| 47 | msgid "NOTE: You are about to replace the media file" | ||
| 48 | msgstr "" | ||
| 49 | |||
| 50 | #: ../popup.php:46 | ||
| 51 | msgid "There is no undo. Think about it!" | ||
| 52 | msgstr "" | ||
| 53 | |||
| 54 | #: ../popup.php:48 | ||
| 55 | msgid "Choose a file to upload from your computer" | ||
| 56 | msgstr "" | ||
| 57 | |||
| 58 | #: ../popup.php:55 | ||
| 59 | msgid "Select media replacement type:" | ||
| 60 | msgstr "" | ||
| 61 | |||
| 62 | #: ../popup.php:57 | ||
| 63 | msgid "Just replace the file" | ||
| 64 | msgstr "" | ||
| 65 | |||
| 66 | #: ../popup.php:58 | ||
| 67 | msgid "Note: This option requires you to upload a file of the same type (" | ||
| 68 | msgstr "" | ||
| 69 | |||
| 70 | #: ../popup.php:58 | ||
| 71 | msgid "" | ||
| 72 | ") as the one you are replacing. The name of the attachment will stay the " | ||
| 73 | "same (" | ||
| 74 | msgstr "" | ||
| 75 | |||
| 76 | #: ../popup.php:58 | ||
| 77 | msgid ") no matter what the file you upload is called." | ||
| 78 | msgstr "" | ||
| 79 | |||
| 80 | #: ../popup.php:61 | ||
| 81 | msgid "Replace the file, use new file name and update all links" | ||
| 82 | msgstr "" | ||
| 83 | |||
| 84 | #: ../popup.php:62 | ||
| 85 | msgid "" | ||
| 86 | "Note: If you check this option, the name and type of the file you are about " | ||
| 87 | "to upload will replace the old file. All links pointing to the current file (" | ||
| 88 | msgstr "" | ||
| 89 | |||
| 90 | #: ../popup.php:62 | ||
| 91 | msgid ") will be updated to point to the new file name." | ||
| 92 | msgstr "" | ||
| 93 | |||
| 94 | #: ../popup.php:63 | ||
| 95 | msgid "" | ||
| 96 | "Please note that if you upload a new image, only embeds/links of the " | ||
| 97 | "original size image will be replaced in your posts." | ||
| 98 | msgstr "" | ||
| 99 | |||
| 100 | #: ../popup.php:68 | ||
| 101 | msgid "Upload" | ||
| 102 | msgstr "" | ||
| 103 | |||
| 104 | #: ../popup.php:68 | ||
| 105 | msgid "Cancel" | ||
| 106 | msgstr "" | ||
| 107 | |||
| 108 | #: ../upload.php:26 | ||
| 109 | #, php-format | ||
| 110 | msgid "" | ||
| 111 | "The file %1$s can not be deleted by the web server, most likely because the " | ||
| 112 | "permissions on the file are wrong." | ||
| 113 | msgstr "" | ||
| 114 | |||
| 115 | #: ../upload.php:84 | ||
| 116 | msgid "File type does not meet security guidelines. Try another." | ||
| 117 | msgstr "" |
| 1 | <?php // Silence is golden | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
| 1 | @import 'datepicker'; | ||
| 2 | |||
| 3 | .emr_upload_form | ||
| 4 | { | ||
| 5 | form | ||
| 6 | { | ||
| 7 | display: flex; //editor and upsell | ||
| 8 | .upsell-wrapper | ||
| 9 | { | ||
| 10 | margin-left: 10px; | ||
| 11 | } | ||
| 12 | } | ||
| 13 | |||
| 14 | .wrapper | ||
| 15 | { | ||
| 16 | // margin: 15px 0; | ||
| 17 | padding: 18px; | ||
| 18 | border: 1px solid #ccc; | ||
| 19 | |||
| 20 | .section-header | ||
| 21 | { | ||
| 22 | font-size: 18px; | ||
| 23 | //text-align: center; | ||
| 24 | border-bottom: 1px solid #ccc; | ||
| 25 | padding: 6px 0; | ||
| 26 | margin: 0 0 15px 0; | ||
| 27 | } | ||
| 28 | } | ||
| 29 | |||
| 30 | .image_chooser.wrapper | ||
| 31 | { | ||
| 32 | min-height: 350px; | ||
| 33 | |||
| 34 | .emr_drop_area | ||
| 35 | { | ||
| 36 | border: 4px dashed #b4b9be; | ||
| 37 | max-width: 600px; | ||
| 38 | padding: 28px 14px; | ||
| 39 | text-align: center; | ||
| 40 | position: relative; | ||
| 41 | h1 { display: none; } | ||
| 42 | .drop-wrapper | ||
| 43 | { | ||
| 44 | margin: 0 auto; | ||
| 45 | |||
| 46 | } | ||
| 47 | &.drop_breakout | ||
| 48 | { | ||
| 49 | position: fixed; | ||
| 50 | left: 0; | ||
| 51 | right:0; | ||
| 52 | bottom: 0; | ||
| 53 | top: 0; | ||
| 54 | max-width: none; | ||
| 55 | border-color: #83b4d8; | ||
| 56 | border-width: 10px; | ||
| 57 | z-index: 999999; | ||
| 58 | background-color: rgba(#444, 0.7); | ||
| 59 | h1 { | ||
| 60 | color: #fff; | ||
| 61 | position: absolute; | ||
| 62 | font-size: 50px; | ||
| 63 | line-height: 50px; | ||
| 64 | margin-top: -25px; | ||
| 65 | top: 50%; | ||
| 66 | width: 100%; | ||
| 67 | text-align: center; | ||
| 68 | display: block; | ||
| 69 | } | ||
| 70 | .drop-wrapper { display: none; } | ||
| 71 | } | ||
| 72 | } | ||
| 73 | .image_previews | ||
| 74 | { | ||
| 75 | margin: 15px 0; | ||
| 76 | .image_placeholder | ||
| 77 | { | ||
| 78 | position: relative; | ||
| 79 | display: inline-block; | ||
| 80 | margin-right: 25px; | ||
| 81 | margin-bottom: 10px; | ||
| 82 | border: 1px solid #ddd; | ||
| 83 | vertical-align: top; | ||
| 84 | max-height: 500px; | ||
| 85 | .textlayer | ||
| 86 | { | ||
| 87 | font-size: 25px; | ||
| 88 | line-height: 25px; | ||
| 89 | opacity: 0.7; | ||
| 90 | position: absolute; | ||
| 91 | color: #ccc; | ||
| 92 | left: 48%; | ||
| 93 | top: 50%; | ||
| 94 | transform: translate(-50%, -50%); | ||
| 95 | border: 1px dashed #eee; | ||
| 96 | background-color: #333; | ||
| 97 | padding: 8px; | ||
| 98 | //max-width: 100%; | ||
| 99 | } | ||
| 100 | .dashicons | ||
| 101 | { | ||
| 102 | font-size: 60px; | ||
| 103 | position: absolute; | ||
| 104 | top: 50%; | ||
| 105 | margin-top: -30px; | ||
| 106 | left: 50%; | ||
| 107 | margin-left: -30px; | ||
| 108 | opacity: 0.5; | ||
| 109 | |||
| 110 | } | ||
| 111 | .image_size | ||
| 112 | { | ||
| 113 | text-align: center; | ||
| 114 | position: absolute; | ||
| 115 | bottom: -25px; | ||
| 116 | width: 100%; | ||
| 117 | } | ||
| 118 | &.is_image | ||
| 119 | { | ||
| 120 | .dashicons::before, .dashicons { display: none } | ||
| 121 | |||
| 122 | |||
| 123 | } | ||
| 124 | &.not_image | ||
| 125 | { | ||
| 126 | img { display: none; } | ||
| 127 | .textlayer { display: none; } | ||
| 128 | &.is_document{ | ||
| 129 | .textlayer { | ||
| 130 | font-size: 18px; | ||
| 131 | line-height: 20px; | ||
| 132 | display: block; | ||
| 133 | |||
| 134 | } | ||
| 135 | } | ||
| 136 | } // not_image | ||
| 137 | } // image_placeholder | ||
| 138 | } // image_previews | ||
| 139 | } // wrapper | ||
| 140 | |||
| 141 | .form-error, .form-warning | ||
| 142 | { | ||
| 143 | background: #fff; | ||
| 144 | padding: 8px; | ||
| 145 | border-left: 4px solid #ff0000; | ||
| 146 | // display: inline-block; | ||
| 147 | margin: 10px 0; | ||
| 148 | display: none; | ||
| 149 | p { | ||
| 150 | margin: 0; | ||
| 151 | font-size: 12px; | ||
| 152 | font-weight: 700; | ||
| 153 | } | ||
| 154 | |||
| 155 | } | ||
| 156 | .form-warning | ||
| 157 | { | ||
| 158 | border-left: 4px solid #ffb900; | ||
| 159 | } | ||
| 160 | |||
| 161 | .option-flex-wrapper | ||
| 162 | { | ||
| 163 | display: flex; | ||
| 164 | } | ||
| 165 | |||
| 166 | .replace_type.wrapper | ||
| 167 | { | ||
| 168 | flex: 1; | ||
| 169 | border: 1px solid #ccc; | ||
| 170 | margin: 15px 0; | ||
| 171 | .option | ||
| 172 | { | ||
| 173 | position: relative; | ||
| 174 | z-index: 1; | ||
| 175 | &.disabled | ||
| 176 | { | ||
| 177 | // color: #eee; | ||
| 178 | } | ||
| 179 | label | ||
| 180 | { | ||
| 181 | font-size: 1.2em; | ||
| 182 | } | ||
| 183 | .nofeature-notice | ||
| 184 | { | ||
| 185 | border: 1px solid #ccc; | ||
| 186 | padding: 8px; | ||
| 187 | margin: 0; | ||
| 188 | position: absolute; | ||
| 189 | left: 0; | ||
| 190 | right: 0; | ||
| 191 | top: 0; | ||
| 192 | bottom: 0; | ||
| 193 | opacity: 0.8; | ||
| 194 | z-index: 9; | ||
| 195 | background: #444; | ||
| 196 | p { | ||
| 197 | text-align: center; | ||
| 198 | color: #fff; | ||
| 199 | margin: 15px 0; | ||
| 200 | } | ||
| 201 | } | ||
| 202 | } | ||
| 203 | |||
| 204 | } | ||
| 205 | |||
| 206 | .options.wrapper | ||
| 207 | { | ||
| 208 | flex: 1; | ||
| 209 | border: 1px solid #ccc; | ||
| 210 | padding: 15px; | ||
| 211 | margin: 15px 0 15px 35px; | ||
| 212 | .custom_date | ||
| 213 | { | ||
| 214 | .emr_datepicker { | ||
| 215 | width: 150px; | ||
| 216 | } | ||
| 217 | .emr_hour, .emr_minute | ||
| 218 | { | ||
| 219 | width: 45px; | ||
| 220 | } | ||
| 221 | } | ||
| 222 | .replace_custom_date | ||
| 223 | { | ||
| 224 | margin-left: 5px; | ||
| 225 | &:hover { | ||
| 226 | text-decoration: underline; | ||
| 227 | cursor: pointer | ||
| 228 | } | ||
| 229 | } | ||
| 230 | ul | ||
| 231 | { | ||
| 232 | li | ||
| 233 | { | ||
| 234 | input | ||
| 235 | { | ||
| 236 | margin-right: 8px; | ||
| 237 | } | ||
| 238 | } | ||
| 239 | } | ||
| 240 | .option | ||
| 241 | { | ||
| 242 | label { vertical-align: top; } | ||
| 243 | } | ||
| 244 | .small | ||
| 245 | { | ||
| 246 | font-size: 10px; | ||
| 247 | vertical-align: top; | ||
| 248 | margin-left: 8px; | ||
| 249 | } | ||
| 250 | .custom_date | ||
| 251 | { | ||
| 252 | margin: 8px 0 0 25px; | ||
| 253 | visibility: hidden; | ||
| 254 | opacity: 0; | ||
| 255 | span.field-title { | ||
| 256 | display: inline-block; | ||
| 257 | margin-bottom: 4px; | ||
| 258 | color: #444; | ||
| 259 | //margin-left: 8px; | ||
| 260 | font-size: 12px; | ||
| 261 | width: 100%; | ||
| 262 | text-align: left; | ||
| 263 | vertical-align: middle; | ||
| 264 | line-height: 26px; | ||
| 265 | &::before | ||
| 266 | { | ||
| 267 | font-size: 20px; | ||
| 268 | vertical-align: top; | ||
| 269 | margin-right: 4px; | ||
| 270 | } | ||
| 271 | } | ||
| 272 | } // custom_date | ||
| 273 | .location_option | ||
| 274 | { | ||
| 275 | display: none; | ||
| 276 | margin-top: 12px; | ||
| 277 | label | ||
| 278 | { | ||
| 279 | vertical-align: baseline; | ||
| 280 | margin-right: 8px; | ||
| 281 | } | ||
| 282 | } | ||
| 283 | } | ||
| 284 | |||
| 285 | .form_controls.wrapper | ||
| 286 | { | ||
| 287 | clear: both; | ||
| 288 | margin: 8px 0 15px 0; | ||
| 289 | border: 0; | ||
| 290 | padding: 0; | ||
| 291 | .button | ||
| 292 | { | ||
| 293 | padding-left: 20px; | ||
| 294 | padding-right: 20px; | ||
| 295 | } | ||
| 296 | } | ||
| 297 | |||
| 298 | .shortpixel.notice | ||
| 299 | { | ||
| 300 | padding: 12px; | ||
| 301 | } | ||
| 302 | .shortpixel-offer | ||
| 303 | { | ||
| 304 | background: #fff; | ||
| 305 | width: 250px; | ||
| 306 | min-height: 270px; | ||
| 307 | border: 1px solid #ccc; | ||
| 308 | padding: 10px; | ||
| 309 | //margin: 0 0 10px 25px; | ||
| 310 | margin-bottom: 10px; | ||
| 311 | float: right; | ||
| 312 | clear: both; | ||
| 313 | background-color: #dcfdff; | ||
| 314 | h3 { | ||
| 315 | color: #00d0e5; | ||
| 316 | font-size: 18px; | ||
| 317 | text-align: center; | ||
| 318 | margin: 0; | ||
| 319 | line-height: 1.3em; | ||
| 320 | } | ||
| 321 | h4 { | ||
| 322 | // margin: 0; | ||
| 323 | font-size: 16px; | ||
| 324 | text-align: center; | ||
| 325 | } | ||
| 326 | .red { color: #ff0000; } | ||
| 327 | .cyan { color: #00d0e5; } | ||
| 328 | .grey { color: grey; } | ||
| 329 | .ucase { text-transform: uppercase; } | ||
| 330 | a { | ||
| 331 | text-decoration: none | ||
| 332 | } | ||
| 333 | .button-wrapper | ||
| 334 | { | ||
| 335 | text-align: center; | ||
| 336 | margin-top: 35px; | ||
| 337 | a { | ||
| 338 | background-color: #ff0000; | ||
| 339 | color: #fff; | ||
| 340 | display: inline-block; | ||
| 341 | padding: 8px; | ||
| 342 | text-decoration: none; | ||
| 343 | font-weight: 700; | ||
| 344 | font-size: 20px; | ||
| 345 | text-transform: uppercase; | ||
| 346 | } | ||
| 347 | } | ||
| 348 | .hidden { display: none !important; } | ||
| 349 | |||
| 350 | .img-wrapper | ||
| 351 | { | ||
| 352 | text-align: center; | ||
| 353 | margin: 0 0 25px 0; | ||
| 354 | img { max-width: 140px; max-height: 140px; margin: 0; } | ||
| 355 | } | ||
| 356 | |||
| 357 | &.spio // shortpixel | ||
| 358 | { | ||
| 359 | } | ||
| 360 | &.site-speed // Site speed | ||
| 361 | { | ||
| 362 | } | ||
| 363 | &.envira-shortpixel-install // envira | ||
| 364 | { | ||
| 365 | background: #fff; | ||
| 366 | } | ||
| 367 | } | ||
| 368 | |||
| 369 | @media( max-width: 1200px) | ||
| 370 | { | ||
| 371 | .image_previews | ||
| 372 | { | ||
| 373 | text-align: center; | ||
| 374 | } | ||
| 375 | .option-flex-wrapper { | ||
| 376 | flex-direction: column; | ||
| 377 | .options.wrapper | ||
| 378 | { margin-left: 0;} | ||
| 379 | } | ||
| 380 | } | ||
| 381 | @media (max-width: 960px) | ||
| 382 | { | ||
| 383 | .upsell-wrapper { display: none; } | ||
| 384 | } | ||
| 385 | @media (max-width: 450px ) | ||
| 386 | { | ||
| 387 | .replace_custom_date_wrapper { | ||
| 388 | display: block; | ||
| 389 | margin-top: 15px; | ||
| 390 | font-size: 16px; | ||
| 391 | |||
| 392 | } | ||
| 393 | .location_option { | ||
| 394 | label { | ||
| 395 | margin: 25px 0; | ||
| 396 | display: inline-block; | ||
| 397 | } | ||
| 398 | |||
| 399 | } | ||
| 400 | } | ||
| 401 | } // emr_upload_form |
| 1 | |||
| 2 | /* Styling for the edit attachment screen */ | ||
| 3 | #emr-replace-box, #emr-showthumbs-box | ||
| 4 | { | ||
| 5 | .previewwrapper | ||
| 6 | { | ||
| 7 | display: inline-block; | ||
| 8 | position: relative; | ||
| 9 | clear: both; | ||
| 10 | margin: 3px 0; | ||
| 11 | |||
| 12 | img { max-width: 100%; } | ||
| 13 | span.label | ||
| 14 | { | ||
| 15 | font-size: 14px; | ||
| 16 | color: #fff; | ||
| 17 | position: absolute; | ||
| 18 | line-height: 16px; | ||
| 19 | margin-top: -8px; | ||
| 20 | top: 50%; | ||
| 21 | left: 0; right: 0; | ||
| 22 | background: rgba(0,0,0,0.5); | ||
| 23 | text-align: center; | ||
| 24 | padding: 4px 0; | ||
| 25 | |||
| 26 | |||
| 27 | } | ||
| 28 | |||
| 29 | } | ||
| 30 | |||
| 31 | } |
| 1 | <?php | ||
| 2 | if ( ! defined( 'ABSPATH' ) ) | ||
| 3 | exit; // Exit if accessed directly. | ||
| 4 | |||
| 5 | use EnableMediaReplace\ShortPixelLogger\ShortPixelLogger as Log; | ||
| 6 | use EnableMediaReplace\Notices\NoticeController as Notices; | ||
| 7 | |||
| 8 | /* Simple class for updating thumbnails. | ||
| 9 | */ | ||
| 10 | class ThumbnailUpdater | ||
| 11 | { | ||
| 12 | protected $attach_id; | ||
| 13 | protected $oldMeta = array(); | ||
| 14 | protected $newMeta = array(); | ||
| 15 | |||
| 16 | protected $convertArray = array(); | ||
| 17 | protected $relPath; | ||
| 18 | |||
| 19 | protected $post_table; | ||
| 20 | |||
| 21 | public function __construct($id) | ||
| 22 | { | ||
| 23 | $this->attach_id = intval($id); | ||
| 24 | |||
| 25 | global $wpdb; | ||
| 26 | $table_name = $wpdb->prefix . "posts"; | ||
| 27 | // $postmeta_table_name = $wpdb->prefix . "postmeta"; | ||
| 28 | |||
| 29 | $this->post_table = $table_name; | ||
| 30 | } | ||
| 31 | |||
| 32 | public function setOldMetadata($metadata) | ||
| 33 | { | ||
| 34 | if (isset($metadata['sizes'])) | ||
| 35 | $this->oldMeta = $metadata; | ||
| 36 | } | ||
| 37 | |||
| 38 | public function setNewMetadata($metadata) | ||
| 39 | { | ||
| 40 | if (isset($metadata['sizes'])) | ||
| 41 | $this->newMeta = $metadata; | ||
| 42 | |||
| 43 | |||
| 44 | // extract month prefix to prevent overwriting wrong images. | ||
| 45 | $file = $metadata['file']; | ||
| 46 | $pos = strrpos($metadata['file'], '/'); | ||
| 47 | $month_path = substr($file, 0, $pos); | ||
| 48 | $this->relPath = trailingslashit($month_path); | ||
| 49 | } | ||
| 50 | |||
| 51 | |||
| 52 | public function updateThumbnails() | ||
| 53 | { | ||
| 54 | if (count($this->oldMeta) == 0 || count($this->newMeta) == 0) | ||
| 55 | return false; | ||
| 56 | |||
| 57 | $convertArray = array(); | ||
| 58 | foreach($this->oldMeta['sizes'] as $sizeName => $data) | ||
| 59 | { | ||
| 60 | if (isset($this->newMeta['sizes'][$sizeName])) | ||
| 61 | { | ||
| 62 | |||
| 63 | //in some rare cases 'file' is missing | ||
| 64 | $oldFile = isset($data['file']) ? $data['file'] : null; | ||
| 65 | if(is_array($oldFile)) { $oldFile = $oldFile[0];} // HelpScout case 709692915 | ||
| 66 | if(empty($oldFile)) { | ||
| 67 | return false; //make sure we don't replace in this case as we will break the URLs for all the images in the folder. | ||
| 68 | } | ||
| 69 | $newFile = $this->newMeta['sizes'][$sizeName]['file']; | ||
| 70 | |||
| 71 | // if images are not same size. | ||
| 72 | if ($oldFile != $newFile) | ||
| 73 | { | ||
| 74 | $this->convertArray[] = array('imageFrom' => $this->relPath . $oldFile, 'imageTo' => $this->relPath . $newFile ); | ||
| 75 | } | ||
| 76 | |||
| 77 | } | ||
| 78 | else { | ||
| 79 | $this->findNearestSize($data, $sizeName); | ||
| 80 | } | ||
| 81 | |||
| 82 | } | ||
| 83 | $this->updateDatabase(); | ||
| 84 | |||
| 85 | } | ||
| 86 | |||
| 87 | protected function updateDatabase() | ||
| 88 | { | ||
| 89 | global $wpdb; | ||
| 90 | $sql = "UPDATE " . $this->post_table . " set post_content = REPLACE(post_content, %s, %s)"; | ||
| 91 | |||
| 92 | Log::addDebug('Thumbnail Updater - Converting Thumbnails for sizes', $this->convertArray); | ||
| 93 | foreach($this->convertArray as $convert_item) | ||
| 94 | { | ||
| 95 | $from = $convert_item['imageFrom']; | ||
| 96 | $to = $convert_item['imageTo']; | ||
| 97 | |||
| 98 | $replace_sql = $wpdb->prepare($sql, $from, $to ); | ||
| 99 | $wpdb->query($replace_sql); | ||
| 100 | } | ||
| 101 | } | ||
| 102 | |||
| 103 | /** FindNearestsize | ||
| 104 | * This works on the assumption that when the exact image size name is not available, find the nearest width with the smallest possible difference to impact the site the least. | ||
| 105 | */ | ||
| 106 | protected function findNearestSize($oldData, $sizeName) | ||
| 107 | { | ||
| 108 | $old_width = $oldData['width']; // the width from size not in new image | ||
| 109 | $new_width = $this->newMeta['width']; // default check - new width on image | ||
| 110 | |||
| 111 | $diff = abs($old_width - $new_width); | ||
| 112 | $closest_file = str_replace($this->relPath, '', $this->newMeta['file']); | ||
| 113 | |||
| 114 | foreach($this->newMeta['sizes'] as $sizeName => $data) | ||
| 115 | { | ||
| 116 | $thisdiff = abs($old_width - $data['width']); | ||
| 117 | |||
| 118 | if ( $thisdiff < $diff ) | ||
| 119 | { | ||
| 120 | $closest_file = $data['file']; | ||
| 121 | if(is_array($closest_file)) { $closest_file = $closest_file[0];} // HelpScout case 709692915 | ||
| 122 | if(!empty($closest_file)) { | ||
| 123 | $diff = $thisdiff; | ||
| 124 | $found_metasize = true; | ||
| 125 | } | ||
| 126 | } | ||
| 127 | } | ||
| 128 | |||
| 129 | if(empty($closest_file)) return; | ||
| 130 | $oldFile = $oldData['file']; | ||
| 131 | if(is_array($oldFile)) { $oldFile = $oldFile[0];} // HelpScout case 709692915 | ||
| 132 | if(empty($oldFile)) { | ||
| 133 | return; //make sure we don't replace in this case as we will break the URLs for all the images in the folder. | ||
| 134 | } | ||
| 135 | $this->convertArray[] = array('imageFrom' => $this->relPath . $oldFile, 'imageTo' => $this->relPath . $closest_file); | ||
| 136 | |||
| 137 | } | ||
| 138 | |||
| 139 | |||
| 140 | } |
| 1 | <div class='notice' id='emr-news' style="padding-top: 7px"> | ||
| 2 | <div style="float:<?php echo (is_rtl()) ? 'left' : 'right' ?>;"><a href="javascript:emrDismissNews()" class="button" style="margin-top:10px;"><?php _e('Dismiss', 'enable-media-replace');?></a></div> | ||
| 3 | <a href="https://shortpixel.com/wp/af/VKG6LYN28044" target="_blank" style="float: <?php echo (is_rtl()) ? 'right' : 'left' ?>;margin-<?php echo (is_rtl()) ? 'left' : 'right' ?>: 10px;"> | ||
| 4 | <img width="30" height="30" src="<?php echo $this->plugin_url . 'img/sp-logo-regular.svg' ?>" class="emr-sp"/> | ||
| 5 | </a> | ||
| 6 | <h3 style="margin:10px;"><?php echo esc_html__('Enable Media Replace is now compatible with ShortPixel!','enable-media-replace');?></h3> | ||
| 7 | <p style="margin-bottom:0px;"> | ||
| 8 | <?php _e( '<a href="https://shortpixel.com/wp/af/VKG6LYN28044" target="_blank">ShortPixel</a> is an image optimization plugin and if you have it activated, upon replacing an image in Enable Media Replace, the image will be also automatically optimized.', 'enable-media-replace' ); ?> | ||
| 9 | </p> | ||
| 10 | <p style="text-align: <?php echo (is_rtl()) ? 'left' : 'right' ?>;margin-top: 0;"> | ||
| 11 | <a href="https://shortpixel.com/wp/af/VKG6LYN28044" target="_blank">>> <?php _e( 'More info', 'enable-media-replace' ); ?></a> | ||
| 12 | </p> | ||
| 13 | </div> | ||
| 14 | <script> | ||
| 15 | function emrDismissNews() { | ||
| 16 | jQuery("#emr-news").hide(); | ||
| 17 | var data = { action : 'emr_dismiss_notices'}; | ||
| 18 | jQuery.get('<?php echo admin_url('admin-ajax.php'); ?>', data, function(response) { | ||
| 19 | data = JSON.parse(response); | ||
| 20 | if(data["Status"] == 0) { | ||
| 21 | console.log("dismissed"); | ||
| 22 | } | ||
| 23 | }); | ||
| 24 | } | ||
| 25 | </script> |
This diff is collapsed.
Click to expand it.
| 1 | <?php | ||
| 2 | namespace EnableMediaReplace; | ||
| 3 | |||
| 4 | if ( ! defined( 'ABSPATH' ) ) | ||
| 5 | exit; // Exit if accessed directly. | ||
| 6 | |||
| 7 | use EnableMediaReplace\ShortPixelLogger\ShortPixelLogger as Log; | ||
| 8 | use EnableMediaReplace\Notices\NoticeController as Notices; | ||
| 9 | |||
| 10 | if (!current_user_can('upload_files')) | ||
| 11 | wp_die( esc_html__('You do not have permission to upload files.', 'enable-media-replace') ); | ||
| 12 | |||
| 13 | /*require_once('classes/replacer.php'); | ||
| 14 | require_once('classes/file.php'); */ | ||
| 15 | |||
| 16 | use \EnableMediaReplace\Replacer as Replacer; | ||
| 17 | |||
| 18 | // Define DB table names | ||
| 19 | global $wpdb; | ||
| 20 | $table_name = $wpdb->prefix . "posts"; | ||
| 21 | $postmeta_table_name = $wpdb->prefix . "postmeta"; | ||
| 22 | |||
| 23 | // Starts processing. | ||
| 24 | $uihelper = new UIHelper(); | ||
| 25 | $emr = EnableMediaReplacePlugin::get(); | ||
| 26 | |||
| 27 | // Get old guid and filetype from DB | ||
| 28 | $post_id = isset($_POST['ID']) ? intval($_POST['ID']) : null; // sanitize, post_id. | ||
| 29 | if (is_null($post_id)) | ||
| 30 | { | ||
| 31 | wp_die( esc_html__('Error in request. Please try again', 'enable-media-replace') ); | ||
| 32 | } | ||
| 33 | $attachment = get_post($post_id); | ||
| 34 | |||
| 35 | if (! $emr->checkImagePermission($attachment->post_author, $attachment->ID)) | ||
| 36 | wp_die( esc_html__('You do not have permission to upload files for this author.', 'enable-media-replace') ); | ||
| 37 | |||
| 38 | $replacer = new Replacer($post_id); | ||
| 39 | |||
| 40 | // Massage a bunch of vars | ||
| 41 | $ID = intval($_POST["ID"]); // legacy | ||
| 42 | $replace_type = isset($_POST["replace_type"]) ? sanitize_text_field($_POST["replace_type"]) : false; | ||
| 43 | $timestamp_replace = intval($_POST['timestamp_replace']); | ||
| 44 | |||
| 45 | $redirect_error = $uihelper->getFailedRedirect($post_id); | ||
| 46 | $redirect_success = $uihelper->getSuccesRedirect($post_id); | ||
| 47 | |||
| 48 | $do_new_location = isset($_POST['new_location']) ? sanitize_text_field($_POST['new_location']) : false; | ||
| 49 | $new_location_dir = isset($_POST['location_dir']) ? sanitize_text_field($_POST['location_dir']) : null; | ||
| 50 | |||
| 51 | $settings = array(); // save settings and show last loaded. | ||
| 52 | $settings['replace_type'] = $replace_type; | ||
| 53 | $settings['timestamp_replace'] = $timestamp_replace; | ||
| 54 | $settings['new_location'] = $do_new_location; | ||
| 55 | $settings['new_location_dir'] = $new_location_dir; | ||
| 56 | |||
| 57 | switch($timestamp_replace) | ||
| 58 | { | ||
| 59 | case \EnableMediaReplace\Replacer::TIME_UPDATEALL: | ||
| 60 | case \EnableMediaReplace\Replacer::TIME_UPDATEMODIFIED: | ||
| 61 | $datetime = current_time('mysql'); | ||
| 62 | break; | ||
| 63 | case \EnableMediaReplace\Replacer::TIME_CUSTOM: | ||
| 64 | $custom_date = $_POST['custom_date_formatted']; | ||
| 65 | $custom_hour = str_pad($_POST['custom_hour'],2,0, STR_PAD_LEFT); | ||
| 66 | $custom_minute = str_pad($_POST['custom_minute'], 2, 0, STR_PAD_LEFT); | ||
| 67 | |||
| 68 | // create a mysql time representation from what we have. | ||
| 69 | Log::addDebug($_POST); | ||
| 70 | Log::addDebug('Custom Date - ' . $custom_date . ' ' . $custom_hour . ':' . $custom_minute ); | ||
| 71 | $custom_date = \DateTime::createFromFormat('Y-m-d G:i', $custom_date . ' ' . $custom_hour . ':' . $custom_minute ); | ||
| 72 | if ($custom_date === false) | ||
| 73 | { | ||
| 74 | |||
| 75 | wp_safe_redirect($redirect_error); | ||
| 76 | $errors = \DateTime::getLastErrors(); | ||
| 77 | $error = ''; | ||
| 78 | if (isset($errors['errors'])) | ||
| 79 | { | ||
| 80 | $error = implode(',', $errors['errors']); | ||
| 81 | } | ||
| 82 | Notices::addError(sprintf(__('Invalid Custom Date. Please custom date values (%s)', 'enable-media-replace'), $error)); | ||
| 83 | |||
| 84 | exit(); | ||
| 85 | } | ||
| 86 | $datetime = $custom_date->format("Y-m-d H:i:s"); | ||
| 87 | $settings['custom_date'] = $datetime; | ||
| 88 | break; | ||
| 89 | } | ||
| 90 | |||
| 91 | update_option('enable_media_replace', $settings, false); | ||
| 92 | |||
| 93 | // We have two types: replace / replace_and_search | ||
| 94 | if ($replace_type == 'replace') | ||
| 95 | { | ||
| 96 | $replacer->setMode(\EnableMediaReplace\Replacer::MODE_REPLACE); | ||
| 97 | $mode = \EnableMediaReplace\Replacer::MODE_REPLACE; | ||
| 98 | } | ||
| 99 | elseif ( 'replace_and_search' == $replace_type && apply_filters( 'emr_enable_replace_and_search', true ) ) | ||
| 100 | { | ||
| 101 | $replacer->setMode(\EnableMediaReplace\Replacer::MODE_SEARCHREPLACE); | ||
| 102 | $mode = \EnableMediaReplace\Replacer::MODE_SEARCHREPLACE; | ||
| 103 | |||
| 104 | if ($do_new_location && ! is_null($new_location_dir)) | ||
| 105 | { | ||
| 106 | $result = $replacer->setNewTargetLocation($new_location_dir); | ||
| 107 | if (! $result) | ||
| 108 | { | ||
| 109 | wp_safe_redirect($redirect_error); | ||
| 110 | exit(); | ||
| 111 | } | ||
| 112 | } | ||
| 113 | } | ||
| 114 | |||
| 115 | $replacer->setTimeMode($timestamp_replace, $datetime); | ||
| 116 | |||
| 117 | /** Check if file is uploaded properly **/ | ||
| 118 | if (is_uploaded_file($_FILES["userfile"]["tmp_name"])) { | ||
| 119 | |||
| 120 | Log::addDebug($_FILES['userfile']); | ||
| 121 | |||
| 122 | // New method for validating that the uploaded file is allowed, using WP:s internal wp_check_filetype_and_ext() function. | ||
| 123 | $filedata = wp_check_filetype_and_ext($_FILES["userfile"]["tmp_name"], $_FILES["userfile"]["name"]); | ||
| 124 | |||
| 125 | Log::addDebug('Data after check', $filedata); | ||
| 126 | if (isset($_FILES['userfile']['error']) && $_FILES['userfile']['error'] > 0) | ||
| 127 | { | ||
| 128 | $e = new RunTimeException('File Uploaded Failed'); | ||
| 129 | Notices::addError($e->getMessage()); | ||
| 130 | wp_safe_redirect($redirect_error); | ||
| 131 | exit(); | ||
| 132 | } | ||
| 133 | |||
| 134 | |||
| 135 | if ($filedata["ext"] == false && ! current_user_can( 'unfiltered_upload' )) { | ||
| 136 | |||
| 137 | Notices::addError(esc_html__("File type does not meet security guidelines. Try another.", 'enable-media-replace') ); | ||
| 138 | wp_safe_redirect($redirect_error); | ||
| 139 | exit(); | ||
| 140 | } | ||
| 141 | |||
| 142 | // Here we have the uploaded file | ||
| 143 | $new_filename = $_FILES["userfile"]["name"]; | ||
| 144 | //$new_filesize = $_FILES["userfile"]["size"]; // Seems not to be in use. | ||
| 145 | $new_filetype = $filedata["type"]; | ||
| 146 | |||
| 147 | // Gather all functions that both options do. | ||
| 148 | do_action('wp_handle_replace', array('post_id' => $post_id)); | ||
| 149 | |||
| 150 | |||
| 151 | /* if ($mode = \EnableMediaReplace\Replacer::MODE_SEARCHREPLACE && $do_new_location && ! is_null($new_location_dir)) | ||
| 152 | { | ||
| 153 | exit($new_filename); | ||
| 154 | $newdirfile = $replacer->newTargetLocation($new_location_dir); | ||
| 155 | } | ||
| 156 | */ | ||
| 157 | try | ||
| 158 | { | ||
| 159 | $result = $replacer->replaceWith($_FILES["userfile"]["tmp_name"], $new_filename); | ||
| 160 | } | ||
| 161 | catch(\RunTimeException $e) | ||
| 162 | { | ||
| 163 | Log::addError($e->getMessage()); | ||
| 164 | // exit($e->getMessage()); | ||
| 165 | } | ||
| 166 | |||
| 167 | if (is_null($result)) | ||
| 168 | { | ||
| 169 | wp_safe_redirect($redirect_error); | ||
| 170 | exit(); | ||
| 171 | } | ||
| 172 | // $returnurl = admin_url("/post.php?post={$_POST["ID"]}&action=edit&message=1"); | ||
| 173 | |||
| 174 | // Execute hook actions - thanks rubious for the suggestion! | ||
| 175 | |||
| 176 | } else { | ||
| 177 | //TODO Better error handling when no file is selected. | ||
| 178 | //For now just go back to media management | ||
| 179 | //$returnurl = admin_url("upload.php"); | ||
| 180 | Log::addInfo('Failed. Redirecting - '. $redirect_error); | ||
| 181 | Notices::addError(__('File Upload seems to have failed. No files were returned by system','enable-media-replace')); | ||
| 182 | wp_safe_redirect($redirect_error); | ||
| 183 | exit(); | ||
| 184 | } | ||
| 185 | |||
| 186 | Notices::addSuccess(__('File successfully replaced','enable-media-replace')); | ||
| 187 | |||
| 188 | // Allow developers to override $returnurl | ||
| 189 | //$returnurl = apply_filters('emr_returnurl', $returnurl); | ||
| 190 | wp_redirect($redirect_success); | ||
| 191 | exit(); | ||
| 192 | ?> |
| 1 | <?php | ||
| 2 | namespace EnableMediaReplace; | ||
| 3 | |||
| 4 | //use \EnableMediaReplace\UIHelper; | ||
| 5 | use EnableMediaReplace\ShortPixelLogger\ShortPixelLogger as Log; | ||
| 6 | use EnableMediaReplace\Notices\NoticeController as Notices; | ||
| 7 | |||
| 8 | if (! apply_filters('emr/upsell', current_user_can('install_plugins'))) | ||
| 9 | { | ||
| 10 | return; | ||
| 11 | } | ||
| 12 | |||
| 13 | #wp_nonce_field('enable-media-replace'); | ||
| 14 | $plugins = get_plugins(); | ||
| 15 | |||
| 16 | $spio_installed = isset($plugins['shortpixel-image-optimiser/wp-shortpixel.php']); | ||
| 17 | $spio_active = is_plugin_active('shortpixel-image-optimiser/wp-shortpixel.php'); | ||
| 18 | |||
| 19 | |||
| 20 | $spai_installed = isset($plugins['shortpixel-adaptive-images/short-pixel-ai.php']); | ||
| 21 | $spai_active = is_plugin_active('shortpixel-adaptive-images/short-pixel-ai.php'); | ||
| 22 | |||
| 23 | $envira_installed = isset($plugins['envira-gallery-lite/envira-gallery-lite.php']); | ||
| 24 | $envira_active = is_plugin_active('envira-gallery-lite/envira-gallery-lite.php'); | ||
| 25 | $envira_pro_active = is_plugin_active('envira-gallery/envira-gallery.php'); | ||
| 26 | |||
| 27 | |||
| 28 | ?> | ||
| 29 | |||
| 30 | <input type="hidden" id='upsell-nonce' value="<?php echo wp_create_nonce( 'emr-plugin-install' ); ?>" /> | ||
| 31 | <input type="hidden" id='upsell-nonce-activate' value="<?php echo wp_create_nonce( 'emr-plugin-activate' ); ?>" /> | ||
| 32 | <section class='upsell-wrapper'> | ||
| 33 | |||
| 34 | <!--- SHORTPIXEL --> | ||
| 35 | <?php if(! $spio_active): ?> | ||
| 36 | |||
| 37 | <div class='shortpixel-offer spio'> | ||
| 38 | <div class='img-wrapper'> | ||
| 39 | <img width="40" height="40" src="<?php echo $emr->getPluginURL('img/sp-logo-regular.svg') ?>" alt="ShortPixel"> | ||
| 40 | </div> | ||
| 41 | <h4 class="grey"> | ||
| 42 | <?php echo esc_html__("ShortPixel Image Optimizer", "enable-media-replace"); ?> | ||
| 43 | </h4> | ||
| 44 | <h3 class="red ucase"><?php _e('Is your website slow?', 'enable-media-replace'); ?></h3> | ||
| 45 | <br> | ||
| 46 | <h3 class="cyan ucase"><?php printf(__('Optimize all images %s automatically', 'enable-media-replace'), '<br>'); ?></h3> | ||
| 47 | <p class='button-wrapper '> | ||
| 48 | <?php | ||
| 49 | $install_class = (! $spio_installed) ? '' : 'hidden'; | ||
| 50 | $activate_class = ($spio_installed && ! $spio_active) ? '' : 'hidden'; | ||
| 51 | ?> | ||
| 52 | <a class="emr-installer <?php echo $install_class ?>" data-action="install" data-plugin="spio" href="javascript:void(0)"> | ||
| 53 | <?php _e('INSTALL NOW', 'enable-media-replace') ?> | ||
| 54 | </a> | ||
| 55 | |||
| 56 | <a class='emr-activate <?php echo $activate_class ?>' data-action="activate" data-plugin="spio" href="javascript:void(0)"> | ||
| 57 | <?php _e('ACTIVATE', 'enable-media-replace') ?> | ||
| 58 | </a> | ||
| 59 | |||
| 60 | <h4 class='emr-activate-done hidden' data-plugin='spio'><?php _e('Shortpixel activated!', 'enable-media-replace'); ?></h4> | ||
| 61 | </p> | ||
| 62 | |||
| 63 | </div> | ||
| 64 | <?php endif; ?> | ||
| 65 | <!--- // SHORTPIXEL --> | ||
| 66 | |||
| 67 | <!--- SHORTPIXEL AI --> | ||
| 68 | <?php if(! $spai_active): ?> | ||
| 69 | |||
| 70 | <div class='shortpixel-offer spai'> | ||
| 71 | <div class='img-wrapper'> | ||
| 72 | <img width="40" height="40" src="<?php echo $emr->getPluginURL('img/spai-logo.svg') ?>" alt="ShortPixel"> | ||
| 73 | </div> | ||
| 74 | <h4 class="grey"> | ||
| 75 | <?php echo esc_html__("ShortPixel Adaptive Images", "enable-media-replace"); ?> | ||
| 76 | </h4> | ||
| 77 | |||
| 78 | |||
| 79 | <h3 class="cyan ucase"><?php printf(__('Start Serving %s Optimized, %s Nextgen images %s From a global CDN', 'enable-media-replace'), '<br>', '<br>', '<br>'); ?></h3> | ||
| 80 | <h3 class="red ucase"><?php _e('In Minutes', 'enable-media-replace'); ?></h3> | ||
| 81 | <p class='button-wrapper '> | ||
| 82 | <?php | ||
| 83 | $install_class = (! $spai_installed) ? '' : 'hidden'; | ||
| 84 | $activate_class = ($spai_installed && ! $spai_active) ? '' : 'hidden'; | ||
| 85 | ?> | ||
| 86 | <a class="emr-installer <?php echo $install_class ?>" data-action="install" data-plugin="spai" href="javascript:void(0)"> | ||
| 87 | <?php _e('INSTALL NOW', 'enable-media-replace') ?> | ||
| 88 | </a> | ||
| 89 | |||
| 90 | <a class='emr-activate <?php echo $activate_class ?>' data-action="activate" data-plugin="spai" href="javascript:void(0)"> | ||
| 91 | <?php _e('ACTIVATE', 'enable-media-replace') ?> | ||
| 92 | </a> | ||
| 93 | |||
| 94 | <h4 class='emr-activate-done hidden' data-plugin='spai'><?php _e('Shortpixel Adaptive Images activated!', 'enable-media-replace'); ?></h4> | ||
| 95 | </p> | ||
| 96 | |||
| 97 | </div> | ||
| 98 | <?php endif; ?> | ||
| 99 | <!--- // SHORTPIXEL --> | ||
| 100 | |||
| 101 | <!--- WPSO --> | ||
| 102 | <div class='shortpixel-offer site-speed'> | ||
| 103 | <p class='img-wrapper'><img width="40" height="40" src="<?php echo $emr->getPluginURL('img/sp-logo-wink.svg'); ?>" alt='ShortPixel'></p> | ||
| 104 | <h3><?php printf(__('GET AN ASSESSMENT FOR %s YOUR WEBSITE %s AND %s %s FIND OUT HOW TO MAKE IT FASTER %s', 'enable-media-replace'),'<br>', '<br>','<br>', '<span class="red">','</span>'); ?></h3> | ||
| 105 | |||
| 106 | <p class='button-wrapper'><a href='https://wso.shortpixel.com/?utm_source=EMR' target="_blank"><?php _e('FIND OUT MORE', 'enable-media-replace') ?></a></p> | ||
| 107 | </div> | ||
| 108 | <!--- // WPSO --> | ||
| 109 | |||
| 110 | <!--- ENVIRA temprary deactivated | ||
| 111 | <?php if (! $envira_pro_active): ?> | ||
| 112 | <div class='envira-shortpixel-install shortpixel-offer'> | ||
| 113 | |||
| 114 | <p class='img-wrapper'><img src="<?php echo $emr->getPluginURL('img/envira-logo.png'); ?>" alt='Envira Gallery'></p> | ||
| 115 | <p><?php esc_html_e('Create beautiful, fast-loading photo & video galleries for your site in minutes.', 'enable-media-replace' ); ?></p> | ||
| 116 | |||
| 117 | <?php | ||
| 118 | $install_class = (! $envira_installed) ? '' : 'hidden'; | ||
| 119 | $activate_class = ($envira_installed && ! $envira_active) ? '' : 'hidden'; | ||
| 120 | ?> | ||
| 121 | <?php if (! $envira_active) { ?> | ||
| 122 | <p class='button-wrapper envira-emr-button-wrap'> | ||
| 123 | |||
| 124 | <a class="emr-installer button button-envira-emr emr-install-envira <?php echo $install_class ?>" data-action="install" data-plugin="envira" href='javascript:void(0)'><?php _e('Install now', 'enable-media-replace') ?></a> | ||
| 125 | |||
| 126 | <a class="emr-activate button button-envira-emr emr-activate-envira <?php echo $activate_class ?>" href='javascript:void(0)' data-action="activate" data-plugin="envira" ><?php _e('Activate', 'enable-media-replace') ?></a> | ||
| 127 | |||
| 128 | <h4 class='emr-activate-done hidden' data-plugin='envira'><?php _e('Envira Gallery activated!', 'enable-media-replace'); ?></h4> | ||
| 129 | |||
| 130 | </p> | ||
| 131 | |||
| 132 | <?php } else { | ||
| 133 | if ( is_plugin_active( 'envira-gallery-lite/envira-gallery-lite.php' ) ) { | ||
| 134 | ?> | ||
| 135 | <p class='button-wrapper envira-emr-button-wrap'><a class="button button-envira-emr" href='https://enviragallery.com/pricing' target="_blank"><?php _e('Get Pro', 'enable-media-replace') ?></a></p> | ||
| 136 | |||
| 137 | <?php } else { ?> | ||
| 138 | |||
| 139 | <?php } | ||
| 140 | } ?> | ||
| 141 | </div> | ||
| 142 | <style> | ||
| 143 | .envira-emr-button-wrap { | ||
| 144 | text-align: center; | ||
| 145 | } | ||
| 146 | .button-envira-emr { | ||
| 147 | background-color: #7cc048 !important; | ||
| 148 | border: none !important; | ||
| 149 | color: rgb(255,255,255) !important; | ||
| 150 | font-size: 21px !important; | ||
| 151 | } | ||
| 152 | .button-envira-emr:hover { | ||
| 153 | background-color: #95dc5e !important; | ||
| 154 | } | ||
| 155 | </style> | ||
| 156 | <?php endif; // envira ?> | ||
| 157 | --> | ||
| 158 | |||
| 159 | </section> |
| ... | @@ -23,7 +23,7 @@ | ... | @@ -23,7 +23,7 @@ |
| 23 | strong{font-family: Calibri;} | 23 | strong{font-family: Calibri;} |
| 24 | </style> | 24 | </style> |
| 25 | </head> | 25 | </head> |
| 26 | <body style="margin:0;padding:0;"> | 26 | <body style="margin:0;padding:0;max-width: 600px;"> |
| 27 | <table role="presentation" style="width:100%;border-collapse:collapse;border:0;border-spacing:0;background:#ffffff;"> | 27 | <table role="presentation" style="width:100%;border-collapse:collapse;border:0;border-spacing:0;background:#ffffff;"> |
| 28 | <tr> | 28 | <tr> |
| 29 | <td align="center" style="padding:0;"> | 29 | <td align="center" style="padding:0;"> | ... | ... |
| ... | @@ -23,7 +23,7 @@ | ... | @@ -23,7 +23,7 @@ |
| 23 | strong{font-family: Calibri;} | 23 | strong{font-family: Calibri;} |
| 24 | </style> | 24 | </style> |
| 25 | </head> | 25 | </head> |
| 26 | <body style="margin:0;padding:0;"> | 26 | <body style="margin:0;padding:0;max-width: 600px;"> |
| 27 | <table role="presentation" style="width:100%;border-collapse:collapse;border:0;border-spacing:0;background:#ffffff;"> | 27 | <table role="presentation" style="width:100%;border-collapse:collapse;border:0;border-spacing:0;background:#ffffff;"> |
| 28 | <tr> | 28 | <tr> |
| 29 | <td align="center" style="padding:0;"> | 29 | <td align="center" style="padding:0;"> | ... | ... |
| ... | @@ -23,7 +23,7 @@ | ... | @@ -23,7 +23,7 @@ |
| 23 | strong{font-family: Calibri;} | 23 | strong{font-family: Calibri;} |
| 24 | </style> | 24 | </style> |
| 25 | </head> | 25 | </head> |
| 26 | <body style="margin:0;padding:0;"> | 26 | <body style="margin:0;padding:0;max-width: 600px;"> |
| 27 | <table role="presentation" style="width:100%;border-collapse:collapse;border:0;border-spacing:0;background:#ffffff;"> | 27 | <table role="presentation" style="width:100%;border-collapse:collapse;border:0;border-spacing:0;background:#ffffff;"> |
| 28 | <tr> | 28 | <tr> |
| 29 | <td align="center" style="padding:0;"> | 29 | <td align="center" style="padding:0;"> | ... | ... |
| ... | @@ -23,7 +23,7 @@ | ... | @@ -23,7 +23,7 @@ |
| 23 | strong{font-family: Calibri;} | 23 | strong{font-family: Calibri;} |
| 24 | </style> | 24 | </style> |
| 25 | </head> | 25 | </head> |
| 26 | <body style="margin:0;padding:0;"> | 26 | <body style="margin:0;padding:0;max-width: 600px;"> |
| 27 | <table role="presentation" style="width:100%;border-collapse:collapse;border:0;border-spacing:0;background:#ffffff;"> | 27 | <table role="presentation" style="width:100%;border-collapse:collapse;border:0;border-spacing:0;background:#ffffff;"> |
| 28 | <tr> | 28 | <tr> |
| 29 | <td align="center" style="padding:0;"> | 29 | <td align="center" style="padding:0;"> | ... | ... |
-
Please register or sign in to post a comment