plugin updates
This commit is contained in:
@@ -0,0 +1,347 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (c) 2008 Sebastián Grignoli
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of copyright holders nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author "Sebastián Grignoli" <grignoli@gmail.com>
|
||||
* @package WpmfEncoding
|
||||
* @version 2.0
|
||||
* @link https://github.com/neitanod/forceutf8
|
||||
* @example https://github.com/neitanod/forceutf8
|
||||
* @license Revised BSD
|
||||
*/
|
||||
|
||||
//namespace ForceUTF8;
|
||||
|
||||
class WpmfEncoding {
|
||||
|
||||
const ICONV_TRANSLIT = "TRANSLIT";
|
||||
const ICONV_IGNORE = "IGNORE";
|
||||
const WITHOUT_ICONV = "";
|
||||
|
||||
protected static $win1252ToUtf8 = array(
|
||||
128 => "\xe2\x82\xac",
|
||||
|
||||
130 => "\xe2\x80\x9a",
|
||||
131 => "\xc6\x92",
|
||||
132 => "\xe2\x80\x9e",
|
||||
133 => "\xe2\x80\xa6",
|
||||
134 => "\xe2\x80\xa0",
|
||||
135 => "\xe2\x80\xa1",
|
||||
136 => "\xcb\x86",
|
||||
137 => "\xe2\x80\xb0",
|
||||
138 => "\xc5\xa0",
|
||||
139 => "\xe2\x80\xb9",
|
||||
140 => "\xc5\x92",
|
||||
|
||||
142 => "\xc5\xbd",
|
||||
|
||||
|
||||
145 => "\xe2\x80\x98",
|
||||
146 => "\xe2\x80\x99",
|
||||
147 => "\xe2\x80\x9c",
|
||||
148 => "\xe2\x80\x9d",
|
||||
149 => "\xe2\x80\xa2",
|
||||
150 => "\xe2\x80\x93",
|
||||
151 => "\xe2\x80\x94",
|
||||
152 => "\xcb\x9c",
|
||||
153 => "\xe2\x84\xa2",
|
||||
154 => "\xc5\xa1",
|
||||
155 => "\xe2\x80\xba",
|
||||
156 => "\xc5\x93",
|
||||
|
||||
158 => "\xc5\xbe",
|
||||
159 => "\xc5\xb8"
|
||||
);
|
||||
|
||||
protected static $brokenUtf8ToUtf8 = array(
|
||||
"\xc2\x80" => "\xe2\x82\xac",
|
||||
|
||||
"\xc2\x82" => "\xe2\x80\x9a",
|
||||
"\xc2\x83" => "\xc6\x92",
|
||||
"\xc2\x84" => "\xe2\x80\x9e",
|
||||
"\xc2\x85" => "\xe2\x80\xa6",
|
||||
"\xc2\x86" => "\xe2\x80\xa0",
|
||||
"\xc2\x87" => "\xe2\x80\xa1",
|
||||
"\xc2\x88" => "\xcb\x86",
|
||||
"\xc2\x89" => "\xe2\x80\xb0",
|
||||
"\xc2\x8a" => "\xc5\xa0",
|
||||
"\xc2\x8b" => "\xe2\x80\xb9",
|
||||
"\xc2\x8c" => "\xc5\x92",
|
||||
|
||||
"\xc2\x8e" => "\xc5\xbd",
|
||||
|
||||
|
||||
"\xc2\x91" => "\xe2\x80\x98",
|
||||
"\xc2\x92" => "\xe2\x80\x99",
|
||||
"\xc2\x93" => "\xe2\x80\x9c",
|
||||
"\xc2\x94" => "\xe2\x80\x9d",
|
||||
"\xc2\x95" => "\xe2\x80\xa2",
|
||||
"\xc2\x96" => "\xe2\x80\x93",
|
||||
"\xc2\x97" => "\xe2\x80\x94",
|
||||
"\xc2\x98" => "\xcb\x9c",
|
||||
"\xc2\x99" => "\xe2\x84\xa2",
|
||||
"\xc2\x9a" => "\xc5\xa1",
|
||||
"\xc2\x9b" => "\xe2\x80\xba",
|
||||
"\xc2\x9c" => "\xc5\x93",
|
||||
|
||||
"\xc2\x9e" => "\xc5\xbe",
|
||||
"\xc2\x9f" => "\xc5\xb8"
|
||||
);
|
||||
|
||||
protected static $utf8ToWin1252 = array(
|
||||
"\xe2\x82\xac" => "\x80",
|
||||
|
||||
"\xe2\x80\x9a" => "\x82",
|
||||
"\xc6\x92" => "\x83",
|
||||
"\xe2\x80\x9e" => "\x84",
|
||||
"\xe2\x80\xa6" => "\x85",
|
||||
"\xe2\x80\xa0" => "\x86",
|
||||
"\xe2\x80\xa1" => "\x87",
|
||||
"\xcb\x86" => "\x88",
|
||||
"\xe2\x80\xb0" => "\x89",
|
||||
"\xc5\xa0" => "\x8a",
|
||||
"\xe2\x80\xb9" => "\x8b",
|
||||
"\xc5\x92" => "\x8c",
|
||||
|
||||
"\xc5\xbd" => "\x8e",
|
||||
|
||||
|
||||
"\xe2\x80\x98" => "\x91",
|
||||
"\xe2\x80\x99" => "\x92",
|
||||
"\xe2\x80\x9c" => "\x93",
|
||||
"\xe2\x80\x9d" => "\x94",
|
||||
"\xe2\x80\xa2" => "\x95",
|
||||
"\xe2\x80\x93" => "\x96",
|
||||
"\xe2\x80\x94" => "\x97",
|
||||
"\xcb\x9c" => "\x98",
|
||||
"\xe2\x84\xa2" => "\x99",
|
||||
"\xc5\xa1" => "\x9a",
|
||||
"\xe2\x80\xba" => "\x9b",
|
||||
"\xc5\x93" => "\x9c",
|
||||
|
||||
"\xc5\xbe" => "\x9e",
|
||||
"\xc5\xb8" => "\x9f"
|
||||
);
|
||||
|
||||
static function toUTF8($text){
|
||||
/**
|
||||
* Function \ForceUTF8\WpmfEncoding::toUTF8
|
||||
*
|
||||
* This function leaves UTF8 characters alone, while converting almost all non-UTF8 to UTF8.
|
||||
*
|
||||
* It assumes that the encoding of the original string is either Windows-1252 or ISO 8859-1.
|
||||
*
|
||||
* It may fail to convert characters to UTF-8 if they fall into one of these scenarios:
|
||||
*
|
||||
* 1) when any of these characters: ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞß
|
||||
* are followed by any of these: ("group B")
|
||||
* ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶•¸¹º»¼½¾¿
|
||||
* For example: %ABREPRESENT%C9%BB. «REPRESENTÉ»
|
||||
* The "«" (%AB) character will be converted, but the "É" followed by "»" (%C9%BB)
|
||||
* is also a valid unicode character, and will be left unchanged.
|
||||
*
|
||||
* 2) when any of these: àáâãäåæçèéêëìíîï are followed by TWO chars from group B,
|
||||
* 3) when any of these: ðñòó are followed by THREE chars from group B.
|
||||
*
|
||||
* @name toUTF8
|
||||
* @param string $text Any string.
|
||||
* @return string The same string, UTF8 encoded
|
||||
*
|
||||
*/
|
||||
|
||||
if(is_array($text))
|
||||
{
|
||||
foreach($text as $k => $v)
|
||||
{
|
||||
$text[$k] = self::toUTF8($v);
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
if(!is_string($text)) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
$max = self::strlen($text);
|
||||
|
||||
$buf = "";
|
||||
for($i = 0; $i < $max; $i++){
|
||||
$c1 = $text[$i];
|
||||
if($c1>="\xc0"){ //Should be converted to UTF8, if it's not UTF8 already
|
||||
$c2 = $i+1 >= $max? "\x00" : $text[$i+1];
|
||||
$c3 = $i+2 >= $max? "\x00" : $text[$i+2];
|
||||
$c4 = $i+3 >= $max? "\x00" : $text[$i+3];
|
||||
if($c1 >= "\xc0" & $c1 <= "\xdf"){ //looks like 2 bytes UTF8
|
||||
if($c2 >= "\x80" && $c2 <= "\xbf"){ //yeah, almost sure it's UTF8 already
|
||||
$buf .= $c1 . $c2;
|
||||
$i++;
|
||||
} else { //not valid UTF8. Convert it.
|
||||
$cc1 = (chr(ord($c1) / 64) | "\xc0");
|
||||
$cc2 = ($c1 & "\x3f") | "\x80";
|
||||
$buf .= $cc1 . $cc2;
|
||||
}
|
||||
} elseif($c1 >= "\xe0" & $c1 <= "\xef"){ //looks like 3 bytes UTF8
|
||||
if($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf"){ //yeah, almost sure it's UTF8 already
|
||||
$buf .= $c1 . $c2 . $c3;
|
||||
$i = $i + 2;
|
||||
} else { //not valid UTF8. Convert it.
|
||||
$cc1 = (chr(ord($c1) / 64) | "\xc0");
|
||||
$cc2 = ($c1 & "\x3f") | "\x80";
|
||||
$buf .= $cc1 . $cc2;
|
||||
}
|
||||
} elseif($c1 >= "\xf0" & $c1 <= "\xf7"){ //looks like 4 bytes UTF8
|
||||
if($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf"){ //yeah, almost sure it's UTF8 already
|
||||
$buf .= $c1 . $c2 . $c3 . $c4;
|
||||
$i = $i + 3;
|
||||
} else { //not valid UTF8. Convert it.
|
||||
$cc1 = (chr(ord($c1) / 64) | "\xc0");
|
||||
$cc2 = ($c1 & "\x3f") | "\x80";
|
||||
$buf .= $cc1 . $cc2;
|
||||
}
|
||||
} else { //doesn't look like UTF8, but should be converted
|
||||
$cc1 = (chr(ord($c1) / 64) | "\xc0");
|
||||
$cc2 = (($c1 & "\x3f") | "\x80");
|
||||
$buf .= $cc1 . $cc2;
|
||||
}
|
||||
} elseif(($c1 & "\xc0") == "\x80"){ // needs conversion
|
||||
if(isset(self::$win1252ToUtf8[ord($c1)])) { //found in Windows-1252 special cases
|
||||
$buf .= self::$win1252ToUtf8[ord($c1)];
|
||||
} else {
|
||||
$cc1 = (chr(ord($c1) / 64) | "\xc0");
|
||||
$cc2 = (($c1 & "\x3f") | "\x80");
|
||||
$buf .= $cc1 . $cc2;
|
||||
}
|
||||
} else { // it doesn't need conversion
|
||||
$buf .= $c1;
|
||||
}
|
||||
}
|
||||
return $buf;
|
||||
}
|
||||
|
||||
static function toWin1252($text, $option = self::WITHOUT_ICONV) {
|
||||
if(is_array($text)) {
|
||||
foreach($text as $k => $v) {
|
||||
$text[$k] = self::toWin1252($v, $option);
|
||||
}
|
||||
return $text;
|
||||
} elseif(is_string($text)) {
|
||||
return static::utf8_decode($text, $option);
|
||||
} else {
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
static function toISO8859($text) {
|
||||
return self::toWin1252($text);
|
||||
}
|
||||
|
||||
static function toLatin1($text) {
|
||||
return self::toWin1252($text);
|
||||
}
|
||||
|
||||
static function fixUTF8($text, $option = self::WITHOUT_ICONV){
|
||||
if(is_array($text)) {
|
||||
foreach($text as $k => $v) {
|
||||
$text[$k] = self::fixUTF8($v, $option);
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
$last = "";
|
||||
while($last <> $text){
|
||||
$last = $text;
|
||||
$text = self::toUTF8(static::utf8_decode($text, $option));
|
||||
}
|
||||
$text = self::toUTF8(static::utf8_decode($text, $option));
|
||||
return $text;
|
||||
}
|
||||
|
||||
static function UTF8FixWin1252Chars($text){
|
||||
// If you received an UTF-8 string that was converted from Windows-1252 as it was ISO8859-1
|
||||
// (ignoring Windows-1252 chars from 80 to 9F) use this function to fix it.
|
||||
// See: http://en.wikipedia.org/wiki/Windows-1252
|
||||
|
||||
return str_replace(array_keys(self::$brokenUtf8ToUtf8), array_values(self::$brokenUtf8ToUtf8), $text);
|
||||
}
|
||||
|
||||
static function removeBOM($str=""){
|
||||
if(substr($str, 0,3) == pack("CCC",0xef,0xbb,0xbf)) {
|
||||
$str=substr($str, 3);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
protected static function strlen($text){
|
||||
return (function_exists('mb_strlen')) ?
|
||||
mb_strlen($text,'8bit') : strlen($text);
|
||||
}
|
||||
|
||||
public static function normalizeEncoding($encodingLabel)
|
||||
{
|
||||
$encoding = strtoupper($encodingLabel);
|
||||
$encoding = preg_replace('/[^a-zA-Z0-9\s]/', '', $encoding);
|
||||
$equivalences = array(
|
||||
'ISO88591' => 'ISO-8859-1',
|
||||
'ISO8859' => 'ISO-8859-1',
|
||||
'ISO' => 'ISO-8859-1',
|
||||
'LATIN1' => 'ISO-8859-1',
|
||||
'LATIN' => 'ISO-8859-1',
|
||||
'UTF8' => 'UTF-8',
|
||||
'UTF' => 'UTF-8',
|
||||
'WIN1252' => 'ISO-8859-1',
|
||||
'WINDOWS1252' => 'ISO-8859-1'
|
||||
);
|
||||
|
||||
if(empty($equivalences[$encoding])){
|
||||
return 'UTF-8';
|
||||
}
|
||||
|
||||
return $equivalences[$encoding];
|
||||
}
|
||||
|
||||
public static function encode($encodingLabel, $text)
|
||||
{
|
||||
$encodingLabel = self::normalizeEncoding($encodingLabel);
|
||||
if($encodingLabel == 'ISO-8859-1') return self::toLatin1($text);
|
||||
return self::toUTF8($text);
|
||||
}
|
||||
|
||||
protected static function utf8_decode($text, $option)
|
||||
{
|
||||
if ($option == self::WITHOUT_ICONV || !function_exists('iconv')) {
|
||||
$o = utf8_decode(
|
||||
str_replace(array_keys(self::$utf8ToWin1252), array_values(self::$utf8ToWin1252), self::toUTF8($text))
|
||||
);
|
||||
} else {
|
||||
$o = iconv("UTF-8", "Windows-1252" . ($option == self::ICONV_TRANSLIT ? '//TRANSLIT' : ($option == self::ICONV_IGNORE ? '//IGNORE' : '')), $text);
|
||||
}
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
if (fusion_is_element_enabled('wpmf_avada_single_file')) {
|
||||
if (!class_exists('WpmfAvadaSingleFileClass')) {
|
||||
/**
|
||||
* Fusion Single File shortcode class.
|
||||
*/
|
||||
class WpmfAvadaSingleFileClass extends Fusion_Element
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
add_shortcode('wpmf_avada_single_file', array($this, 'render'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the shortcode
|
||||
*
|
||||
* @param array $args Shortcode parameters.
|
||||
* @param string $content Content between shortcode.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render($args, $content = '')
|
||||
{
|
||||
if (empty($args['url'])) {
|
||||
$html = '<div class="wpmf-avada-container">
|
||||
<div id="avada-file-design-placeholder" class="avada-file-design-placeholder">
|
||||
<span class="wpmf-avada-message">
|
||||
' . esc_html__('WP Media Folder media download. Select a media and transform it into a download button', 'wpmf') . '
|
||||
</span>
|
||||
</div>
|
||||
</div>';
|
||||
} else {
|
||||
$align = (!empty($args['align'])) ? $args['align'] : 'left';
|
||||
$html = do_shortcode('[wpmffiledesign url="' . esc_attr($args['url']) . '" align="' . esc_attr($align) . '"]');
|
||||
}
|
||||
return apply_filters('wpmfAvadaSingleFile_content', $html, $args);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new WpmfAvadaSingleFileClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Map shortcode to Avada Builder.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wpmfAvadaSingleFile()
|
||||
{
|
||||
if (!function_exists('fusion_builder_frontend_data')) {
|
||||
return;
|
||||
}
|
||||
fusion_builder_map(
|
||||
fusion_builder_frontend_data(
|
||||
'WpmfAvadaSingleFileClass',
|
||||
array(
|
||||
'name' => esc_attr__('WPMF Media Download', 'wpmf'),
|
||||
'shortcode' => 'wpmf_avada_single_file',
|
||||
'icon' => 'wpmf-avada-icon wpmf-avada-singlefile-icon',
|
||||
'custom_settings_view_js' => WPMF_PLUGIN_URL . 'assets/js/avada/avada_singlefile_script.js',
|
||||
'front_end_custom_settings_view_js' => WPMF_PLUGIN_URL . 'assets/js/avada/avada_singlefile_script.js',
|
||||
'preview' => WP_MEDIA_FOLDER_PLUGIN_DIR . 'class/avada-widgets/templates/single-file.php',
|
||||
'preview_id' => 'fusion-builder-wpmf-single-file-preview-template',
|
||||
'allow_generator' => true,
|
||||
'inline_editor' => true,
|
||||
'params' => array(
|
||||
array(
|
||||
'type' => 'wpmf_single_file',
|
||||
'heading' => esc_html__('Select a file', 'wpmf'),
|
||||
'description' => esc_html__('Select a file to display.', 'wpmf'),
|
||||
'param_name' => 'single_file_button'
|
||||
),
|
||||
array(
|
||||
'type' => 'textfield',
|
||||
'heading' => esc_html__('URL', 'wpmf'),
|
||||
'description' => esc_html__('Add a file URL to display.', 'wpmf'),
|
||||
'param_name' => 'url',
|
||||
'value' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'radio_button_set',
|
||||
'heading' => esc_attr__('Align', 'wpmf'),
|
||||
'description' => esc_attr__('Select the file alignment.', 'wpmf'),
|
||||
'param_name' => 'align',
|
||||
'value' => array(
|
||||
'left' => esc_attr__('Left', 'wpmf'),
|
||||
'right' => esc_attr__('Right', 'wpmf'),
|
||||
'center' => esc_attr__('Center', 'wpmf'),
|
||||
),
|
||||
'default' => 'left'
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'wpmf-avada-style',
|
||||
WPMF_PLUGIN_URL . '/assets/css/avada_style.css',
|
||||
array(),
|
||||
WPMF_VERSION
|
||||
);
|
||||
}
|
||||
wpmfAvadaSingleFile();
|
||||
add_action('fusion_builder_before_init', 'wpmfAvadaSingleFile');
|
||||
@@ -0,0 +1,573 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
if (fusion_is_element_enabled('wpmf_fusion_gallery')) {
|
||||
if (!class_exists('WpmfAvadaGalleryClass')) {
|
||||
/**
|
||||
* Fusion Gallery shortcode class.
|
||||
*/
|
||||
class WpmfAvadaGalleryClass extends Fusion_Element
|
||||
{
|
||||
/**
|
||||
* The gallery counter.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $gallery_counter = 1;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
add_shortcode('wpmf_fusion_gallery', array($this, 'render'));
|
||||
add_action('wp_ajax_wpmf_fusion_gallery_get_images', array($this, 'fusionGalleryGetImages'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get gallery images
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fusionGalleryGetImages()
|
||||
{
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Missing -- Nonce is not required
|
||||
$items = (isset($_POST['items'])) ? $_POST['items'] : '';
|
||||
// phpcs:enable
|
||||
$image_ids = explode(',', $items);
|
||||
$image_ids = array_filter(array_unique($image_ids));
|
||||
$html = '';
|
||||
if (!empty($image_ids)) {
|
||||
$args = array(
|
||||
'post_status' => 'inherit',
|
||||
'post_type' => 'attachment',
|
||||
'post_mime_type' => 'image',
|
||||
'orderby' => 'post__in',
|
||||
'order' => 'ASC',
|
||||
'include' => $image_ids
|
||||
);
|
||||
|
||||
$attachments = get_posts($args);
|
||||
foreach ($attachments as $attachment) {
|
||||
$image_url = wp_get_attachment_image_url($attachment->ID, 'thumbnail');
|
||||
$image = '<img src="'. esc_url($image_url) .'">';
|
||||
$image = '<div class="wpmf-image-preview"><div class="square_thumbnail"><div class="img_centered">'. $image .'</div></div></div>';
|
||||
$html .= '<div class="wpmf-fusion-image-child" data-id="' . esc_attr($attachment->ID) . '"><button type="button" class="fusiona-remove-image fusion-wpmf-gallery-remove-image"> </button>' . $image . '</div>';
|
||||
}
|
||||
}
|
||||
wp_send_json(array('status' => true, 'html' => $html));
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the shortcode
|
||||
*
|
||||
* @param array $args Shortcode parameters.
|
||||
* @param string $content Content between shortcode.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render($args, $content = '')
|
||||
{
|
||||
$attrs = FusionBuilder::set_shortcode_defaults(self::get_element_defaults(), $args, 'wpmf_fusion_gallery');
|
||||
$attrs = apply_filters('fusion_builder_default_args', $attrs, 'wpmf_fusion_gallery', $args);
|
||||
foreach ($attrs as $k => $v) {
|
||||
${$k} = $v;
|
||||
}
|
||||
$items = trim($items, ',');
|
||||
if (empty($items) && ($gallery_folders === 'no' || ($gallery_folders === 'yes' && empty($gallery_folder_id)))) {
|
||||
$html = '<div class="wpmf-avada-container">
|
||||
<div id="avada-gallery-placeholder" class="avada-gallery-placeholder">
|
||||
<span class="wpmf-avada-message">
|
||||
' . esc_html__('Please add some images to the gallery to activate the preview', 'wpmf') . '
|
||||
</span>
|
||||
</div>
|
||||
</div>';
|
||||
} else {
|
||||
if ($enable_shadow) {
|
||||
$img_shadow = $shadow_horizontal . 'px ' . $shadow_vertical . 'px ' . $shadow_blur . 'px ' . $shadow_spread . 'px ' . $shadow_color;
|
||||
} else {
|
||||
$img_shadow = '';
|
||||
}
|
||||
$gallery_folders = (isset($attrs['gallery_folders']) && $attrs['gallery_folders'] === 'yes') ? 1 : 0;
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- No action, nonce is not required
|
||||
$is_builder = (function_exists('fusion_is_preview_frame') && fusion_is_preview_frame()) || (function_exists('fusion_is_builder_frame') && fusion_is_builder_frame());
|
||||
$style = '';
|
||||
switch ($theme) {
|
||||
case 'default':
|
||||
case 'masonry':
|
||||
case 'portfolio':
|
||||
if ($img_shadow !== '') {
|
||||
$style .= '#gallery-' . $this->gallery_counter . ' .wpmf-gallery-item img:hover {box-shadow: ' . $img_shadow . ' !important; transition: all 200ms ease;}';
|
||||
}
|
||||
|
||||
if ($border_style !== 'none') {
|
||||
$style .= '#gallery-' . $this->gallery_counter . ' .wpmf-gallery-item img {border: ' . $border_color . ' ' . $border_width . 'px ' . $border_style . '}';
|
||||
}
|
||||
break;
|
||||
case 'slider':
|
||||
if ($img_shadow !== '') {
|
||||
if ((int)$columns > 1) {
|
||||
$style .= '#gallery-' . $this->gallery_counter . ' .wpmf-gallery-item:hover {box-shadow: ' . $img_shadow . ' !important; transition: all 200ms ease;}';
|
||||
}
|
||||
}
|
||||
|
||||
if ($border_style !== 'none') {
|
||||
if ((int)$columns === 1) {
|
||||
$style .= '#gallery-' . $this->gallery_counter . ' .wpmf-gallery-item img {border: ' . $border_color . ' ' . $border_width . 'px ' . $border_style . ';}';
|
||||
} else {
|
||||
$style .= '#gallery-' . $this->gallery_counter . ' .wpmf-gallery-item {border: ' . $border_color . ' ' . $border_width . 'px ' . $border_style . ';}';
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ('' !== $style) {
|
||||
$style = '<style type="text/css">' . $style . '</style>';
|
||||
}
|
||||
|
||||
if ($is_builder) {
|
||||
$html = do_shortcode('[wpmf_gallery include="' . esc_attr($items) . '" display="' . esc_attr($theme) . '" columns="' . esc_attr($columns) . '" size="' . esc_attr($size) . '" targetsize="' . esc_attr($targetsize) . '" link="none" wpmf_orderby="' . esc_attr($orderby) . '" wpmf_order="' . esc_attr($order) . '" gutterwidth="' . esc_attr($gutterwidth) . '" img_border_radius="' . esc_attr($border_radius) . '" border_width="' . esc_attr($border_width) . '" border_style="' . esc_attr($border_style) . '" border_color="' . esc_attr($border_color) . '" img_shadow="' . esc_attr($img_shadow) . '" wpmf_autoinsert="' . esc_attr($gallery_folders) . '" wpmf_folder_id="' . esc_attr($gallery_folder_id) . '" crop_image="'. esc_attr($crop_image) .'" aspect_ratio="' . esc_attr($aspect_ratio) . '"]');
|
||||
} else {
|
||||
$html = do_shortcode('[wpmf_gallery include="' . esc_attr($items) . '" display="' . esc_attr($theme) . '" columns="' . esc_attr($columns) . '" size="' . esc_attr($size) . '" targetsize="' . esc_attr($targetsize) . '" link="' . esc_attr($link) . '" wpmf_orderby="' . esc_attr($orderby) . '" wpmf_order="' . esc_attr($order) . '" gutterwidth="' . esc_attr($gutterwidth) . '" img_border_radius="' . esc_attr($border_radius) . '" border_width="' . esc_attr($border_width) . '" border_style="' . esc_attr($border_style) . '" border_color="' . esc_attr($border_color) . '" img_shadow="' . esc_attr($img_shadow) . '" wpmf_autoinsert="' . esc_attr($gallery_folders) . '" wpmf_folder_id="' . esc_attr($gallery_folder_id) . '" crop_image="'. esc_attr($crop_image) .'" aspect_ratio="' . esc_attr($aspect_ratio) . '"]');
|
||||
}
|
||||
|
||||
$html = $style . $html;
|
||||
$this->gallery_counter++;
|
||||
}
|
||||
|
||||
return apply_filters('wpmf_fusion_gallery_element_content', $html, $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default values.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_element_defaults() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from Fusion_Element class
|
||||
{
|
||||
$settings = wpmfGetOption('gallery_settings');
|
||||
$masonry_settings = $settings['theme']['masonry_theme'];
|
||||
$defaults = array(
|
||||
'theme' => 'masonry',
|
||||
'items' => '',
|
||||
'aspect_ratio' => 'default',
|
||||
'columns' => (isset($masonry_settings['columns'])) ? (int)$masonry_settings['columns'] : 3,
|
||||
'gutterwidth' => (isset($masonry_settings['gutterwidth'])) ? (int)$masonry_settings['gutterwidth'] : 5,
|
||||
'size' => (isset($masonry_settings['size'])) ? $masonry_settings['size'] : 'medium',
|
||||
'link' => (isset($masonry_settings['link'])) ? $masonry_settings['link'] : 'file',
|
||||
'targetsize' => (isset($masonry_settings['targetsize'])) ? $masonry_settings['targetsize'] : 'large',
|
||||
'orderby' => (isset($masonry_settings['orderby'])) ? $masonry_settings['orderby'] : 'post__in',
|
||||
'order' => (isset($masonry_settings['order'])) ? $masonry_settings['order'] : 'ASC',
|
||||
'border_radius' => 0,
|
||||
'border_width' => 0,
|
||||
'border_style' => 'solid',
|
||||
'border_color' => '#cccccc',
|
||||
'enable_shadow' => 'no',
|
||||
'crop_image' => 'yes',
|
||||
'shadow_horizontal' => 0,
|
||||
'shadow_vertical' => 0,
|
||||
'shadow_blur' => 0,
|
||||
'shadow_spread' => 0,
|
||||
'shadow_color' => '#cccccc',
|
||||
'gallery_folders' => 'no',
|
||||
'gallery_folder_id' => '0',
|
||||
);
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new WpmfAvadaGalleryClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Map shortcode to Avada Builder.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wpmfFusionElementGallery()
|
||||
{
|
||||
if (!function_exists('fusion_builder_frontend_data')) {
|
||||
return;
|
||||
}
|
||||
$settings = wpmfGetOption('gallery_settings');
|
||||
$defaults = $settings['theme']['masonry_theme'];
|
||||
$main_class = wpmfGetMainClass();
|
||||
$getFolders = $main_class->getAttachmentTerms('builder');
|
||||
$folders = $getFolders['attachment_terms'];
|
||||
$folders_order = $getFolders['attachment_terms_order'];
|
||||
$list_cloud = array();
|
||||
$list_local = array();
|
||||
foreach ($folders_order as $folder_order) {
|
||||
$folder = $folders[$folder_order];
|
||||
if ($folder['id'] !== 0) {
|
||||
if (!isset($folder['depth'])) {
|
||||
$folder['depth'] = 0;
|
||||
}
|
||||
|
||||
if (isset($folder['drive_type']) && $folder['drive_type'] !== '') {
|
||||
$list_cloud[$folder['id']] = str_repeat('--', $folder['depth']) . $folder['label'];
|
||||
} else {
|
||||
$list_local[$folder['id']] = str_repeat('--', $folder['depth']) . $folder['label'];
|
||||
}
|
||||
} else {
|
||||
$list_local[0] = $folder['label'];
|
||||
}
|
||||
}
|
||||
|
||||
fusion_builder_map(
|
||||
fusion_builder_frontend_data(
|
||||
'WpmfAvadaGalleryClass',
|
||||
array(
|
||||
'name' => esc_attr__('WPMF Gallery', 'wpmf'),
|
||||
'shortcode' => 'wpmf_fusion_gallery',
|
||||
'icon' => 'wpmf-avada-icon wpmf-avada-gallery-icon',
|
||||
'allow_generator' => true,
|
||||
'preview' => WP_MEDIA_FOLDER_PLUGIN_DIR . 'class/avada-widgets/templates/gallery.php',
|
||||
'preview_id' => 'fusion-builder-wpmf-gallery-preview-template',
|
||||
'custom_settings_view_js' => WPMF_PLUGIN_URL . 'assets/js/avada/avada_gallery_script.js',
|
||||
'front_end_custom_settings_view_js' => WPMF_PLUGIN_URL . 'assets/js/avada/avada_gallery_script.js',
|
||||
'sortable' => false,
|
||||
'params' => array(
|
||||
array(
|
||||
'type' => 'radio_button_set',
|
||||
'heading' => esc_html__('Theme', 'wpmf'),
|
||||
'description' => esc_html__('Select the gallery layout type.', 'wpmf'),
|
||||
'param_name' => 'theme',
|
||||
'value' => array(
|
||||
'default' => esc_html__('Default', 'wpmf'),
|
||||
'masonry' => esc_html__('Masonry', 'wpmf'),
|
||||
'portfolio' => esc_html__('Portfolio', 'wpmf'),
|
||||
'slider' => esc_html__('Slider', 'wpmf')
|
||||
),
|
||||
'default' => 'masonry'
|
||||
),
|
||||
array(
|
||||
'type' => 'wpmf_gallery_select',
|
||||
'heading' => esc_html__('Select images', 'wpmf'),
|
||||
'description' => esc_html__('This option allows you to select multiple images at once. It saves time instead of adding one image at a time. Use Ctrl or Shift key to select multiple images.', 'wpmf'),
|
||||
'param_name' => 'wpmf_gallery_select',
|
||||
'group' => esc_html__('Images', 'wpmf'),
|
||||
),
|
||||
array(
|
||||
'type' => 'textfield',
|
||||
'heading' => esc_html__('Images', 'wpmf'),
|
||||
'param_name' => 'items',
|
||||
'value' => '',
|
||||
'group' => esc_html__('Images', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'heading' => esc_attr__('Aspect ratio', 'wpmf'),
|
||||
'description' => __('Aspect ratio for default, slider, portfolio theme', 'wpmf'),
|
||||
'param_name' => 'aspect_ratio',
|
||||
'value' => array(
|
||||
'default' => esc_html__('Default', 'wpmf'),
|
||||
'1_1' => '1:1',
|
||||
'3_2' => '3:2',
|
||||
'2_3' => '2:3',
|
||||
'4_3' => '4:3',
|
||||
'3_4' => '3:4',
|
||||
'16_9' => '16:9',
|
||||
'9_16' => '9:16',
|
||||
'21_9' => '21:9',
|
||||
'9_21' => '9:21'
|
||||
),
|
||||
'default' => 'default'
|
||||
),
|
||||
array(
|
||||
'type' => 'range',
|
||||
'heading' => esc_attr__('Columns', 'wpmf'),
|
||||
'param_name' => 'columns',
|
||||
'value' => $defaults['columns'],
|
||||
'min' => '1',
|
||||
'max' => '8',
|
||||
'step' => '1'
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'heading' => esc_attr__('Image Size', 'wpmf'),
|
||||
'param_name' => 'size',
|
||||
'value' => apply_filters('image_size_names_choose', array(
|
||||
'thumbnail' => __('Thumbnail', 'wpmf'),
|
||||
'medium' => __('Medium', 'wpmf'),
|
||||
'large' => __('Large', 'wpmf'),
|
||||
'full' => __('Full Size', 'wpmf'),
|
||||
)),
|
||||
'default' => $defaults['size']
|
||||
),
|
||||
array(
|
||||
'type' => 'radio_button_set',
|
||||
'heading' => esc_attr__('Crop Image', 'wpmf'),
|
||||
'description' => esc_attr__('Only apply for slider theme', 'wpmf'),
|
||||
'param_name' => 'crop_image',
|
||||
'value' => array(
|
||||
'yes' => esc_attr__('Yes', 'wpmf'),
|
||||
'no' => esc_attr__('No', 'wpmf'),
|
||||
),
|
||||
'default' => 'yes',
|
||||
),
|
||||
array(
|
||||
'type' => 'radio_button_set',
|
||||
'heading' => esc_attr__('Action On Click', 'wpmf'),
|
||||
'param_name' => 'link',
|
||||
'value' => array(
|
||||
'file' => esc_html__('Lightbox', 'wpmf'),
|
||||
'post' => esc_html__('Attachment Page', 'wpmf'),
|
||||
'none' => esc_html__('None', 'wpmf'),
|
||||
),
|
||||
'default' => $defaults['link'],
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'heading' => esc_attr__('Lightbox Size', 'wpmf'),
|
||||
'param_name' => 'targetsize',
|
||||
'value' => apply_filters('image_size_names_choose', array(
|
||||
'thumbnail' => __('Thumbnail', 'wpmf'),
|
||||
'medium' => __('Medium', 'wpmf'),
|
||||
'large' => __('Large', 'wpmf'),
|
||||
'full' => __('Full Size', 'wpmf'),
|
||||
)),
|
||||
'default' => $defaults['targetsize'],
|
||||
'dependency' => array(
|
||||
array(
|
||||
'element' => 'link',
|
||||
'value' => 'file',
|
||||
'operator' => '==',
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'radio_button_set',
|
||||
'heading' => esc_attr__('Order by', 'wpmf'),
|
||||
'param_name' => 'orderby',
|
||||
'value' => array(
|
||||
'post__in' => esc_html__('Custom', 'wpmf'),
|
||||
'rand' => esc_html__('Random', 'wpmf'),
|
||||
'title' => esc_html__('Title', 'wpmf'),
|
||||
'date' => esc_html__('Date', 'wpmf')
|
||||
),
|
||||
'default' => $defaults['orderby']
|
||||
),
|
||||
array(
|
||||
'type' => 'radio_button_set',
|
||||
'heading' => esc_attr__('Order', 'wpmf'),
|
||||
'param_name' => 'order',
|
||||
'value' => array(
|
||||
'ASC' => esc_html__('Ascending', 'wpmf'),
|
||||
'DESC' => esc_html__('Descending', 'wpmf')
|
||||
),
|
||||
'default' => $defaults['order']
|
||||
),
|
||||
array(
|
||||
'type' => 'range',
|
||||
'heading' => esc_attr__('Gutter', 'wpmf'),
|
||||
'param_name' => 'gutterwidth',
|
||||
'value' => '5',
|
||||
'min' => '0',
|
||||
'max' => '100',
|
||||
'step' => '5'
|
||||
),
|
||||
array(
|
||||
'type' => 'range',
|
||||
'heading' => esc_attr__('Border Radius', 'wpmf'),
|
||||
'param_name' => 'border_radius',
|
||||
'value' => '0',
|
||||
'min' => '0',
|
||||
'max' => '20',
|
||||
'step' => '1'
|
||||
),
|
||||
array(
|
||||
'type' => 'range',
|
||||
'heading' => esc_attr__('Border Width', 'wpmf'),
|
||||
'param_name' => 'border_width',
|
||||
'value' => '0',
|
||||
'min' => '0',
|
||||
'max' => '30',
|
||||
'step' => '1'
|
||||
),
|
||||
array(
|
||||
'type' => 'radio_button_set',
|
||||
'heading' => esc_attr__('Border Type', 'wpmf'),
|
||||
'param_name' => 'border_style',
|
||||
'value' => array(
|
||||
'solid' => esc_html__('Solid', 'wpmf'),
|
||||
'double' => esc_html__('Double', 'wpmf'),
|
||||
'dotted' => esc_html__('Dotted', 'wpmf'),
|
||||
'dashed' => esc_html__('Dashed', 'wpmf'),
|
||||
'groove' => esc_html__('Groove', 'wpmf')
|
||||
),
|
||||
'default' => 'solid',
|
||||
'dependency' => array(
|
||||
array(
|
||||
'element' => 'border_width',
|
||||
'value' => '0',
|
||||
'operator' => '!=',
|
||||
),
|
||||
),
|
||||
|
||||
),
|
||||
array(
|
||||
'type' => 'colorpickeralpha',
|
||||
'heading' => esc_attr__('Border Color', 'wpmf'),
|
||||
'param_name' => 'border_color',
|
||||
'value' => '',
|
||||
'default' => '#cccccc',
|
||||
'dependency' => array(
|
||||
array(
|
||||
'element' => 'border_width',
|
||||
'value' => '0',
|
||||
'operator' => '!=',
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'radio_button_set',
|
||||
'heading' => esc_attr__('Enable Shadow', 'wpmf'),
|
||||
'param_name' => 'enable_shadow',
|
||||
'value' => array(
|
||||
'yes' => esc_attr__('Yes', 'wpmf'),
|
||||
'no' => esc_attr__('No', 'wpmf'),
|
||||
),
|
||||
'default' => 'no',
|
||||
),
|
||||
array(
|
||||
'type' => 'colorpickeralpha',
|
||||
'heading' => esc_attr__('Shadow Color', 'wpmf'),
|
||||
'param_name' => 'shadow_color',
|
||||
'value' => '',
|
||||
'default' => '#cccccc',
|
||||
'dependency' => array(
|
||||
array(
|
||||
'element' => 'enable_shadow',
|
||||
'value' => 'yes',
|
||||
'operator' => '==',
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'range',
|
||||
'heading' => esc_attr__('Shadow Horizontal', 'wpmf'),
|
||||
'param_name' => 'shadow_horizontal',
|
||||
'value' => '0',
|
||||
'min' => '-50',
|
||||
'max' => '50',
|
||||
'step' => '1',
|
||||
'dependency' => array(
|
||||
array(
|
||||
'element' => 'enable_shadow',
|
||||
'value' => 'yes',
|
||||
'operator' => '==',
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'range',
|
||||
'heading' => esc_attr__('Shadow Vertical', 'wpmf'),
|
||||
'param_name' => 'shadow_vertical',
|
||||
'value' => '0',
|
||||
'min' => '-50',
|
||||
'max' => '50',
|
||||
'step' => '1',
|
||||
'dependency' => array(
|
||||
array(
|
||||
'element' => 'enable_shadow',
|
||||
'value' => 'yes',
|
||||
'operator' => '==',
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'range',
|
||||
'heading' => esc_attr__('Shadow Blur', 'wpmf'),
|
||||
'param_name' => 'shadow_blur',
|
||||
'value' => '0',
|
||||
'min' => '0',
|
||||
'max' => '50',
|
||||
'step' => '1',
|
||||
'dependency' => array(
|
||||
array(
|
||||
'element' => 'enable_shadow',
|
||||
'value' => 'yes',
|
||||
'operator' => '==',
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'range',
|
||||
'heading' => esc_attr__('Shadow Spread', 'wpmf'),
|
||||
'param_name' => 'shadow_spread',
|
||||
'value' => '0',
|
||||
'min' => '0',
|
||||
'max' => '50',
|
||||
'step' => '1',
|
||||
'dependency' => array(
|
||||
array(
|
||||
'element' => 'enable_shadow',
|
||||
'value' => 'yes',
|
||||
'operator' => '==',
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'radio_button_set',
|
||||
'heading' => esc_attr__('Gallery From Folder', 'wpmf'),
|
||||
'param_name' => 'gallery_folders',
|
||||
'value' => array(
|
||||
'yes' => esc_attr__('Yes', 'wpmf'),
|
||||
'no' => esc_attr__('No', 'wpmf'),
|
||||
),
|
||||
'default' => 'no'
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'heading' => esc_attr__('Select a Folder', 'wpmf'),
|
||||
'param_name' => 'gallery_folder_id',
|
||||
'value' => $list_local + $list_cloud,
|
||||
'default' => 0,
|
||||
'dependency' => array(
|
||||
array(
|
||||
'element' => 'gallery_folders',
|
||||
'value' => 'yes',
|
||||
'operator' => '==',
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'wpmf-avada-style',
|
||||
WPMF_PLUGIN_URL . '/assets/css/avada_style.css',
|
||||
array(),
|
||||
WPMF_VERSION
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'wpmf-slick-style',
|
||||
WPMF_PLUGIN_URL . 'assets/js/slick/slick.css',
|
||||
array(),
|
||||
WPMF_VERSION
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'wpmf-slick-theme-style',
|
||||
WPMF_PLUGIN_URL . 'assets/js/slick/slick-theme.css',
|
||||
array(),
|
||||
WPMF_VERSION
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'wpmf-avada-gallery-style',
|
||||
WPMF_PLUGIN_URL . 'assets/css/display-gallery/style-display-gallery.css',
|
||||
array(),
|
||||
WPMF_VERSION
|
||||
);
|
||||
}
|
||||
|
||||
wpmfFusionElementGallery();
|
||||
add_action('fusion_builder_before_init', 'wpmfFusionElementGallery');
|
||||
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
if (fusion_is_element_enabled('wpmf_avada_pdf_embed')) {
|
||||
if (!class_exists('WpmfAvadaPdfEmbedClass')) {
|
||||
/**
|
||||
* Fusion PDF Embed shortcode class.
|
||||
*/
|
||||
class WpmfAvadaPdfEmbedClass extends Fusion_Element
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
add_shortcode('wpmf_avada_pdf_embed', array($this, 'render'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the shortcode
|
||||
*
|
||||
* @param array $args Shortcode parameters.
|
||||
* @param string $content Content between shortcode.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render($args, $content = '')
|
||||
{
|
||||
if (empty($args['url'])) {
|
||||
$html = '<div class="wpmf-avada-container">
|
||||
<div id="avada-pdf-embed-placeholder" class="avada-pdf-embed-placeholder">
|
||||
<span class="wpmf-avada-message">
|
||||
' . esc_html__('Please select a PDF file to activate the preview', 'wpmf') . '
|
||||
</span>
|
||||
</div>
|
||||
</div>';
|
||||
} else {
|
||||
$embed = (!empty($args['embed'])) ? $args['embed'] : 'on';
|
||||
$target = (!empty($args['target'])) ? $args['target'] : 'self';
|
||||
$html = do_shortcode('[wpmfpdf url="' . esc_url($args['url']) . '" embed="' . esc_attr($embed) . '" target="' . esc_attr($target) . '"]');
|
||||
}
|
||||
return apply_filters('wpmfAvadaPdfEmbed_content', $html, $args);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new WpmfAvadaPdfEmbedClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Map shortcode to Avada Builder.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wpmfAvadaPdfEmbed()
|
||||
{
|
||||
if (!function_exists('fusion_builder_frontend_data')) {
|
||||
return;
|
||||
}
|
||||
fusion_builder_map(
|
||||
fusion_builder_frontend_data(
|
||||
'WpmfAvadaPdfEmbedClass',
|
||||
array(
|
||||
'name' => esc_attr__('WPMF PDF Embed', 'wpmf'),
|
||||
'shortcode' => 'wpmf_avada_pdf_embed',
|
||||
'icon' => 'wpmf-avada-icon wpmf-avada-pdf-embed-icon',
|
||||
'custom_settings_view_js' => WPMF_PLUGIN_URL . 'assets/js/avada/avada_pdfembed_script.js',
|
||||
'front_end_custom_settings_view_js' => WPMF_PLUGIN_URL . 'assets/js/avada/avada_pdfembed_script.js',
|
||||
'preview' => WP_MEDIA_FOLDER_PLUGIN_DIR . 'class/avada-widgets/templates/pdf-embed.php',
|
||||
'preview_id' => 'fusion-builder-wpmf-pdf-embed-preview-template',
|
||||
'allow_generator' => true,
|
||||
'inline_editor' => true,
|
||||
'params' => array(
|
||||
array(
|
||||
'type' => 'wpmf_pdf_embed',
|
||||
'heading' => esc_html__('Select a file', 'wpmf'),
|
||||
'description' => esc_html__('Select a PDF file to display.', 'wpmf'),
|
||||
'param_name' => 'pdf_embed_button'
|
||||
),
|
||||
array(
|
||||
'type' => 'textfield',
|
||||
'heading' => esc_html__('URL', 'wpmf'),
|
||||
'description' => esc_html__('Add a PDF URL to display.', 'wpmf'),
|
||||
'param_name' => 'url',
|
||||
'value' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'radio_button_set',
|
||||
'heading' => esc_attr__('Embed', 'wpmf'),
|
||||
'description' => esc_html__('When enabling this option you will have the possibility to embed PDF file.', 'wpmf'),
|
||||
'param_name' => 'embed',
|
||||
'value' => array(
|
||||
'on' => esc_attr__('On', 'wpmf'),
|
||||
'off' => esc_attr__('Off', 'wpmf'),
|
||||
),
|
||||
'default' => 'on'
|
||||
),
|
||||
array(
|
||||
'type' => 'radio_button_set',
|
||||
'heading' => esc_attr__('Target', 'wpmf'),
|
||||
'description' => '',
|
||||
'param_name' => 'target',
|
||||
'value' => array(
|
||||
'_blank' => esc_attr__('New Window', 'wpmf'),
|
||||
'self' => esc_attr__('Same Window', 'wpmf'),
|
||||
),
|
||||
'default' => 'self',
|
||||
'dependency' => array(
|
||||
array(
|
||||
'element' => 'embed',
|
||||
'value' => 'off',
|
||||
'operator' => '==',
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'wpmf-avada-style',
|
||||
WPMF_PLUGIN_URL . '/assets/css/avada_style.css',
|
||||
array(),
|
||||
WPMF_VERSION
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'pdfemba_embed_pdf_css',
|
||||
WPMF_PLUGIN_URL . 'assets/css/pdfemb-embed-pdf.css'
|
||||
);
|
||||
}
|
||||
|
||||
wpmfAvadaPdfEmbed();
|
||||
add_action('fusion_builder_before_init', 'wpmfAvadaPdfEmbed');
|
||||
@@ -0,0 +1,3 @@
|
||||
<div class="">
|
||||
<button class="button wpmf_avada_select_pdf" type="button"><?php esc_html_e('Select', 'wpmf') ?></button>
|
||||
</div>
|
||||
@@ -0,0 +1,4 @@
|
||||
<div class="wpmf_avada_select_images_wrap">
|
||||
<button class="button wpmf_avada_select_images" type="button"><?php esc_html_e('Select Images', 'wpmf') ?></button>
|
||||
<div class="wpmf-fusion-images"></div>
|
||||
</div>
|
||||
@@ -0,0 +1,3 @@
|
||||
<div class="">
|
||||
<button class="button wpmf_avada_select_file" type="button"><?php esc_html_e('Select', 'wpmf') ?></button>
|
||||
</div>
|
||||
@@ -0,0 +1,121 @@
|
||||
/* global fusionAppConfig, FusionPageBuilderViewManager, imagesLoaded */
|
||||
/* jshint -W098 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
var FusionPageBuilder = FusionPageBuilder || {};
|
||||
|
||||
(function () {
|
||||
/**
|
||||
* run masonry layout
|
||||
*/
|
||||
function wpmfAvadaInitSlider($container, params) {
|
||||
//$container.imagesLoaded(function () {
|
||||
var slick_args = {
|
||||
infinite: true,
|
||||
slidesToShow: parseInt(params.columns),
|
||||
slidesToScroll: parseInt(params.columns),
|
||||
pauseOnHover: false,
|
||||
adaptiveHeight: (parseInt(columns) === 1),
|
||||
autoplay: false,
|
||||
autoplaySpeed: 5000,
|
||||
rows: 1,
|
||||
dots: true,
|
||||
responsive: [
|
||||
{
|
||||
breakpoint: 1024,
|
||||
settings: {
|
||||
slidesToShow: 3,
|
||||
slidesToScroll: 3,
|
||||
infinite: true,
|
||||
dots: true
|
||||
}
|
||||
},
|
||||
{
|
||||
breakpoint: 600,
|
||||
settings: {
|
||||
slidesToShow: 2,
|
||||
slidesToScroll: 2
|
||||
}
|
||||
},
|
||||
{
|
||||
breakpoint: 480,
|
||||
settings: {
|
||||
slidesToShow: 1,
|
||||
slidesToScroll: 1
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
if (!$container.hasClass('slick-initialized')) {
|
||||
setTimeout(function () {
|
||||
$container.slick(slick_args);
|
||||
}, 120);
|
||||
}
|
||||
//});
|
||||
}
|
||||
|
||||
function wpmfAvadaInitMasonry($container) {
|
||||
var $grid = $container.isotope({
|
||||
itemSelector: '.wpmf-gallery-item',
|
||||
percentPosition: true,
|
||||
layoutMode: 'packery',
|
||||
resizable: true,
|
||||
initLayout: true
|
||||
});
|
||||
|
||||
// layout Isotope after each image loads
|
||||
$grid.find('.wpmf-gallery-item').imagesLoaded().progress( function() {
|
||||
setTimeout(function () {
|
||||
$grid.isotope('layout');
|
||||
$grid.find('.wpmf-gallery-item').addClass('masonry-brick');
|
||||
},200);
|
||||
});
|
||||
}
|
||||
|
||||
jQuery(document).ready(function ($) {
|
||||
FusionPageBuilder.wpmf_avada_pdf_embed = FusionPageBuilder.ElementView.extend({
|
||||
onRender: function () {
|
||||
this.afterPatch();
|
||||
},
|
||||
|
||||
afterPatch: function() {
|
||||
var container = this.$el;
|
||||
var element_type = this.model.attributes.element_type;
|
||||
var params = this.model.attributes.params;
|
||||
}
|
||||
});
|
||||
|
||||
FusionPageBuilder.wpmf_fusion_gallery = FusionPageBuilder.ElementView.extend({
|
||||
onRender: function () {
|
||||
this.afterPatch();
|
||||
},
|
||||
|
||||
beforePatch: function() {
|
||||
var container = this.$el;
|
||||
var masonry_container = container.find('.wpmf-gallerys');
|
||||
masonry_container.remove();
|
||||
},
|
||||
|
||||
afterPatch: function() {
|
||||
var container = this.$el;
|
||||
var params = this.model.attributes.params;
|
||||
if (params.items !== '' || (params.gallery_folders === 'yes' && parseInt(params.gallery_folder_id) !== 0)) {
|
||||
var masonry_container = container.find('.gallery-masonry');
|
||||
if (masonry_container.length) {
|
||||
if (masonry_container.find('.wpmf-gallery-item').length) {
|
||||
wpmfAvadaInitMasonry(masonry_container);
|
||||
}
|
||||
}
|
||||
|
||||
var a = setInterval(function () {
|
||||
var slider_container = container.find('.wpmfslick');
|
||||
if (slider_container.length) {
|
||||
wpmfAvadaInitSlider(slider_container, params);
|
||||
clearInterval(a);
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}(jQuery));
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* Underscore.js template.
|
||||
*
|
||||
* @package fusion-builder
|
||||
*/
|
||||
?>
|
||||
<script type="text/template" id="fusion-builder-wpmf-gallery-preview-template">
|
||||
<h4 class="fusion_module_title"><span class="fusion-module-icon {{ fusionAllElements[element_type].icon }}"></span>{{ fusionAllElements[element_type].name }}</h4>
|
||||
</script>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Underscore.js template.
|
||||
*
|
||||
* @package fusion-builder
|
||||
*/
|
||||
?>
|
||||
<script type="text/template" id="fusion-builder-wpmf-pdf-embed-preview-template">
|
||||
<h4 class="fusion_module_title"><span class="fusion-module-icon {{ fusionAllElements[element_type].icon }}"></span>{{ fusionAllElements[element_type].name }}</h4>
|
||||
<#
|
||||
var url = params.url;
|
||||
var preview = '';
|
||||
|
||||
if ( '' !== url ) {
|
||||
preview = jQuery( '<div></div>' ).html( url ).text();
|
||||
}
|
||||
#>
|
||||
|
||||
<# if ( '' !== params.url ) { #>
|
||||
<span style="font-weight: bold">PDF URL: </span>
|
||||
<# } #>
|
||||
|
||||
<span class="file-url" style="font-style: italic"> {{{ preview }}} </span>
|
||||
</script>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Underscore.js template.
|
||||
*
|
||||
* @package fusion-builder
|
||||
*/
|
||||
?>
|
||||
<script type="text/template" id="fusion-builder-wpmf-single-file-preview-template">
|
||||
<h4 class="fusion_module_title"><span class="fusion-module-icon {{ fusionAllElements[element_type].icon }}"></span>{{ fusionAllElements[element_type].name }}</h4>
|
||||
<#
|
||||
var url = params.url;
|
||||
var preview = '';
|
||||
|
||||
if ( '' !== url ) {
|
||||
preview = jQuery( '<div></div>' ).html( url ).text();
|
||||
}
|
||||
#>
|
||||
|
||||
<# if ( '' !== params.url ) { #>
|
||||
<span style="font-weight: bold">File URL: </span>
|
||||
<# } #>
|
||||
|
||||
<span class="file-url" style="font-style: italic"> {{{ preview }}} </span>
|
||||
</script>
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
|
||||
/**
|
||||
* Element Description: VC Single File
|
||||
*/
|
||||
if (class_exists('WPBakeryShortCode')) {
|
||||
/**
|
||||
* Class WpmfBakerySingleFile
|
||||
*/
|
||||
class WpmfBakerySingleFile extends WPBakeryShortCode
|
||||
{
|
||||
/**
|
||||
* WpmfBakerySingleFile constructor.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct() // phpcs:ignore Squiz.Scope.MethodScope.Missing -- Method extends from WPBakeryShortCode class
|
||||
{
|
||||
// Stop all if VC is not enabled
|
||||
if (!defined('WPB_VC_VERSION')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Map the block with vc_map()
|
||||
vc_map(
|
||||
array(
|
||||
'name' => esc_html__('WPMF Media Download', 'wpmf'),
|
||||
'description' => esc_html__('Display media download', 'wpmf'),
|
||||
'base' => 'vc_sing_file',
|
||||
'category' => 'JoomUnited',
|
||||
'icon' => WPMF_PLUGIN_URL . '/assets/images/file_design-bakery.svg',
|
||||
'admin_enqueue_js' => WPMF_PLUGIN_URL . '/assets/js/vc_script.js',
|
||||
'front_enqueue_js' => WPMF_PLUGIN_URL . '/assets/js/vc_script.js',
|
||||
'params' => array(
|
||||
array(
|
||||
'type' => 'wpmf_media',
|
||||
'block_name' => 'singlefile_url',
|
||||
'heading' => esc_html__('URL', 'wpmf'),
|
||||
'class' => 'wpmf_vc_select_file vc_general vc_ui-button vc_ui-button-success',
|
||||
'button_label' => esc_html__('Select a File', 'wpmf'),
|
||||
'param_name' => 'url',
|
||||
'value' => '',
|
||||
'group' => esc_html__('Settings', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'heading' => esc_html__('Align', 'wpmf'),
|
||||
'param_name' => 'align',
|
||||
'value' => array(
|
||||
esc_html__('Left', 'wpmf') => 'left',
|
||||
esc_html__('Right', 'wpmf') => 'right',
|
||||
esc_html__('Center', 'wpmf') => 'center'
|
||||
),
|
||||
'std' => 'left',
|
||||
'group' => esc_html__('Settings', 'wpmf')
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
add_shortcode('vc_sing_file', array($this, 'vcSingFileHtml'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Render html
|
||||
*
|
||||
* @param array $atts Param details
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function vcSingFileHtml($atts)
|
||||
{
|
||||
if (empty($atts['url'])) {
|
||||
$html = '<div class="wpmf-vc-container">
|
||||
<div id="vc-file-design-placeholder" class="vc-file-design-placeholder">
|
||||
<span class="wpmf-vc-message">
|
||||
' . esc_html__('WP Media Folder media download. Select a media and transform it into a download button', 'wpmf') . '
|
||||
</span>
|
||||
</div>
|
||||
</div>';
|
||||
} else {
|
||||
$align = (!empty($atts['align'])) ? $atts['align'] : 'left';
|
||||
$html = do_shortcode('[wpmffiledesign url="' . esc_attr($atts['url']) . '" align="' . esc_attr($align) . '"]');
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
new WpmfBakerySingleFile();
|
||||
}
|
||||
@@ -0,0 +1,407 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
|
||||
/**
|
||||
* Element Description: VC Gallery
|
||||
*/
|
||||
if (class_exists('WPBakeryShortCode')) {
|
||||
/**
|
||||
* Class WpmfBakeryGallery
|
||||
*/
|
||||
class WpmfBakeryGallery extends WPBakeryShortCode
|
||||
{
|
||||
/**
|
||||
* WpmfBakeryGallery constructor.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct() // phpcs:ignore Squiz.Scope.MethodScope.Missing -- Method extends from WPBakeryShortCode class
|
||||
{
|
||||
// Stop all if VC is not enabled
|
||||
if (!defined('WPB_VC_VERSION')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$main_class = wpmfGetMainClass();
|
||||
$settings = wpmfGetOption('gallery_settings');
|
||||
$getFolders = $main_class->getAttachmentTerms('builder');
|
||||
$folders = $getFolders['attachment_terms'];
|
||||
$folders_order = $getFolders['attachment_terms_order'];
|
||||
$list_cloud = array();
|
||||
$list_local = array();
|
||||
foreach ($folders_order as $folder_order) {
|
||||
$folder = $folders[$folder_order];
|
||||
if ($folder['id'] !== 0) {
|
||||
if (!isset($folder['depth'])) {
|
||||
$folder['depth'] = 0;
|
||||
}
|
||||
|
||||
$label = str_repeat('--', $folder['depth']) . $folder['label'];
|
||||
if (isset($folder['drive_type']) && $folder['drive_type'] !== '') {
|
||||
$list_cloud[$label] = $folder['id'];
|
||||
} else {
|
||||
$list_local[$label] = $folder['id'];
|
||||
}
|
||||
} else {
|
||||
$list_local[$folder['label']] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Map the block with vc_map()
|
||||
vc_map(
|
||||
array(
|
||||
'name' => esc_html__('WPMF Gallery', 'wpmf'),
|
||||
'description' => esc_html__('Responsive image gallery with themes', 'wpmf'),
|
||||
'base' => 'vc_wpmf_gallery',
|
||||
'category' => 'JoomUnited',
|
||||
'icon' => WPMF_PLUGIN_URL . '/assets/images/gallery-bakery.svg',
|
||||
'front_enqueue_js' => array(
|
||||
WPMF_PLUGIN_URL . 'assets/js/slick/slick.min.js',
|
||||
WPMF_PLUGIN_URL . '/assets/js/vc_front.js'
|
||||
),
|
||||
'front_enqueue_css' => array(
|
||||
WPMF_PLUGIN_URL . 'assets/js/slick/slick.css',
|
||||
WPMF_PLUGIN_URL . 'assets/js/slick/slick-theme.css',
|
||||
WPMF_PLUGIN_URL . '/assets/css/display-gallery/style-display-gallery.css',
|
||||
),
|
||||
'params' => array(
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'heading' => esc_html__('Theme', 'wpmf'),
|
||||
'param_name' => 'theme',
|
||||
'class' => 'wpmf_vc_dropdown',
|
||||
'value' => array(
|
||||
esc_html__('Default', 'wpmf') => 'default',
|
||||
esc_html__('Masonry', 'wpmf') => 'masonry',
|
||||
esc_html__('Portfolio', 'wpmf') => 'portfolio',
|
||||
esc_html__('Slider', 'wpmf') => 'slider'
|
||||
),
|
||||
'std' => 'masonry',
|
||||
'group' => esc_html__('General', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'attach_images',
|
||||
'heading' => esc_html__('Images', 'wpmf'),
|
||||
'param_name' => 'items',
|
||||
'value' => '',
|
||||
'description' => esc_html__('Select images from media library.', 'wpmf'),
|
||||
'dependency' => array(
|
||||
'element' => 'source',
|
||||
'value' => 'media_library',
|
||||
),
|
||||
'group' => esc_html__('General', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'heading' => esc_html__('Aspect ratio', 'wpmf'),
|
||||
'description' => esc_html__('Aspect ratio for default, slider, portfolio theme', 'wpmf'),
|
||||
'param_name' => 'aspect_ratio',
|
||||
'class' => 'wpmf_vc_dropdown',
|
||||
'std' => 'default',
|
||||
'value' => array(
|
||||
esc_html__('Default', 'wpmf') => 'default',
|
||||
'1:1' => '1_1',
|
||||
'3:2' => '3_2',
|
||||
'2:3' => '2_3',
|
||||
'4:3' => '4_3',
|
||||
'3:4' => '3_4',
|
||||
'16:9' => '16_9',
|
||||
'9:16' => '9_16',
|
||||
'21:9' => '21_9',
|
||||
'9:21' => '9_21'
|
||||
),
|
||||
'group' => esc_html__('General', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'wpmf_number',
|
||||
'heading' => esc_html__('Columns', 'wpmf'),
|
||||
'param_name' => 'columns',
|
||||
'value' => $settings['theme']['masonry_theme']['columns'],
|
||||
'min' => 1,
|
||||
'max' => 8,
|
||||
'step' => 1,
|
||||
'edit_field_class' => 'vc_col-sm-6',
|
||||
'group' => esc_html__('General', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'wpmf_number',
|
||||
'heading' => esc_html__('Gutter', 'wpmf'),
|
||||
'param_name' => 'gutterwidth',
|
||||
'value' => 5,
|
||||
'min' => 0,
|
||||
'max' => 100,
|
||||
'step' => 5,
|
||||
'edit_field_class' => 'vc_col-sm-6',
|
||||
'group' => esc_html__('General', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'textfield',
|
||||
'heading' => esc_html__('Image size', 'wpmf'),
|
||||
'param_name' => 'size',
|
||||
'value' => $settings['theme']['masonry_theme']['size'],
|
||||
'description' => esc_html__('Enter image size. Example: thumbnail, medium, large, full or other sizes defined by current theme. Alternatively enter image size in pixels: 200x100 (Width x Height). Leave empty to use "medium" size.', 'wpmf'),
|
||||
'dependency' => array(
|
||||
'element' => 'source',
|
||||
'value' => 'media_library',
|
||||
),
|
||||
'group' => esc_html__('General', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'heading' => esc_html__('Crop image', 'wpmf'),
|
||||
'description' => esc_html__('Only apply for slider theme', 'wpmf'),
|
||||
'param_name' => 'crop_image',
|
||||
'value' => array(esc_html__('Yes', 'wpmf') => 'yes'),
|
||||
'group' => esc_html__('General', 'wpmf'),
|
||||
'dependency' => array(
|
||||
'element' => 'theme',
|
||||
'value' => 'slider',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'heading' => esc_html__('Action On Click', 'wpmf'),
|
||||
'param_name' => 'link',
|
||||
'class' => 'wpmf_vc_dropdown',
|
||||
'std' => $settings['theme']['masonry_theme']['link'],
|
||||
'value' => array(
|
||||
esc_html__('Lightbox', 'wpmf') => 'file',
|
||||
esc_html__('Attachment Page', 'wpmf') => 'post',
|
||||
esc_html__('None', 'wpmf') => 'none'
|
||||
),
|
||||
'group' => esc_html__('General', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'textfield',
|
||||
'heading' => esc_html__('Lightbox size', 'wpmf'),
|
||||
'param_name' => 'targetsize',
|
||||
'value' => $settings['theme']['masonry_theme']['targetsize'],
|
||||
'description' => esc_html__('Enter image size. Example: thumbnail, medium, large, full or other sizes defined by current theme. Alternatively enter image size in pixels: 200x100 (Width x Height). Leave empty to use "large" size.', 'wpmf'),
|
||||
'dependency' => array(
|
||||
'element' => 'source',
|
||||
'value' => 'media_library',
|
||||
),
|
||||
'group' => esc_html__('General', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'heading' => esc_html__('Order by', 'wpmf'),
|
||||
'param_name' => 'orderby',
|
||||
'class' => 'wpmf_vc_dropdown',
|
||||
'std' => $settings['theme']['masonry_theme']['orderby'],
|
||||
'value' => array(
|
||||
esc_html__('Custom', 'wpmf') => 'post__in',
|
||||
esc_html__('Random', 'wpmf') => 'rand',
|
||||
esc_html__('Title', 'wpmf') => 'title',
|
||||
esc_html__('Date', 'wpmf') => 'date'
|
||||
),
|
||||
'edit_field_class' => 'vc_col-sm-6',
|
||||
'group' => esc_html__('General', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'heading' => esc_html__('Order', 'wpmf'),
|
||||
'param_name' => 'order',
|
||||
'class' => 'wpmf_vc_dropdown',
|
||||
'std' => $settings['theme']['masonry_theme']['order'],
|
||||
'value' => array(
|
||||
esc_html__('Ascending', 'wpmf') => 'ASC',
|
||||
esc_html__('Descending', 'wpmf') => 'DESC'
|
||||
),
|
||||
'edit_field_class' => 'vc_col-sm-6',
|
||||
'group' => esc_html__('General', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'wpmf_number',
|
||||
'heading' => esc_html__('Border Radius', 'wpmf'),
|
||||
'param_name' => 'border_radius',
|
||||
'value' => 0,
|
||||
'min' => 0,
|
||||
'max' => 20,
|
||||
'step' => 1,
|
||||
'group' => esc_html__('Border', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'wpmf_number',
|
||||
'heading' => esc_html__('Border Width', 'wpmf'),
|
||||
'param_name' => 'border_width',
|
||||
'value' => 0,
|
||||
'min' => 0,
|
||||
'max' => 30,
|
||||
'step' => 1,
|
||||
'group' => esc_html__('Border', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'heading' => esc_html__('Border Type', 'wpmf'),
|
||||
'param_name' => 'border_style',
|
||||
'class' => 'wpmf_vc_dropdown',
|
||||
'std' => 'solid',
|
||||
'value' => array(
|
||||
esc_html__('Solid', 'wpmf') => 'solid',
|
||||
esc_html__('Double', 'wpmf') => 'double',
|
||||
esc_html__('Dotted', 'wpmf') => 'dotted',
|
||||
esc_html__('Dashed', 'wpmf') => 'dashed',
|
||||
esc_html__('Groove', 'wpmf') => 'groove'
|
||||
),
|
||||
'group' => esc_html__('Border', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'colorpicker',
|
||||
'heading' => esc_html__('Border Color', 'wpmf'),
|
||||
'param_name' => 'border_color',
|
||||
'edit_field_class' => 'vc_col-sm-6',
|
||||
'std' => '#cccccc',
|
||||
'group' => esc_html__('Border', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'heading' => esc_html__('Enable', 'wpmf'),
|
||||
'param_name' => 'enable_shadow',
|
||||
'value' => array(esc_html__('Yes', 'wpmf') => 'yes'),
|
||||
'group' => esc_html__('Shadow', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'wpmf_number',
|
||||
'heading' => esc_html__('Horizontal', 'wpmf'),
|
||||
'param_name' => 'shadow_horizontal',
|
||||
'value' => 0,
|
||||
'min' => -50,
|
||||
'max' => 50,
|
||||
'step' => 1,
|
||||
'edit_field_class' => 'vc_col-sm-6',
|
||||
'group' => esc_html__('Shadow', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'wpmf_number',
|
||||
'heading' => esc_html__('Vertical', 'wpmf'),
|
||||
'param_name' => 'shadow_vertical',
|
||||
'value' => 0,
|
||||
'min' => -50,
|
||||
'max' => 50,
|
||||
'step' => 1,
|
||||
'edit_field_class' => 'vc_col-sm-6',
|
||||
'group' => esc_html__('Shadow', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'wpmf_number',
|
||||
'heading' => esc_html__('Blur', 'wpmf'),
|
||||
'param_name' => 'shadow_blur',
|
||||
'value' => 0,
|
||||
'min' => 0,
|
||||
'max' => 50,
|
||||
'step' => 1,
|
||||
'edit_field_class' => 'vc_col-sm-6',
|
||||
'group' => esc_html__('Shadow', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'wpmf_number',
|
||||
'heading' => esc_html__('Spread', 'wpmf'),
|
||||
'param_name' => 'shadow_spread',
|
||||
'value' => 0,
|
||||
'min' => 0,
|
||||
'max' => 50,
|
||||
'step' => 1,
|
||||
'edit_field_class' => 'vc_col-sm-6',
|
||||
'group' => esc_html__('Shadow', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'colorpicker',
|
||||
'heading' => esc_html__('Shadow Color', 'wpmf'),
|
||||
'param_name' => 'shadow_color',
|
||||
'edit_field_class' => 'vc_col-sm-6',
|
||||
'std' => '#cccccc',
|
||||
'group' => esc_html__('Shadow', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'heading' => esc_html__('Enable', 'wpmf'),
|
||||
'param_name' => 'gallery_folders',
|
||||
'value' => array(esc_html__('Yes', 'wpmf') => 'yes'),
|
||||
'group' => esc_html__('Gallery From folder', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'heading' => esc_html__('Select a Folder', 'wpmf'),
|
||||
'param_name' => 'gallery_folder_id',
|
||||
'class' => 'wpmf_vc_dropdown',
|
||||
'std' => 0,
|
||||
'value' => $list_local + $list_cloud,
|
||||
'group' => esc_html__('Gallery From folder', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'heading' => esc_html__('Include images from subfolder', 'wpmf'),
|
||||
'param_name' => 'include_children',
|
||||
'value' => array(esc_html__('Yes', 'wpmf') => 'yes'),
|
||||
'group' => esc_html__('Gallery From folder', 'wpmf')
|
||||
),
|
||||
|
||||
)
|
||||
)
|
||||
);
|
||||
add_shortcode('vc_wpmf_gallery', array($this, 'vcWpmfGalleryHtml'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Render html
|
||||
*
|
||||
* @param array $atts Param details
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function vcWpmfGalleryHtml($atts)
|
||||
{
|
||||
if (empty($atts['items']) && (empty($atts['gallery_folders']) || (!empty($atts['gallery_folders']) && empty($atts['gallery_folder_id'])))) {
|
||||
$html = '<div class="wpmf-vc-container">
|
||||
<div id="vc-gallery-placeholder" class="vc-gallery-placeholder">
|
||||
<span class="wpmf-vc-message">
|
||||
' . esc_html__('Please add some images to the gallery to activate the preview', 'wpmf') . '
|
||||
</span>
|
||||
</div>
|
||||
</div>';
|
||||
} else {
|
||||
$items = (!empty($atts['items'])) ? $atts['items'] : '';
|
||||
$theme = (!empty($atts['theme'])) ? $atts['theme'] : 'masonry';
|
||||
$aspect_ratio = (!empty($atts['aspect_ratio'])) ? $atts['aspect_ratio'] : 'default';
|
||||
$columns = (!empty($atts['columns'])) ? $atts['columns'] : 3;
|
||||
$size = (!empty($atts['size'])) ? $atts['size'] : 'medium';
|
||||
$crop_image = (isset($atts['crop_image']) && $atts['crop_image'] === 'yes') ? 1 : 0;
|
||||
$targetsize = (!empty($atts['targetsize'])) ? $atts['targetsize'] : 'large';
|
||||
$link = (!empty($atts['link'])) ? $atts['link'] : 'file';
|
||||
$orderby = (!empty($atts['orderby'])) ? $atts['orderby'] : 'post__in';
|
||||
$order = (!empty($atts['order'])) ? $atts['order'] : 'ASC';
|
||||
$gutterwidth = (!empty($atts['gutterwidth'])) ? $atts['gutterwidth'] : 5;
|
||||
$border_radius = (!empty($atts['border_radius'])) ? $atts['border_radius'] : 0;
|
||||
$border_style = (!empty($atts['border_style'])) ? $atts['border_style'] : 'solid';
|
||||
$border_width = (!empty($atts['border_width'])) ? $atts['border_width'] : 0;
|
||||
$border_color = (!empty($atts['border_color'])) ? $atts['border_color'] : '#cccccc';
|
||||
$enable_shadow = (isset($atts['enable_shadow']) && $atts['enable_shadow'] === 'yes') ? true : false;
|
||||
$shadow_horizontal = (!empty($atts['shadow_horizontal'])) ? $atts['shadow_horizontal'] : 0;
|
||||
$shadow_vertical = (!empty($atts['shadow_vertical'])) ? $atts['shadow_vertical'] : 0;
|
||||
$shadow_blur = (!empty($atts['shadow_blur'])) ? $atts['shadow_blur'] : 0;
|
||||
$shadow_spread = (!empty($atts['shadow_spread'])) ? $atts['shadow_spread'] : 0;
|
||||
$shadow_color = (!empty($atts['shadow_color'])) ? $atts['shadow_color'] : '#cccccc';
|
||||
|
||||
if ($enable_shadow) {
|
||||
$img_shadow = $shadow_horizontal . 'px ' . $shadow_vertical . 'px ' . $shadow_blur . 'px ' . $shadow_spread . 'px ' . $shadow_color;
|
||||
} else {
|
||||
$img_shadow = '';
|
||||
}
|
||||
$gallery_folders = (isset($atts['gallery_folders']) && $atts['gallery_folders'] === 'yes') ? 1 : 0;
|
||||
$include_children = (isset($atts['include_children']) && $atts['include_children'] === 'yes') ? 1 : 0;
|
||||
$folder_id = (!empty($atts['gallery_folder_id'])) ? $atts['gallery_folder_id'] : 0;
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- No action, nonce is not required
|
||||
if (isset($_REQUEST['vc_editable'])) {
|
||||
$html = do_shortcode('[wpmf_gallery include="'. esc_attr($items) .'" display="' . esc_attr($theme) . '" columns="' . esc_attr($columns) . '" size="' . esc_attr($size) . '" targetsize="' . esc_attr($targetsize) . '" link="none" wpmf_orderby="' . esc_attr($orderby) . '" wpmf_order="' . esc_attr($order) . '" gutterwidth="' . esc_attr($gutterwidth) . '" img_border_radius="' . esc_attr($border_radius) . '" border_width="' . esc_attr($border_width) . '" border_style="' . esc_attr($border_style) . '" border_color="' . esc_attr($border_color) . '" img_shadow="' . esc_attr($img_shadow) . '" wpmf_autoinsert="' . esc_attr($gallery_folders) . '" include_children="' . esc_attr($include_children) . '" wpmf_folder_id="' . esc_attr($folder_id) . '" crop_image="'. $crop_image .'" aspect_ratio="' . esc_attr($aspect_ratio) . '"]');
|
||||
} else {
|
||||
$html = do_shortcode('[wpmf_gallery include="'. esc_attr($items) .'" display="' . esc_attr($theme) . '" columns="' . esc_attr($columns) . '" size="' . esc_attr($size) . '" targetsize="' . esc_attr($targetsize) . '" link="' . esc_attr($link) . '" wpmf_orderby="' . esc_attr($orderby) . '" wpmf_order="' . esc_attr($order) . '" gutterwidth="' . esc_attr($gutterwidth) . '" img_border_radius="' . esc_attr($border_radius) . '" border_width="' . esc_attr($border_width) . '" border_style="' . esc_attr($border_style) . '" border_color="' . esc_attr($border_color) . '" img_shadow="' . esc_attr($img_shadow) . '" wpmf_autoinsert="' . esc_attr($gallery_folders) . '" include_children="' . esc_attr($include_children) . '" wpmf_folder_id="' . esc_attr($folder_id) . '" crop_image="'. $crop_image .'" aspect_ratio="' . esc_attr($aspect_ratio) . '"]');
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
new WpmfBakeryGallery();
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
|
||||
/**
|
||||
* Element Description: VC PDF Embed
|
||||
*/
|
||||
if (class_exists('WPBakeryShortCode')) {
|
||||
/**
|
||||
* Class WpmfBakeryPdfEmbed
|
||||
*/
|
||||
class WpmfBakeryPdfEmbed extends WPBakeryShortCode
|
||||
{
|
||||
/**
|
||||
* WpmfBakeryPdfEmbed constructor.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct() // phpcs:ignore Squiz.Scope.MethodScope.Missing -- Method extends from WPBakeryShortCode class
|
||||
{
|
||||
// Stop all if VC is not enabled
|
||||
if (!defined('WPB_VC_VERSION')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Map the block with vc_map()
|
||||
vc_map(
|
||||
array(
|
||||
'name' => esc_html__('WPMF PDF Embed', 'wpmf'),
|
||||
'description' => esc_html__('Display PDF embed', 'wpmf'),
|
||||
'base' => 'vc_pdf_embed',
|
||||
'category' => 'JoomUnited',
|
||||
'icon' => WPMF_PLUGIN_URL . '/assets/images/pdf_embed-bakery.svg',
|
||||
'admin_enqueue_js' => WPMF_PLUGIN_URL . '/assets/js/vc_script.js',
|
||||
'front_enqueue_js' => WPMF_PLUGIN_URL . '/assets/js/vc_script.js',
|
||||
'params' => array(
|
||||
array(
|
||||
'type' => 'wpmf_media',
|
||||
'block_name' => 'pdfembed_url',
|
||||
'heading' => esc_html__('URL', 'wpmf'),
|
||||
'class' => 'wpmf_vc_select_pdf vc_general vc_ui-button vc_ui-button-success',
|
||||
'button_label' => esc_html__('Select a PDF', 'wpmf'),
|
||||
'param_name' => 'url',
|
||||
'value' => '',
|
||||
'group' => esc_html__('Settings', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'heading' => esc_html__('Embed', 'wpmf'),
|
||||
'param_name' => 'embed',
|
||||
'class' => 'wpmf_vc_dropdown',
|
||||
'std' => 'on',
|
||||
'value' => array(
|
||||
esc_html__('On', 'wpmf') => 'on',
|
||||
esc_html__('Off', 'wpmf') => 'off'
|
||||
),
|
||||
'group' => esc_html__('Settings', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'dropdown',
|
||||
'heading' => esc_html__('Target', 'wpmf'),
|
||||
'param_name' => 'target',
|
||||
'class' => 'wpmf_vc_dropdown',
|
||||
'std' => 'self',
|
||||
'value' => array(
|
||||
esc_html__('New Window', 'wpmf') => '_blank',
|
||||
esc_html__('Same Window', 'wpmf') => 'self'
|
||||
),
|
||||
'group' => esc_html__('Settings', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'textfield',
|
||||
'heading' => esc_html__('Width', 'wpmf'),
|
||||
'param_name' => 'width',
|
||||
'value' => '',
|
||||
'edit_field_class' => 'vc_col-sm-6',
|
||||
'group' => esc_html__('Settings', 'wpmf')
|
||||
),
|
||||
array(
|
||||
'type' => 'textfield',
|
||||
'heading' => esc_html__('Height', 'wpmf'),
|
||||
'param_name' => 'height',
|
||||
'value' => '',
|
||||
'edit_field_class' => 'vc_col-sm-6',
|
||||
'group' => esc_html__('Settings', 'wpmf')
|
||||
),
|
||||
)
|
||||
)
|
||||
);
|
||||
add_shortcode('vc_pdf_embed', array($this, 'vcPdfEmbedHtml'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Render html
|
||||
*
|
||||
* @param array $atts Param details
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function vcPdfEmbedHtml($atts)
|
||||
{
|
||||
if (empty($atts['url'])) {
|
||||
$html = '<div class="wpmf-vc-container">
|
||||
<div id="vc-pdf-embed-placeholder" class="vc-pdf-embed-placeholder">
|
||||
<span class="wpmf-vc-message">
|
||||
' . esc_html__('Please select a PDF file to activate the preview', 'wpmf') . '
|
||||
</span>
|
||||
</div>
|
||||
</div>';
|
||||
} else {
|
||||
$embed = (!empty($atts['embed'])) ? $atts['embed'] : 'on';
|
||||
$target = (!empty($atts['target'])) ? $atts['target'] : 'self';
|
||||
$width = (!empty($atts['width'])) ? $atts['width'] : '';
|
||||
$height = (!empty($atts['height'])) ? $atts['height'] : '';
|
||||
$html = do_shortcode('[wpmfpdf url="' . esc_url($atts['url']) . '" width="'. (int)$width .'" height="'. (int)$height .'" embed="' . esc_attr($embed) . '" target="' . esc_attr($target) . '"]');
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
new WpmfBakeryPdfEmbed();
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
|
||||
/**
|
||||
* Class WpmfDuplicateFile
|
||||
* This class that holds most of the duplicate functionality for Media Folder.
|
||||
*/
|
||||
class WpmfDuplicateFile
|
||||
{
|
||||
|
||||
/**
|
||||
* Wpmf_Duplicate_File constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
add_action('wp_enqueue_media', array($this, 'enqueueAdminScripts'));
|
||||
add_action('wp_ajax_wpmf_duplicate_file', array($this, 'duplicateFile'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Includes styles and scripts
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enqueueAdminScripts()
|
||||
{
|
||||
wp_enqueue_script('duplicate-image');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax duplicate attachment
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function duplicateFile()
|
||||
{
|
||||
if (empty($_POST['wpmf_nonce'])
|
||||
|| !wp_verify_nonce($_POST['wpmf_nonce'], 'wpmf_nonce')) {
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter check capability of current user to duplicate a file
|
||||
*
|
||||
* @param boolean The current user has the given capability
|
||||
* @param string Action name
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @ignore Hook already documented
|
||||
*/
|
||||
$wpmf_capability = apply_filters('wpmf_user_can', current_user_can('upload_files'), 'duplicate_file');
|
||||
if (!$wpmf_capability) {
|
||||
wp_send_json(false);
|
||||
}
|
||||
if (isset($_POST['id']) && is_numeric($_POST['id'])) {
|
||||
$id = (int) $_POST['id'];
|
||||
$post = get_post($id);
|
||||
if (empty($post)) {
|
||||
wp_send_json(array('status' => false, 'message' => __('This post is not exists', 'wpmf')));
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'orderby' => 'name',
|
||||
'order' => 'ASC',
|
||||
'fields' => 'ids'
|
||||
);
|
||||
$terms_parent = wp_get_object_terms($post->ID, WPMF_TAXO, $args);
|
||||
$alt_post = get_post_meta($id, '_wp_attachment_image_alt', true);
|
||||
$file_path = get_attached_file($id);
|
||||
if (!file_exists($file_path)) {
|
||||
wp_send_json(array('status' => false, 'message' => __('File does not exist', 'wpmf')));
|
||||
}
|
||||
$infos_url = pathinfo($post->guid);
|
||||
$mime_type = get_post_mime_type($id);
|
||||
$infos_path = pathinfo($file_path);
|
||||
$name = $infos_path['basename'];
|
||||
$filename = wp_unique_filename($infos_path['dirname'], $name);
|
||||
$upload = copy($file_path, $infos_path['dirname'] . '/' . $filename);
|
||||
if ($upload) {
|
||||
$attachment = array(
|
||||
'guid' => $infos_url['dirname'] . '/' . $filename,
|
||||
'post_mime_type' => $mime_type,
|
||||
'post_title' => $post->post_title,
|
||||
'post_content' => $post->post_content,
|
||||
'post_excerpt' => $post->post_excerpt,
|
||||
'post_status' => 'inherit'
|
||||
);
|
||||
|
||||
// insert attachment
|
||||
$attach_id = wp_insert_attachment($attachment, $infos_path['dirname'] . '/' . $filename);
|
||||
// set term
|
||||
if (!empty($terms_parent)) {
|
||||
foreach ($terms_parent as $term_id) {
|
||||
wp_set_object_terms($attach_id, $term_id, WPMF_TAXO, true);
|
||||
|
||||
/**
|
||||
* Duplicate an attachment
|
||||
*
|
||||
* @param integer Attachment ID
|
||||
* @param integer Target folder
|
||||
*/
|
||||
do_action('wpmf_duplicate_attachment', $attach_id, $term_id);
|
||||
}
|
||||
}
|
||||
$attach_data = wp_generate_attachment_metadata($attach_id, $infos_path['dirname'] . '/' . $filename);
|
||||
wp_update_attachment_metadata($attach_id, $attach_data);
|
||||
update_post_meta($attach_id, '_wp_attachment_image_alt', $alt_post);
|
||||
wp_send_json(array('status' => true, 'message' => __('Duplicated file ', 'wpmf') . $name));
|
||||
}
|
||||
wp_send_json(array('status' => false, 'message' => __('Error duplicated file', 'wpmf')));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
|
||||
/**
|
||||
* Class WpmfFilterSize
|
||||
* This class do filter file by size for Media Folder.
|
||||
*/
|
||||
class WpmfFilterSize
|
||||
{
|
||||
|
||||
/**
|
||||
* Wpmf_Filter_Size constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Filter attachments when requesting posts
|
||||
add_action('pre_get_posts', array($this, 'filterAttachments'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter attachments
|
||||
*
|
||||
* @param object $query Params use to query attachment
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function filterAttachments($query)
|
||||
{
|
||||
// Only filter attachments post type
|
||||
if (!isset($query->query_vars['post_type']) || $query->query_vars['post_type'] !== 'attachment') {
|
||||
return $query;
|
||||
}
|
||||
|
||||
if (!empty($query->query_vars['wpmf_gallery']) || !empty($query->query_vars['wpmf_download_folder'])) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
// We are on the upload page
|
||||
global $pagenow;
|
||||
if ($pagenow === 'upload.php') {
|
||||
return $this->uploadPageFilter($query);
|
||||
}
|
||||
|
||||
// It could be an ajax request
|
||||
return $this->modalFilter($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter attachments for modal windows and upload.php in grid mode
|
||||
* More generally handle attachment queries via ajax requests
|
||||
*
|
||||
* @param object $query Params use to query attachment
|
||||
*
|
||||
* @return mixed $query
|
||||
*/
|
||||
protected function modalFilter($query)
|
||||
{
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended -- No action, nonce is not required
|
||||
$sizes = array('all');
|
||||
$weights = array('all');
|
||||
$parse_url = parse_url(site_url());
|
||||
$host = md5($parse_url['host']);
|
||||
// load file type filter from cookie
|
||||
if (!isset($_REQUEST['query']['wpmf_size'])) {
|
||||
if (isset($_COOKIE['wpmf_wpmf_size' . $host]) && $_COOKIE['wpmf_wpmf_size' . $host] !== '' && $_COOKIE['wpmf_wpmf_size' . $host] !== 'all') {
|
||||
$sizes = explode(',', $_COOKIE['wpmf_wpmf_size' . $host]);
|
||||
}
|
||||
} else {
|
||||
$sizes = explode(',', $_REQUEST['query']['wpmf_size']);
|
||||
}
|
||||
|
||||
if (!isset($_REQUEST['query']['wpmf_weight'])) {
|
||||
if (isset($_COOKIE['wpmf_wpmf_weight' . $host]) && $_COOKIE['wpmf_wpmf_weight' . $host] !== '' && $_COOKIE['wpmf_wpmf_weight' . $host] !== 'all') {
|
||||
$weights = explode(',', $_COOKIE['wpmf_wpmf_weight' . $host]);
|
||||
}
|
||||
} else {
|
||||
$weights = explode(',', $_REQUEST['query']['wpmf_weight']);
|
||||
}
|
||||
|
||||
if (in_array('all', $sizes) && in_array('all', $weights)) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
$post_ids = $this->getSize($sizes, $weights);
|
||||
if (!empty($post_ids)) {
|
||||
$query->query_vars['post__in'] = $post_ids;
|
||||
}
|
||||
// phpcs:enable
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query attachment by size and weight for upload.php page
|
||||
* Base on /wp-includes/class-wp-query.php
|
||||
*
|
||||
* @param object $query Params use to query attachment
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function uploadPageFilter($query)
|
||||
{
|
||||
$sizes = array('all');
|
||||
$weights = array('all');
|
||||
$parse_url = parse_url(site_url());
|
||||
$host = md5($parse_url['host']);
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Recommended -- No action, nonce is not required
|
||||
if (!isset($_GET['attachment_sizes'])) {
|
||||
if (isset($_COOKIE['wpmf_wpmf_size' . $host]) && $_COOKIE['wpmf_wpmf_size' . $host] !== '' && $_COOKIE['wpmf_wpmf_size' . $host] !== 'all') {
|
||||
$sizes = explode(',', $_COOKIE['wpmf_wpmf_size' . $host]);
|
||||
}
|
||||
} else {
|
||||
$sizes = explode(',', $_GET['attachment_sizes']);
|
||||
}
|
||||
|
||||
if (!isset($_GET['attachment_weights'])) {
|
||||
if (isset($_COOKIE['wpmf_wpmf_weight' . $host]) && $_COOKIE['wpmf_wpmf_weight' . $host] !== '' && $_COOKIE['wpmf_wpmf_weight' . $host] !== 'all') {
|
||||
$weights = explode(',', $_COOKIE['wpmf_wpmf_weight' . $host]);
|
||||
}
|
||||
} else {
|
||||
$weights = explode(',', $_GET['attachment_weights']);
|
||||
}
|
||||
// phpcs:enable
|
||||
|
||||
if ((in_array('all', $sizes) || in_array('', $sizes)) && (in_array('all', $weights) || in_array('', $weights))) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
$post_ids = $this->getSize($sizes, $weights);
|
||||
if (!empty($post_ids)) {
|
||||
$query->query_vars['post__in'] = $post_ids;
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attachment size
|
||||
*
|
||||
* @param array $sizes Width x height of file
|
||||
* @param array $weights Min-weight - max-weight of file
|
||||
*
|
||||
* @return array $post_ids
|
||||
*/
|
||||
protected function getSize($sizes, $weights)
|
||||
{
|
||||
$width_lists = array();
|
||||
$height_lists = array();
|
||||
$weight_lists = array();
|
||||
foreach ($sizes as $single_size) {
|
||||
if ($single_size !== 'all' && $single_size !== '') {
|
||||
$size = explode('x', $single_size);
|
||||
$width_lists[] = (float) $size[0];
|
||||
$height_lists[] = (float) $size[1];
|
||||
}
|
||||
}
|
||||
|
||||
$min_width = (!empty($width_lists)) ? min($width_lists) : 0;
|
||||
$min_height = (!empty($height_lists)) ? min($height_lists) : 0;
|
||||
foreach ($weights as $single_weight) {
|
||||
if ($single_weight !== 'all' && $single_weight !== '') {
|
||||
$weight = explode('-', $single_weight);
|
||||
$weight_lists[] = array((float) $weight[0], (float) $weight[1]);
|
||||
}
|
||||
}
|
||||
|
||||
$post_ids = array(0);
|
||||
$upload_dir = wp_upload_dir();
|
||||
global $wpdb;
|
||||
$attachments = $wpdb->get_results($wpdb->prepare(
|
||||
'SELECT ID FROM ' . $wpdb->prefix . 'posts WHERE post_type = %s ',
|
||||
array('attachment')
|
||||
));
|
||||
foreach ($attachments as $attachment) {
|
||||
$meta_img = wp_get_attachment_metadata($attachment->ID);
|
||||
$meta = get_post_meta($attachment->ID, '_wp_attached_file');
|
||||
if (isset($meta[0])) {
|
||||
$url_path = $upload_dir['basedir'] . '/' . $meta[0];
|
||||
if (isset($meta_img['filesize'])) {
|
||||
$weight_att = $meta_img['filesize'];
|
||||
} elseif (file_exists($url_path)) {
|
||||
$weight_att = filesize($url_path);
|
||||
} else {
|
||||
$weight_att = 0;
|
||||
}
|
||||
} else {
|
||||
$weight_att = 0;
|
||||
}
|
||||
|
||||
// Not an image
|
||||
if (!is_array($meta_img)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (empty($meta_img['width'])) {
|
||||
$meta_img['width'] = 0;
|
||||
}
|
||||
|
||||
if (empty($meta_img['height'])) {
|
||||
$meta_img['height'] = 0;
|
||||
}
|
||||
|
||||
if (empty($weights) || in_array('all', $weights)) {
|
||||
if ((float) $meta_img['width'] >= $min_width || (float) $meta_img['height'] >= $min_height) {
|
||||
if (substr(get_post_mime_type($attachment->ID), 0, 5) === 'image') {
|
||||
$post_ids[] = $attachment->ID;
|
||||
}
|
||||
}
|
||||
} elseif (empty($sizes) || in_array('all', $sizes)) {
|
||||
if (!empty($weight_lists)) {
|
||||
foreach ($weight_lists as $weight_filter) {
|
||||
if ((float) $weight_att >= $weight_filter[0] && (float) $weight_att <= $weight_filter[1]) {
|
||||
$post_ids[] = $attachment->ID;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$post_ids[] = $attachment->ID;
|
||||
}
|
||||
} else {
|
||||
$find = false;
|
||||
if (!empty($weight_lists)) {
|
||||
foreach ($weight_lists as $weight_filter) {
|
||||
if ((float) $weight_att >= $weight_filter[0] && (float) $weight_att <= $weight_filter[1]) {
|
||||
$find = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$find = true;
|
||||
}
|
||||
|
||||
if (((float) $meta_img['width'] >= $min_width || (float) $meta_img['height'] >= $min_height)
|
||||
&& $find
|
||||
) {
|
||||
if (substr(get_post_mime_type($attachment->ID), 0, 5) === 'image') {
|
||||
$post_ids[] = $attachment->ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $post_ids;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
use Joomunited\WPMediaFolder\WpmfHelper;
|
||||
|
||||
/**
|
||||
* Class WpmfFolderAccess
|
||||
*/
|
||||
class WpmfFolderAccess
|
||||
{
|
||||
/**
|
||||
* WpmfFolderAccess constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
add_action('init', array($this, 'createUserFolder'));
|
||||
add_filter('wp_generate_attachment_metadata', array($this, 'autoAddAttachmentToFolder'), 10, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create user folder
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function createUserFolder()
|
||||
{
|
||||
// insert term when user login and enable option 'Display only media by User/User'
|
||||
global $current_user;
|
||||
$user_roles = $current_user->roles;
|
||||
$role = array_shift($user_roles);
|
||||
/**
|
||||
* Filter check capability of current user when create user folder
|
||||
*
|
||||
* @param boolean The current user has the given capability
|
||||
* @param string Action name
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @ignore Hook already documented
|
||||
*/
|
||||
$wpmf_capability = apply_filters('wpmf_user_can', current_user_can('upload_files'), 'create_user_folder');
|
||||
if (($role !== 'administrator' && $wpmf_capability) || $role === 'employer') {
|
||||
$wpmf_create_folder = get_option('wpmf_create_folder');
|
||||
if ($wpmf_create_folder === 'user') {
|
||||
$slug = sanitize_title($current_user->data->user_login) . '-wpmf';
|
||||
$check_term = get_term_by('slug', $slug, WPMF_TAXO);
|
||||
if (empty($check_term)) {
|
||||
$parent = $this->getUserParentFolder();
|
||||
$this->doCreateUserFolder($current_user->data->user_login, $slug, $parent, $current_user);
|
||||
}
|
||||
|
||||
$google_connect = WpmfHelper::isConnected('google_drive');
|
||||
$dropbox_connect = WpmfHelper::isConnected('dropbox');
|
||||
$onedrive_connect = WpmfHelper::isConnected('onedrive');
|
||||
$onedrive_business_connect = WpmfHelper::isConnected('onedrive_business');
|
||||
if ($google_connect) {
|
||||
$is_exist = get_term_by('slug', $current_user->data->user_login . '-wpmf-google_drive', WPMF_TAXO);
|
||||
if (empty($is_exist)) {
|
||||
$parent = WpmfHelper::getCloudRootFolderID('google_drive');
|
||||
if ($parent) {
|
||||
$this->doCreateUserFolder($current_user->data->user_login, $current_user->data->user_login . '-wpmf-google_drive', $parent, $current_user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($dropbox_connect) {
|
||||
$is_exist = get_term_by('slug', $current_user->data->user_login . '-wpmf-dropbox', WPMF_TAXO);
|
||||
if (empty($is_exist)) {
|
||||
$parent = WpmfHelper::getCloudRootFolderID('dropbox');
|
||||
if ($parent) {
|
||||
$this->doCreateUserFolder($current_user->data->user_login, $current_user->data->user_login . '-wpmf-dropbox', $parent, $current_user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($onedrive_connect) {
|
||||
$is_exist = get_term_by('slug', $current_user->data->user_login . '-wpmf-onedrive', WPMF_TAXO);
|
||||
if (empty($is_exist)) {
|
||||
$parent = WpmfHelper::getCloudRootFolderID('onedrive');
|
||||
if ($parent) {
|
||||
$this->doCreateUserFolder($current_user->data->user_login, $current_user->data->user_login . '-wpmf-onedrive', $parent, $current_user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($onedrive_business_connect) {
|
||||
$is_exist = get_term_by('slug', $current_user->data->user_login . '-wpmf-onedrive_business', WPMF_TAXO);
|
||||
if (empty($is_exist)) {
|
||||
$parent = WpmfHelper::getCloudRootFolderID('onedrive_business');
|
||||
if ($parent) {
|
||||
$this->doCreateUserFolder($current_user->data->user_login, $current_user->data->user_login . '-wpmf-onedrive_business', $parent, $current_user);
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($wpmf_create_folder === 'role') {
|
||||
$slug = sanitize_title($role) . '-wpmf-role';
|
||||
$check_term = get_term_by('slug', $slug, WPMF_TAXO);
|
||||
if (empty($check_term)) {
|
||||
$inserted = wp_insert_term($role, WPMF_TAXO, array('parent' => 0, 'slug' => $slug));
|
||||
if (!is_wp_error($inserted)) {
|
||||
$role = WpmfHelper::getRoles($current_user->data->ID);
|
||||
add_term_meta((int)$inserted['term_id'], 'wpmf_folder_role_permissions', array($role, 'add_media', 'move_media', 'view_folder', 'add_folder', 'update_folder', 'remove_folder', 'view_media', 'remove_media', 'update_media'));
|
||||
do_action('wpmf_create_folder', $inserted['term_id'], $role, 0, array('trigger' => 'media_library_action'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$google_connect = WpmfHelper::isConnected('google_drive');
|
||||
$dropbox_connect = WpmfHelper::isConnected('dropbox');
|
||||
$onedrive_connect = WpmfHelper::isConnected('onedrive');
|
||||
$onedrive_business_connect = WpmfHelper::isConnected('onedrive_business');
|
||||
if ($google_connect) {
|
||||
$options = get_option('_wpmfAddon_cloud_config');
|
||||
if (!empty($options['access_by']) && $options['access_by'] === 'user') {
|
||||
$is_exist = get_term_by('slug', $current_user->data->user_login . '-wpmf-google_drive', WPMF_TAXO);
|
||||
$name = $current_user->data->user_login;
|
||||
$slug = $current_user->data->user_login . '-wpmf-google_drive';
|
||||
$type = '';
|
||||
} else {
|
||||
$is_exist = get_term_by('slug', $role . '-wpmf-role-google_drive', WPMF_TAXO);
|
||||
$name = $role;
|
||||
$slug = $role . '-wpmf-role-google_drive';
|
||||
$type = 'role';
|
||||
}
|
||||
|
||||
if (empty($is_exist)) {
|
||||
$parent = WpmfHelper::getCloudRootFolderID('google_drive');
|
||||
if ($parent) {
|
||||
$this->doCreateUserFolder($name, $slug, $parent, $current_user, $type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($dropbox_connect) {
|
||||
$options = get_option('_wpmfAddon_dropbox_config');
|
||||
if (!empty($options['access_by']) && $options['access_by'] === 'user') {
|
||||
$is_exist = get_term_by('slug', $current_user->data->user_login . '-wpmf-dropbox', WPMF_TAXO);
|
||||
$name = $current_user->data->user_login;
|
||||
$slug = $current_user->data->user_login . '-wpmf-dropbox';
|
||||
$type = '';
|
||||
} else {
|
||||
$is_exist = get_term_by('slug', $role . '-wpmf-role-dropbox', WPMF_TAXO);
|
||||
$name = $role;
|
||||
$slug = $role . '-wpmf-role-dropbox';
|
||||
$type = 'role';
|
||||
}
|
||||
|
||||
if (empty($is_exist)) {
|
||||
$parent = WpmfHelper::getCloudRootFolderID('dropbox');
|
||||
if ($parent) {
|
||||
$this->doCreateUserFolder($name, $slug, $parent, $current_user, $type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($onedrive_connect) {
|
||||
$options = get_option('_wpmfAddon_onedrive_config');
|
||||
if (!empty($options['access_by']) && $options['access_by'] === 'user') {
|
||||
$is_exist = get_term_by('slug', $current_user->data->user_login . '-wpmf-onedrive', WPMF_TAXO);
|
||||
$name = $current_user->data->user_login;
|
||||
$slug = $current_user->data->user_login . '-wpmf-onedrive';
|
||||
$type = '';
|
||||
} else {
|
||||
$is_exist = get_term_by('slug', $role . '-wpmf-role-onedrive', WPMF_TAXO);
|
||||
$name = $role;
|
||||
$slug = $role . '-wpmf-role-onedrive';
|
||||
$type = 'role';
|
||||
}
|
||||
|
||||
if (empty($is_exist)) {
|
||||
$parent = WpmfHelper::getCloudRootFolderID('onedrive');
|
||||
if ($parent) {
|
||||
$this->doCreateUserFolder($name, $slug, $parent, $current_user, $type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($onedrive_business_connect) {
|
||||
$options = get_option('_wpmfAddon_onedrive_business_config');
|
||||
if (!empty($options['access_by']) && $options['access_by'] === 'user') {
|
||||
$is_exist = get_term_by('slug', $current_user->data->user_login . '-wpmf-onedrive_business', WPMF_TAXO);
|
||||
$name = $current_user->data->user_login;
|
||||
$slug = $current_user->data->user_login . '-wpmf-onedrive_business';
|
||||
$type = '';
|
||||
} else {
|
||||
$is_exist = get_term_by('slug', $role . '-wpmf-role-onedrive_business', WPMF_TAXO);
|
||||
$name = $role;
|
||||
$slug = $role . '-wpmf-role-onedrive_business';
|
||||
$type = 'role';
|
||||
}
|
||||
|
||||
if (empty($is_exist)) {
|
||||
$parent = WpmfHelper::getCloudRootFolderID('onedrive_business');
|
||||
if ($parent) {
|
||||
$this->doCreateUserFolder($name, $slug, $parent, $current_user, $type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do create user folder
|
||||
*
|
||||
* @param string $name Folder name
|
||||
* @param string $slug Folder slug
|
||||
* @param integer $parent Folder parent
|
||||
* @param object $current_user Current_user
|
||||
* @param string $type Type
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function doCreateUserFolder($name, $slug, $parent, $current_user, $type = 'user')
|
||||
{
|
||||
$inserted = wp_insert_term(
|
||||
$name,
|
||||
WPMF_TAXO,
|
||||
array('parent' => $parent, 'slug' => $slug)
|
||||
);
|
||||
if (!is_wp_error($inserted)) {
|
||||
if ($type === 'user') {
|
||||
wp_update_term($inserted['term_id'], WPMF_TAXO, array('term_group' => $current_user->data->ID));
|
||||
add_term_meta((int)$inserted['term_id'], 'wpmf_folder_user_permissions', array($current_user->data->ID, 'add_media', 'move_media', 'view_folder', 'add_folder', 'update_folder', 'remove_folder', 'view_media', 'remove_media', 'update_media'));
|
||||
add_term_meta((int)$inserted['term_id'], 'inherit_folder', 0);
|
||||
} else {
|
||||
$role = WpmfHelper::getRoles($current_user->data->ID);
|
||||
add_term_meta((int)$inserted['term_id'], 'wpmf_folder_role_permissions', array($role, 'add_media', 'move_media', 'view_folder', 'add_folder', 'update_folder', 'remove_folder', 'view_media', 'remove_media', 'update_media'));
|
||||
add_term_meta((int)$inserted['term_id'], 'inherit_folder', 0);
|
||||
}
|
||||
|
||||
// do_action('wpmf_create_folder', $inserted['term_id'], $name, $parent, array('trigger' => 'media_library_action'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto add attachment to folder
|
||||
*
|
||||
* @param array $data Meta data
|
||||
* @param integer $post_id Attachment ID
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function autoAddAttachmentToFolder($data, $post_id)
|
||||
{
|
||||
$active_media = get_option('wpmf_active_media');
|
||||
if (isset($active_media) && (int) $active_media === 1) {
|
||||
$wpmf_create_folder = get_option('wpmf_create_folder');
|
||||
if ($wpmf_create_folder === 'user') {
|
||||
global $wpdb, $current_user;
|
||||
if (!empty($current_user->ID)) {
|
||||
$user_login = $current_user->data->user_login;
|
||||
$user_roles = $current_user->roles;
|
||||
$role = array_shift($user_roles);
|
||||
if ($role === 'employer') {
|
||||
$parent = $this->getUserParentFolder();
|
||||
$user_folder = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->terms . ' as t INNER JOIN ' . $wpdb->term_taxonomy . ' AS tt ON tt.term_id = t.term_id WHERE t.name = %s AND t.term_group = %d AND tt.parent = %d AND tt.taxonomy = %s', array($user_login, (int) $current_user->ID, (int) $parent, WPMF_TAXO)));
|
||||
if (!empty($user_folder)) {
|
||||
wp_set_object_terms($post_id, $user_folder->term_id, WPMF_TAXO, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user parent folder
|
||||
*
|
||||
* @return integer|mixed|void
|
||||
*/
|
||||
public function getUserParentFolder()
|
||||
{
|
||||
$wpmf_checkbox_tree = get_option('wpmf_checkbox_tree');
|
||||
$parent = 0;
|
||||
if (!empty($wpmf_checkbox_tree)) {
|
||||
$current_parrent = get_term($wpmf_checkbox_tree, WPMF_TAXO);
|
||||
if (!empty($current_parrent)) {
|
||||
$parent = $wpmf_checkbox_tree;
|
||||
}
|
||||
}
|
||||
|
||||
return $parent;
|
||||
}
|
||||
}
|
||||
2300
wp/wp-content/plugins/wp-media-folder/class/class-helper.php
Normal file
2300
wp/wp-content/plugins/wp-media-folder/class/class-helper.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,808 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
|
||||
/**
|
||||
* Class WpmfWatermark
|
||||
* This class that holds most of the image watermark functionality for Media Folder.
|
||||
*/
|
||||
class WpmfWatermark
|
||||
{
|
||||
/**
|
||||
* Allow logo file extension to add watermark
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $allowed_ext = array('jpg', 'jpeg', 'png', 'gif');
|
||||
|
||||
/**
|
||||
* Wpmf_Watermark constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
add_action('wp_ajax_wpmf_watermark_regeneration', array($this, 'regeneratePictures'));
|
||||
add_filter('wp_generate_attachment_metadata', array($this, 'createWatermarkImage'), 10, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create watermark image after upload image
|
||||
*
|
||||
* @param array $metadata An array of attachment meta data.
|
||||
* @param integer $attachment_id Current attachment ID.
|
||||
*
|
||||
* @return mixed $metadata
|
||||
*/
|
||||
public function createWatermarkImage($metadata, $attachment_id)
|
||||
{
|
||||
$option_image_watermark = get_option('wpmf_option_image_watermark');
|
||||
if (empty($option_image_watermark)) {
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
$post_upload = get_post($attachment_id);
|
||||
if (isset($post_upload->post_mime_type) && strpos($post_upload->post_mime_type, 'image') === false) {
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
if (!empty($attachment_id)) {
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing -- No action, nonce is not required
|
||||
$galleryid = (int)$_POST['up_gallery_id'];
|
||||
if (is_plugin_active('wp-media-folder-gallery-addon/wp-media-folder-gallery-addon.php')) {
|
||||
$watermark_exclude_public_gallery = wpmfGetOption('watermark_exclude_public_gallery');
|
||||
$watermark_exclude_photograph_gallery = wpmfGetOption('watermark_exclude_photograph_gallery');
|
||||
$check = false;
|
||||
if (!empty($watermark_exclude_public_gallery)) {
|
||||
if (!empty($galleryid)) {
|
||||
$gallery_type = get_term_meta((int)$galleryid, 'gallery_type', true);
|
||||
if (!empty($gallery_type) && $gallery_type === 'photographer') {
|
||||
$check = true;
|
||||
}
|
||||
}
|
||||
if (!$check) {
|
||||
return $metadata;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($watermark_exclude_photograph_gallery)) {
|
||||
if (!empty($galleryid)) {
|
||||
$gallery_type = get_term_meta((int)$galleryid, 'gallery_type', true);
|
||||
if (!empty($gallery_type) && $gallery_type === 'photographer') {
|
||||
$check = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($check) {
|
||||
return $metadata;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$current_attachment = get_post($attachment_id);
|
||||
if (empty($current_attachment)) {
|
||||
return $metadata;
|
||||
}
|
||||
$watermark_apply = get_option('wpmf_image_watermark_apply');
|
||||
$exclude_folders = wpmfGetOption('watermark_exclude_folders');
|
||||
$excludes = array();
|
||||
foreach (array_unique($exclude_folders) as $folder) {
|
||||
if ($folder === 'root') {
|
||||
$excludes[] = 0;
|
||||
} else {
|
||||
if ((int) $folder !== 0) {
|
||||
$excludes[] = (int) $folder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$folderIDs = array();
|
||||
$terms = get_the_terms($attachment_id, WPMF_TAXO);
|
||||
if (empty($terms)) {
|
||||
$folderIDs[] = 0;
|
||||
} else {
|
||||
foreach ($terms as $term) {
|
||||
$folderIDs[] = $term->term_id;
|
||||
}
|
||||
}
|
||||
|
||||
$same_value = array_intersect($excludes, $folderIDs);
|
||||
if (!empty($same_value)) {
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
$uploads = wp_upload_dir();
|
||||
$imageInfo = 0;
|
||||
if (isset($watermark_apply['all_size']) && (int) $watermark_apply['all_size'] === 1) {
|
||||
$sizes = array('full');
|
||||
foreach ($metadata['sizes'] as $si => $size_info) {
|
||||
$sizes[] = $si;
|
||||
}
|
||||
|
||||
foreach ($sizes as $imageSize) {
|
||||
$image_url = '';
|
||||
if ($imageSize === 'full') {
|
||||
$image_url = $uploads['baseurl'] . '/' . $metadata['file'];
|
||||
} else {
|
||||
if (isset($metadata['sizes'][$imageSize])) {
|
||||
$image_url = $uploads['url'] . '/' . $metadata['sizes'][$imageSize]['file'];
|
||||
}
|
||||
}
|
||||
// Using the wp_upload_dir replace the baseurl with the basedir
|
||||
$path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_url);
|
||||
if (!empty($path)) {
|
||||
$pathinfo = pathinfo($path);
|
||||
$imageInfo = getimagesize($path);
|
||||
}
|
||||
|
||||
try {
|
||||
if (!empty($pathinfo)) {
|
||||
$this->generatePicture($pathinfo['basename'], $imageInfo, $pathinfo['dirname'], $imageSize);
|
||||
} else {
|
||||
wp_send_json(array('status' => false));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
wp_send_json(array('status' => false));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($watermark_apply as $imageSize => $value) {
|
||||
// Using the wp_upload_dir replace the baseurl with the basedir
|
||||
$infos = pathinfo($current_attachment->guid);
|
||||
// Using the wp_upload_dir replace the baseurl with the basedir
|
||||
if (empty($value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$image_url = '';
|
||||
if ($imageSize === 'full') {
|
||||
$image_url = $uploads['baseurl'] . '/' . $metadata['file'];
|
||||
} else {
|
||||
if (isset($metadata['sizes'][$imageSize])) {
|
||||
$image_url = $uploads['url'] . '/' . $metadata['sizes'][$imageSize]['file'];
|
||||
}
|
||||
}
|
||||
// Using the wp_upload_dir replace the baseurl with the basedir
|
||||
$path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_url);
|
||||
if (!empty($path)) {
|
||||
$pathinfo = pathinfo($path);
|
||||
$imageInfo = getimagesize($path);
|
||||
}
|
||||
|
||||
try {
|
||||
if (!empty($pathinfo)) {
|
||||
$this->generatePicture($pathinfo['basename'], $imageInfo, $pathinfo['dirname'], $imageSize);
|
||||
} else {
|
||||
wp_send_json(array('status' => false));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
wp_send_json(array('status' => false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax create watermark image
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function regeneratePictures()
|
||||
{
|
||||
if (empty($_POST['wpmf_nonce'])
|
||||
|| !wp_verify_nonce($_POST['wpmf_nonce'], 'wpmf_nonce')) {
|
||||
die();
|
||||
}
|
||||
|
||||
set_time_limit(0);
|
||||
/**
|
||||
* Filter check capability of current user to create watermark image
|
||||
*
|
||||
* @param boolean The current user has the given capability
|
||||
* @param string Action name
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @ignore Hook already documented
|
||||
*/
|
||||
$wpmf_capability = apply_filters('wpmf_user_can', current_user_can('upload_files'), 'render_watermark');
|
||||
if (!$wpmf_capability) {
|
||||
wp_send_json(false);
|
||||
}
|
||||
global $wpdb;
|
||||
$limit = 1;
|
||||
$offset = ((int) $_POST['paged'] - 1) * $limit;
|
||||
$logo_image_id = get_option('wpmf_watermark_image_id', 0);
|
||||
$count_images = $wpdb->get_var($wpdb->prepare(
|
||||
'SELECT COUNT(ID) FROM ' . $wpdb->posts . "
|
||||
WHERE post_type = 'attachment' AND ID != %d
|
||||
AND post_mime_type LIKE %s AND guid NOT LIKE %s",
|
||||
array($logo_image_id, 'image%', '%.svg')
|
||||
));
|
||||
$present = (100 / $count_images) * $limit;
|
||||
$k = 0;
|
||||
|
||||
$args = array(
|
||||
'posts_per_page' => $limit,
|
||||
'offset' => $offset,
|
||||
'post_type' => 'attachment',
|
||||
'post_mime_type' => array('image/jpg', 'image/jpeg', 'image/png', 'image/webp'),
|
||||
'post_status' => 'any',
|
||||
'orderby' => 'ID',
|
||||
'order' => 'DESC',
|
||||
'meta_query' => array(
|
||||
'relation' => 'AND',
|
||||
array(
|
||||
'key' => 'wpmf_drive_id',
|
||||
'compare' => 'NOT EXISTS'
|
||||
),
|
||||
array(
|
||||
'key' => 'wpmf_awsS3_info',
|
||||
'compare' => 'NOT EXISTS'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$uploads = wp_upload_dir();
|
||||
$tax_query = array();
|
||||
$excludes = array();
|
||||
$exclude_folders = wpmfGetOption('watermark_exclude_folders');
|
||||
$watermark_apply = get_option('wpmf_image_watermark_apply');
|
||||
foreach (array_unique($exclude_folders) as $folder) {
|
||||
if ($folder === 'root') {
|
||||
$excludes[] = 0;
|
||||
$root_id = get_option('wpmf_folder_root_id');
|
||||
$tax_query[] = array(
|
||||
'taxonomy' => WPMF_TAXO,
|
||||
'field' => 'term_id',
|
||||
'terms' => (int)$root_id,
|
||||
'operator' => 'NOT IN'
|
||||
);
|
||||
} else {
|
||||
if ((int) $folder !== 0) {
|
||||
$excludes[] = (int)$folder;
|
||||
}
|
||||
$tax_query[] = array(
|
||||
'taxonomy' => WPMF_TAXO,
|
||||
'field' => 'term_id',
|
||||
'terms' => (int)$folder,
|
||||
'operator' => 'NOT IN'
|
||||
);
|
||||
}
|
||||
}
|
||||
if (!empty($tax_query)) {
|
||||
$tax_query['relation'] = 'AND';
|
||||
$args['tax_query'] = $tax_query;
|
||||
}
|
||||
|
||||
$query = new WP_Query($args);
|
||||
$attachments = $query->get_posts();
|
||||
if (empty($attachments)) {
|
||||
wp_send_json(array('status' => 'ok', 'paged' => 0));
|
||||
}
|
||||
|
||||
if (empty($watermark_apply)) {
|
||||
wp_send_json(array('status' => false));
|
||||
}
|
||||
if (!empty($attachments)) {
|
||||
foreach ($attachments as $attachment) {
|
||||
// exclude watermark on gallery
|
||||
if (is_plugin_active('wp-media-folder-gallery-addon/wp-media-folder-gallery-addon.php')) {
|
||||
$watermark_exclude_public_gallery = wpmfGetOption('watermark_exclude_public_gallery');
|
||||
$watermark_exclude_photograph_gallery = wpmfGetOption('watermark_exclude_photograph_gallery');
|
||||
$check = false;
|
||||
if (!empty($watermark_exclude_public_gallery)) {
|
||||
$gallery_terms = get_the_terms($attachment->ID, WPMF_GALLERY_ADDON_TAXO);
|
||||
if (!empty($gallery_terms)) {
|
||||
foreach ($gallery_terms as $gallery_term) {
|
||||
$gallery_type = get_term_meta((int)$gallery_term->term_id, 'gallery_type', true);
|
||||
if (!empty($gallery_type) && $gallery_type === 'photographer') {
|
||||
$check = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$check) {
|
||||
$k ++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($watermark_exclude_photograph_gallery)) {
|
||||
$gallery_terms = get_the_terms($attachment->ID, WPMF_GALLERY_ADDON_TAXO);
|
||||
if (!empty($gallery_terms)) {
|
||||
foreach ($gallery_terms as $gallery_term) {
|
||||
$gallery_type = get_term_meta((int)$gallery_term->term_id, 'gallery_type', true);
|
||||
if (!empty($gallery_type) && $gallery_type === 'photographer') {
|
||||
$check = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($check) {
|
||||
$k ++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$full_path = get_attached_file($attachment->ID);
|
||||
// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Ignore warning php if file not exist or not have permission
|
||||
if ((int) $logo_image_id === (int) $attachment->ID || !@file_exists($full_path)) {
|
||||
$k ++;
|
||||
continue;
|
||||
}
|
||||
|
||||
$terms = get_the_terms($attachment->ID, WPMF_TAXO);
|
||||
$folderIDs = array();
|
||||
if (empty($terms)) {
|
||||
$folderIDs[] = 0;
|
||||
} else {
|
||||
foreach ($terms as $term) {
|
||||
$folderIDs[] = (int) $term->term_id;
|
||||
}
|
||||
}
|
||||
|
||||
$same_value = array_intersect($excludes, $folderIDs);
|
||||
if (!empty($same_value)) {
|
||||
$k ++;
|
||||
continue;
|
||||
}
|
||||
|
||||
$check_remote = get_post_meta($attachment->ID, 'wpmf_remote_video_link');
|
||||
if (empty($check_remote)) {
|
||||
if (isset($watermark_apply['all_size']) && (int) $watermark_apply['all_size'] === 1) {
|
||||
$sizes = array_merge(array('full'), get_intermediate_image_sizes());
|
||||
foreach ($sizes as $imageSize) {
|
||||
$image_object = wp_get_attachment_image_src($attachment->ID, $imageSize);
|
||||
// Isolate the url
|
||||
$image_url = $image_object[0];
|
||||
// Using the wp_upload_dir replace the baseurl with the basedir
|
||||
$path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_url);
|
||||
$pathinfo = pathinfo($path);
|
||||
$imageInfo = getimagesize($path);
|
||||
try {
|
||||
$this->generatePicture($pathinfo['basename'], $imageInfo, $pathinfo['dirname'], $imageSize);
|
||||
} catch (Exception $e) {
|
||||
wp_send_json(array('status' => 'limit', 'percent' => $present));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($watermark_apply as $imageSize => $value) {
|
||||
// Isolate the url
|
||||
$metadata = get_post_meta($attachment->ID, '_wp_attachment_metadata', true);
|
||||
if (!isset($metadata['sizes'][$imageSize]) && $imageSize !== 'full') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$infos = pathinfo($attachment->guid);
|
||||
// Using the wp_upload_dir replace the baseurl with the basedir
|
||||
if ($imageSize === 'full') {
|
||||
$path = $full_path;
|
||||
} else {
|
||||
$path = str_replace(
|
||||
$infos['basename'],
|
||||
$metadata['sizes'][$imageSize]['file'],
|
||||
$full_path
|
||||
);
|
||||
}
|
||||
|
||||
if (!file_exists($path)) {
|
||||
wp_send_json(array('status' => 'limit', 'percent' => $present));
|
||||
}
|
||||
|
||||
$pathinfo = pathinfo($path);
|
||||
$imageInfo = getimagesize($path);
|
||||
if ((int) $value === 1) {
|
||||
try {
|
||||
$this->generatePicture($pathinfo['basename'], $imageInfo, $pathinfo['dirname'], $imageSize);
|
||||
} catch (Exception $e) {
|
||||
wp_send_json(array('status' => 'limit', 'percent' => $present));
|
||||
}
|
||||
} else {
|
||||
$check_name_wtm = 'imageswatermark';
|
||||
$name_change_file_wtm = pathinfo($pathinfo['basename'], PATHINFO_FILENAME) . $check_name_wtm;
|
||||
$name_change_file_wtm .= '.' . pathinfo($pathinfo['basename'], PATHINFO_EXTENSION);
|
||||
$file = $pathinfo['dirname'] . '/' . $pathinfo['basename'];
|
||||
$newfile = $pathinfo['dirname'] . '/' . $name_change_file_wtm;
|
||||
if (file_exists($newfile)) {
|
||||
unlink($file);
|
||||
copy($newfile, $file);
|
||||
unlink($newfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$k ++;
|
||||
}
|
||||
}
|
||||
if ($k >= $limit) {
|
||||
wp_send_json(array('status' => 'limit', 'percent' => $present));
|
||||
} else {
|
||||
wp_send_json(array('status' => 'ok', 'paged' => 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Picture
|
||||
*
|
||||
* @param string $newname New name of image
|
||||
* @param array $imageInfo Image infomartion
|
||||
* @param string $full_dir Path of image
|
||||
* @param string $wtm_apply_on Image size
|
||||
* @param string $type Type
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function generatePicture($newname, $imageInfo, $full_dir, $wtm_apply_on, $type = '')
|
||||
{
|
||||
$wtm_images = get_option('wpmf_option_image_watermark');
|
||||
//$wtm_apply_on = get_option('wpmf_image_watermark_apply');
|
||||
if ((int) $wtm_images === 0) {
|
||||
$logo_image_id = 0;
|
||||
} else {
|
||||
$logo_image_id = get_option('wpmf_watermark_image_id');
|
||||
}
|
||||
if ((int) $logo_image_id === 0) {
|
||||
$check_image_logo_exit = false;
|
||||
} else {
|
||||
$wtm_image_logo = get_attached_file($logo_image_id);
|
||||
$info_logo = pathinfo($wtm_image_logo);
|
||||
$check_image_logo_exit = true;
|
||||
if (!empty($info_logo['extension']) && !in_array(strtolower($info_logo['extension']), $this->allowed_ext)) {
|
||||
$check_image_logo_exit = false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->copyFileWithNewName($full_dir, $newname, 'initimage');
|
||||
if ($imageInfo['mime'] === 'image/jpeg') {
|
||||
if (!empty($wtm_images) && $check_image_logo_exit) {
|
||||
$this->checkCopyFileWithNewName($full_dir, $newname, $wtm_apply_on, $type);
|
||||
}
|
||||
} elseif ($imageInfo['mime'] === 'image/png') {
|
||||
if (!empty($wtm_images) && $check_image_logo_exit) {
|
||||
$this->checkCopyFileWithNewName($full_dir, $newname, $wtm_apply_on, $type);
|
||||
}
|
||||
} elseif ($imageInfo['mime'] === 'image/gif') {
|
||||
if (!empty($wtm_images) && $check_image_logo_exit) {
|
||||
$this->checkCopyFileWithNewName($full_dir, $newname, $wtm_apply_on, $type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Picture
|
||||
*
|
||||
* @param string $full_dir Path of image
|
||||
* @param string $newname New name of image
|
||||
* @param string $wtm_apply_on The sizes to apply watermark
|
||||
* @param string $type Type
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function checkCopyFileWithNewName($full_dir, $newname, $wtm_apply_on, $type = '')
|
||||
{
|
||||
$this->copyFileWithNewName($full_dir, $newname, $wtm_apply_on, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Picture
|
||||
*
|
||||
* @param string $pathdir Path to file
|
||||
* @param string $fname New file name
|
||||
* @param string $wtmApplyOn The size to apply watermark
|
||||
* @param string $type Type
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function copyFileWithNewName($pathdir, $fname, $wtmApplyOn, $type = '')
|
||||
{
|
||||
$option_image_watermark = get_option('wpmf_option_image_watermark');
|
||||
if ((int) $option_image_watermark === 0) {
|
||||
$add_water = false;
|
||||
} else {
|
||||
$logo_image_id = get_option('wpmf_watermark_image_id');
|
||||
if ((int) $logo_image_id === 0) {
|
||||
$add_water = false;
|
||||
} else {
|
||||
$wtm_image_logo = get_attached_file($logo_image_id);
|
||||
if (file_exists($wtm_image_logo)) {
|
||||
$add_water = true;
|
||||
} else {
|
||||
$add_water = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$wtm_position = get_option('wpmf_watermark_position');
|
||||
$wtm_apply_on = get_option('wpmf_image_watermark_apply');
|
||||
if ($type === 'photographer') {
|
||||
$wtm_apply_on = wpmfGetOption('photograper_image_watermark_apply');
|
||||
}
|
||||
|
||||
$watermark_image_scaling = wpmfGetOption('watermark_image_scaling');
|
||||
$watermark_margin = wpmfGetOption('watermark_margin');
|
||||
$watermark_opacity = wpmfGetOption('watermark_opacity');
|
||||
$watermark_margin_unit = wpmfGetOption('watermark_margin_unit');
|
||||
if ((int) $watermark_opacity > 100) {
|
||||
$watermark_opacity = 100;
|
||||
}
|
||||
|
||||
if ((int) $watermark_opacity < 0) {
|
||||
$watermark_opacity = 0;
|
||||
}
|
||||
|
||||
$watermark_opacity = (int) $watermark_opacity / 100;
|
||||
|
||||
$check_name_wtm = 'imageswatermark';
|
||||
$name_change_file_wtm = pathinfo($fname, PATHINFO_FILENAME) . $check_name_wtm;
|
||||
$name_change_file_wtm .= '.' . pathinfo($fname, PATHINFO_EXTENSION);
|
||||
$file = $pathdir . '/' . $fname;
|
||||
$newfile = $pathdir . '/' . $name_change_file_wtm;
|
||||
if ($wtmApplyOn === 'initimage') {
|
||||
if (file_exists($newfile)) {
|
||||
if (unlink($file)) {
|
||||
if (copy($newfile, $file)) {
|
||||
unlink($newfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($add_water) {
|
||||
if ((int) $wtm_apply_on['all_size'] === 1) {
|
||||
if (file_exists($newfile)) {
|
||||
$this->watermark(
|
||||
$file,
|
||||
$wtm_image_logo,
|
||||
$wtm_position,
|
||||
$watermark_margin,
|
||||
$watermark_image_scaling,
|
||||
$watermark_opacity,
|
||||
$watermark_margin_unit
|
||||
);
|
||||
} else {
|
||||
if (copy($file, $newfile)) {
|
||||
$this->watermark(
|
||||
$file,
|
||||
$wtm_image_logo,
|
||||
$wtm_position,
|
||||
$watermark_margin,
|
||||
$watermark_image_scaling,
|
||||
$watermark_opacity,
|
||||
$watermark_margin_unit
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (empty($wtm_apply_on[$wtmApplyOn])) {
|
||||
if (file_exists($newfile)) {
|
||||
unlink($file);
|
||||
copy($newfile, $file);
|
||||
unlink($newfile);
|
||||
}
|
||||
} else {
|
||||
if (file_exists($newfile)) {
|
||||
if (unlink($file)) {
|
||||
if (copy($newfile, $file)) {
|
||||
$this->watermark(
|
||||
$file,
|
||||
$wtm_image_logo,
|
||||
$wtm_position,
|
||||
$watermark_margin,
|
||||
$watermark_image_scaling,
|
||||
$watermark_opacity,
|
||||
$watermark_margin_unit
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (file_exists($file)) {
|
||||
if (copy($file, $newfile)) {
|
||||
$this->watermark(
|
||||
$file,
|
||||
$wtm_image_logo,
|
||||
$wtm_position,
|
||||
$watermark_margin,
|
||||
$watermark_image_scaling,
|
||||
$watermark_opacity,
|
||||
$watermark_margin_unit
|
||||
);
|
||||
}//
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new image from file or URL
|
||||
*
|
||||
* @param string $image Path to the JPEG image.
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
public function imagecreatefrom($image)
|
||||
{
|
||||
$size = getimagesize($image);
|
||||
// Load image from file
|
||||
switch (strtolower($size['mime'])) {
|
||||
case 'image/jpeg':
|
||||
case 'image/pjpeg':
|
||||
return imagecreatefromjpeg($image);
|
||||
case 'image/png':
|
||||
return imagecreatefrompng($image);
|
||||
case 'image/gif':
|
||||
return imagecreatefromgif($image);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Opacity watermark
|
||||
*
|
||||
* @param resource $imageSrc Image resource. Not being modified.
|
||||
* @param float $opacity Opacity to set from 0 (fully transparent) to 1 (no change)
|
||||
*
|
||||
* @return resource Transparent image resource
|
||||
*/
|
||||
public function imagesetopacity($imageSrc, $opacity)
|
||||
{
|
||||
$width = imagesx($imageSrc);
|
||||
$height = imagesy($imageSrc);
|
||||
|
||||
// Duplicate image and convert to TrueColor
|
||||
$imageDst = imagecreatetruecolor($width, $height);
|
||||
imagealphablending($imageDst, false);
|
||||
imagefill($imageDst, 0, 0, imagecolortransparent($imageDst));
|
||||
imagecopy($imageDst, $imageSrc, 0, 0, 0, 0, $width, $height);
|
||||
|
||||
// Set new opacity to each pixel
|
||||
for ($x = 0; $x < $width; ++$x) {
|
||||
for ($y = 0; $y < $height; ++$y) {
|
||||
$pixelColor = imagecolorat($imageDst, $x, $y);
|
||||
$pixelOpacity = 127 - (($pixelColor >> 24) & 0xFF);
|
||||
if ($pixelOpacity > 0) {
|
||||
$pixelOpacity = $pixelOpacity * $opacity;
|
||||
$pixelColor = ($pixelColor & 0xFFFFFF) | ((int)round(127 - $pixelOpacity) << 24);
|
||||
imagesetpixel($imageDst, $x, $y, $pixelColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $imageDst;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create image with watermark logo
|
||||
*
|
||||
* @param string $image_path Path of image
|
||||
* @param string $logoImage_path Path of logo
|
||||
* @param string $position Possition of logo
|
||||
* @param array $watermark_margin Margin of logo
|
||||
* @param integer $percent Image scaling
|
||||
* @param integer $watermark_opacity Watermark opacity
|
||||
* @param integer $watermark_margin_unit Watermark margin unit
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function watermark($image_path, $logoImage_path, $position, $watermark_margin, $percent, $watermark_opacity, $watermark_margin_unit)
|
||||
{
|
||||
if (!file_exists($image_path)) {
|
||||
die('Image does not exist.');
|
||||
}
|
||||
|
||||
try {
|
||||
// Find base image size
|
||||
$image = $this->imagecreatefrom($image_path);
|
||||
$logoImage = $this->imagecreatefrom($logoImage_path);
|
||||
// opacity watermark
|
||||
if ((int) $watermark_opacity !== 1) {
|
||||
$logoImage = $this->imagesetopacity($logoImage, $watermark_opacity);
|
||||
}
|
||||
|
||||
list($image_x, $image_y) = getimagesize($image_path);
|
||||
list($logo_x, $logo_y) = getimagesize($logoImage_path);
|
||||
$watermark_pos_x = 0;
|
||||
$watermark_pos_y = 0;
|
||||
|
||||
// get image margin
|
||||
if ($watermark_margin_unit === '%') {
|
||||
$percent_watermark_margin = array();
|
||||
$percent_watermark_margin['left'] = ($image_x / 100) * $watermark_margin['left'];
|
||||
$percent_watermark_margin['right'] = ($image_x / 100) * $watermark_margin['right'];
|
||||
$percent_watermark_margin['top'] = ($image_y / 100) * $watermark_margin['top'];
|
||||
$percent_watermark_margin['bottom'] = ($image_y / 100) * $watermark_margin['bottom'];
|
||||
$watermark_margin = $percent_watermark_margin;
|
||||
}
|
||||
|
||||
// set image scaling
|
||||
$r = $logo_x / $logo_y;
|
||||
$new_width = $image_x * (int) $percent / 100;
|
||||
if ($new_width > $logo_x) {
|
||||
$new_width = $logo_x;
|
||||
}
|
||||
|
||||
$new_height = $new_width / $r;
|
||||
if ($new_height > $logo_y) {
|
||||
$new_height = $logo_y;
|
||||
}
|
||||
|
||||
if ($position === 'center' || (int) $position === 0) {
|
||||
$watermark_pos_x = ($image_x - $new_width) / 2; //watermark left
|
||||
$watermark_pos_y = ($image_y - $new_height) / 2; //watermark bottom
|
||||
}
|
||||
if ($position === 'top_left') {
|
||||
$watermark_pos_x = (int) $watermark_margin['left'];
|
||||
$watermark_pos_y = (int) $watermark_margin['top'];
|
||||
}
|
||||
if ($position === 'top_right') {
|
||||
$watermark_pos_x = $image_x - $new_width - (int) $watermark_margin['right'];
|
||||
$watermark_pos_y = (int) $watermark_margin['top'];
|
||||
}
|
||||
if ($position === 'bottom_right') {
|
||||
$watermark_pos_x = $image_x - $new_width - (int) $watermark_margin['right'];
|
||||
$watermark_pos_y = $image_y - $new_height - (int) $watermark_margin['bottom'];
|
||||
}
|
||||
if ($position === 'bottom_left') {
|
||||
$watermark_pos_x = (int) $watermark_margin['left'];
|
||||
$watermark_pos_y = $image_y - $new_height - (int) $watermark_margin['bottom'];
|
||||
}
|
||||
|
||||
imagecopyresampled(
|
||||
$image,
|
||||
$logoImage,
|
||||
$watermark_pos_x,
|
||||
$watermark_pos_y,
|
||||
0,
|
||||
0,
|
||||
$new_width,
|
||||
$new_height,
|
||||
$logo_x,
|
||||
$logo_y
|
||||
);
|
||||
// Output to the browser
|
||||
$imageInfo = getimagesize($image_path);
|
||||
switch (strtolower($imageInfo['mime'])) {
|
||||
case 'image/jpeg':
|
||||
case 'image/pjpeg':
|
||||
header('Content-Type: image/jpeg');
|
||||
imagejpeg($image, $image_path);
|
||||
break;
|
||||
case 'image/png':
|
||||
header('Content-Type: image/png');
|
||||
$background = imagecolorallocate($image, 0, 0, 0);
|
||||
// removing the black from the placeholder
|
||||
imagecolortransparent($image, $background);
|
||||
|
||||
// turning off alpha blending (to ensure alpha channel information
|
||||
// is preserved, rather than removed (blending with the rest of the
|
||||
// image in the form of black))
|
||||
imagealphablending($image, false);
|
||||
|
||||
// turning on alpha channel information saving (to ensure the full range
|
||||
// of transparency is preserved)
|
||||
imagesavealpha($image, true);
|
||||
imagepng($image, $image_path, 9);
|
||||
break;
|
||||
case 'image/gif':
|
||||
header('Content-Type: image/gif');
|
||||
imagegif($image, $image_path);
|
||||
break;
|
||||
case 'image/webp':
|
||||
header('Content-Type: image/gif');
|
||||
imagewebp($image, $image_path);
|
||||
break;
|
||||
default:
|
||||
die('Image is of unsupported type.');
|
||||
}
|
||||
// Destroy the images
|
||||
imagedestroy($image);
|
||||
imagedestroy($logoImage);
|
||||
} catch (Exception $e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
|
||||
/**
|
||||
* Class WpmfLoadGif
|
||||
* This class that holds most of the frontend functionality for load gif file
|
||||
*/
|
||||
class WpmfLoadGif
|
||||
{
|
||||
/**
|
||||
* WpmfLoadGif constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if (!is_admin()) {
|
||||
add_action('wp_enqueue_scripts', array($this, 'enqueue'));
|
||||
}
|
||||
add_filter('the_content', array($this, 'gifReplace'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel gif file load on front end
|
||||
*
|
||||
* @param string $content Current post content
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function gifReplace($content)
|
||||
{
|
||||
if (preg_match_all('/<img [^<>]+ \/>/i', $content, $matches)) {
|
||||
if (isset($matches[0]) && is_array($matches[0])) {
|
||||
foreach ($matches[0] as $img) {
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadHTML($img);
|
||||
$src = $dom->getElementsByTagName('img')->item(0)->getAttribute('src');
|
||||
$still_attach = preg_replace('/\.gif$/', '_still_tmp.jpeg', $src);
|
||||
$alt = $dom->getElementsByTagName('img')->item(0)->getAttribute('alt');
|
||||
$width = $dom->getElementsByTagName('img')->item(0)->getAttribute('width');
|
||||
$class = $dom->getElementsByTagName('img')->item(0)->getAttribute('class');
|
||||
if (empty($src)) {
|
||||
return $content;
|
||||
}
|
||||
$infos = pathinfo($src);
|
||||
if (isset($infos['extension']) && $infos['extension'] === 'gif') {
|
||||
$output = '<div class="gif_wrap ' . $width . '">
|
||||
<a href="javascript:void(0);" class="gif_link_wrap ' . $width . '"
|
||||
title="Click to play" rel="nofollow"></a>
|
||||
<span class="play_gif ' . $width . '">GIF</span>
|
||||
<img src="' . $still_attach . '"
|
||||
class="_showing frame no-lazy ' . $class . '" alt="' . $alt . '">
|
||||
</div>
|
||||
<img src="' . $still_attach . '" class="_hidden no-lazy" alt="' . $alt . '" style="display:none;">';
|
||||
|
||||
$content = str_replace($img, $output, $content);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// otherwise returns the database content
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load script
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue()
|
||||
{
|
||||
if (!is_admin()) {
|
||||
wp_register_script(
|
||||
'wpmf_play_gifs',
|
||||
plugins_url('assets/js/gif/play_gif.js', dirname(__FILE__)),
|
||||
array('jquery'),
|
||||
WPMF_VERSION,
|
||||
true
|
||||
);
|
||||
wp_enqueue_script('wpmf_play_gifs');
|
||||
wp_register_script(
|
||||
'wpmf_spin',
|
||||
plugins_url('assets/js/gif/spin.js', dirname(__FILE__)),
|
||||
array('jquery'),
|
||||
'1.0',
|
||||
true
|
||||
);
|
||||
wp_enqueue_script('wpmf_spin');
|
||||
wp_register_script(
|
||||
'wpmf_spinjQuery',
|
||||
plugins_url('assets/js/gif/jquery.spin.js', dirname(__FILE__)),
|
||||
array('jquery'),
|
||||
'1.0',
|
||||
true
|
||||
);
|
||||
wp_enqueue_script('wpmf_spinjQuery');
|
||||
}
|
||||
}
|
||||
}
|
||||
5641
wp/wp-content/plugins/wp-media-folder/class/class-main.php
Normal file
5641
wp/wp-content/plugins/wp-media-folder/class/class-main.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
use Joomunited\WPMediaFolder\WpmfHelper;
|
||||
|
||||
/**
|
||||
* Class WpmfMediaRename
|
||||
* This class that holds most of the rename file functionality for Media Folder.
|
||||
*/
|
||||
class WpmfMediaRename
|
||||
{
|
||||
/**
|
||||
* WpmfMediaRename constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
add_filter('wp_handle_upload_prefilter', array($this, 'customUploadFilter'));
|
||||
add_filter('wp_generate_attachment_metadata', array($this, 'afterUpload'), 10, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename attachment after upload
|
||||
*
|
||||
* @param array $file An array of data for a single file.
|
||||
*
|
||||
* @return array $file
|
||||
*/
|
||||
public function customUploadFilter($file)
|
||||
{
|
||||
global $pagenow;
|
||||
if (isset($pagenow) && $pagenow === 'update.php') {
|
||||
return $file;
|
||||
}
|
||||
|
||||
$pattern = get_option('wpmf_patern_rename');
|
||||
$upload_dir = wp_upload_dir();
|
||||
$info = pathinfo($file['name']);
|
||||
$parent = 0;
|
||||
$parentFolderName = '';
|
||||
if (!empty($_POST['wpmf_folder'])) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- No action, nonce is not required
|
||||
$parent = (int)$_POST['wpmf_folder']; // phpcs:ignore WordPress.Security.NonceVerification.Missing -- No action, nonce is not required
|
||||
$current_folder = get_term((int) $parent, WPMF_TAXO);
|
||||
$foldername = sanitize_title($current_folder->name);
|
||||
$folderslug = $current_folder->slug;
|
||||
if ($current_folder->parent) {
|
||||
$parentFolder = get_term((int) $current_folder->parent, WPMF_TAXO);
|
||||
$parentFolderName = sanitize_title($parentFolder->name);
|
||||
}
|
||||
} else {
|
||||
$foldername = 'uncategorized';
|
||||
$folderslug = 'uncategorized';
|
||||
}
|
||||
|
||||
$sitename = sanitize_title(get_bloginfo('name'));
|
||||
$original_filename = $info['filename'];
|
||||
$date = trim($upload_dir['subdir'], '/');
|
||||
if ($date === '') {
|
||||
$date = date('Ym', time());
|
||||
}
|
||||
|
||||
$ext = empty($info['extension']) ? '' : '.' . $info['extension'];
|
||||
$format_date = date('Y-m-d H-i-s', current_time('timestamp'));
|
||||
$pattern = str_replace('{sitename}', $sitename, $pattern);
|
||||
$pattern = str_replace('{date}', $date, $pattern);
|
||||
$pattern = str_replace('{original name}', $original_filename, $pattern);
|
||||
$pattern = str_replace('{folderslug}', $folderslug, $pattern);
|
||||
$pattern = str_replace('{parent_folder}', $parentFolderName, $pattern);
|
||||
$pattern = str_replace('{timestamp}', $format_date, $pattern);
|
||||
|
||||
if (strpos($pattern, '#') !== false) {
|
||||
$number = 0;
|
||||
if (strpos($pattern, '{foldername}') !== false) {
|
||||
$pattern = str_replace('{foldername}', $foldername, $pattern);
|
||||
$number_list = get_option('wpmf_rename_number_list');
|
||||
if (isset($number_list[$parent])) {
|
||||
$number = $number_list[$parent];
|
||||
}
|
||||
if (!$number) {
|
||||
$number = 0;
|
||||
}
|
||||
$number++;
|
||||
} else {
|
||||
$number = get_option('wpmf_rename_number');
|
||||
if (!$number) {
|
||||
$number = 0;
|
||||
}
|
||||
$number++;
|
||||
}
|
||||
|
||||
if (strlen($number) === 1) {
|
||||
$number = '0' . $number;
|
||||
}
|
||||
|
||||
$pattern = str_replace('#', $number . $ext, $pattern);
|
||||
$pattern = do_shortcode($pattern);
|
||||
$filename = $pattern;
|
||||
} else {
|
||||
$pattern = str_replace('{foldername}', $foldername, $pattern);
|
||||
$pattern = do_shortcode($pattern);
|
||||
$filename = wp_unique_filename($upload_dir['path'], $pattern . $ext);
|
||||
}
|
||||
|
||||
$file['name'] = $filename;
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update option wpmf_rename_number
|
||||
* Base on /wp-admin/includes/image.php
|
||||
*
|
||||
* @param array $metadata An array of attachment meta data.
|
||||
* @param integer $attachment_id Current attachment ID.
|
||||
*
|
||||
* @return mixed $metadata
|
||||
*/
|
||||
public function afterUpload($metadata, $attachment_id)
|
||||
{
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- No action, nonce is not required
|
||||
if (isset($_POST['wpmf_folder'])) {
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- No action, nonce is not required
|
||||
$parent = (int) $_POST['wpmf_folder'];
|
||||
} else {
|
||||
$parent = 0;
|
||||
}
|
||||
|
||||
$pattern = get_option('wpmf_patern_rename');
|
||||
if (strpos($pattern, '#') !== false && strpos($pattern, '{foldername}') !== false) {
|
||||
$number_list = get_option('wpmf_rename_number_list', false);
|
||||
if (!empty($number_list) && is_array($number_list)) {
|
||||
if (isset($number_list[$parent])) {
|
||||
$number_list[$parent] = (int) $number_list[$parent] + 1;
|
||||
} else {
|
||||
$number_list[$parent] = 1;
|
||||
}
|
||||
} else {
|
||||
$number_list = array();
|
||||
$number_list[$parent] = 1;
|
||||
}
|
||||
update_option('wpmf_rename_number_list', $number_list);
|
||||
} else {
|
||||
$number = get_option('wpmf_rename_number');
|
||||
if (!$number) {
|
||||
$number = 0;
|
||||
}
|
||||
$number++;
|
||||
update_option('wpmf_rename_number', (int) $number);
|
||||
}
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,404 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
use Joomunited\WPMediaFolder\WpmfHelper;
|
||||
|
||||
/**
|
||||
* Class WpmfOrderbyMedia
|
||||
* This class that holds most of the order functionality for Media Folder.
|
||||
*/
|
||||
class WpmfOrderbyMedia
|
||||
{
|
||||
|
||||
/**
|
||||
* Wpmf_Orderby_Media constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
add_filter('manage_media_columns', array($this, 'manageMediaColumns'));
|
||||
add_filter('manage_upload_sortable_columns', array($this, 'imwidthColumnRegisterSortable'));
|
||||
add_filter('manage_media_custom_column', array($this, 'manageMediaCustomColumn'), 10, 2);
|
||||
add_action('pre_get_posts', array($this, 'filter'), 0, 1);
|
||||
add_filter('post_mime_types', array($this, 'modifyPostMimeTypes'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add file type to Filetype filter
|
||||
*
|
||||
* @param array $post_mime_types List of post mime types.
|
||||
*
|
||||
* @return array $post_mime_types
|
||||
*/
|
||||
public function modifyPostMimeTypes($post_mime_types)
|
||||
{
|
||||
if (empty($post_mime_types['wpmf-pdf'])) {
|
||||
$post_mime_types['wpmf-pdf'] = array(__('PDF', 'wpmf'));
|
||||
}
|
||||
|
||||
$post_mime_types['wpmf-other'] = array(__('Other', 'wpmf'));
|
||||
return $post_mime_types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query attachment by file type
|
||||
* Base on /wp-includes/class-wp-query.php
|
||||
*
|
||||
* @param object $query Params use to query attachment
|
||||
*
|
||||
* @return mixed $query
|
||||
*/
|
||||
public function filter($query)
|
||||
{
|
||||
$parse_url = parse_url(site_url());
|
||||
$host = md5($parse_url['host']);
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended -- No action, nonce is not required
|
||||
global $pagenow;
|
||||
if (!isset($query->query_vars['post_type']) || $query->query_vars['post_type'] !== 'attachment') {
|
||||
return $query;
|
||||
}
|
||||
|
||||
if (!empty($query->query_vars['wpmf_gallery']) || !empty($query->query_vars['wpmf_download_folder'])) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
$orderby = 'date';
|
||||
$order = 'DESC';
|
||||
$sort_media = 'all';
|
||||
if ($pagenow === 'upload.php') {
|
||||
if (!empty($_COOKIE['media-order-media' . $host])) {
|
||||
$sort_media = $_COOKIE['media-order-media' . $host];
|
||||
}
|
||||
|
||||
if (isset($_GET['media-order-media'])) {
|
||||
$sort_media = $_GET['media-order-media'];
|
||||
}
|
||||
|
||||
if ($sort_media === 'custom') {
|
||||
$query->set('meta_key', 'wpmf_order');
|
||||
$orderby = 'meta_value_num';
|
||||
$order = 'ASC';
|
||||
} else {
|
||||
if ($sort_media !== 'all') {
|
||||
$sorts = explode('|', $sort_media);
|
||||
$orderby = $sorts[0];
|
||||
$order = $sorts[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_GET['orderby'])) {
|
||||
$orderby = $_GET['orderby'];
|
||||
}
|
||||
|
||||
if (!empty($_GET['order'])) {
|
||||
$order = $_GET['order'];
|
||||
}
|
||||
|
||||
if ($orderby === 'size') {
|
||||
$query->set('meta_key', 'wpmf_size');
|
||||
$query->set('orderby', 'meta_value_num');
|
||||
$query->set('order', $order);
|
||||
} elseif ($orderby === 'filetype') {
|
||||
$query->set('meta_key', 'wpmf_filetype');
|
||||
$query->set('orderby', 'meta_value');
|
||||
$query->set('order', $order);
|
||||
} else {
|
||||
$query->set('orderby', $orderby);
|
||||
$query->set('order', $order);
|
||||
}
|
||||
} else {
|
||||
if (isset($_REQUEST['query']['meta_key']) && isset($_REQUEST['query']['wpmf_orderby'])) {
|
||||
$query->query_vars['meta_key'] = $_REQUEST['query']['meta_key'];
|
||||
$query->query_vars['orderby'] = $_REQUEST['query']['wpmf_orderby'];
|
||||
}
|
||||
$query->query_vars['ignore_custom_sort'] = true;
|
||||
}
|
||||
|
||||
global $pagenow;
|
||||
$dates = array();
|
||||
if (!isset($_GET['attachment_dates']) && !isset($_REQUEST['query']['wpmf_date'])) {
|
||||
if (isset($_COOKIE['wpmf_wpmf_date' . $host]) && $_COOKIE['wpmf_wpmf_date' . $host] !== '' && $_COOKIE['wpmf_wpmf_date' . $host] !== 'all') {
|
||||
$dates = explode(',', $_COOKIE['wpmf_wpmf_date' . $host]);
|
||||
}
|
||||
} else {
|
||||
if ($pagenow === 'upload.php') {
|
||||
if (isset($_GET['attachment_dates'])) {
|
||||
$dates = explode(',', $_GET['attachment_dates']);
|
||||
}
|
||||
} else {
|
||||
if (!empty($_REQUEST['query']['wpmf_date'])) {
|
||||
$dates = explode(',', $_REQUEST['query']['wpmf_date']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($dates)) {
|
||||
$date_query = array();
|
||||
if (!empty($dates)) {
|
||||
$date_query['relation'] = 'OR';
|
||||
foreach ($dates as $date) {
|
||||
if ((int)$date !== 0 && strlen($date) > 4) {
|
||||
$year = substr($date, 0, 4);
|
||||
$month = substr($date, 4, 2);
|
||||
$date_query[] = array(
|
||||
'year' => $year,
|
||||
'month' => $month
|
||||
);
|
||||
}
|
||||
}
|
||||
$query->query_vars['date_query'] = $date_query;
|
||||
}
|
||||
}
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
$filetype = array('all');
|
||||
// Load file type from $query->query_vars
|
||||
// When run WP_Query from other plugin/theme
|
||||
// ex: $media_attachments_query = new WP_Query( 'post_type=attachment&post_mime_type=oembed/gallery&posts_per_page=-1&post_status=any' );
|
||||
if (isset($query->query_vars['post_mime_type'])) {
|
||||
if (is_array($query->query_vars['post_mime_type'])) {
|
||||
$filetype = $query->query_vars['post_mime_type'];
|
||||
} else {
|
||||
$filetype = explode(',', $query->query_vars['post_mime_type']);
|
||||
}
|
||||
} elseif (!isset($_GET['attachment_types']) && !isset($_REQUEST['query']['post_mime_type'])) {
|
||||
// load file type filter from cookie
|
||||
if (isset($_COOKIE['wpmf_post_mime_type' . $host]) && $_COOKIE['wpmf_post_mime_type' . $host] !== '' && $_COOKIE['wpmf_post_mime_type' . $host] !== 'all') {
|
||||
$filetype = $_COOKIE['wpmf_post_mime_type' . $host];
|
||||
if ($filetype !== '') {
|
||||
$filetype = explode(',', $filetype);
|
||||
}
|
||||
}
|
||||
if (in_array('trash', $filetype) && $pagenow === 'upload.php') {
|
||||
$filetype = array();
|
||||
}
|
||||
} else {
|
||||
// load file type filter from url
|
||||
if (!empty($_GET['attachment_types'])) {
|
||||
$filetype = explode(',', $_GET['attachment_types']);
|
||||
}
|
||||
|
||||
// load file type filter from ajax params
|
||||
if (!empty($_REQUEST['query']['post_mime_type'])) {
|
||||
if (is_array($_REQUEST['query']['post_mime_type'])) {
|
||||
$filetype = $_REQUEST['query']['post_mime_type'];
|
||||
} else {
|
||||
$filetype = explode(',', $_REQUEST['query']['post_mime_type']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array('mine', $filetype)) {
|
||||
$query->set('author', $user_id);
|
||||
}
|
||||
|
||||
if (!empty($filetype)) {
|
||||
if (is_array($filetype) && in_array('all', $filetype)) {
|
||||
$query->query_vars['post_mime_type'] = '';
|
||||
return $query;
|
||||
}
|
||||
|
||||
$extensions = array();
|
||||
$mimetypes = array();
|
||||
foreach ($filetype as $ft) {
|
||||
$ft = str_replace('post_mime_type:', '', $ft);
|
||||
if (strpos($ft, 'application/') !== false) {
|
||||
$extensions = array_merge($extensions, array('application'));
|
||||
$mimetypes[] = $ft;
|
||||
}
|
||||
|
||||
if ($ft === 'unattached' || $ft === 'detached') {
|
||||
$query->query_vars['post_parent'] = 0;
|
||||
}
|
||||
|
||||
if ($ft === 'trash') {
|
||||
$query->query_vars['post_status'] = 'trash';
|
||||
}
|
||||
|
||||
if ($ft === 'uploaded') {
|
||||
$query->query_vars['post_parent'] = $_REQUEST['post_id'];
|
||||
}
|
||||
|
||||
if ($ft === 'mine') {
|
||||
$query->query_vars['author'] = $user_id;
|
||||
}
|
||||
|
||||
switch ($ft) {
|
||||
case 'audio':
|
||||
$extensions = array_merge($extensions, wp_get_audio_extensions());
|
||||
break;
|
||||
case 'video':
|
||||
$extensions = array_merge($extensions, wp_get_video_extensions(), array('mpg', 'mov', 'avi', 'wmv', '3gp', '3g2'));
|
||||
break;
|
||||
case 'image':
|
||||
$extensions = array_merge($extensions, array('jpg', 'jpeg', 'jpe', 'gif', 'png', 'webp', 'svg', 'heic', 'heif', 'avif'));
|
||||
break;
|
||||
case 'wpmf-pdf':
|
||||
$extensions = array_merge($extensions, array('pdf'));
|
||||
break;
|
||||
case 'wpmf-other':
|
||||
$extensions = array_merge($extensions, array(
|
||||
'tiff', 'tif', 'ico', 'asf', 'asx', 'wmv',
|
||||
'wmx', 'wm', 'avi', 'divx', 'flv', 'mov',
|
||||
'qt', 'mpeg', 'mpg', 'mpe', 'm4v',
|
||||
'ogv', 'webm', 'mkv', '3gp', '3gpp', '3g2',
|
||||
'3gp2', 'txt', 'asc', 'c', 'cc', 'h', 'srt',
|
||||
'csv', 'tsv', 'ics', 'rtx', 'css', 'html',
|
||||
'htm', 'vtt', 'dfxp', 'm4a', 'm4b',
|
||||
'ra', 'ram', 'ogg', 'oga', 'mid', 'midi',
|
||||
'wma', 'wax', 'mka', 'rtf', 'js', 'class',
|
||||
'gz', '7z', 'psd',
|
||||
'xcf', 'doc', 'pot', 'pps', 'ppt', 'wri', 'xla',
|
||||
'xls', 'xlt', 'xlw', 'mdp', 'mpp', 'docx', 'docm',
|
||||
'dotx', 'xlsx', 'xlsm', 'xlsb', 'xltx', 'xltm',
|
||||
'xlam', 'pptx', 'pptm', 'ppsx', 'ppsm', 'potx',
|
||||
'potm', 'ppam', 'sldx', 'sldm', 'onetoc', 'onetoc2',
|
||||
'onetmp', 'onepkg', 'oxps', 'xps', 'odt', 'odp',
|
||||
'ods', 'odg', 'odc', 'odb', 'odf', 'wp', 'wpd',
|
||||
'key', 'numbers', 'pages'
|
||||
));
|
||||
break;
|
||||
default:
|
||||
$mimetypes[] = $ft;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($extensions)) {
|
||||
foreach ($extensions as $extension) {
|
||||
if ($extension !== 'application') {
|
||||
$mimetype = WpmfHelper::getMimeType($extension);
|
||||
$mimetypes[] = $mimetype;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($mimetypes)) {
|
||||
$query->query_vars['post_mime_type'] = $mimetypes;
|
||||
}
|
||||
} else {
|
||||
if (!empty($filetype) && is_array($filetype) && ($filetype[0] === 'unattached' || $filetype[0] === 'detached' || $filetype[0] === 'uploaded' || $filetype[0] === 'trash')) {
|
||||
$query->query_vars['post_mime_type'] = '';
|
||||
}
|
||||
|
||||
if (!empty($filetype) && is_array($filetype) && $filetype[0] === 'mine') {
|
||||
$query->query_vars['author'] = $user_id;
|
||||
$query->query_vars['post_mime_type'] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
// phpcs:enable
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add size column and filetype column
|
||||
*
|
||||
* @param array $columns An array of columns displayed in the Media list table.
|
||||
*
|
||||
* @return array $columns
|
||||
*/
|
||||
public static function manageMediaColumns($columns)
|
||||
{
|
||||
$columns['wpmf_size'] = __('Size', 'wpmf');
|
||||
$columns['wpmf_filetype'] = __('File type', 'wpmf');
|
||||
$columns['wpmf_iptc'] = __('IPTC Meta', 'wpmf');
|
||||
return $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register sortcolumn
|
||||
*
|
||||
* @param array $columns An array of sort columns.
|
||||
*
|
||||
* @return array $columns
|
||||
*/
|
||||
public function imwidthColumnRegisterSortable($columns)
|
||||
{
|
||||
$columns['wpmf_size'] = 'size';
|
||||
$columns['wpmf_filetype'] = 'filetype';
|
||||
return $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get size and filetype of attachment
|
||||
*
|
||||
* @param integer $pid Id of attachment
|
||||
*
|
||||
* @return array $wpmf_size_filetype
|
||||
*/
|
||||
public function getSizeFiletype($pid)
|
||||
{
|
||||
$wpmf_size_filetype = array();
|
||||
// get path file
|
||||
$filepath = get_attached_file($pid);
|
||||
$info = pathinfo($filepath);
|
||||
// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Ignore warning php if file not exist or not have permission
|
||||
if (@file_exists($filepath)) {
|
||||
// get size
|
||||
$size = filesize($filepath);
|
||||
// get file type
|
||||
$filetype = wp_check_filetype($filepath);
|
||||
$ext = $filetype['ext'];
|
||||
} else {
|
||||
$size = get_post_meta($pid, 'wpmf_size', true);
|
||||
if (empty($size)) {
|
||||
$size = 0;
|
||||
}
|
||||
|
||||
if (isset($info['extension'])) {
|
||||
$ext = $info['extension'];
|
||||
} else {
|
||||
$ext = '';
|
||||
}
|
||||
}
|
||||
|
||||
$wpmf_size_filetype['size'] = $size;
|
||||
$wpmf_size_filetype['ext'] = $ext;
|
||||
return $wpmf_size_filetype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get size and filetype of attachment
|
||||
*
|
||||
* @param string $column_name Column name
|
||||
* @param integer $id Id of attachment
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manageMediaCustomColumn($column_name, $id)
|
||||
{
|
||||
$wpmf_size_filetype = $this->getSizeFiletype($id);
|
||||
$size = $wpmf_size_filetype['size'];
|
||||
$ext = $wpmf_size_filetype['ext'];
|
||||
if ($size < 1024 * 1024) {
|
||||
$size = round($size / 1024, 1) . ' kB';
|
||||
} elseif ($size > 1024 * 1024) {
|
||||
$size = round($size / (1024 * 1024), 1) . ' MB';
|
||||
}
|
||||
|
||||
switch ($column_name) {
|
||||
case 'wpmf_size':
|
||||
echo esc_html($size);
|
||||
break;
|
||||
|
||||
case 'wpmf_filetype':
|
||||
echo esc_html($ext);
|
||||
break;
|
||||
|
||||
case 'wpmf_iptc':
|
||||
$iptc = get_post_meta($id, 'wpmf_iptc', true);
|
||||
$iptchtml = '';
|
||||
if (!empty($iptc)) {
|
||||
$iptcHeaderArray = getIptcHeader();
|
||||
$iptchtml .= '<div class="wpmf_iptc_wrap">';
|
||||
foreach ($iptc as $code => $iptcValue) {
|
||||
$iptchtml .= '<span><b>' . $iptcHeaderArray[$code] . ': </b>'. implode(',', $iptcValue) .'</span><br>';
|
||||
}
|
||||
$iptchtml .= '</div>';
|
||||
}
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput -- Content already escaped in the method
|
||||
echo $iptchtml;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
483
wp/wp-content/plugins/wp-media-folder/class/class-pdf-embed.php
Normal file
483
wp/wp-content/plugins/wp-media-folder/class/class-pdf-embed.php
Normal file
@@ -0,0 +1,483 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
|
||||
/**
|
||||
* Class WpmfPdfEmbed
|
||||
* This class that holds most of the PDF embed functionality for Media Folder.
|
||||
*/
|
||||
class WpmfPdfEmbed
|
||||
{
|
||||
|
||||
/**
|
||||
* Wpmf_Pdf_Embed constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
add_action('wp_enqueue_media', array($this, 'loadScript'));
|
||||
add_action('wp_enqueue_scripts', array($this, 'registerScript'));
|
||||
add_action('wp_enqueue_scripts', array($this, 'loadStyleScript'));
|
||||
add_filter('media_send_to_editor', array($this, 'addImageFiles'), 10, 3);
|
||||
add_filter('attachment_fields_to_edit', array($this, 'attachmentFieldsToEdit'), 10, 2);
|
||||
add_filter('attachment_fields_to_save', array($this, 'attachmentFieldsToSave'), 10, 2);
|
||||
add_action('enqueue_block_editor_assets', array($this, 'addEditorAssets'));
|
||||
add_shortcode('wpmfpdf', array($this, 'wpmfPdf'));
|
||||
add_filter('the_content', array($this, 'theContent'));
|
||||
if (defined('ELEMENTOR_VERSION') && version_compare(ELEMENTOR_VERSION, '3.5', '<')) {
|
||||
add_action('elementor/widgets/widgets_registered', array($this, 'loadElementorWidget'));
|
||||
} else {
|
||||
add_action('elementor/widgets/register', array($this, 'loadElementorWidget'));
|
||||
}
|
||||
|
||||
add_action('wp_ajax_wpmf_load_pdf_embed', array($this, 'loadPdfEmbedHtmlGutenberg'));
|
||||
add_action('wp_ajax_wpmf_divi_load_pdf_embed_html', array($this, 'loadPdfEmbedHtml'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Load file design html
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadPdfEmbedHtmlGutenberg()
|
||||
{
|
||||
if (empty($_REQUEST['wpmf_nonce'])
|
||||
|| !wp_verify_nonce($_REQUEST['wpmf_nonce'], 'wpmf_nonce')) {
|
||||
wp_send_json(array('status' => false, 'html' => '<p>'. esc_html__('Have error when load html from URL', 'wpmf') .'</p>'));
|
||||
}
|
||||
|
||||
$width = (!empty($_REQUEST['width'])) ? (int)$_REQUEST['width'] : '';
|
||||
$height = (!empty($_REQUEST['height'])) ? (int)$_REQUEST['height'] : '';
|
||||
$html = do_shortcode('[wpmfpdf id="'. (int)$_REQUEST['id'] .'" width="'. $width .'" height="'. $height .'" embed="'. $_REQUEST['embed'] .'" target="'. $_REQUEST['target'] .'"]');
|
||||
wp_send_json(array('status' => true, 'html' => $html));
|
||||
}
|
||||
|
||||
/**
|
||||
* Load file design html
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadPdfEmbedHtml()
|
||||
{
|
||||
if (empty($_REQUEST['et_admin_load_nonce'])
|
||||
|| !wp_verify_nonce($_REQUEST['et_admin_load_nonce'], 'et_admin_load_nonce')) {
|
||||
wp_send_json(array('status' => false, 'html' => '<p>'. esc_html__('Have error when load html from URL', 'wpmf') .'</p>'));
|
||||
}
|
||||
|
||||
if (empty($_REQUEST['url'])) {
|
||||
wp_send_json(array('status' => false, 'html' => '<p>'. esc_html__('Have error when load html from URL', 'wpmf') .'</p>'));
|
||||
}
|
||||
$url = str_replace(array('-pdf.jpg', '-pdf.jpeg', '-pdf.png'), '.pdf', $_REQUEST['url']);
|
||||
if (strpos($url, 'admin-ajax.php?action=wpmf') !== false) {
|
||||
if (!empty($_REQUEST['id'])) {
|
||||
$url .= '&id=' . $_REQUEST['id'] . '&dl=0';
|
||||
}
|
||||
}
|
||||
$width = (!empty($_REQUEST['width']) && $_REQUEST['width'] !== 'auto') ? $_REQUEST['width'] : '100%';
|
||||
$height = (!empty($_REQUEST['height']) && $_REQUEST['height'] !== 'auto') ? $_REQUEST['height'] : '800';
|
||||
$html = do_shortcode('[wpmfpdf is_divi="1" url="'. $url .'" width="'. $width .'" height="'. $height .'" embed="'. $_REQUEST['embed'] .'" target="'. $_REQUEST['target'] .'"]');
|
||||
wp_send_json(array('status' => true, 'html' => $html));
|
||||
}
|
||||
|
||||
/**
|
||||
* Load elementor widget
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadElementorWidget()
|
||||
{
|
||||
require_once(WP_MEDIA_FOLDER_PLUGIN_DIR . 'class/elementor-widgets/class-pdf-embed-elementor-widget.php');
|
||||
if (defined('ELEMENTOR_VERSION') && version_compare(ELEMENTOR_VERSION, '3.5', '<')) {
|
||||
\Elementor\Plugin::instance()->widgets_manager->register_widget_type(new \WpmfPdfEmbedElementorWidget());
|
||||
} else {
|
||||
\Elementor\Plugin::instance()->widgets_manager->register(new \WpmfPdfEmbedElementorWidget());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue styles and scripts for gutenberg
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addEditorAssets()
|
||||
{
|
||||
wp_enqueue_script(
|
||||
'wpmf_pdf_blocks',
|
||||
WPMF_PLUGIN_URL . 'assets/js/blocks/pdfembed/block.js',
|
||||
array('wp-blocks', 'wp-i18n', 'wp-element', 'wp-data', 'wp-block-editor'),
|
||||
WPMF_VERSION
|
||||
);
|
||||
|
||||
$this->registerScript();
|
||||
$this->enqueue();
|
||||
$params = array(
|
||||
'l18n' => array(
|
||||
'block_pdf_title' => __('WP Media Folder PDF Embed', 'wpmf'),
|
||||
),
|
||||
'vars' => array(
|
||||
'wpmf_nonce' => wp_create_nonce('wpmf_nonce'),
|
||||
'ajaxurl' => admin_url('admin-ajax.php')
|
||||
)
|
||||
);
|
||||
|
||||
wp_localize_script('wpmf_pdf_blocks', 'wpmf_pdf_blocks', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load PDF script
|
||||
*
|
||||
* @param string $content Content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function theContent($content)
|
||||
{
|
||||
if (strpos($content, 'wpmf-pdfemb-viewer') || strpos($content, 'data-wpmf_pdf_embed="embed"') || strpos($content, 'wpmfpdf')) {
|
||||
$this->enqueue();
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render PDF embed
|
||||
*
|
||||
* @param array $attrs Shortcode params
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function wpmfPdf($attrs)
|
||||
{
|
||||
if (!empty($attrs['url'])) {
|
||||
$url = $attrs['url'];
|
||||
$title = basename($attrs['url']);
|
||||
} else {
|
||||
if (empty($attrs['id'])) {
|
||||
return '';
|
||||
}
|
||||
$url = wp_get_attachment_url($attrs['id']);
|
||||
$pdf = get_post($attrs['id']);
|
||||
if (empty($pdf)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$cloud_type = get_post_meta((int)$attrs['id'], 'wpmf_drive_type', true);
|
||||
if ($cloud_type === 'dropbox') {
|
||||
$drive_id = get_post_meta((int)$attrs['id'], 'wpmf_drive_id', true);
|
||||
$url = admin_url('admin-ajax.php') . '?action=wpmf-dbxdownload-file&id=' . urlencode($drive_id) . '&link=true&dl=0';
|
||||
}
|
||||
|
||||
if ($cloud_type === 'onedrive') {
|
||||
$drive_id = get_post_meta((int)$attrs['id'], 'wpmf_drive_id', true);
|
||||
$url = admin_url('admin-ajax.php') . '?action=wpmf_onedrive_download&id=' . urlencode($drive_id) . '&link=true&dl=0';
|
||||
}
|
||||
|
||||
if ($cloud_type === 'onedrive_business') {
|
||||
$drive_id = get_post_meta((int)$attrs['id'], 'wpmf_drive_id', true);
|
||||
$url = admin_url('admin-ajax.php') . '?action=wpmf_onedrive_business_download&id=' . urlencode($drive_id) . '&link=true&dl=0';
|
||||
}
|
||||
|
||||
if ($cloud_type === 'google_drive') {
|
||||
$drive_id = get_post_meta((int)$attrs['id'], 'wpmf_drive_id', true);
|
||||
$url = admin_url('admin-ajax.php') . '?action=wpmf-download-file&id=' . urlencode($drive_id) . '&link=true&dl=0';
|
||||
}
|
||||
|
||||
$title = $pdf->post_title;
|
||||
}
|
||||
|
||||
if (!empty($attrs['embed']) && $attrs['embed'] !== 'off') {
|
||||
if (empty($attrs['is_divi'])) {
|
||||
$this->enqueue();
|
||||
}
|
||||
$width = (!empty($attrs['width']) && strpos($attrs['width'], '%') === false) ? $attrs['width'] : '100%';
|
||||
$height = (!empty($attrs['height']) && strpos($attrs['height'], '%') === false) ? $attrs['height'] : '800';
|
||||
$download = (!empty($attrs['download'])) ? $attrs['download'] : 'off';
|
||||
$plugin_dir_url = plugin_dir_url(__DIR__);
|
||||
$viewer_base_url = $plugin_dir_url . 'class/templates/pdf-embed.php';
|
||||
|
||||
$response = wp_remote_head($url);
|
||||
if (is_wp_error($response)) {
|
||||
$url = $plugin_dir_url . 'assets/pdf-loading-error.pdf';
|
||||
}
|
||||
|
||||
$status_code = wp_remote_retrieve_response_code($response);
|
||||
if ($status_code === 404) {
|
||||
$url = $plugin_dir_url . 'assets/pdf-loading-error.pdf';
|
||||
}
|
||||
|
||||
$attachment_info = '?file=' . $url;
|
||||
$final_url = $viewer_base_url . $attachment_info . '&plugins_url=' . $plugin_dir_url;
|
||||
$return = '<div><iframe width="' . esc_attr($width) . '" height="' . esc_attr($height) . '" src="' . esc_url($final_url) . '" title="Embedded PDF" class="wpmf-pdfjs-iframe"></iframe></div>';
|
||||
} else {
|
||||
$return = '<a href="'.esc_url($url).'" '. (($attrs['target'] !== '') ? 'target="'.esc_attr($attrs['target']).'"' : '') .'>'.esc_html($title).'</a>';
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load styles and scripts
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadStyleScript()
|
||||
{
|
||||
global $post;
|
||||
if (!empty($post)) {
|
||||
$is_elementor = get_post_meta($post->ID, '_elementor_edit_mode', true);
|
||||
if ($is_elementor === 'builder') {
|
||||
$_elementor_data = get_post_meta($post->ID, '_elementor_data', true);
|
||||
if (!is_string($_elementor_data)) {
|
||||
$_elementor_data = json_encode($_elementor_data);
|
||||
}
|
||||
if (strpos($_elementor_data, 'wpmf-pdfemb-viewer') || strpos($_elementor_data, 'data-wpmf_pdf_embed="embed"') || strpos($_elementor_data, 'wpmfpdf')) {
|
||||
$this->enqueue();
|
||||
}
|
||||
} else {
|
||||
if (strpos($post->post_content, 'wpmf-pdfemb-viewer') || strpos($post->post_content, 'data-wpmf_pdf_embed="embed"') || strpos($post->post_content, 'wpmfpdf')) {
|
||||
$this->enqueue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load script and style
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue()
|
||||
{
|
||||
wp_enqueue_script('wpmf_compat_js');
|
||||
}
|
||||
|
||||
/**
|
||||
* Localize a script.
|
||||
* Works only if the script has already been added.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTranslation()
|
||||
{
|
||||
$array = array(
|
||||
// 'worker_src' => plugins_url('assets/js/pdf-embed/pdf.worker.min.js', dirname(__FILE__)),
|
||||
'worker_src' => plugins_url('assets/js/pdf-embed/pdf.worker.js', dirname(__FILE__)),
|
||||
'cmap_url' => plugins_url('assets/js/pdf-embed/cmaps/', dirname(__FILE__)),
|
||||
'pdf_sandbox'=> plugins_url('assets/js/pdf-embed/pdf.sandbox.js', dirname(__FILE__)),
|
||||
'objectL10n' =>
|
||||
array(
|
||||
'loading' => __('Loading...', 'wpmf'),
|
||||
'page' => __('Page', 'wpmf'),
|
||||
'zoom' => __('Zoom', 'wpmf'),
|
||||
'prev' => __('Previous page', 'wpmf'),
|
||||
'next' => __('Next page', 'wpmf'),
|
||||
'zoomin' => __('Zoom In', 'wpmf'),
|
||||
'zoomout' => __('Zoom Out', 'wpmf'),
|
||||
'secure' => __('Secure', 'wpmf'),
|
||||
'download' => __('Download PDF', 'wpmf'),
|
||||
'fullscreen' => __('Full Screen', 'wpmf'),
|
||||
'domainerror' => __('Error: URL to the PDF file must be on exactly the same domain as the current web page.', 'wpmf'),
|
||||
'clickhereinfo' => __('Click here for more info', 'wpmf'),
|
||||
'widthheightinvalid' => __('PDF page width or height are invalid', 'wpmf'),
|
||||
'viewinfullscreen' => __('View in Full Screen', 'wpmf'),
|
||||
'poweredby' => 1
|
||||
)
|
||||
);
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add pdf embed html to editor
|
||||
*
|
||||
* @param string $html HTML markup for a media item sent to the editor.
|
||||
* @param integer $id The first key from the $_POST['send'] data.
|
||||
* @param array $attachment Array of attachment metadata.
|
||||
*
|
||||
* @return string $html
|
||||
*/
|
||||
public function addImageFiles($html, $id, $attachment)
|
||||
{
|
||||
$post = get_post($id);
|
||||
$mimetype = explode('/', $post->post_mime_type);
|
||||
$pdf_embed = get_post_meta($id, 'wpmf_pdf_embed', true);
|
||||
$target = get_post_meta($id, '_gallery_link_target', true);
|
||||
if ($mimetype[1] === 'pdf') {
|
||||
if (isset($pdf_embed) && $pdf_embed === 'embed') {
|
||||
$doc = new DOMDocument();
|
||||
libxml_use_internal_errors(true);
|
||||
$sousce = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8');
|
||||
$doc->loadHTML($sousce);
|
||||
$tags = $doc->getElementsByTagName('a');
|
||||
if ($tags->length > 0) {
|
||||
if (!empty($tags)) {
|
||||
$cloud_type = get_post_meta((int)$id, 'wpmf_drive_type', true);
|
||||
if ($cloud_type === 'dropbox') {
|
||||
$drive_id = get_post_meta((int)$id, 'wpmf_drive_id', true);
|
||||
$url = admin_url('admin-ajax.php') . '?action=wpmf-dbxdownload-file&id=' . urlencode($drive_id) . '&link=true&dl=0';
|
||||
$tags->item(0)->setAttribute('href', $url);
|
||||
}
|
||||
|
||||
$class = $tags->item(0)->getAttribute('class');
|
||||
if (!empty($class)) {
|
||||
$newclass = $class . ' wpmf-pdfemb-viewer';
|
||||
} else {
|
||||
$newclass = 'wpmf-pdfemb-viewer';
|
||||
}
|
||||
$tags->item(0)->setAttribute('target', $target);
|
||||
$tags->item(0)->setAttribute('class', $newclass);
|
||||
$html = $doc->saveHTML();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$singlefile = get_option('wpmf_option_singlefile');
|
||||
if (isset($singlefile) && (int) $singlefile === 1) {
|
||||
$meta = get_post_meta($id, '_wp_attached_file');
|
||||
$upload_dir = wp_upload_dir();
|
||||
$url_attachment = $upload_dir['basedir'] . '/' . $meta[0];
|
||||
if (file_exists($url_attachment)) {
|
||||
$size = filesize($url_attachment);
|
||||
if ($size < 1024 * 1024) {
|
||||
$size = round($size / 1024, 1) . ' kB';
|
||||
} elseif ($size > 1024 * 1024) {
|
||||
$size = round($size / (1024 * 1024), 1) . ' MB';
|
||||
}
|
||||
} else {
|
||||
$size = 0;
|
||||
}
|
||||
|
||||
$type = wp_check_filetype($post->guid);
|
||||
$ext = $type['ext'];
|
||||
$html = '<span class="wpmf_mce-wrap" data-file="' . $id . '" style="overflow: hidden;">';
|
||||
$html .= '<a class="wpmf-defile wpmf_mce-single-child"
|
||||
href="' . $post->guid . '" data-id="' . $id . '" target="' . $target . '">';
|
||||
$html .= '<span class="wpmf_mce-single-child" style="font-weight: bold;">';
|
||||
$html .= $post->post_title;
|
||||
$html .= '</span><br>';
|
||||
$html .= '<span class="wpmf_mce-single-child" style="font-weight: normal;font-size: 0.8em;">';
|
||||
$html .= '<b class="wpmf_mce-single-child">' . esc_html__('Size', 'wpmf') . ' : </b>' . $size;
|
||||
$html .= '<b class="wpmf_mce-single-child"> ' . esc_html__('Format', 'wpmf') . ' : </b>' . strtoupper($ext) . '</span>';
|
||||
$html .= '</a>';
|
||||
$html .= '</span>';
|
||||
} else {
|
||||
$html = preg_replace('/(<a\b[^><]*)>/i', '$1 target="' . $target . '">', $html);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add footer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function adminFooterPdfEmbed()
|
||||
{
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
if (typeof jQuery !== "undefined") {
|
||||
jQuery(function () {
|
||||
if (typeof wp !== "undefined" && typeof wp.media !== "undefined" && typeof wp.media.events !== "undefined") {
|
||||
wp.media.events.on('editor:image-edit', function (data) {
|
||||
data.metadata.wpmf_pdf_embed = data.editor.dom.getAttrib(data.image, 'data-wpmf_pdf_embed');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Add script
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function registerScript()
|
||||
{
|
||||
wp_register_script(
|
||||
'wpmf_compat_js',
|
||||
plugins_url('assets/js/pdf-embed/compatibility.js', dirname(__FILE__)),
|
||||
array('jquery')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add script
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addCustomPdfL10nLink()
|
||||
{
|
||||
$locale_url = plugins_url('assets/js/pdf-embed/locale/locale.properties', dirname(__FILE__));
|
||||
echo '<link rel="resource" type="application/l10n" href="' . esc_url($locale_url) . '">';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add footer script
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadScript()
|
||||
{
|
||||
add_action('admin_footer', array($this, 'adminFooterPdfEmbed'), 11);
|
||||
add_action('wp_footer', array($this, 'adminFooterPdfEmbed'), 11);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create enable PDF embed field
|
||||
* Based on /wp-admin/includes/media.php
|
||||
*
|
||||
* @param array $form_fields An array of attachment form fields.
|
||||
* @param WP_Post $post The WP_Post attachment object.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function attachmentFieldsToEdit($form_fields, $post)
|
||||
{
|
||||
if ($post->post_mime_type === 'application/pdf') {
|
||||
$value = get_post_meta($post->ID, 'wpmf_pdf_embed', true);
|
||||
if (empty($value)) {
|
||||
$value = 'large';
|
||||
}
|
||||
$embed = array(
|
||||
'link' => __('Off', 'wpmf'),
|
||||
'embed' => __('On', 'wpmf'),
|
||||
);
|
||||
$option = '';
|
||||
foreach ($embed as $k => $v) {
|
||||
if ($value === $k) {
|
||||
$option .= '<option selected value="' . $k . '">' . $v . '</option>';
|
||||
} else {
|
||||
$option .= '<option value="' . $k . '">' . $v . '</option>';
|
||||
}
|
||||
}
|
||||
$form_fields['wpmf_pdf_embed'] = array(
|
||||
'label' => __('PDF Embed', 'wpmf'),
|
||||
'input' => 'html',
|
||||
'html' => '
|
||||
<select name="attachments[' . $post->ID . '][wpmf_pdf_embed]"
|
||||
id="attachments[' . $post->ID . '][wpmf_pdf_embed]">
|
||||
' . $option . '
|
||||
</select>'
|
||||
);
|
||||
}
|
||||
|
||||
return $form_fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save enable PDF embed option
|
||||
* Based on /wp-admin/includes/media.php
|
||||
*
|
||||
* @param array $post An array of post data.
|
||||
* @param array $attachment An array of attachment metadata.
|
||||
*
|
||||
* @return mixed $post
|
||||
*/
|
||||
public function attachmentFieldsToSave($post, $attachment)
|
||||
{
|
||||
if (isset($attachment['wpmf_pdf_embed'])) {
|
||||
update_post_meta($post['ID'], 'wpmf_pdf_embed', $attachment['wpmf_pdf_embed']);
|
||||
}
|
||||
return $post;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,296 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
use Joomunited\WPMediaFolder\WpmfHelper;
|
||||
|
||||
/**
|
||||
* Class WpmfReplaceFile
|
||||
* This class that holds most of the replace file functionality for Media Folder.
|
||||
*/
|
||||
class WpmfReplaceFile
|
||||
{
|
||||
|
||||
/**
|
||||
* WpmfReplaceFile constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
add_action('wp_enqueue_media', array($this, 'enqueueAdminScripts'));
|
||||
add_action('wp_ajax_wpmf_replace_file', array($this, 'replaceFile'));
|
||||
add_filter('attachment_fields_to_edit', array($this, 'attachmentFieldsToEdit'), 10, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax replace attachment
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function replaceFile()
|
||||
{
|
||||
if (empty($_POST['wpmf_nonce'])
|
||||
|| !wp_verify_nonce($_POST['wpmf_nonce'], 'wpmf_nonce')) {
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter check capability of current user to replace a file
|
||||
*
|
||||
* @param boolean The current user has the given capability
|
||||
* @param string Action name
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @ignore Hook already documented
|
||||
*/
|
||||
$wpmf_capability = apply_filters('wpmf_user_can', current_user_can('edit_posts'), 'replace_file');
|
||||
if (!$wpmf_capability) {
|
||||
wp_send_json(false);
|
||||
}
|
||||
if (!empty($_FILES['wpmf_replace_file'])) {
|
||||
if (empty($_POST['post_selected'])) {
|
||||
esc_html_e('Post empty', 'wpmf');
|
||||
die();
|
||||
}
|
||||
|
||||
$id = $_POST['post_selected'];
|
||||
$metadata = wp_get_attachment_metadata($id);
|
||||
|
||||
$filepath = get_attached_file($id);
|
||||
$infopath = pathinfo($filepath);
|
||||
$allowedImageTypes = array('gif', 'jpg', 'png', 'bmp', 'webp', 'pdf');
|
||||
$new_filetype = wp_check_filetype($_FILES['wpmf_replace_file']['name']);
|
||||
if ($new_filetype['ext'] === 'jpeg') {
|
||||
$new_filetype['ext'] = 'jpg';
|
||||
}
|
||||
|
||||
if ($infopath['extension'] === 'jpeg') {
|
||||
$infopath['extension'] = 'jpg';
|
||||
}
|
||||
if ($new_filetype['ext'] !== $infopath['extension']) {
|
||||
wp_send_json(
|
||||
array(
|
||||
'status' => false,
|
||||
'msg' => __('To replace a media and keep the link to this media working,
|
||||
it must be in the same format, ie. jpg > jpg… Thanks!', 'wpmf')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($_FILES['wpmf_replace_file']['error'] > 0) {
|
||||
wp_send_json(
|
||||
array(
|
||||
'status' => false,
|
||||
'msg' => $_FILES['wpmf_replace_file']['error']
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$uploadpath = wp_upload_dir();
|
||||
if (!file_exists($filepath)) {
|
||||
wp_send_json(
|
||||
array(
|
||||
'status' => false,
|
||||
'msg' => __('File doesn\'t exist', 'wpmf')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
unlink($filepath);
|
||||
if (in_array($infopath['extension'], $allowedImageTypes)) {
|
||||
if (isset($metadata['sizes']) && is_array($metadata['sizes'])) {
|
||||
foreach ($metadata['sizes'] as $size => $sizeinfo) {
|
||||
$intermediate_file = str_replace(basename($filepath), $sizeinfo['file'], $filepath);
|
||||
// This filter is documented in wp-includes/functions.php
|
||||
$intermediate_file = apply_filters('wp_delete_file', $intermediate_file);
|
||||
$link = path_join(
|
||||
$uploadpath['basedir'],
|
||||
$intermediate_file
|
||||
);
|
||||
if (file_exists($link) && is_writable($link)) {
|
||||
unlink($link);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
move_uploaded_file(
|
||||
$_FILES['wpmf_replace_file']['tmp_name'],
|
||||
$infopath['dirname'] . '/' . $infopath['basename']
|
||||
);
|
||||
update_post_meta($id, 'wpmf_size', filesize($infopath['dirname'] . '/' . $infopath['basename']));
|
||||
|
||||
if ($infopath['extension'] === 'pdf') {
|
||||
WpmfHelper::createPdfThumbnail($filepath);
|
||||
}
|
||||
|
||||
if (in_array($infopath['extension'], $allowedImageTypes)) {
|
||||
if ($infopath['extension'] !== 'pdf') {
|
||||
$actual_sizes_array = getimagesize($filepath);
|
||||
$metadata['width'] = $actual_sizes_array[0];
|
||||
$metadata['height'] = $actual_sizes_array[1];
|
||||
WpmfHelper::createThumbs($filepath, $infopath['extension'], $metadata, $id);
|
||||
}
|
||||
}
|
||||
do_action('wpmf_after_file_replace', $infopath, $id);
|
||||
if (isset($_FILES['wpmf_replace_file']['size'])) {
|
||||
$size = $_FILES['wpmf_replace_file']['size'];
|
||||
$metadata = wp_get_attachment_metadata($id);
|
||||
$metadata['filesize'] = $size;
|
||||
update_post_meta($id, '_wp_attachment_metadata', $metadata);
|
||||
update_post_meta($id, 'wpmf_size', $size);
|
||||
if ($size >= 1024 && $size < 1024 * 1024) {
|
||||
$size = ceil($size / 1024) . ' KB';
|
||||
} elseif ($size >= 1024 * 1024) {
|
||||
$size = ceil($size / (1024 * 1024)) . ' MB';
|
||||
} elseif ($size < 1024) {
|
||||
$size = $size . ' B';
|
||||
}
|
||||
} else {
|
||||
$size = '0 B';
|
||||
}
|
||||
|
||||
// apply watermark after replace
|
||||
$origin_infos = pathinfo($filepath);
|
||||
$origin_name = $origin_infos['filename'] . 'imageswatermark.' . $origin_infos['extension'];
|
||||
$path_origin = str_replace(wp_basename($filepath), $origin_name, $filepath);
|
||||
if (file_exists($path_origin)) {
|
||||
$paths = array(
|
||||
'origin' => $path_origin
|
||||
);
|
||||
|
||||
if (isset($metadata['sizes'])) {
|
||||
foreach ($metadata['sizes'] as $size => $file) {
|
||||
$infos = pathinfo($file['file']);
|
||||
$filewater = $infos['filename'] . 'imageswatermark.' . $infos['extension'];
|
||||
$paths[$size] = str_replace(wp_basename($filepath), $filewater, $filepath);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($paths as $path) {
|
||||
if (!realpath($path)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (file_exists($path) && is_writable($path)) {
|
||||
unlink($path);
|
||||
}
|
||||
}
|
||||
|
||||
require_once(WP_MEDIA_FOLDER_PLUGIN_DIR . 'class/class-image-watermark.php');
|
||||
$wpmfwatermark = new WpmfWatermark();
|
||||
$wpmfwatermark->createWatermarkImage($metadata, $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Do action after replace file
|
||||
*
|
||||
* @param integer Attachment ID
|
||||
*/
|
||||
do_action('wpmf_after_replace', $id);
|
||||
// end apply watermark after replace
|
||||
if (in_array($infopath['extension'], $allowedImageTypes) && $infopath['extension'] !== 'pdf') {
|
||||
$metadata = wp_get_attachment_metadata($id);
|
||||
$dimensions = $metadata['width'] . ' x ' . $metadata['height'];
|
||||
wp_send_json(array('status' => true, 'size' => $size, 'dimensions' => $dimensions));
|
||||
} else {
|
||||
wp_send_json(array('status' => true, 'size' => $size));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
wp_send_json(array('status' => false, 'msg' => __('File doesn\'t exist', 'wpmf')));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Includes styles and some scripts
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enqueueAdminScripts()
|
||||
{
|
||||
/**
|
||||
* Filter check capability of current user to load assets
|
||||
*
|
||||
* @param boolean The current user has the given capability
|
||||
* @param string Action name
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @ignore Hook already documented
|
||||
*/
|
||||
$wpmf_capability = apply_filters('wpmf_user_can', current_user_can('edit_posts'), 'load_script_style');
|
||||
if ($wpmf_capability) {
|
||||
wp_enqueue_script(
|
||||
'wpmf-folder-snackbar',
|
||||
plugins_url('/assets/js/snackbar.js', dirname(__FILE__)),
|
||||
array('jquery'),
|
||||
WPMF_VERSION
|
||||
);
|
||||
wp_enqueue_script(
|
||||
'wpmf-jquery-form',
|
||||
plugins_url('assets/js/jquery.form.js', dirname(__FILE__)),
|
||||
array('jquery'),
|
||||
WPMF_VERSION
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'replace-image',
|
||||
plugins_url('assets/js/replace-image.js', dirname(__FILE__)),
|
||||
array('jquery'),
|
||||
WPMF_VERSION
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'wpmf-material-icon',
|
||||
plugins_url('/assets/css/google-material-icon.css', dirname(__FILE__)),
|
||||
array(),
|
||||
WPMF_VERSION
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'wpmf-style',
|
||||
plugins_url('/assets/css/style.css', dirname(__FILE__)),
|
||||
array(),
|
||||
WPMF_VERSION
|
||||
);
|
||||
global $pagenow;
|
||||
$get_plugin_active = json_encode(get_option('active_plugins'));
|
||||
$option_override = get_option('wpmf_option_override');
|
||||
$params = array(
|
||||
'vars' => array(
|
||||
'ajaxurl' => admin_url('admin-ajax.php'),
|
||||
'wpmf_nonce' => wp_create_nonce('wpmf_nonce'),
|
||||
'wpmf_pagenow' => $pagenow,
|
||||
'get_plugin_active' => $get_plugin_active,
|
||||
'override' => (int) $option_override
|
||||
),
|
||||
'l18n' => array(
|
||||
'file_uploading' => __('File upload on the way...', 'wpmf'),
|
||||
'replace' => __('Replace', 'wpmf'),
|
||||
'filesize_label' => __('File size:', 'wpmf'),
|
||||
'dimensions_label' => __('Dimensions:', 'wpmf'),
|
||||
'wpmf_file_replace' => __('File replaced!', 'wpmf')
|
||||
)
|
||||
);
|
||||
wp_localize_script('replace-image', 'wpmfParams', $params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create attachment fields
|
||||
* Based on /wp-admin/includes/media.php
|
||||
*
|
||||
* @param array $form_fields An array of attachment form fields.
|
||||
* @param WP_Post $post The WP_Post attachment object.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function attachmentFieldsToEdit($form_fields, $post)
|
||||
{
|
||||
global $pagenow;
|
||||
if (!empty($pagenow) && $pagenow === 'post.php') {
|
||||
$this->enqueueAdminScripts();
|
||||
}
|
||||
|
||||
return $form_fields;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,285 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
use Joomunited\WPMediaFolder\WpmfHelper;
|
||||
|
||||
/**
|
||||
* Class WpmfSingleFile
|
||||
* This class that holds most of the single file functionality for Media Folder.
|
||||
*/
|
||||
class WpmfSingleFile
|
||||
{
|
||||
/**
|
||||
* Single_File constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
add_action('admin_enqueue_scripts', array($this, 'singleFileStyleAdmin'));
|
||||
add_filter('media_send_to_editor', array($this, 'addImageFiles'), 10, 3);
|
||||
add_action('wp_enqueue_scripts', array($this, 'loadCustomWpAdminScript'));
|
||||
add_action('admin_enqueue_scripts', array($this, 'loadCustomWpAdminScript'));
|
||||
add_filter('mce_external_plugins', array($this, 'register'));
|
||||
add_action('enqueue_block_editor_assets', array($this, 'addEditorAssets'));
|
||||
add_shortcode('wpmffiledesign', array($this, 'wpmfFileDesign'));
|
||||
if (defined('ELEMENTOR_VERSION') && version_compare(ELEMENTOR_VERSION, '3.5', '<')) {
|
||||
add_action('elementor/widgets/widgets_registered', array($this, 'loadElementorWidget'));
|
||||
} else {
|
||||
add_action('elementor/widgets/register', array($this, 'loadElementorWidget'));
|
||||
}
|
||||
add_action('wp_ajax_wpmf_divi_load_file_design_html', array($this, 'loadFileDesignHtml'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Load file design html
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadFileDesignHtml()
|
||||
{
|
||||
if (empty($_REQUEST['et_admin_load_nonce'])
|
||||
|| !wp_verify_nonce($_REQUEST['et_admin_load_nonce'], 'et_admin_load_nonce')) {
|
||||
wp_send_json(array('status' => false, 'html' => '<p>'. esc_html__('Have error when load html from URL', 'wpmf') .'</p>'));
|
||||
}
|
||||
|
||||
if (empty($_REQUEST['url'])) {
|
||||
wp_send_json(array('status' => false, 'html' => '<p>'. esc_html__('Have error when load html from URL', 'wpmf') .'</p>'));
|
||||
}
|
||||
$html = do_shortcode('[wpmffiledesign url="'. $_REQUEST['url'] .'" align="'. $_REQUEST['align'] .'"]');
|
||||
wp_send_json(array('status' => true, 'html' => $html));
|
||||
}
|
||||
|
||||
/**
|
||||
* Load elementor widget
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadElementorWidget()
|
||||
{
|
||||
require_once(WP_MEDIA_FOLDER_PLUGIN_DIR . 'class/elementor-widgets/class-file-design-elementor-widget.php');
|
||||
if (defined('ELEMENTOR_VERSION') && version_compare(ELEMENTOR_VERSION, '3.5', '<')) {
|
||||
\Elementor\Plugin::instance()->widgets_manager->register_widget_type(new \WpmfFileDesignElementorWidget());
|
||||
} else {
|
||||
\Elementor\Plugin::instance()->widgets_manager->register(new \WpmfFileDesignElementorWidget());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render File Design by shortcode
|
||||
*
|
||||
* @param array $attrs Shortcode params
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function wpmfFileDesign($attrs)
|
||||
{
|
||||
if (empty($attrs['url']) && empty($attrs['id'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!empty($attrs['url'])) {
|
||||
$file_id = WpmfHelper::attachmentUrlToPostid($attrs['url'], 'pdf');
|
||||
} else {
|
||||
$file_id = (int)$attrs['id'];
|
||||
}
|
||||
|
||||
$file = get_post($file_id);
|
||||
$mimetype = explode('/', $file->post_mime_type);
|
||||
$target = get_post_meta($file_id, '_gallery_link_target', true);
|
||||
$fileUrl = wp_get_attachment_url($file_id);
|
||||
$filePath = get_attached_file($file_id);
|
||||
$meta = wp_get_attachment_metadata($file_id);
|
||||
if (isset($meta['filesize'])) {
|
||||
$size = $meta['filesize'];
|
||||
} elseif (file_exists($filePath)) {
|
||||
$size = filesize($filePath);
|
||||
} else {
|
||||
$size = 0;
|
||||
}
|
||||
|
||||
if ($size < 1024 * 1024) {
|
||||
$size = round($size / 1024, 1) . ' kB';
|
||||
} elseif ($size > 1024 * 1024) {
|
||||
$size = round($size / (1024 * 1024), 1) . ' MB';
|
||||
}
|
||||
|
||||
$style = array();
|
||||
$style[] = 'overflow: hidden';
|
||||
if (isset($attrs['align'])) {
|
||||
$style[] = 'text-align: ' . $attrs['align'];
|
||||
}
|
||||
$style = implode(';', $style);
|
||||
$html = '';
|
||||
$type = pathinfo($filePath);
|
||||
if (isset($type['extension']) && $type['extension']) {
|
||||
$drive_type = get_post_meta($file_id, 'wpmf_drive_type', true);
|
||||
if (!empty($drive_type)) {
|
||||
$drive_id = get_post_meta($file_id, 'wpmf_drive_id', true);
|
||||
switch ($drive_type) {
|
||||
case 'google_drive':
|
||||
$fileUrl = admin_url('admin-ajax.php') . '?action=wpmf-download-file&local_id='. $file_id .'&id=' . urlencode($drive_id) . '&link=true&dl=1';
|
||||
break;
|
||||
case 'dropbox':
|
||||
$fileUrl = admin_url('admin-ajax.php') . '?action=wpmf-dbxdownload-file&local_id='. $file_id .'&id=' . urlencode($drive_id) . '&link=true&dl=1';
|
||||
break;
|
||||
case 'onedrive':
|
||||
$fileUrl = admin_url('admin-ajax.php') . '?action=wpmf_onedrive_download&local_id='. $file_id .'&id=' . urlencode($drive_id) . '&link=true&dl=1';
|
||||
break;
|
||||
case 'onedrive_business':
|
||||
$fileUrl = admin_url('admin-ajax.php') . '?action=wpmf_onedrive_business_download&local_id='. $file_id .'&id=' . urlencode($drive_id) . '&link=true&dl=1';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$html .= '<div class="wpmf_mce-wrap" data-file="' . $file_id . '" style="'. $style .'">';
|
||||
$html .= '<a class="wpmf-defile wpmf_mce-single-child"
|
||||
href="' . $fileUrl . '" data-id="' . $file_id . '" target="' . $target . '" download>';
|
||||
$html .= '<span class="wpmf_mce-single-child" style="font-weight: bold; font-family: \'Arial\', sans-serif;line-height: 20px;">';
|
||||
$html .= $file->post_title;
|
||||
$html .= '</span><br>';
|
||||
$html .= '<span class="wpmf_mce-single-child" style="font-weight: normal;font-size: 0.8em; font-family: \'Arial\', sans-serif;line-height: 20px;">';
|
||||
$html .= '<b class="wpmf_mce-single-child">Size : </b>' . $size;
|
||||
$html .= '<b class="wpmf_mce-single-child"> Format : </b>' . strtoupper($type['extension']);
|
||||
$html .= '</span>';
|
||||
$html .= '</a>';
|
||||
$html .= '</div>';
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue styles and scripts for gutenberg
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addEditorAssets()
|
||||
{
|
||||
global $pagenow;
|
||||
$deps = (isset($pagenow) && $pagenow === 'widgets.php') ? array('wp-blocks', 'wp-i18n', 'wp-element', 'wp-data', 'wp-block-editor') : array('wp-blocks', 'wp-i18n', 'wp-element', 'wp-data', 'wp-editor');
|
||||
wp_enqueue_script(
|
||||
'wpmf_filedesign_blocks',
|
||||
WPMF_PLUGIN_URL . 'assets/js/blocks/file_design/block.js',
|
||||
$deps,
|
||||
WPMF_VERSION
|
||||
);
|
||||
|
||||
$params = array(
|
||||
'l18n' => array(),
|
||||
'vars' => array(
|
||||
'block_cover' => WPMF_PLUGIN_URL .'assets/js/blocks/file_design/preview.png'
|
||||
)
|
||||
);
|
||||
|
||||
wp_localize_script('wpmf_filedesign_blocks', 'wpmf_filedesign_blocks', $params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Includes script to editor
|
||||
*
|
||||
* @param array $plugin_array List editor plugin
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function register($plugin_array)
|
||||
{
|
||||
$url = WPMF_PLUGIN_URL . '/assets/js/single-file.js';
|
||||
$plugin_array['wpmf_mce'] = $url;
|
||||
return $plugin_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Includes styles to editor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function singleFileStyleAdmin()
|
||||
{
|
||||
$upload_dir = wp_upload_dir();
|
||||
if (file_exists($upload_dir['basedir'] . '/wpmf/css/wpmf_single_file.css')) {
|
||||
add_editor_style($upload_dir['baseurl'] . '/wpmf/css/wpmf_single_file.css');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Includes styles
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadCustomWpAdminScript()
|
||||
{
|
||||
$upload_dir = wp_upload_dir();
|
||||
wp_enqueue_script(
|
||||
'wpmf-single-file',
|
||||
plugins_url('/assets/js/single_file.js', dirname(__FILE__)),
|
||||
array('jquery'),
|
||||
WPMF_VERSION
|
||||
);
|
||||
|
||||
$vars = array(
|
||||
'site_url' => site_url(),
|
||||
'ajaxurl' => admin_url('admin-ajax.php'),
|
||||
'wpmf_nonce' => wp_create_nonce('wpmf_nonce'),
|
||||
);
|
||||
|
||||
wp_localize_script('wpmf-single-file', 'wpmf_single', array('vars' => $vars));
|
||||
if (file_exists($upload_dir['basedir'] . '/wpmf/css/wpmf_single_file.css')) {
|
||||
wp_enqueue_style(
|
||||
'wpmf-single-file',
|
||||
$upload_dir['baseurl'] . '/wpmf/css/wpmf_single_file.css',
|
||||
array(),
|
||||
WPMF_VERSION
|
||||
);
|
||||
wp_add_inline_style('wpmf-single-file', '.content-align-center.elementor-widget-wpmf_file_design .wpmf_mce-wrap {text-align: center;}.content-align-left.elementor-widget-wpmf_file_design .wpmf_mce-wrap {text-align: left;}.content-align-right.elementor-widget-wpmf_file_design .wpmf_mce-wrap {text-align: right;}.wpmf-defile{display: inline-block; float:none !important}.wpmf-defile span.wpmf_mce-single-child{float:left}');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add single file to editor
|
||||
*
|
||||
* @param string $html HTML markup for a media item sent to the editor.
|
||||
* @param integer $id The first key from the $_POST['send'] data.
|
||||
* @param array $attachment Array of attachment metadata.
|
||||
*
|
||||
* @return string $html
|
||||
*/
|
||||
public function addImageFiles($html, $id, $attachment)
|
||||
{
|
||||
$post = get_post($id);
|
||||
$mimetype = explode('/', $post->post_mime_type);
|
||||
$target = get_post_meta($id, '_gallery_link_target', true);
|
||||
$fileUrl = wp_get_attachment_url($id);
|
||||
$filePath = get_attached_file($id);
|
||||
$meta = wp_get_attachment_metadata($id);
|
||||
if (isset($meta['filesize'])) {
|
||||
$size = $meta['filesize'];
|
||||
} elseif (file_exists($filePath)) {
|
||||
$size = filesize($filePath);
|
||||
} else {
|
||||
$size = 0;
|
||||
}
|
||||
|
||||
if ($size < 1024 * 1024) {
|
||||
$size = round($size / 1024, 1) . ' kB';
|
||||
} elseif ($size > 1024 * 1024) {
|
||||
$size = round($size / (1024 * 1024), 1) . ' MB';
|
||||
}
|
||||
|
||||
if ($mimetype[0] === 'application' && $mimetype[1] !== 'pdf') {
|
||||
$type = wp_check_filetype($fileUrl);
|
||||
$ext = $type['ext'];
|
||||
$html = '<div class="wpmf_mce-wrap" data-file="' . $id . '" style="overflow: hidden;">';
|
||||
$html .= '<a class="wpmf-defile wpmf_mce-single-child"
|
||||
href="' . $fileUrl . '" data-id="' . $id . '" target="' . $target . '" download>';
|
||||
$html .= '<span class="wpmf_mce-single-child" style="font-weight: bold;">';
|
||||
$html .= $post->post_title;
|
||||
$html .= '</span><br>';
|
||||
$html .= '<span class="wpmf_mce-single-child" style="font-weight: normal;font-size: 0.8em;">';
|
||||
$html .= '<b class="wpmf_mce-single-child">Size : </b>' . $size;
|
||||
$html .= '<b class="wpmf_mce-single-child"> Format : </b>' . strtoupper($ext);
|
||||
$html .= '</span>';
|
||||
$html .= '</a>';
|
||||
$html .= '</div>';
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,318 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
|
||||
/**
|
||||
* Class WpmfSingleLightbox
|
||||
* This class that holds most of the single lightbox functionality for Media Folder.
|
||||
*/
|
||||
class WpmfSingleLightbox
|
||||
{
|
||||
|
||||
/**
|
||||
* Wpmf_Single_Lightbox constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
add_action('wp_enqueue_media', array($this, 'loadScript'));
|
||||
add_action('wp_enqueue_scripts', array($this, 'enqueueScript'));
|
||||
add_action('enqueue_block_editor_assets', array($this, 'addEditorAssets'));
|
||||
add_filter('attachment_fields_to_edit', array($this, 'attachmentFieldsToEdit'), 10, 2);
|
||||
add_filter('attachment_fields_to_save', array($this, 'attachmentFieldsToSave'), 10, 2);
|
||||
add_filter('image_send_to_editor', array($this, 'imageLightboxSendToEditor'), 10, 8);
|
||||
add_action('print_media_templates', array($this, 'printMediaTemplates'));
|
||||
add_action('wp_ajax_wpmf_get_thumb_image', array($this, 'getThumbImage'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue styles and scripts for gutenberg
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addEditorAssets()
|
||||
{
|
||||
wp_enqueue_script(
|
||||
'wpmf_lightbox_blocks',
|
||||
WPMF_PLUGIN_URL . 'assets/js/blocks/image_lightbox/block.js',
|
||||
array('wp-blocks', 'wp-i18n', 'wp-element', 'wp-data', 'wp-block-editor'),
|
||||
WPMF_VERSION
|
||||
);
|
||||
|
||||
$sizes = apply_filters('image_size_names_choose', array(
|
||||
'thumbnail' => __('Thumbnail', 'wpmf'),
|
||||
'medium' => __('Medium', 'wpmf'),
|
||||
'large' => __('Large', 'wpmf'),
|
||||
'full' => __('Full Size', 'wpmf'),
|
||||
));
|
||||
$params = array(
|
||||
'l18n' => array(
|
||||
'block_image_lightbox_title' => __('WP Media Folder Image Lightbox', 'wpmf'),
|
||||
),
|
||||
'vars' => array(
|
||||
'sizes' => $sizes
|
||||
)
|
||||
);
|
||||
|
||||
wp_localize_script('wpmf_lightbox_blocks', 'wpmf_lightbox_blocks', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add script to footer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function adminFooterImagelightbox()
|
||||
{
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery(function ($) {
|
||||
if (wp && wp.media && wp.media.events) {
|
||||
wp.media.events.on('editor:image-edit', function (data) {
|
||||
data.metadata.wpmf_image_lightbox =
|
||||
data.editor.dom.getAttrib(data.image, 'data-wpmf_image_lightbox');
|
||||
data.metadata.wpmf_size_lightbox =
|
||||
data.editor.dom.getAttrib(data.image, 'data-wpmf_size_lightbox');
|
||||
data.metadata.wpmflightbox = data.editor.dom.getAttrib(data.image, 'data-wpmflightbox');
|
||||
});
|
||||
wp.media.events.on('editor:image-update', function (data) {
|
||||
if (data.metadata.link === 'file' && data.metadata.wpmf_size_lightbox !== 'none') {
|
||||
data.editor.dom.setAttrib(data.image, 'data-wpmflightbox', 1);
|
||||
} else {
|
||||
data.editor.dom.setAttrib(data.image, 'data-wpmflightbox', 0);
|
||||
}
|
||||
$.ajax({
|
||||
url: ajaxurl,
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
action: "wpmf_get_thumb_image",
|
||||
attachment_id: data.metadata.attachment_id,
|
||||
size: data.metadata.wpmf_size_lightbox,
|
||||
wpmf_nonce: wpmf.vars.wpmf_nonce
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.status) {
|
||||
data.editor.dom.setAttrib(data.image, 'data-wpmf_image_lightbox', res.url_thumb);
|
||||
data.editor.dom.setAttrib(
|
||||
data.image,
|
||||
'data-wpmf_size_lightbox',
|
||||
data.metadata.wpmf_size_lightbox
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Add script to footer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadScript()
|
||||
{
|
||||
wp_enqueue_script(
|
||||
'wpmf-singleimage-lightbox',
|
||||
plugins_url('/assets/js/single_image_lightbox/image_lightbox.js', dirname(__FILE__)),
|
||||
array('jquery'),
|
||||
WPMF_VERSION
|
||||
);
|
||||
add_action('admin_footer', array($this, 'adminFooterImagelightbox'), 11);
|
||||
add_action('wp_footer', array($this, 'adminFooterImagelightbox'), 11);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load styles and scripts
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enqueueScript()
|
||||
{
|
||||
wp_enqueue_script(
|
||||
'wpmf-gallery-popup',
|
||||
plugins_url('/assets/js/display-gallery/jquery.magnific-popup.min.js', dirname(__FILE__)),
|
||||
array('jquery'),
|
||||
'0.9.9',
|
||||
true
|
||||
);
|
||||
wp_enqueue_script(
|
||||
'wpmf-singleimage-lightbox',
|
||||
plugins_url('/assets/js/single_image_lightbox/single_image_lightbox.js', dirname(__FILE__)),
|
||||
array('jquery'),
|
||||
WPMF_VERSION
|
||||
);
|
||||
wp_enqueue_style(
|
||||
'wpmf-singleimage-popup-style',
|
||||
plugins_url('/assets/css/display-gallery/magnific-popup.css', dirname(__FILE__)),
|
||||
array(),
|
||||
'0.9.9'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax get thumbnail for image
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getThumbImage()
|
||||
{
|
||||
if (empty($_POST['wpmf_nonce'])
|
||||
|| !wp_verify_nonce($_POST['wpmf_nonce'], 'wpmf_nonce')) {
|
||||
die();
|
||||
}
|
||||
|
||||
if (isset($_POST['attachment_id']) && isset($_POST['size'])) {
|
||||
$image_src = wp_get_attachment_image_src($_POST['attachment_id'], $_POST['size']);
|
||||
$url_image = $image_src[0];
|
||||
wp_send_json(array('status' => true, 'url_thumb' => $url_image));
|
||||
}
|
||||
wp_send_json(array('status' => false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add media templates
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function printMediaTemplates()
|
||||
{
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- No action, nonce is not required
|
||||
if (isset($_GET['action']) && $_GET['action'] === 'elementor') {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
|
||||
<script type="text/html" id="tmpl-image-wpmf">
|
||||
<label class="setting wpmf_size_lightbox">
|
||||
<span><?php esc_html_e('Lightbox size', 'wpmf'); ?></span>
|
||||
<select class="wpmf_size_lightbox" name="wpmf_size_lightbox" data-setting="wpmf_size_lightbox">
|
||||
<option value="none"><?php esc_html_e('None', 'wpmf') ?></option>
|
||||
<?php
|
||||
$sizes = apply_filters('image_size_names_choose', array(
|
||||
'none' => __('None', 'wpmf'),
|
||||
'thumbnail' => __('Thumbnail', 'wpmf'),
|
||||
'medium' => __('Medium', 'wpmf'),
|
||||
'large' => __('Large', 'wpmf'),
|
||||
'full' => __('Full Size', 'wpmf'),
|
||||
));
|
||||
?>
|
||||
|
||||
<?php foreach ($sizes as $k => $v) : ?>
|
||||
<option value="<?php echo esc_html($k) ?>"><?php echo esc_html($v) ?></option>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</select>
|
||||
</label>
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the image HTML markup to send to the editor when inserting an image.
|
||||
*
|
||||
* @param string $html The image HTML markup to send.
|
||||
* @param integer $id The attachment id.
|
||||
* @param string $caption The image caption.
|
||||
* @param string $title The image title.
|
||||
* @param string $align The image alignment.
|
||||
* @param string $url The image source URL.
|
||||
* @param string|array $size Size of image. Image size or array of width and height values
|
||||
* @param string $alt The image alternative, or alt, text.
|
||||
*
|
||||
* @return string $html
|
||||
*/
|
||||
public function imageLightboxSendToEditor($html, $id, $caption, $title, $align, $url, $size, $alt = '')
|
||||
{
|
||||
if (isset($url) && $url !== '') {
|
||||
$url_attachment = wp_get_attachment_url($id);
|
||||
$lightbox_size = get_post_meta($id, 'wpmf_image_lightbox', true);
|
||||
if (empty($lightbox_size)) {
|
||||
$lightbox_size = 'large';
|
||||
}
|
||||
|
||||
// check link to option, if value not empty do set attribute
|
||||
if ($url_attachment !== $url || $size === 'none') {
|
||||
return $html;
|
||||
}
|
||||
|
||||
$lightbox_url = wp_get_attachment_image_url($id, $lightbox_size);
|
||||
$html_array = array();
|
||||
$arrs = explode('<img ', $html);
|
||||
$html_array[] = $arrs[0];
|
||||
$html_array[] = '<img';
|
||||
$html_array[] = 'data-wpmf_image_lightbox="'. $lightbox_url .'"';
|
||||
$html_array[] = 'data-wpmf_size_lightbox="'. $size .'"';
|
||||
$html_array[] = 'data-wpmflightbox="1"';
|
||||
$html_array[] = $arrs[1];
|
||||
$html = implode(' ', $html_array);
|
||||
$html = str_replace($url, $lightbox_url, $html);
|
||||
$html = str_replace('wp-image-'. $id, 'wp-image-'. $id .' wpmf_image_lightbox', $html);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create lightbox size field
|
||||
* Based on /wp-admin/includes/media.php
|
||||
*
|
||||
* @param array $form_fields An array of attachment form fields.
|
||||
* @param WP_Post $post The WP_Post attachment object.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function attachmentFieldsToEdit($form_fields, $post)
|
||||
{
|
||||
$value = get_post_meta($post->ID, 'wpmf_image_lightbox', true);
|
||||
if (empty($value)) {
|
||||
$value = 'large';
|
||||
}
|
||||
$sizes = apply_filters('image_size_names_choose', array(
|
||||
'thumbnail' => __('Thumbnail', 'wpmf'),
|
||||
'medium' => __('Medium', 'wpmf'),
|
||||
'large' => __('Large', 'wpmf'),
|
||||
'full' => __('Full Size', 'wpmf'),
|
||||
));
|
||||
$option = '';
|
||||
$option .= '<option value="none">' . __('None', 'wpmf') . '</option>';
|
||||
foreach ($sizes as $k => $v) {
|
||||
if ($value === $k) {
|
||||
$option .= '<option selected value="' . $k . '">' . $v . '</option>';
|
||||
} else {
|
||||
$option .= '<option value="' . $k . '">' . $v . '</option>';
|
||||
}
|
||||
}
|
||||
$form_fields['wpmf_image_lightbox'] = array(
|
||||
'label' => __('Lightbox size', 'wpmf'),
|
||||
'input' => 'html',
|
||||
'html' => '
|
||||
<select name="attachments[' . $post->ID . '][wpmf_image_lightbox]"
|
||||
id="attachments[' . $post->ID . '][wpmf_image_lightbox]">
|
||||
' . $option . '
|
||||
</select>'
|
||||
);
|
||||
|
||||
return $form_fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save lightbox size field
|
||||
* Based on /wp-admin/includes/media.php
|
||||
*
|
||||
* @param array $post An array of post data.
|
||||
* @param array $attachment An array of attachment metadata.
|
||||
*
|
||||
* @return mixed $post
|
||||
*/
|
||||
public function attachmentFieldsToSave($post, $attachment)
|
||||
{
|
||||
if (isset($attachment['wpmf_image_lightbox'])) {
|
||||
update_post_meta($post['ID'], 'wpmf_image_lightbox', $attachment['wpmf_image_lightbox']);
|
||||
}
|
||||
return $post;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"builder.css": "/styles/style.min.css",
|
||||
"builder.js": "/scripts/builder-bundle.min.js",
|
||||
"frontend.css": "/styles/style.min.css",
|
||||
"frontend.js": "/scripts/frontend-bundle.min.js"
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
|
||||
/**
|
||||
* Class WpmfDivi
|
||||
*/
|
||||
class WpmfDivi extends DiviExtension
|
||||
{
|
||||
|
||||
/**
|
||||
* The gettext domain for the extension's translations.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $gettext_domain = 'wpmf';
|
||||
|
||||
/**
|
||||
* The extension's WP Plugin name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name = 'wpmf';
|
||||
|
||||
/**
|
||||
* The extension's version
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $version = '1.0.0';
|
||||
|
||||
/**
|
||||
* WpmfDivi constructor.
|
||||
*
|
||||
* @param string $name Name of extension
|
||||
* @param array $args Params
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($name = 'wpmf', $args = array())
|
||||
{
|
||||
$this->plugin_dir = plugin_dir_path(__FILE__);
|
||||
$this->plugin_dir_url = plugin_dir_url($this->plugin_dir);
|
||||
|
||||
parent::__construct($name, $args);
|
||||
}
|
||||
}
|
||||
|
||||
new WpmfDivi;
|
||||
@@ -0,0 +1,8 @@
|
||||
// External Dependencies
|
||||
import $ from 'jquery';
|
||||
|
||||
// Internal Dependencies
|
||||
import modules from './modules';
|
||||
$(window).on('et_builder_api_ready', (event, API) => {
|
||||
API.registerModules(modules);
|
||||
});
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
if (!class_exists('ET_Builder_Element')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$enable_singlefile = get_option('wpmf_option_singlefile');
|
||||
if (isset($enable_singlefile) && (int)$enable_singlefile === 1) {
|
||||
require_once WP_MEDIA_FOLDER_PLUGIN_DIR . 'class/divi-widgets/includes/modules/FileDesign/FileDesign.php';
|
||||
}
|
||||
|
||||
$enable_gallery = get_option('wpmf_usegellery');
|
||||
if (isset($enable_gallery) && (int)$enable_gallery === 1) {
|
||||
require_once WP_MEDIA_FOLDER_PLUGIN_DIR . 'class/divi-widgets/includes/modules/Gallery/Gallery.php';
|
||||
}
|
||||
|
||||
if (is_plugin_active('wp-media-folder-gallery-addon/wp-media-folder-gallery-addon.php')) {
|
||||
require_once WP_MEDIA_FOLDER_PLUGIN_DIR . 'class/divi-widgets/includes/modules/GalleryAddon/GalleryAddon.php';
|
||||
}
|
||||
|
||||
require_once WP_MEDIA_FOLDER_PLUGIN_DIR . 'class/divi-widgets/includes/modules/PdfEmbed/PdfEmbed.php';
|
||||
@@ -0,0 +1,114 @@
|
||||
// External Dependencies
|
||||
import React, {Component} from 'react';
|
||||
|
||||
// Internal Dependencies
|
||||
import './style.css';
|
||||
|
||||
class WpmfFileDesignDivi extends Component {
|
||||
|
||||
static slug = 'wpmf_file_design';
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
html: '',
|
||||
loading: true
|
||||
};
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
if (typeof this.props.url !== "undefined") {
|
||||
this.loadHtml(this.props);
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (this.props.url !== nextProps.url || this.props.align !== nextProps.align) {
|
||||
this.loadHtml(nextProps);
|
||||
}
|
||||
}
|
||||
|
||||
loadHtml(props) {
|
||||
if (!this.state.loading) {
|
||||
this.setState({
|
||||
loading: true
|
||||
});
|
||||
}
|
||||
fetch(window.et_fb_options.ajaxurl + `?action=wpmf_divi_load_file_design_html&url=${props.url}&align=${props.align}&et_admin_load_nonce=${window.et_fb_options.et_admin_load_nonce}`)
|
||||
.then(res => res.json())
|
||||
.then(
|
||||
(result) => {
|
||||
this.setState({
|
||||
html: result.html,
|
||||
loading: false
|
||||
});
|
||||
},
|
||||
// errors
|
||||
(error) => {
|
||||
this.setState({
|
||||
html: '',
|
||||
loading: true
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
const loadingIcon = (
|
||||
<svg className={'wpfd-loading'} width="100%" height="100%" xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 100 100" preserveAspectRatio="xMidYMid">
|
||||
<g transform="translate(25 50)">
|
||||
<circle cx="0" cy="0" r="10" fill="#cfcfcf" transform="scale(0.590851 0.590851)">
|
||||
<animateTransform attributeName="transform" type="scale" begin="-0.8666666666666667s" calcMode="spline"
|
||||
keySplines="0.3 0 0.7 1;0.3 0 0.7 1" values="0.5;1;0.5" keyTimes="0;0.5;1" dur="2.6s"
|
||||
repeatCount="indefinite"/>
|
||||
</circle>
|
||||
</g>
|
||||
<g transform="translate(50 50)">
|
||||
<circle cx="0" cy="0" r="10" fill="#cfcfcf" transform="scale(0.145187 0.145187)">
|
||||
<animateTransform attributeName="transform" type="scale" begin="-0.43333333333333335s" calcMode="spline"
|
||||
keySplines="0.3 0 0.7 1;0.3 0 0.7 1" values="0.5;1;0.5" keyTimes="0;0.5;1" dur="2.6s"
|
||||
repeatCount="indefinite"/>
|
||||
</circle>
|
||||
</g>
|
||||
<g transform="translate(75 50)">
|
||||
<circle cx="0" cy="0" r="10" fill="#cfcfcf" transform="scale(0.0339143 0.0339143)">
|
||||
<animateTransform attributeName="transform" type="scale" begin="0s" calcMode="spline"
|
||||
keySplines="0.3 0 0.7 1;0.3 0 0.7 1" values="0.5;1;0.5" keyTimes="0;0.5;1" dur="2.6s"
|
||||
repeatCount="indefinite"/>
|
||||
</circle>
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
|
||||
if (typeof this.props.url === "undefined") {
|
||||
return (
|
||||
<div className="wpmf-divi-container">
|
||||
<div id="divi-file-design-placeholder" className="divi-file-design-placeholder">
|
||||
<span className="wpmf-divi-message">
|
||||
{'WP Media Folder media download. Select a media and transform it into a download button'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (this.state.loading) {
|
||||
return (
|
||||
<div className="wpmf-divi-container">
|
||||
<div className={'wpmf-loading-wrapper'}>
|
||||
<i className={'wpmf-loading'}>{loadingIcon}</i>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!this.state.loading) {
|
||||
return (
|
||||
<div className="wpmf-file-design-wrap" dangerouslySetInnerHTML={{__html: this.state.html}}/>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default WpmfFileDesignDivi;
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
|
||||
/**
|
||||
* Class WpmfPdfEmbedDivi
|
||||
*/
|
||||
class WpmfFileDesignDivi extends ET_Builder_Module
|
||||
{
|
||||
|
||||
/**
|
||||
* Module slug
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $slug = 'wpmf_file_design';
|
||||
|
||||
/**
|
||||
* Whether module support visual builder. e.g `on` or `off`.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $vb_support = 'on';
|
||||
|
||||
/**
|
||||
* Credits of all custom modules.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $module_credits = array(
|
||||
'module_uri' => 'https://www.joomunited.com/',
|
||||
'author' => 'Joomunited',
|
||||
'author_uri' => 'https://www.joomunited.com/',
|
||||
);
|
||||
|
||||
/**
|
||||
* Init
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->name = esc_html__('WPMF Media Download', 'wpmf');
|
||||
}
|
||||
|
||||
/**
|
||||
* Advanced Fields Config
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_advanced_fields_config() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from ET_Builder_Module class
|
||||
{
|
||||
return array(
|
||||
'button' => false,
|
||||
'link_options' => false
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the settings fields data for this element.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_fields() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from ET_Builder_Module class
|
||||
{
|
||||
return array(
|
||||
'url' => array(
|
||||
'type' => 'upload',
|
||||
'data_type' => '*',
|
||||
'option_category' => 'configuration',
|
||||
'upload_button_text' => esc_attr__('Upload a File', 'wpmf'),
|
||||
'choose_text' => esc_attr__('Choose a File', 'wpmf'),
|
||||
'update_text' => esc_attr__('Set As File', 'wpmf'),
|
||||
'hide_metadata' => true,
|
||||
'affects' => array(
|
||||
'alt',
|
||||
'title_text',
|
||||
),
|
||||
'description' => esc_html__('Upload your desired file, or type in the URL to the image you would like to display.', 'wpmf'),
|
||||
),
|
||||
'align' => array(
|
||||
'label' => esc_html__('File Alignment', 'wpmf'),
|
||||
'type' => 'text_align',
|
||||
'option_category' => 'layout',
|
||||
'options' => et_builder_get_text_orientation_options(array('justified')),
|
||||
'default_on_front' => 'left',
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'alignment',
|
||||
'description' => esc_html__('Here you can choose the image alignment.', 'wpmf'),
|
||||
'options_icon' => 'module_align',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render content
|
||||
*
|
||||
* @param array $attrs List of attributes.
|
||||
* @param string $content Content being processed.
|
||||
* @param string $render_slug Slug of module that is used for rendering output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render($attrs, $content, $render_slug) // phpcs:ignore PEAR.Functions.ValidDefaultValue.NotAtEnd -- Method extends from ET_Builder_Module class
|
||||
{
|
||||
if (empty($this->props['url'])) {
|
||||
$html = '<div class="wpmf-divi-container">
|
||||
<div id="divi-file-design-placeholder" class="divi-file-design-placeholder">
|
||||
<span class="wpmf-divi-message">
|
||||
' . esc_html__('Please select a PDF file to activate the preview', 'wpmf') . '
|
||||
</span>
|
||||
</div>
|
||||
</div>';
|
||||
return $html;
|
||||
}
|
||||
return do_shortcode('[wpmffiledesign url="' . esc_attr($this->props['url']) . '" align="' . esc_attr($this->props['align']) . '"]');
|
||||
}
|
||||
}
|
||||
|
||||
new WpmfFileDesignDivi;
|
||||
@@ -0,0 +1,301 @@
|
||||
// External Dependencies
|
||||
import React, {Component} from 'react';
|
||||
import $ from 'jquery';
|
||||
// Internal Dependencies
|
||||
import './style.css';
|
||||
|
||||
class WpmfGalleryDivi extends Component {
|
||||
|
||||
static slug = 'wpmf_gallery_divi';
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
html: '',
|
||||
loading: true
|
||||
};
|
||||
this.wrap = React.createRef();
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
if (this.props.items !== '') {
|
||||
this.loadHtml(this.props);
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (this.props.items !== nextProps.items || this.props.aspect_ratio !== nextProps.aspect_ratio || this.props.columns !== nextProps.columns || this.props.theme !== nextProps.theme || this.props.size !== nextProps.size || this.props.orderby !== nextProps.orderby || this.props.order !== nextProps.order || this.props.border_radius !== nextProps.border_radius || this.props.gutterwidth !== nextProps.gutterwidth
|
||||
|| this.props.border_width !== nextProps.border_width || this.props.border_color !== nextProps.border_color || this.props.border_style !== nextProps.border_style
|
||||
|| this.props.enable_shadow !== nextProps.enable_shadow || this.props.shadow_color !== nextProps.shadow_color || this.props.shadow_horizontal !== nextProps.shadow_horizontal || this.props.shadow_vertical !== nextProps.shadow_vertical || this.props.shadow_blur !== nextProps.shadow_blur || this.props.shadow_spread !== nextProps.shadow_spread
|
||||
|| this.props.gallery_folders !== nextProps.gallery_folders || this.props.gallery_folder_id !== nextProps.gallery_folder_id) {
|
||||
this.loadHtml(nextProps);
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (this.props.items !== '') {
|
||||
let t = this;
|
||||
let a = setInterval(function () {
|
||||
if (t.props.theme === 'masonry' || t.props.theme === 'portfolio') {
|
||||
if ($(t.wrap.current).find('.gallery-masonry').length) {
|
||||
t.initMasonry();
|
||||
clearInterval(a);
|
||||
}
|
||||
}
|
||||
|
||||
if (t.props.theme === 'slider') {
|
||||
if ($(t.wrap.current).find('.wpmfslick').length) {
|
||||
t.initSlider();
|
||||
clearInterval(a);
|
||||
}
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
// Deselect images when deselecting the block
|
||||
if (this.props.items !== '' && !(this.props.items === prevProps.items && this.props.aspect_ratio === prevProps.aspect_ratio && this.props.columns === prevProps.columns && this.props.theme === prevProps.theme && this.props.size === prevProps.size && this.props.orderby === prevProps.orderby && this.props.order === prevProps.order && this.props.border_radius === prevProps.border_radius && this.props.gutterwidth === prevProps.gutterwidth && this.props.border_width === prevProps.border_width && this.props.border_color === prevProps.border_color && this.props.border_style === prevProps.border_style && this.props.enable_shadow === prevProps.enable_shadow && this.props.shadow_color === prevProps.shadow_color && this.props.shadow_horizontal === prevProps.shadow_horizontal && this.props.shadow_vertical === prevProps.shadow_vertical && this.props.shadow_blur === prevProps.shadow_blur && this.props.shadow_spread === prevProps.shadow_spread && this.props.gallery_folders === prevProps.gallery_folders && this.props.gallery_folder_id === prevProps.gallery_folder_id)) {
|
||||
let t = this;
|
||||
let a = setInterval(function () {
|
||||
if (t.props.theme === 'masonry' || t.props.theme === 'portfolio') {
|
||||
if ($(t.wrap.current).find('.gallery-masonry').length) {
|
||||
t.initMasonry();
|
||||
clearInterval(a);
|
||||
}
|
||||
}
|
||||
|
||||
if (t.props.theme === 'slider') {
|
||||
if ($(t.wrap.current).find('.wpmfslick').length) {
|
||||
if (t.props.aspect_ratio !== prevProps.aspect_ratio) {
|
||||
t.initSlider(true);
|
||||
} else {
|
||||
t.initSlider();
|
||||
}
|
||||
clearInterval(a);
|
||||
}
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
|
||||
calculateGrid($container) {
|
||||
let columns = parseInt($container.data('wpmfcolumns'));
|
||||
let gutterWidth = $container.data('gutterWidth');
|
||||
let containerWidth = $container.width();
|
||||
|
||||
if (isNaN(gutterWidth)) {
|
||||
gutterWidth = 5;
|
||||
} else if (gutterWidth > 500 || gutterWidth < 0) {
|
||||
gutterWidth = 5;
|
||||
}
|
||||
|
||||
if (parseInt(columns) < 2 || containerWidth <= 450) {
|
||||
columns = 2;
|
||||
}
|
||||
|
||||
gutterWidth = parseInt(gutterWidth);
|
||||
|
||||
let allGutters = gutterWidth * (columns - 1);
|
||||
let contentWidth = containerWidth - allGutters;
|
||||
|
||||
let columnWidth = Math.floor(contentWidth / columns);
|
||||
|
||||
return {columnWidth: columnWidth, gutterWidth: gutterWidth, columns: columns};
|
||||
};
|
||||
|
||||
initMasonry() {
|
||||
let $container = $(this.wrap.current).find('.gallery-masonry');
|
||||
if ($container.is(':hidden')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($container.hasClass('masonry')) {
|
||||
$container.masonry('destroy');
|
||||
}
|
||||
|
||||
var t = this;
|
||||
$container.imagesLoaded(function () {
|
||||
var $postBox = $container.children('.wpmf-gallery-item');
|
||||
var o = t.calculateGrid($container);
|
||||
$postBox.css({'width': o.columnWidth + 'px', 'margin-bottom': o.gutterWidth + 'px'});
|
||||
$container.masonry({
|
||||
itemSelector: '.wpmf-gallery-item',
|
||||
columnWidth: o.columnWidth,
|
||||
gutter: o.gutterWidth,
|
||||
isFitWidth: true,
|
||||
transitionDuration: 0,
|
||||
});
|
||||
$container.css('visibility', 'visible');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* run masonry layout
|
||||
*/
|
||||
initSlider(reload = false) {
|
||||
let $slider_container = $(this.wrap.current).find('.wpmfslick');
|
||||
if ($slider_container.is(':hidden')) {
|
||||
return;
|
||||
}
|
||||
|
||||
let columns = parseInt($slider_container.data('wpmfcolumns'));
|
||||
let autoplay = $slider_container.data('auto_animation');
|
||||
if ($slider_container.hasClass('slick-initialized') || reload) {
|
||||
$slider_container.slick('destroy');
|
||||
}
|
||||
|
||||
$slider_container.imagesLoaded(function () {
|
||||
var slick_args = {
|
||||
infinite: true,
|
||||
slidesToShow: parseInt(columns),
|
||||
slidesToScroll: parseInt(columns),
|
||||
pauseOnHover: true,
|
||||
autoplay: (autoplay === 1),
|
||||
adaptiveHeight: (parseInt(columns) === 1),
|
||||
autoplaySpeed: 5000,
|
||||
rows: 1,
|
||||
responsive: [
|
||||
{
|
||||
breakpoint: 1024,
|
||||
settings: {
|
||||
slidesToShow: 3,
|
||||
slidesToScroll: 3,
|
||||
infinite: true,
|
||||
dots: true
|
||||
}
|
||||
},
|
||||
{
|
||||
breakpoint: 600,
|
||||
settings: {
|
||||
slidesToShow: 2,
|
||||
slidesToScroll: 2
|
||||
}
|
||||
},
|
||||
{
|
||||
breakpoint: 480,
|
||||
settings: {
|
||||
slidesToShow: 1,
|
||||
slidesToScroll: 1
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
$slider_container.slick(slick_args);
|
||||
});
|
||||
}
|
||||
|
||||
loadHtml(props) {
|
||||
if (!this.state.loading) {
|
||||
this.setState({
|
||||
loading: true
|
||||
});
|
||||
}
|
||||
let img_shadow = '';
|
||||
if (props.enable_shadow === 'on') {
|
||||
img_shadow = props.shadow_horizontal + ' ' + props.shadow_vertical + ' ' + props.shadow_blur + ' ' + props.shadow_spread + ' ' + props.shadow_color;
|
||||
}
|
||||
let datas = {
|
||||
items: props.items,
|
||||
display: props.theme,
|
||||
columns: props.columns,
|
||||
size: props.size,
|
||||
targetsize: props.targetsize,
|
||||
link: props.action,
|
||||
orderby: props.orderby,
|
||||
order: props.order,
|
||||
gutterwidth: props.gutterwidth,
|
||||
border_width: props.border_width,
|
||||
border_style: props.border_style,
|
||||
border_color: props.border_color,
|
||||
img_shadow: img_shadow,
|
||||
border_radius: props.border_radius,
|
||||
wpmf_autoinsert: props.gallery_folders,
|
||||
wpmf_folder_id: props.gallery_folder_id
|
||||
};
|
||||
|
||||
fetch(window.et_fb_options.ajaxurl + `?action=wpmf_divi_load_gallery_html&et_admin_load_nonce=${window.et_fb_options.et_admin_load_nonce}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(datas)
|
||||
} )
|
||||
.then(res => res.json())
|
||||
.then(
|
||||
(result) => {
|
||||
this.setState({
|
||||
html: result.html,
|
||||
loading: false
|
||||
});
|
||||
},
|
||||
// errors
|
||||
(error) => {
|
||||
this.setState({
|
||||
html: '',
|
||||
loading: true
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
const loadingIcon = (
|
||||
<svg className={'wpfd-loading'} width="100%" height="100%" xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 100 100" preserveAspectRatio="xMidYMid">
|
||||
<g transform="translate(25 50)">
|
||||
<circle cx="0" cy="0" r="10" fill="#cfcfcf" transform="scale(0.590851 0.590851)">
|
||||
<animateTransform attributeName="transform" type="scale" begin="-0.8666666666666667s" calcMode="spline"
|
||||
keySplines="0.3 0 0.7 1;0.3 0 0.7 1" values="0.5;1;0.5" keyTimes="0;0.5;1" dur="2.6s"
|
||||
repeatCount="indefinite"/>
|
||||
</circle>
|
||||
</g>
|
||||
<g transform="translate(50 50)">
|
||||
<circle cx="0" cy="0" r="10" fill="#cfcfcf" transform="scale(0.145187 0.145187)">
|
||||
<animateTransform attributeName="transform" type="scale" begin="-0.43333333333333335s" calcMode="spline"
|
||||
keySplines="0.3 0 0.7 1;0.3 0 0.7 1" values="0.5;1;0.5" keyTimes="0;0.5;1" dur="2.6s"
|
||||
repeatCount="indefinite"/>
|
||||
</circle>
|
||||
</g>
|
||||
<g transform="translate(75 50)">
|
||||
<circle cx="0" cy="0" r="10" fill="#cfcfcf" transform="scale(0.0339143 0.0339143)">
|
||||
<animateTransform attributeName="transform" type="scale" begin="0s" calcMode="spline"
|
||||
keySplines="0.3 0 0.7 1;0.3 0 0.7 1" values="0.5;1;0.5" keyTimes="0;0.5;1" dur="2.6s"
|
||||
repeatCount="indefinite"/>
|
||||
</circle>
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
|
||||
if (this.props.items === '' && parseInt(this.props.gallery_folder_id) === 0) {
|
||||
return (
|
||||
<div className="wpmf-divi-container wpmf-gallery-divi-wrap" ref={this.wrap}>
|
||||
<div id="divi-gallery-placeholder" className="divi-gallery-placeholder">
|
||||
<span className="wpmf-divi-message">
|
||||
{'Please add some images to the gallery to activate the preview'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (this.state.loading) {
|
||||
return (
|
||||
<div className="wpmf-divi-container wpmf-gallery-divi-wrap" ref={this.wrap}>
|
||||
<div className={'wpmf-loading-wrapper'}>
|
||||
<i className={'wpmf-loading'}>{loadingIcon}</i>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!this.state.loading) {
|
||||
return (
|
||||
<div className="wpmf-gallery-divi-wrap" ref={this.wrap} dangerouslySetInnerHTML={{__html: this.state.html}}/>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default WpmfGalleryDivi;
|
||||
@@ -0,0 +1,377 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
|
||||
/**
|
||||
* Class WpmfGalleryDivi
|
||||
*/
|
||||
class WpmfGalleryDivi extends ET_Builder_Module
|
||||
{
|
||||
|
||||
/**
|
||||
* Module slug
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $slug = 'wpmf_gallery_divi';
|
||||
|
||||
/**
|
||||
* Whether module support visual builder. e.g `on` or `off`.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $vb_support = 'on';
|
||||
|
||||
/**
|
||||
* Credits of all custom modules.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $module_credits = array(
|
||||
'module_uri' => 'https://www.joomunited.com/',
|
||||
'author' => 'Joomunited',
|
||||
'author_uri' => 'https://www.joomunited.com/',
|
||||
);
|
||||
|
||||
/**
|
||||
* Init
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->name = esc_html__('WPMF Gallery', 'wpmf');
|
||||
}
|
||||
|
||||
/**
|
||||
* Advanced Fields Config
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_advanced_fields_config() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from ET_Builder_Module class
|
||||
{
|
||||
return array(
|
||||
'button' => false,
|
||||
'link_options' => false
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the settings fields data for this element.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_fields() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from ET_Builder_Module class
|
||||
{
|
||||
$settings = wpmfGetOption('gallery_settings');
|
||||
return array(
|
||||
'theme' => array(
|
||||
'label' => esc_html__('Theme', 'wpmf'),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'masonry' => esc_html__('Masonry', 'wpmf'),
|
||||
'default' => esc_html__('Default', 'wpmf'),
|
||||
'portfolio' => esc_html__('Portfolio', 'wpmf'),
|
||||
'slider' => esc_html__('Slider', 'wpmf')
|
||||
),
|
||||
'default' => 'default',
|
||||
'default_on_front' => 'default'
|
||||
),
|
||||
'items' => array(
|
||||
'label' => esc_html__('Images', 'wpmf'),
|
||||
'type' => 'upload-gallery',
|
||||
'option_category' => 'configuration',
|
||||
'computed_affects' => array(
|
||||
'__gallery',
|
||||
),
|
||||
'default' => '',
|
||||
'default_on_front' => '',
|
||||
),
|
||||
'aspect_ratio' => array(
|
||||
'label' => esc_html__('Aspect ratio', 'wpmf'),
|
||||
'description' => esc_html__('Aspect ratio for default, slider, portfolio theme', 'wpmf'),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'default' => esc_html__('Default', 'wpmf'),
|
||||
'1_1' => '1:1',
|
||||
'3_2' => '3:2',
|
||||
'2_3' => '2:3',
|
||||
'4_3' => '4:3',
|
||||
'3_4' => '3:4',
|
||||
'16_9' => '16:9',
|
||||
'9_16' => '9:16',
|
||||
'21_9' => '21:9',
|
||||
'9_21' => '9:21'
|
||||
),
|
||||
'default' => '1_1',
|
||||
'default_on_front' => '1_1'
|
||||
),
|
||||
'columns' => array(
|
||||
'label' => esc_html__('Columns', 'wpmf'),
|
||||
'type' => 'range',
|
||||
'option_category' => 'configuration',
|
||||
'default' => 3,
|
||||
'default_on_front' => $settings['theme']['masonry_theme']['columns'],
|
||||
'validate_unit' => false,
|
||||
'unitless' => true,
|
||||
'range_settings' => array(
|
||||
'min' => 1,
|
||||
'max' => 8,
|
||||
'step' => 1
|
||||
)
|
||||
),
|
||||
'size' => array(
|
||||
'label' => esc_html__('Image Size', 'wpmf'),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => apply_filters('image_size_names_choose', array(
|
||||
'thumbnail' => __('Thumbnail', 'wpmf'),
|
||||
'medium' => __('Medium', 'wpmf'),
|
||||
'large' => __('Large', 'wpmf'),
|
||||
'full' => __('Full Size', 'wpmf'),
|
||||
)),
|
||||
'default' => $settings['theme']['masonry_theme']['size'],
|
||||
'default_on_front' => $settings['theme']['masonry_theme']['size']
|
||||
),
|
||||
'targetsize' => array(
|
||||
'label' => esc_html__('Lightbox Size', 'wpmf'),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => apply_filters('image_size_names_choose', array(
|
||||
'thumbnail' => __('Thumbnail', 'wpmf'),
|
||||
'medium' => __('Medium', 'wpmf'),
|
||||
'large' => __('Large', 'wpmf'),
|
||||
'full' => __('Full Size', 'wpmf'),
|
||||
)),
|
||||
'default' => $settings['theme']['masonry_theme']['targetsize'],
|
||||
'default_on_front' => $settings['theme']['masonry_theme']['targetsize']
|
||||
),
|
||||
'action' => array(
|
||||
'label' => esc_html__('Action On Click', 'wpmf'),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'file' => esc_html__('Lightbox', 'wpmf'),
|
||||
'post' => esc_html__('Attachment Page', 'wpmf'),
|
||||
'none' => esc_html__('None', 'wpmf'),
|
||||
),
|
||||
'default' => $settings['theme']['masonry_theme']['link'],
|
||||
'default_on_front' => $settings['theme']['masonry_theme']['link']
|
||||
),
|
||||
'orderby' => array(
|
||||
'label' => esc_html__('Order by', 'wpmf'),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'post__in' => esc_html__('Custom', 'wpmf'),
|
||||
'rand' => esc_html__('Random', 'wpmf'),
|
||||
'title' => esc_html__('Title', 'wpmf'),
|
||||
'date' => esc_html__('Date', 'wpmf')
|
||||
),
|
||||
'default' => $settings['theme']['masonry_theme']['orderby'],
|
||||
'default_on_front' => $settings['theme']['masonry_theme']['orderby']
|
||||
),
|
||||
'order' => array(
|
||||
'label' => esc_html__('Order', 'wpmf'),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'ASC' => esc_html__('Ascending', 'wpmf'),
|
||||
'DESC' => esc_html__('Descending', 'wpmf')
|
||||
),
|
||||
'default' => $settings['theme']['masonry_theme']['order'],
|
||||
'default_on_front' => $settings['theme']['masonry_theme']['order']
|
||||
),
|
||||
'gutterwidth' => array(
|
||||
'label' => esc_html__('Gutter', 'wpmf'),
|
||||
'type' => 'range',
|
||||
'option_category' => 'configuration',
|
||||
'default' => 5,
|
||||
'default_on_front' => 5,
|
||||
'validate_unit' => false,
|
||||
'unitless' => true,
|
||||
'range_settings' => array(
|
||||
'min' => 0,
|
||||
'max' => 100,
|
||||
'step' => 5
|
||||
)
|
||||
),
|
||||
'border_radius' => array(
|
||||
'label' => esc_html__('Border Radius', 'wpmf'),
|
||||
'type' => 'range',
|
||||
'option_category' => 'configuration',
|
||||
'default' => 0,
|
||||
'default_on_front' => 0,
|
||||
'validate_unit' => false,
|
||||
'unitless' => true,
|
||||
'range_settings' => array(
|
||||
'min' => 0,
|
||||
'max' => 20,
|
||||
'step' => 1
|
||||
)
|
||||
),
|
||||
'border_style' => array(
|
||||
'label' => esc_html__('Border Type', 'wpmf'),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'solid' => esc_html__('Solid', 'wpmf'),
|
||||
'double' => esc_html__('Double', 'wpmf'),
|
||||
'dotted' => esc_html__('Dotted', 'wpmf'),
|
||||
'dashed' => esc_html__('Dashed', 'wpmf'),
|
||||
'groove' => esc_html__('Groove', 'wpmf')
|
||||
),
|
||||
'default' => 'solid',
|
||||
'default_on_front' => 'solid'
|
||||
),
|
||||
'border_width' => array(
|
||||
'label' => esc_html__('Border Width', 'wpmf'),
|
||||
'type' => 'range',
|
||||
'option_category' => 'configuration',
|
||||
'default' => 0,
|
||||
'default_on_front' => 0,
|
||||
'validate_unit' => false,
|
||||
'unitless' => true,
|
||||
'range_settings' => array(
|
||||
'min' => 0,
|
||||
'max' => 30,
|
||||
'step' => 1
|
||||
)
|
||||
),
|
||||
'border_color' => array(
|
||||
'label' => esc_html__('Border Color', 'wpmf'),
|
||||
'type' => 'color-alpha',
|
||||
'custom_color' => true,
|
||||
'default' => '#cccccc',
|
||||
'default_on_front' => '#cccccc'
|
||||
),
|
||||
'enable_shadow' => array(
|
||||
'label' => esc_html__('Enable Shadow', 'wpmf'),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__('On', 'wpmf'),
|
||||
'off' => esc_html__('Off', 'wpmf'),
|
||||
),
|
||||
'default' => 'off',
|
||||
'default_on_front' => 'off'
|
||||
),
|
||||
'shadow_color' => array(
|
||||
'label' => esc_html__('Shadow Color', 'wpmf'),
|
||||
'type' => 'color-alpha',
|
||||
'custom_color' => true,
|
||||
'default' => '#cccccc',
|
||||
'default_on_front' => '#cccccc'
|
||||
),
|
||||
'shadow_horizontal' => array(
|
||||
'label' => esc_html__('Horizontal', 'wpmf'),
|
||||
'type' => 'range',
|
||||
'option_category' => 'configuration',
|
||||
'validate_unit' => true,
|
||||
'default' => '0px',
|
||||
'default_unit' => 'px',
|
||||
'default_on_front' => '0px',
|
||||
'range_settings' => array(
|
||||
'min' => '-50',
|
||||
'max' => '50',
|
||||
'step' => '1'
|
||||
)
|
||||
),
|
||||
'shadow_vertical' => array(
|
||||
'label' => esc_html__('Vertical', 'wpmf'),
|
||||
'type' => 'range',
|
||||
'option_category' => 'configuration',
|
||||
'validate_unit' => true,
|
||||
'default' => '0px',
|
||||
'default_unit' => 'px',
|
||||
'default_on_front' => '0px',
|
||||
'range_settings' => array(
|
||||
'min' => '-50',
|
||||
'max' => '50',
|
||||
'step' => '1'
|
||||
)
|
||||
),
|
||||
'shadow_blur' => array(
|
||||
'label' => esc_html__('Blur', 'wpmf'),
|
||||
'type' => 'range',
|
||||
'option_category' => 'configuration',
|
||||
'validate_unit' => true,
|
||||
'default' => '0px',
|
||||
'default_unit' => 'px',
|
||||
'default_on_front' => '0px',
|
||||
'range_settings' => array(
|
||||
'min' => '0',
|
||||
'max' => '50',
|
||||
'step' => '1'
|
||||
)
|
||||
),
|
||||
'shadow_spread' => array(
|
||||
'label' => esc_html__('Spread', 'wpmf'),
|
||||
'type' => 'range',
|
||||
'option_category' => 'configuration',
|
||||
'validate_unit' => true,
|
||||
'default' => '0px',
|
||||
'default_unit' => 'px',
|
||||
'default_on_front' => '0px',
|
||||
'range_settings' => array(
|
||||
'min' => '0',
|
||||
'max' => '50',
|
||||
'step' => '1'
|
||||
)
|
||||
),
|
||||
'gallery_folders' => array(
|
||||
'label' => esc_html__('Gallery From Folder', 'wpmf'),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__('On', 'wpmf'),
|
||||
'off' => esc_html__('Off', 'wpmf'),
|
||||
),
|
||||
'default' => 'off',
|
||||
'default_on_front' => 'off'
|
||||
),
|
||||
'gallery_folder_id' => array(
|
||||
'label' => esc_html__('Choose a Folder', 'wpmf'),
|
||||
'type' => 'text',
|
||||
'option_category' => 'configuration',
|
||||
'default' => 0,
|
||||
'default_on_front' => 0
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render content
|
||||
*
|
||||
* @param array $attrs List of attributes.
|
||||
* @param string $content Content being processed.
|
||||
* @param string $render_slug Slug of module that is used for rendering output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render($attrs, $content, $render_slug) // phpcs:ignore PEAR.Functions.ValidDefaultValue.NotAtEnd -- Method extends from ET_Builder_Module class
|
||||
{
|
||||
$gallery_folders = (!empty($this->props['gallery_folders']) && $this->props['gallery_folders'] === 'on') ? 1 : 0;
|
||||
if (!empty($this->props['enable_shadow']) && $this->props['enable_shadow'] === 'on') {
|
||||
$img_shadow = $this->props['shadow_horizontal'] . ' ' . $this->props['shadow_vertical'] . ' ' . $this->props['shadow_blur'] . ' ' . $this->props['shadow_spread'] . ' ' . $this->props['shadow_color'];
|
||||
} else {
|
||||
$img_shadow = '';
|
||||
}
|
||||
if (empty($this->props['items']) && empty($this->props['gallery_folder_id'])) {
|
||||
$html = '<div class="wpmf-divi-container">
|
||||
<div id="divi-gallery-placeholder" class="divi-gallery-placeholder">
|
||||
<span class="wpmf-divi-message">
|
||||
' . esc_html__('Please add some images to the gallery to activate the preview', 'wpmf') . '
|
||||
</span>
|
||||
</div>
|
||||
</div>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
return do_shortcode('[wpmf_gallery is_divi="1" include="'. esc_attr($this->props['items']) .'" display="' . esc_attr($this->props['theme']) . '" columns="' . esc_attr($this->props['columns']) . '" size="' . esc_attr($this->props['size']) . '" targetsize="' . esc_attr($this->props['targetsize']) . '" link="' . esc_attr($this->props['action']) . '" wpmf_orderby="' . esc_attr($this->props['orderby']) . '" wpmf_order="' . esc_attr($this->props['order']) . '" gutterwidth="' . esc_attr($this->props['gutterwidth']) . '" border_width="' . esc_attr($this->props['border_width']) . '" border_style="' . esc_attr($this->props['border_style']) . '" border_color="' . esc_attr($this->props['border_color']) . '" img_shadow="' . esc_attr($img_shadow) . '" img_border_radius="' . esc_attr($this->props['border_radius']) . '" wpmf_autoinsert="' . esc_attr($gallery_folders) . '" wpmf_folder_id="' . esc_attr($this->props['gallery_folder_id']) . '" aspect_ratio="' . esc_attr($this->props['aspect_ratio']) . '"]');
|
||||
}
|
||||
}
|
||||
|
||||
new WpmfGalleryDivi;
|
||||
@@ -0,0 +1,155 @@
|
||||
.gallery-columns-1 .wpmf-gallery-item {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.gallery-columns-2 .wpmf-gallery-item {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.gallery-columns-3 .wpmf-gallery-item {
|
||||
width: calc(100%/3);
|
||||
}
|
||||
|
||||
.gallery-columns-4 .wpmf-gallery-item {
|
||||
width: 25%;
|
||||
}
|
||||
|
||||
.gallery-columns-5 .wpmf-gallery-item {
|
||||
width: 20%;
|
||||
}
|
||||
|
||||
.gallery-columns-6 .wpmf-gallery-item {
|
||||
width: calc(100%/6);
|
||||
}
|
||||
|
||||
.gallery-columns-7 .wpmf-gallery-item {
|
||||
width: calc(100%/7);
|
||||
}
|
||||
|
||||
.gallery-columns-8 .wpmf-gallery-item {
|
||||
width: 12.5%
|
||||
}
|
||||
|
||||
.gallery-columns-9 .wpmf-gallery-item {
|
||||
width: calc(100%/9);
|
||||
}
|
||||
|
||||
.wpmf-has-border-radius-1 .wpmf-gallery-item img,
|
||||
.wpmf-has-border-radius-1.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon,
|
||||
.wpmf-has-border-radius-1 .wpmf-gallery-item .wpmf_overlay {
|
||||
border-radius: 1px
|
||||
}
|
||||
|
||||
.wpmf-has-border-radius-2 .wpmf-gallery-item img,
|
||||
.wpmf-has-border-radius-2.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon,
|
||||
.wpmf-has-border-radius-2 .wpmf-gallery-item .wpmf_overlay {
|
||||
border-radius: 2px
|
||||
}
|
||||
|
||||
.wpmf-has-border-radius-3 .wpmf-gallery-item img,
|
||||
.wpmf-has-border-radius-3.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon,
|
||||
.wpmf-has-border-radius-3 .wpmf-gallery-item .wpmf_overlay {
|
||||
border-radius: 3px
|
||||
}
|
||||
|
||||
.wpmf-has-border-radius-4 .wpmf-gallery-item img,
|
||||
.wpmf-has-border-radius-4.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon,
|
||||
.wpmf-has-border-radius-4 .wpmf-gallery-item .wpmf_overlay {
|
||||
border-radius: 4px
|
||||
}
|
||||
|
||||
.wpmf-has-border-radius-5 .wpmf-gallery-item img,
|
||||
.wpmf-has-border-radius-5.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon,
|
||||
.wpmf-has-border-radius-5 .wpmf-gallery-item .wpmf_overlay {
|
||||
border-radius: 5px
|
||||
}
|
||||
|
||||
.wpmf-has-border-radius-6 .wpmf-gallery-item img,
|
||||
.wpmf-has-border-radius-6.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon,
|
||||
.wpmf-has-border-radius-6 .wpmf-gallery-item .wpmf_overlay {
|
||||
border-radius: 6px
|
||||
}
|
||||
|
||||
.wpmf-has-border-radius-7 .wpmf-gallery-item img,
|
||||
.wpmf-has-border-radius-7.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon,
|
||||
.wpmf-has-border-radius-7 .wpmf-gallery-item .wpmf_overlay {
|
||||
border-radius: 7px
|
||||
}
|
||||
|
||||
.wpmf-has-border-radius-8 .wpmf-gallery-item img,
|
||||
.wpmf-has-border-radius-8.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon,
|
||||
.wpmf-has-border-radius-8 .wpmf-gallery-item .wpmf_overlay {
|
||||
border-radius: 8px
|
||||
}
|
||||
|
||||
.wpmf-has-border-radius-9 .wpmf-gallery-item img,
|
||||
.wpmf-has-border-radius-9.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon,
|
||||
.wpmf-has-border-radius-9 .wpmf-gallery-item .wpmf_overlay {
|
||||
border-radius: 9px
|
||||
}
|
||||
|
||||
.wpmf-has-border-radius-10 .wpmf-gallery-item img,
|
||||
.wpmf-has-border-radius-10.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon,
|
||||
.wpmf-has-border-radius-10 .wpmf-gallery-item .wpmf_overlay {
|
||||
border-radius: 10px
|
||||
}
|
||||
|
||||
.wpmf-has-border-radius-11 .wpmf-gallery-item img,
|
||||
.wpmf-has-border-radius-11.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon,
|
||||
.wpmf-has-border-radius-11 .wpmf-gallery-item .wpmf_overlay {
|
||||
border-radius: 11px
|
||||
}
|
||||
|
||||
.wpmf-has-border-radius-12 .wpmf-gallery-item img,
|
||||
.wpmf-has-border-radius-12.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon,
|
||||
.wpmf-has-border-radius-12 .wpmf-gallery-item .wpmf_overlay {
|
||||
border-radius: 12px
|
||||
}
|
||||
|
||||
.wpmf-has-border-radius-13 .wpmf-gallery-item img,
|
||||
.wpmf-has-border-radius-13.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon,
|
||||
.wpmf-has-border-radius-13 .wpmf-gallery-item .wpmf_overlay {
|
||||
border-radius: 13px
|
||||
}
|
||||
|
||||
.wpmf-has-border-radius-14 .wpmf-gallery-item img,
|
||||
.wpmf-has-border-radius-14.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon,
|
||||
.wpmf-has-border-radius-14 .wpmf-gallery-item .wpmf_overlay {
|
||||
border-radius: 14px
|
||||
}
|
||||
|
||||
.wpmf-has-border-radius-15 .wpmf-gallery-item img,
|
||||
.wpmf-has-border-radius-15.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon,
|
||||
.wpmf-has-border-radius-15 .wpmf-gallery-item .wpmf_overlay {
|
||||
border-radius: 15px
|
||||
}
|
||||
|
||||
.wpmf-has-border-radius-16 .wpmf-gallery-item img,
|
||||
.wpmf-has-border-radius-16.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon,
|
||||
.wpmf-has-border-radius-16 .wpmf-gallery-item .wpmf_overlay {
|
||||
border-radius: 16px
|
||||
}
|
||||
|
||||
.wpmf-has-border-radius-17 .wpmf-gallery-item img,
|
||||
.wpmf-has-border-radius-17.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon,
|
||||
.wpmf-has-border-radius-17 .wpmf-gallery-item .wpmf_overlay {
|
||||
border-radius: 17px
|
||||
}
|
||||
|
||||
.wpmf-has-border-radius-18 .wpmf-gallery-item img,
|
||||
.wpmf-has-border-radius-18.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon,
|
||||
.wpmf-has-border-radius-18 .wpmf-gallery-item .wpmf_overlay {
|
||||
border-radius: 18px
|
||||
}
|
||||
|
||||
.wpmf-has-border-radius-19 .wpmf-gallery-item img,
|
||||
.wpmf-has-border-radius-19.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon,
|
||||
.wpmf-has-border-radius-19 .wpmf-gallery-item .wpmf_overlay {
|
||||
border-radius: 19px
|
||||
}
|
||||
|
||||
.wpmf-has-border-radius-20 .wpmf-gallery-item img,
|
||||
.wpmf-has-border-radius-20.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon,
|
||||
.wpmf-has-border-radius-20 .wpmf-gallery-item .wpmf_overlay {
|
||||
border-radius: 20px
|
||||
}
|
||||
@@ -0,0 +1,473 @@
|
||||
// External Dependencies
|
||||
import React, {Component} from 'react';
|
||||
import $ from 'jquery';
|
||||
// Internal Dependencies
|
||||
import './style.css';
|
||||
|
||||
class WpmfGalleryAddonDivi extends Component {
|
||||
|
||||
static slug = 'wpmf_gallery_addon_divi';
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
html: '',
|
||||
loading: true
|
||||
};
|
||||
this.wrap = React.createRef();
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
if (this.props.items !== '') {
|
||||
this.loadHtml(this.props);
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (this.props.gallery_id !== nextProps.gallery_id || this.props.columns !== nextProps.columns || this.props.theme !== nextProps.theme || this.props.layout !== nextProps.layout || this.props.row_height !== nextProps.row_height || this.props.aspect_ratio !== nextProps.aspect_ratio || this.props.size !== nextProps.size || this.props.orderby !== nextProps.orderby || this.props.order !== nextProps.order || this.props.border_radius !== nextProps.border_radius || this.props.gutterwidth !== nextProps.gutterwidth
|
||||
|| this.props.border_width !== nextProps.border_width || this.props.border_color !== nextProps.border_color || this.props.border_style !== nextProps.border_style
|
||||
|| this.props.enable_shadow !== nextProps.enable_shadow || this.props.shadow_color !== nextProps.shadow_color || this.props.shadow_horizontal !== nextProps.shadow_horizontal || this.props.shadow_vertical !== nextProps.shadow_vertical || this.props.shadow_blur !== nextProps.shadow_blur || this.props.shadow_spread !== nextProps.shadow_spread
|
||||
|| this.props.gallery_image_tags !== nextProps.gallery_image_tags || this.props.gallery_navigation !== nextProps.gallery_navigation || this.props.sub_galleries_listing !== nextProps.sub_galleries_listing || this.props.number_lines !== nextProps.number_lines
|
||||
|| this.props.disable_overlay !== nextProps.disable_overlay || this.props.hover_color !== nextProps.hover_color || this.props.hover_opacity !== nextProps.hover_opacity || this.props.hover_title_position !== nextProps.hover_title_position
|
||||
|| this.props.hover_title_size !== nextProps.hover_title_size || this.props.hover_title_color !== nextProps.hover_title_color || this.props.hover_desc_position !== nextProps.hover_desc_position
|
||||
|| this.props.hover_desc_size !== nextProps.hover_desc_size || this.props.hover_desc_color !== nextProps.hover_desc_color) {
|
||||
this.loadHtml(nextProps);
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (parseInt(this.props.gallery_id) !== 0) {
|
||||
let t = this;
|
||||
let a = setInterval(function () {
|
||||
$(t.wrap.current).find('.loading_gallery').hide();
|
||||
if (t.props.theme === 'masonry') {
|
||||
if ($(t.wrap.current).find('.gallery-masonry').length) {
|
||||
t.initMasonry();
|
||||
clearInterval(a);
|
||||
}
|
||||
}
|
||||
|
||||
if (t.props.theme === 'custom_grid') {
|
||||
if ($(t.wrap.current).find('.wpmf-custom-grid').length) {
|
||||
t.initCustomGrid();
|
||||
clearInterval(a);
|
||||
}
|
||||
}
|
||||
|
||||
if (t.props.theme === 'slider') {
|
||||
if ($(t.wrap.current).find('.wpmfslick').length) {
|
||||
t.initSlider();
|
||||
clearInterval(a);
|
||||
}
|
||||
}
|
||||
|
||||
if (t.props.theme === 'flowslide') {
|
||||
if ($(t.wrap.current).find('.wpmf-flipster').length) {
|
||||
t.initFlowsSlide();
|
||||
clearInterval(a);
|
||||
}
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
// Deselect images when deselecting the block
|
||||
if (parseInt(this.props.gallery_id) !== 0 && !(this.props.gallery_id === prevProps.gallery_id && this.props.columns === prevProps.columns && this.props.theme === prevProps.theme && this.props.layout === prevProps.layout && this.props.row_height === prevProps.row_height && this.props.aspect_ratio === prevProps.aspect_ratio && this.props.size === prevProps.size && this.props.orderby === prevProps.orderby && this.props.order === prevProps.order && this.props.border_radius === prevProps.border_radius && this.props.gutterwidth === prevProps.gutterwidth && this.props.border_width === prevProps.border_width && this.props.border_color === prevProps.border_color && this.props.border_style === prevProps.border_style && this.props.enable_shadow === prevProps.enable_shadow && this.props.shadow_color === prevProps.shadow_color && this.props.shadow_horizontal === prevProps.shadow_horizontal && this.props.shadow_vertical === prevProps.shadow_vertical && this.props.shadow_blur === prevProps.shadow_blur && this.props.shadow_spread === prevProps.shadow_spread && this.props.gallery_image_tags === prevProps.gallery_image_tags && this.props.disable_overlay === prevProps.disable_overlay && this.props.gallery_navigation === prevProps.gallery_navigation && this.props.sub_galleries_listing === prevProps.sub_galleries_listing && this.props.number_lines === prevProps.number_lines && this.props.hover_color === prevProps.hover_color && this.props.hover_opacity === prevProps.hover_opacity && this.props.hover_title_position === prevProps.hover_title_position && this.props.hover_title_size === prevProps.hover_title_size && this.props.hover_title_color === prevProps.hover_title_color && this.props.hover_desc_position === prevProps.hover_desc_position && this.props.hover_desc_size === prevProps.hover_desc_size && this.props.hover_desc_color === prevProps.hover_desc_color)) {
|
||||
let t = this;
|
||||
let a = setInterval(function () {
|
||||
$(t.wrap.current).find('.loading_gallery').hide();
|
||||
if (t.props.theme === 'masonry') {
|
||||
if ($(t.wrap.current).find('.gallery-masonry').length) {
|
||||
t.initMasonry();
|
||||
clearInterval(a);
|
||||
}
|
||||
}
|
||||
|
||||
if (t.props.theme === 'custom_grid') {
|
||||
if ($(t.wrap.current).find('.wpmf-custom-grid').length) {
|
||||
t.initCustomGrid();
|
||||
clearInterval(a);
|
||||
}
|
||||
}
|
||||
|
||||
if (t.props.theme === 'slider') {
|
||||
if ($(t.wrap.current).find('.wpmfslick').length) {
|
||||
t.initSlider();
|
||||
clearInterval(a);
|
||||
}
|
||||
}
|
||||
|
||||
if (t.props.theme === 'flowslide') {
|
||||
if ($(t.wrap.current).find('.wpmf-flipster').length) {
|
||||
t.initFlowsSlide();
|
||||
clearInterval(a);
|
||||
}
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
calculateGrid($container) {
|
||||
let columns = parseInt($container.data('wpmfcolumns'));
|
||||
let gutterWidth = $container.data('gutterWidth');
|
||||
let containerWidth = $container.width();
|
||||
|
||||
if (isNaN(gutterWidth)) {
|
||||
gutterWidth = 5;
|
||||
} else if (gutterWidth > 500 || gutterWidth < 0) {
|
||||
gutterWidth = 5;
|
||||
}
|
||||
|
||||
if (parseInt(columns) < 2 || containerWidth <= 450) {
|
||||
columns = 2;
|
||||
}
|
||||
|
||||
gutterWidth = parseInt(gutterWidth);
|
||||
|
||||
let allGutters = gutterWidth * (columns - 1);
|
||||
let contentWidth = containerWidth - allGutters;
|
||||
|
||||
let columnWidth = Math.floor(contentWidth / columns);
|
||||
|
||||
return {columnWidth: columnWidth, gutterWidth: gutterWidth, columns: columns};
|
||||
};
|
||||
|
||||
initFlowsSlide() {
|
||||
let $container = $(this.wrap.current).find('.wpmf-flipster');
|
||||
let enableNavButtons = $container.data('button');
|
||||
if (typeof enableNavButtons !== "undefined" && parseInt(enableNavButtons) === 1) {
|
||||
$container.flipster({
|
||||
style: 'coverflow',
|
||||
buttons: 'custom',
|
||||
spacing: 0,
|
||||
loop: true,
|
||||
autoplay: 5000,
|
||||
buttonNext: '<i class="flipto-next material-icons"> keyboard_arrow_right </i>',
|
||||
buttonPrev: '<i class="flipto-prev material-icons"> keyboard_arrow_left </i>',
|
||||
onItemSwitch: function (currentItem, previousItem) {
|
||||
$container.find('.flipster__container').height($(currentItem).height());
|
||||
},
|
||||
onItemStart: function (currentItem) {
|
||||
$container.find('.flipster__container').height($(currentItem).height());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$container.flipster({
|
||||
style: 'coverflow',
|
||||
spacing: 0,
|
||||
loop: true,
|
||||
autoplay: 5000,
|
||||
onItemSwitch: function (currentItem, previousItem) {
|
||||
$container.find('.flipster__container').height($(currentItem).height());
|
||||
},
|
||||
onItemStart: function (currentItem) {
|
||||
$container.find('.flipster__container').height($(currentItem).height());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
initMasonry() {
|
||||
let $container = $(this.wrap.current).find('.gallery-masonry');
|
||||
let layout = $container.closest('.wpmf-gallerys-addon').data('layout');
|
||||
let padding = $container.data('gutter-width');
|
||||
if ($container.is(':hidden')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($container.hasClass('masonry')) {
|
||||
$container.masonry('destroy');
|
||||
}
|
||||
|
||||
if ($container.hasClass('justified-gallery')) {
|
||||
$container.justifiedGallery('destroy');
|
||||
}
|
||||
|
||||
if (layout === 'horizontal') {
|
||||
var row_height = $container.closest('.wpmf-gallerys-addon').data('row_height');
|
||||
if (typeof row_height === "undefined" || row_height === '') {
|
||||
row_height = 200;
|
||||
}
|
||||
|
||||
$container.imagesLoaded(function () {
|
||||
setTimeout(function () {
|
||||
$container.justifiedGallery({
|
||||
rowHeight: row_height,
|
||||
margins: padding
|
||||
});
|
||||
},200);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
var t = this;
|
||||
$container.imagesLoaded(function () {
|
||||
var $postBox = $container.children('.wpmf-gallery-item');
|
||||
var o = t.calculateGrid($container);
|
||||
$postBox.css({'width': o.columnWidth + 'px', 'margin-bottom': o.gutterWidth + 'px'});
|
||||
$container.masonry({
|
||||
itemSelector: '.wpmf-gallery-item',
|
||||
columnWidth: o.columnWidth,
|
||||
gutter: o.gutterWidth,
|
||||
isFitWidth: true,
|
||||
transitionDuration: 0,
|
||||
});
|
||||
$container.css('visibility', 'visible');
|
||||
});
|
||||
}
|
||||
|
||||
initCustomGrid() {
|
||||
let $container = $(this.wrap.current).find('.wpmf-custom-grid');
|
||||
if ($container.is(':hidden')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($container.hasClass('masonry')) {
|
||||
$container.masonry('destroy');
|
||||
}
|
||||
|
||||
if ($container.hasClass('justified-gallery')) {
|
||||
$container.justifiedGallery('destroy');
|
||||
}
|
||||
|
||||
if ($container.hasClass('wpmfInitPackery')) {
|
||||
$container.isotope('destroy');
|
||||
}
|
||||
|
||||
$container.imagesLoaded(function () {
|
||||
var gutter = $container.data('gutter');
|
||||
$container.closest('.wpmf_gallery_wrap').find('.loading_gallery').hide();
|
||||
var wrap_width = $container.width();
|
||||
var one_col_width = (wrap_width - gutter*12)/12;
|
||||
$container.find('.grid-item').each(function() {
|
||||
var dimensions = $(this).data('styles');
|
||||
var w = (typeof dimensions.width !== "undefined") ? parseInt(dimensions.width) : 2;
|
||||
var h = (typeof dimensions.height !== "undefined") ? parseInt(dimensions.height) : 2;
|
||||
var g = (parseInt(w) - 1)*gutter;
|
||||
var display_width = one_col_width;
|
||||
var display_height = one_col_width;
|
||||
|
||||
if (w > 1) {
|
||||
display_width = one_col_width*w + g;
|
||||
}
|
||||
|
||||
if (w == h) {
|
||||
display_height = display_width;
|
||||
} else {
|
||||
if (h > 1) {
|
||||
display_height = (one_col_width*h) + (h - 1)*gutter;
|
||||
}
|
||||
}
|
||||
|
||||
$(this).width(display_width);
|
||||
$(this).height(display_height);
|
||||
});
|
||||
|
||||
$container.isotope({
|
||||
itemSelector: '.grid-item',
|
||||
layoutMode: 'packery',
|
||||
resizable: true,
|
||||
initLayout: true,
|
||||
packery: {
|
||||
gutter: gutter
|
||||
}
|
||||
});
|
||||
$container.addClass('wpmfInitPackery');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* run masonry layout
|
||||
*/
|
||||
initSlider() {
|
||||
let $slider_container = $(this.wrap.current).find('.wpmfslick');
|
||||
if ($slider_container.is(':hidden')) {
|
||||
return;
|
||||
}
|
||||
|
||||
let number_lines = parseInt($slider_container.data('number_lines'));
|
||||
let columns = parseInt($slider_container.data('wpmfcolumns'));
|
||||
let autoplay = $slider_container.data('auto_animation');
|
||||
if ($slider_container.hasClass('slick-initialized')) {
|
||||
$slider_container.slick('destroy');
|
||||
}
|
||||
|
||||
$slider_container.imagesLoaded(function () {
|
||||
var slick_args = {
|
||||
infinite: true,
|
||||
slidesToShow: parseInt(columns),
|
||||
slidesToScroll: parseInt(columns),
|
||||
pauseOnHover: true,
|
||||
autoplay: (autoplay === 1),
|
||||
adaptiveHeight: (parseInt(columns) === 1),
|
||||
autoplaySpeed: 5000,
|
||||
rows: number_lines,
|
||||
responsive: [
|
||||
{
|
||||
breakpoint: 1024,
|
||||
settings: {
|
||||
slidesToShow: 3,
|
||||
slidesToScroll: 3,
|
||||
infinite: true,
|
||||
dots: true
|
||||
}
|
||||
},
|
||||
{
|
||||
breakpoint: 600,
|
||||
settings: {
|
||||
slidesToShow: 2,
|
||||
slidesToScroll: 2
|
||||
}
|
||||
},
|
||||
{
|
||||
breakpoint: 480,
|
||||
settings: {
|
||||
slidesToShow: 1,
|
||||
slidesToScroll: 1
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
$slider_container.slick(slick_args);
|
||||
});
|
||||
}
|
||||
|
||||
loadHtml(props) {
|
||||
if (!this.state.loading) {
|
||||
this.setState({
|
||||
loading: true
|
||||
});
|
||||
}
|
||||
let img_shadow = '';
|
||||
if (props.enable_shadow === 'on') {
|
||||
img_shadow = props.shadow_horizontal + ' ' + props.shadow_vertical + ' ' + props.shadow_blur + ' ' + props.shadow_spread + ' ' + props.shadow_color;
|
||||
}
|
||||
|
||||
let gallery_id_string = props.gallery_id;
|
||||
let gallery_id;
|
||||
if (gallery_id_string.indexOf('-') != -1) {
|
||||
let gallery_ids = gallery_id_string.split('-');
|
||||
gallery_id = gallery_ids[1];
|
||||
} else {
|
||||
gallery_id = gallery_id_string;
|
||||
}
|
||||
let datas = {
|
||||
gallery_id: gallery_id,
|
||||
display: props.theme,
|
||||
layout: props.layout,
|
||||
row_height: props.row_height,
|
||||
aspect_ratio: props.aspect_ratio,
|
||||
columns: props.columns,
|
||||
number_lines: props.number_lines,
|
||||
size: props.size,
|
||||
targetsize: props.targetsize,
|
||||
link: props.action,
|
||||
orderby: props.orderby,
|
||||
order: props.order,
|
||||
gutterwidth: props.gutterwidth,
|
||||
border_width: props.border_width,
|
||||
border_style: props.border_style,
|
||||
border_color: props.border_color,
|
||||
img_shadow: img_shadow,
|
||||
border_radius: props.border_radius,
|
||||
display_tree: props.gallery_navigation,
|
||||
sub_galleries_listing: props.sub_galleries_listing,
|
||||
display_tag: props.gallery_image_tags,
|
||||
disable_overlay: props.disable_overlay,
|
||||
hover_color: props.hover_color,
|
||||
hover_opacity: props.hover_opacity,
|
||||
hover_title_position: props.hover_title_position,
|
||||
hover_title_size: props.hover_title_size,
|
||||
hover_title_color: props.hover_title_color,
|
||||
hover_desc_position: props.hover_desc_position,
|
||||
hover_desc_size: props.hover_desc_size,
|
||||
hover_desc_color: props.hover_desc_color
|
||||
};
|
||||
|
||||
fetch(window.et_fb_options.ajaxurl + `?action=wpmf_divi_load_gallery_addon_html&et_admin_load_nonce=${window.et_fb_options.et_admin_load_nonce}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(datas)
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(
|
||||
(result) => {
|
||||
this.setState({
|
||||
html: result.html,
|
||||
loading: false
|
||||
});
|
||||
},
|
||||
// errors
|
||||
(error) => {
|
||||
this.setState({
|
||||
html: '',
|
||||
loading: true
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
const loadingIcon = (
|
||||
<svg className={'wpfd-loading'} width="100%" height="100%" xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 100 100" preserveAspectRatio="xMidYMid">
|
||||
<g transform="translate(25 50)">
|
||||
<circle cx="0" cy="0" r="10" fill="#cfcfcf" transform="scale(0.590851 0.590851)">
|
||||
<animateTransform attributeName="transform" type="scale" begin="-0.8666666666666667s" calcMode="spline"
|
||||
keySplines="0.3 0 0.7 1;0.3 0 0.7 1" values="0.5;1;0.5" keyTimes="0;0.5;1" dur="2.6s"
|
||||
repeatCount="indefinite"/>
|
||||
</circle>
|
||||
</g>
|
||||
<g transform="translate(50 50)">
|
||||
<circle cx="0" cy="0" r="10" fill="#cfcfcf" transform="scale(0.145187 0.145187)">
|
||||
<animateTransform attributeName="transform" type="scale" begin="-0.43333333333333335s" calcMode="spline"
|
||||
keySplines="0.3 0 0.7 1;0.3 0 0.7 1" values="0.5;1;0.5" keyTimes="0;0.5;1" dur="2.6s"
|
||||
repeatCount="indefinite"/>
|
||||
</circle>
|
||||
</g>
|
||||
<g transform="translate(75 50)">
|
||||
<circle cx="0" cy="0" r="10" fill="#cfcfcf" transform="scale(0.0339143 0.0339143)">
|
||||
<animateTransform attributeName="transform" type="scale" begin="0s" calcMode="spline"
|
||||
keySplines="0.3 0 0.7 1;0.3 0 0.7 1" values="0.5;1;0.5" keyTimes="0;0.5;1" dur="2.6s"
|
||||
repeatCount="indefinite"/>
|
||||
</circle>
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
|
||||
if (parseInt(this.props.gallery_id) === 0) {
|
||||
return (
|
||||
<div className="wpmf-divi-container wpmf-gallery-divi-wrap" ref={this.wrap}>
|
||||
<div id="divi-gallery-addon-placeholder" className="divi-gallery-addon-placeholder">
|
||||
<span className="wpmf-divi-message">
|
||||
{'Please select a gallery to activate the preview'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (this.state.loading) {
|
||||
return (
|
||||
<div className="wpmf-divi-container wpmf-gallery-divi-wrap" ref={this.wrap}>
|
||||
<div className={'wpmf-loading-wrapper'}>
|
||||
<i className={'wpmf-loading'}>{loadingIcon}</i>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!this.state.loading) {
|
||||
return (
|
||||
<div className="wpmf-gallery-divi-wrap" ref={this.wrap}
|
||||
dangerouslySetInnerHTML={{__html: this.state.html}}/>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default WpmfGalleryAddonDivi;
|
||||
@@ -0,0 +1,609 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
|
||||
/**
|
||||
* Class WpmfGalleryDivi
|
||||
*/
|
||||
class WpmfGalleryAddonDivi extends ET_Builder_Module
|
||||
{
|
||||
|
||||
/**
|
||||
* Module slug
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $slug = 'wpmf_gallery_addon_divi';
|
||||
|
||||
/**
|
||||
* Whether module support visual builder. e.g `on` or `off`.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $vb_support = 'on';
|
||||
|
||||
/**
|
||||
* Credits of all custom modules.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $module_credits = array(
|
||||
'module_uri' => 'https://www.joomunited.com/',
|
||||
'author' => 'Joomunited',
|
||||
'author_uri' => 'https://www.joomunited.com/',
|
||||
);
|
||||
|
||||
/**
|
||||
* Init
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->name = esc_html__('WPMF Gallery Addon', 'wpmf');
|
||||
}
|
||||
|
||||
/**
|
||||
* Advanced Fields Config
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_advanced_fields_config() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from ET_Builder_Module class
|
||||
{
|
||||
return array(
|
||||
'button' => false,
|
||||
'link_options' => false
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the settings fields data for this element.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_fields() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from ET_Builder_Module class
|
||||
{
|
||||
$settings = get_option('wpmf_gallery_settings');
|
||||
$galleries = get_categories(
|
||||
array(
|
||||
'hide_empty' => false,
|
||||
'taxonomy' => WPMF_GALLERY_ADDON_TAXO,
|
||||
'pll_get_terms_not_translated' => 1
|
||||
)
|
||||
);
|
||||
|
||||
if (count($galleries) < 100) {
|
||||
$galleries = wpmfParentSort($galleries);
|
||||
}
|
||||
|
||||
$galleries_list = array();
|
||||
$galleries_list[0] = esc_html__('WP Media Folder Gallery', 'wpmf');
|
||||
$i = 0;
|
||||
foreach ($galleries as $gallery) {
|
||||
$gallery_type = get_term_meta((int)$gallery->term_id, 'gallery_type', true);
|
||||
if (!empty($gallery_type) && ($gallery_type === 'photographer' || $gallery_type === 'archive')) {
|
||||
continue;
|
||||
}
|
||||
$depth = $gallery->depth + 1;
|
||||
$galleries_list[$i . '-' . $gallery->term_id] = str_repeat(' ', $depth) . $gallery->name;
|
||||
$i++;
|
||||
}
|
||||
|
||||
foreach ($galleries as $gallery) {
|
||||
$gallery_type = get_term_meta((int)$gallery->term_id, 'gallery_type', true);
|
||||
if (!empty($gallery_type) && $gallery_type === 'archive') {
|
||||
continue;
|
||||
}
|
||||
if (!empty($gallery_type) && $gallery_type === 'photographer') {
|
||||
$root = get_term_by('slug', 'photographer-gallery', WPMF_GALLERY_ADDON_TAXO);
|
||||
if ((int)$root->term_id === (int)$gallery->term_id) {
|
||||
$galleries_list[$i . '-' . $gallery->term_id] = esc_html__('Photographer Gallery', 'wpmf');
|
||||
} else {
|
||||
$depth = $gallery->depth;
|
||||
$galleries_list[$i . '-' . $gallery->term_id] = str_repeat(' ', $depth) . $gallery->name;
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
return array(
|
||||
'gallery_id' => array(
|
||||
'label' => esc_html__('Choose a Gallery', 'wpmf'),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => $galleries_list,
|
||||
'default' => 0,
|
||||
'default_on_front' => 0
|
||||
),
|
||||
'theme' => array(
|
||||
'label' => esc_html__('Theme', 'wpmf'),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'default' => esc_html__('Default', 'wpmf'),
|
||||
'masonry' => esc_html__('Masonry', 'wpmf'),
|
||||
'portfolio' => esc_html__('Portfolio', 'wpmf'),
|
||||
'slider' => esc_html__('Slider', 'wpmf'),
|
||||
'flowslide' => esc_html__('Flow slide', 'wpmf'),
|
||||
'square_grid' => esc_html__('Square grid', 'wpmf'),
|
||||
'material' => esc_html__('Material', 'wpmf'),
|
||||
'custom_grid' => esc_html__('Custom grid', 'wpmf')
|
||||
),
|
||||
'default' => 'masonry',
|
||||
'default_on_front' => 'masonry'
|
||||
),
|
||||
'layout' => array(
|
||||
'label' => esc_html__('Layout', 'wpmf'),
|
||||
'description' => esc_html__('Layout for masonry and square grid theme', 'wpmf'),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'vertical' => esc_html__('Vertical', 'wpmf'),
|
||||
'horizontal' => esc_html__('Horizontal', 'wpmf'),
|
||||
),
|
||||
'default' => 'vertical',
|
||||
'default_on_front' => 'vertical'
|
||||
),
|
||||
'row_height' => array(
|
||||
'label' => esc_html__('Row height', 'wpmf'),
|
||||
'description' => esc_html__('Layout for masonry and square grid theme', 'wpmf'),
|
||||
'type' => 'range',
|
||||
'option_category' => 'configuration',
|
||||
'default' => 200,
|
||||
'default_on_front' => 200,
|
||||
'validate_unit' => false,
|
||||
'unitless' => true,
|
||||
'range_settings' => array(
|
||||
'min' => 50,
|
||||
'max' => 500,
|
||||
'step' => 1
|
||||
)
|
||||
),
|
||||
'aspect_ratio' => array(
|
||||
'label' => esc_html__('Aspect ratio', 'wpmf'),
|
||||
'description' => esc_html__('Aspect ratio for default, material, slider and square grid theme', 'wpmf'),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'default' => esc_html__('Default', 'wpmf'),
|
||||
'1_1' => '1:1',
|
||||
'3_2' => '3:2',
|
||||
'2_3' => '2:3',
|
||||
'4_3' => '4:3',
|
||||
'3_4' => '3:4',
|
||||
'16_9' => '16:9',
|
||||
'9_16' => '9:16',
|
||||
'21_9' => '21:9',
|
||||
'9_21' => '9:21'
|
||||
),
|
||||
'default' => '1_1',
|
||||
'default_on_front' => '1_1',
|
||||
'show_if_not' => array(
|
||||
'theme' => array(
|
||||
'masonry',
|
||||
'flowslide',
|
||||
'custom_grid'
|
||||
)
|
||||
)
|
||||
),
|
||||
'gallery_navigation' => array(
|
||||
'label' => esc_html__('Gallery Navigation', 'wpmf'),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__('On', 'wpmf'),
|
||||
'off' => esc_html__('Off', 'wpmf'),
|
||||
),
|
||||
'default' => 'off',
|
||||
'default_on_front' => 'off'
|
||||
),
|
||||
'sub_galleries_listing' => array(
|
||||
'label' => esc_html__('Sub-galleries listing', 'wpmf'),
|
||||
'description' => esc_html__('This gallery will only list its sub-galleries, using the galleries covers as image.', 'wpmf'),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__('On', 'wpmf'),
|
||||
'off' => esc_html__('Off', 'wpmf'),
|
||||
),
|
||||
'default' => 'off',
|
||||
'default_on_front' => 'off'
|
||||
),
|
||||
'gallery_image_tags' => array(
|
||||
'label' => esc_html__('Display Images Tags', 'wpmf'),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__('On', 'wpmf'),
|
||||
'off' => esc_html__('Off', 'wpmf'),
|
||||
),
|
||||
'default' => 'off',
|
||||
'default_on_front' => 'off'
|
||||
),
|
||||
'columns' => array(
|
||||
'label' => esc_html__('Columns', 'wpmf'),
|
||||
'type' => 'range',
|
||||
'option_category' => 'configuration',
|
||||
'default' => $settings['theme']['masonry_theme']['columns'],
|
||||
'default_on_front' => $settings['theme']['masonry_theme']['columns'],
|
||||
'validate_unit' => false,
|
||||
'unitless' => true,
|
||||
'range_settings' => array(
|
||||
'min' => 1,
|
||||
'max' => 8,
|
||||
'step' => 1
|
||||
),
|
||||
'show_if_not' => array(
|
||||
'theme' => array(
|
||||
'flowslide',
|
||||
'custom_grid'
|
||||
)
|
||||
)
|
||||
),
|
||||
'number_lines' => array(
|
||||
'label' => esc_html__('Slider number lines', 'wpmf'),
|
||||
'type' => 'range',
|
||||
'option_category' => 'configuration',
|
||||
'default' => 1,
|
||||
'default_on_front' => 1,
|
||||
'validate_unit' => false,
|
||||
'unitless' => true,
|
||||
'range_settings' => array(
|
||||
'min' => 1,
|
||||
'max' => 3,
|
||||
'step' => 1
|
||||
)
|
||||
),
|
||||
'size' => array(
|
||||
'label' => esc_html__('Image Size', 'wpmf'),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => apply_filters('image_size_names_choose', array(
|
||||
'thumbnail' => __('Thumbnail', 'wpmf'),
|
||||
'medium' => __('Medium', 'wpmf'),
|
||||
'large' => __('Large', 'wpmf'),
|
||||
'full' => __('Full Size', 'wpmf'),
|
||||
)),
|
||||
'default' => $settings['theme']['masonry_theme']['size'],
|
||||
'default_on_front' => $settings['theme']['masonry_theme']['size']
|
||||
),
|
||||
'targetsize' => array(
|
||||
'label' => esc_html__('Lightbox Size', 'wpmf'),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => apply_filters('image_size_names_choose', array(
|
||||
'thumbnail' => __('Thumbnail', 'wpmf'),
|
||||
'medium' => __('Medium', 'wpmf'),
|
||||
'large' => __('Large', 'wpmf'),
|
||||
'full' => __('Full Size', 'wpmf'),
|
||||
)),
|
||||
'default' => $settings['theme']['masonry_theme']['targetsize'],
|
||||
'default_on_front' => $settings['theme']['masonry_theme']['targetsize']
|
||||
),
|
||||
'action' => array(
|
||||
'label' => esc_html__('Action On Click', 'wpmf'),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'file' => esc_html__('Lightbox', 'wpmf'),
|
||||
'post' => esc_html__('Attachment Page', 'wpmf'),
|
||||
'none' => esc_html__('None', 'wpmf'),
|
||||
),
|
||||
'default' => $settings['theme']['masonry_theme']['link'],
|
||||
'default_on_front' => $settings['theme']['masonry_theme']['link']
|
||||
),
|
||||
'orderby' => array(
|
||||
'label' => esc_html__('Order by', 'wpmf'),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'post__in' => esc_html__('Custom', 'wpmf'),
|
||||
'rand' => esc_html__('Random', 'wpmf'),
|
||||
'title' => esc_html__('Title', 'wpmf'),
|
||||
'date' => esc_html__('Date', 'wpmf')
|
||||
),
|
||||
'default' => $settings['theme']['masonry_theme']['orderby'],
|
||||
'default_on_front' => $settings['theme']['masonry_theme']['orderby']
|
||||
),
|
||||
'order' => array(
|
||||
'label' => esc_html__('Order', 'wpmf'),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'ASC' => esc_html__('Ascending', 'wpmf'),
|
||||
'DESC' => esc_html__('Descending', 'wpmf')
|
||||
),
|
||||
'default' => $settings['theme']['masonry_theme']['order'],
|
||||
'default_on_front' => $settings['theme']['masonry_theme']['order']
|
||||
),
|
||||
'gutterwidth' => array(
|
||||
'label' => esc_html__('Gutter', 'wpmf'),
|
||||
'type' => 'range',
|
||||
'option_category' => 'configuration',
|
||||
'default' => 5,
|
||||
'default_on_front' => 5,
|
||||
'validate_unit' => false,
|
||||
'unitless' => true,
|
||||
'range_settings' => array(
|
||||
'min' => 0,
|
||||
'max' => 100,
|
||||
'step' => 5
|
||||
)
|
||||
),
|
||||
'border_radius' => array(
|
||||
'label' => esc_html__('Border Radius', 'wpmf'),
|
||||
'type' => 'range',
|
||||
'option_category' => 'configuration',
|
||||
'default' => 0,
|
||||
'default_on_front' => 0,
|
||||
'validate_unit' => false,
|
||||
'unitless' => true,
|
||||
'range_settings' => array(
|
||||
'min' => 0,
|
||||
'max' => 20,
|
||||
'step' => 1
|
||||
)
|
||||
),
|
||||
'border_style' => array(
|
||||
'label' => esc_html__('Border Type', 'wpmf'),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'solid' => esc_html__('Solid', 'wpmf'),
|
||||
'double' => esc_html__('Double', 'wpmf'),
|
||||
'dotted' => esc_html__('Dotted', 'wpmf'),
|
||||
'dashed' => esc_html__('Dashed', 'wpmf'),
|
||||
'groove' => esc_html__('Groove', 'wpmf')
|
||||
),
|
||||
'default' => 'solid',
|
||||
'default_on_front' => 'solid'
|
||||
),
|
||||
'border_width' => array(
|
||||
'label' => esc_html__('Border Width', 'wpmf'),
|
||||
'type' => 'range',
|
||||
'option_category' => 'configuration',
|
||||
'default' => 0,
|
||||
'default_on_front' => 0,
|
||||
'validate_unit' => false,
|
||||
'unitless' => true,
|
||||
'range_settings' => array(
|
||||
'min' => 0,
|
||||
'max' => 30,
|
||||
'step' => 1
|
||||
)
|
||||
),
|
||||
'border_color' => array(
|
||||
'label' => esc_html__('Border Color', 'wpmf'),
|
||||
'type' => 'color-alpha',
|
||||
'custom_color' => true,
|
||||
'default' => '#cccccc',
|
||||
'default_on_front' => '#cccccc'
|
||||
),
|
||||
'enable_shadow' => array(
|
||||
'label' => esc_html__('Enable Shadow', 'wpmf'),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__('On', 'wpmf'),
|
||||
'off' => esc_html__('Off', 'wpmf'),
|
||||
),
|
||||
'default' => 'off',
|
||||
'default_on_front' => 'off'
|
||||
),
|
||||
'shadow_color' => array(
|
||||
'label' => esc_html__('Shadow Color', 'wpmf'),
|
||||
'type' => 'color-alpha',
|
||||
'custom_color' => true,
|
||||
'default' => '#cccccc',
|
||||
'default_on_front' => '#cccccc'
|
||||
),
|
||||
'shadow_horizontal' => array(
|
||||
'label' => esc_html__('Horizontal', 'wpmf'),
|
||||
'type' => 'range',
|
||||
'option_category' => 'configuration',
|
||||
'validate_unit' => true,
|
||||
'default' => '0px',
|
||||
'default_unit' => 'px',
|
||||
'default_on_front' => '0px',
|
||||
'range_settings' => array(
|
||||
'min' => '-50',
|
||||
'max' => '50',
|
||||
'step' => '1'
|
||||
)
|
||||
),
|
||||
'shadow_vertical' => array(
|
||||
'label' => esc_html__('Vertical', 'wpmf'),
|
||||
'type' => 'range',
|
||||
'option_category' => 'configuration',
|
||||
'validate_unit' => true,
|
||||
'default' => '0px',
|
||||
'default_unit' => 'px',
|
||||
'default_on_front' => '0px',
|
||||
'range_settings' => array(
|
||||
'min' => '-50',
|
||||
'max' => '50',
|
||||
'step' => '1'
|
||||
)
|
||||
),
|
||||
'shadow_blur' => array(
|
||||
'label' => esc_html__('Blur', 'wpmf'),
|
||||
'type' => 'range',
|
||||
'option_category' => 'configuration',
|
||||
'validate_unit' => true,
|
||||
'default' => '0px',
|
||||
'default_unit' => 'px',
|
||||
'default_on_front' => '0px',
|
||||
'range_settings' => array(
|
||||
'min' => '0',
|
||||
'max' => '50',
|
||||
'step' => '1'
|
||||
)
|
||||
),
|
||||
'shadow_spread' => array(
|
||||
'label' => esc_html__('Spread', 'wpmf'),
|
||||
'type' => 'range',
|
||||
'option_category' => 'configuration',
|
||||
'validate_unit' => true,
|
||||
'default' => '0px',
|
||||
'default_unit' => 'px',
|
||||
'default_on_front' => '0px',
|
||||
'range_settings' => array(
|
||||
'min' => '0',
|
||||
'max' => '50',
|
||||
'step' => '1'
|
||||
)
|
||||
),
|
||||
'disable_overlay' => array(
|
||||
'label' => esc_html__('Disable Overlay', 'wpmf'),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__('On', 'wpmf'),
|
||||
'off' => esc_html__('Off', 'wpmf'),
|
||||
),
|
||||
'default' => 'off',
|
||||
'default_on_front' => 'off'
|
||||
),
|
||||
'hover_color' => array(
|
||||
'label' => esc_html__('Hover Color', 'wpmf'),
|
||||
'type' => 'color-alpha',
|
||||
'custom_color' => true,
|
||||
'default' => '#000',
|
||||
'default_on_front' => '#000'
|
||||
),
|
||||
'hover_opacity' => array(
|
||||
'label' => esc_html__('Hover Opacity', 'wpmf'),
|
||||
'type' => 'range',
|
||||
'option_category' => 'configuration',
|
||||
'default' => 0.4,
|
||||
'default_on_front' => 0.4,
|
||||
'validate_unit' => false,
|
||||
'unitless' => true,
|
||||
'range_settings' => array(
|
||||
'min' => 0,
|
||||
'max' => 1,
|
||||
'step' => 0.1
|
||||
)
|
||||
),
|
||||
'hover_title_position' => array(
|
||||
'label' => esc_html__('Title Position', 'wpmf'),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'none' => esc_html__('None', 'wpmf'),
|
||||
'top_left' => esc_html__('Top left', 'wpmf'),
|
||||
'top_right' => esc_html__('Top right', 'wpmf'),
|
||||
'top_center' => esc_html__('Top center', 'wpmf'),
|
||||
'bottom_left' => esc_html__('Bottom left', 'wpmf'),
|
||||
'bottom_right' => esc_html__('Bottom right', 'wpmf'),
|
||||
'bottom_center' => esc_html__('Bottom center', 'wpmf'),
|
||||
'center_center' => esc_html__('Center center', 'wpmf'),
|
||||
),
|
||||
'default' => 'center_center',
|
||||
'default_on_front' => 'center_center'
|
||||
),
|
||||
'hover_title_size' => array(
|
||||
'label' => esc_html__('Title Size', 'wpmf'),
|
||||
'type' => 'range',
|
||||
'option_category' => 'configuration',
|
||||
'default' => 16,
|
||||
'default_on_front' => 16,
|
||||
'validate_unit' => false,
|
||||
'unitless' => true,
|
||||
'range_settings' => array(
|
||||
'min' => 0,
|
||||
'max' => 150,
|
||||
'step' => 1
|
||||
)
|
||||
),
|
||||
'hover_title_color' => array(
|
||||
'label' => esc_html__('Title Color', 'wpmf'),
|
||||
'type' => 'color-alpha',
|
||||
'custom_color' => true,
|
||||
'default' => '#fff',
|
||||
'default_on_front' => '#fff'
|
||||
),
|
||||
'hover_desc_position' => array(
|
||||
'label' => esc_html__('Description Position', 'wpmf'),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'none' => esc_html__('None', 'wpmf'),
|
||||
'top_left' => esc_html__('Top left', 'wpmf'),
|
||||
'top_right' => esc_html__('Top right', 'wpmf'),
|
||||
'top_center' => esc_html__('Top center', 'wpmf'),
|
||||
'bottom_left' => esc_html__('Bottom left', 'wpmf'),
|
||||
'bottom_right' => esc_html__('Bottom right', 'wpmf'),
|
||||
'bottom_center' => esc_html__('Bottom center', 'wpmf'),
|
||||
'center_center' => esc_html__('Center center', 'wpmf'),
|
||||
),
|
||||
'default' => 'center_center',
|
||||
'default_on_front' => 'center_center'
|
||||
),
|
||||
'hover_desc_size' => array(
|
||||
'label' => esc_html__('Description Size', 'wpmf'),
|
||||
'type' => 'range',
|
||||
'option_category' => 'configuration',
|
||||
'default' => 14,
|
||||
'default_on_front' => 14,
|
||||
'validate_unit' => false,
|
||||
'unitless' => true,
|
||||
'range_settings' => array(
|
||||
'min' => 0,
|
||||
'max' => 150,
|
||||
'step' => 1
|
||||
)
|
||||
),
|
||||
'hover_desc_color' => array(
|
||||
'label' => esc_html__('Description Color', 'wpmf'),
|
||||
'type' => 'color-alpha',
|
||||
'custom_color' => true,
|
||||
'default' => '#fff',
|
||||
'default_on_front' => '#fff'
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render content
|
||||
*
|
||||
* @param array $attrs List of attributes.
|
||||
* @param string $content Content being processed.
|
||||
* @param string $render_slug Slug of module that is used for rendering output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render($attrs, $content, $render_slug) // phpcs:ignore PEAR.Functions.ValidDefaultValue.NotAtEnd -- Method extends from ET_Builder_Module class
|
||||
{
|
||||
$gallery_navigation = (!empty($this->props['gallery_navigation']) && $this->props['gallery_navigation'] === 'on') ? 1 : 0;
|
||||
$sub_galleries_listing = (!empty($this->props['sub_galleries_listing']) && $this->props['sub_galleries_listing'] === 'on') ? 1 : 0;
|
||||
$gallery_image_tags = (!empty($this->props['gallery_image_tags']) && $this->props['gallery_image_tags'] === 'on') ? 1 : 0;
|
||||
$disable_overlay = (!empty($this->props['disable_overlay']) && $this->props['disable_overlay'] === 'on') ? 1 : 0;
|
||||
if (!empty($this->props['enable_shadow']) && $this->props['enable_shadow'] === 'on') {
|
||||
$img_shadow = $this->props['shadow_horizontal'] . ' ' . $this->props['shadow_vertical'] . ' ' . $this->props['shadow_blur'] . ' ' . $this->props['shadow_spread'] . ' ' . $this->props['shadow_color'];
|
||||
} else {
|
||||
$img_shadow = '';
|
||||
}
|
||||
if (empty($this->props['gallery_id'])) {
|
||||
$html = '<div class="wpmf-divi-container">
|
||||
<div id="divi-gallery-addon-placeholder" class="divi-gallery-addon-placeholder">
|
||||
<span class="wpmf-divi-message">
|
||||
' . esc_html__('Please select a gallery to activate the preview', 'wpmf') . '
|
||||
</span>
|
||||
</div>
|
||||
</div>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
$gallery_id_string = $this->props['gallery_id'];
|
||||
if (strpos($gallery_id_string, '-') !== false) {
|
||||
$gallery_ids = explode('-', $gallery_id_string);
|
||||
$gallery_id = $gallery_ids[1];
|
||||
} else {
|
||||
$gallery_id = $gallery_id_string;
|
||||
}
|
||||
return do_shortcode('[wpmfgallery gallery_id="'. (int)$gallery_id .'" display_tree="' . esc_attr($gallery_navigation) . '" sub_galleries_listing="' . esc_attr($sub_galleries_listing) . '" display_tag="' . esc_attr($gallery_image_tags) . '" disable_overlay="' . esc_attr($disable_overlay) . '" display="' . esc_attr($this->props['theme']) . '" layout="' . esc_attr($this->props['layout']) . '" row_height="' . esc_attr($this->props['row_height']) . '" aspect_ratio="' . esc_attr($this->props['aspect_ratio']) . '" columns="' . esc_attr($this->props['columns']) . '" size="' . esc_attr($this->props['size']) . '" targetsize="' . esc_attr($this->props['targetsize']) . '" link="' . esc_attr($this->props['action']) . '" wpmf_orderby="' . esc_attr($this->props['orderby']) . '" wpmf_order="' . esc_attr($this->props['order']) . '" gutterwidth="' . esc_attr($this->props['gutterwidth']) . '" border_width="' . esc_attr($this->props['border_width']) . '" border_style="' . esc_attr($this->props['border_style']) . '" border_color="' . esc_attr($this->props['border_color']) . '" img_shadow="' . esc_attr($img_shadow) . '" img_border_radius="' . esc_attr($this->props['border_radius']) . '" number_lines="' . esc_attr($this->props['number_lines']) . '" hover_color="'. $this->props['hover_color'] .'" hover_opacity="'. $this->props['hover_opacity'] .'" hover_title_position="'. $this->props['hover_title_position'] .'" hover_title_size="'. $this->props['hover_title_size'] .'" hover_title_color="'. $this->props['hover_title_color'] .'" hover_desc_position="'. $this->props['hover_desc_position'] .'" hover_desc_size="'. $this->props['hover_desc_size'] .'" hover_desc_color="'. $this->props['hover_desc_color'] .'"]');
|
||||
}
|
||||
}
|
||||
|
||||
new WpmfGalleryAddonDivi;
|
||||
@@ -0,0 +1,148 @@
|
||||
// External Dependencies
|
||||
import React, {Component} from 'react';
|
||||
import $ from 'jquery';
|
||||
// Internal Dependencies
|
||||
import './style.css';
|
||||
|
||||
class WpmfPdfEmbedDivi extends Component {
|
||||
|
||||
static slug = 'wpmf_pdf_embed';
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
html: '',
|
||||
loading: true,
|
||||
embed: true
|
||||
};
|
||||
this.wrap = React.createRef();
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
if (typeof this.props.url !== "undefined") {
|
||||
this.loadHtml(this.props);
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (this.props.url !== nextProps.url || this.props.embed !== nextProps.embed || this.props.target !== nextProps.target) {
|
||||
this.loadHtml(nextProps);
|
||||
}
|
||||
}
|
||||
|
||||
loadHtml(props) {
|
||||
if (!this.state.loading) {
|
||||
this.setState({
|
||||
loading: true
|
||||
});
|
||||
}
|
||||
let width = '';
|
||||
let height = '';
|
||||
if (typeof props.width !== "undefined") {
|
||||
width = props.width;
|
||||
} else {
|
||||
if (typeof props.max_width !== "undefined") {
|
||||
width = props.max_width;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof props.height !== "undefined") {
|
||||
height = props.height;
|
||||
} else {
|
||||
if (typeof props.max_height !== "undefined") {
|
||||
height = props.max_height;
|
||||
}
|
||||
}
|
||||
fetch(window.et_fb_options.ajaxurl + `?action=wpmf_divi_load_pdf_embed_html&url=${props.url}&embed=${props.embed}&target=${props.target}&width=${width}&height=${height}&et_admin_load_nonce=${window.et_fb_options.et_admin_load_nonce}`)
|
||||
.then(res => res.json())
|
||||
.then(
|
||||
(result) => {
|
||||
this.setState({
|
||||
html: result.html,
|
||||
loading: false,
|
||||
embed: false
|
||||
});
|
||||
},
|
||||
// errors
|
||||
(error) => {
|
||||
this.setState({
|
||||
html: '',
|
||||
loading: true
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
if (this.props.embed === 'on' && !this.state.embed) {
|
||||
this.setState({
|
||||
embed: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const loadingIcon = (
|
||||
<svg className={'wpfd-loading'} width="100%" height="100%" xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 100 100" preserveAspectRatio="xMidYMid">
|
||||
<g transform="translate(25 50)">
|
||||
<circle cx="0" cy="0" r="10" fill="#cfcfcf" transform="scale(0.590851 0.590851)">
|
||||
<animateTransform attributeName="transform" type="scale" begin="-0.8666666666666667s"
|
||||
calcMode="spline"
|
||||
keySplines="0.3 0 0.7 1;0.3 0 0.7 1" values="0.5;1;0.5" keyTimes="0;0.5;1"
|
||||
dur="2.6s"
|
||||
repeatCount="indefinite"/>
|
||||
</circle>
|
||||
</g>
|
||||
<g transform="translate(50 50)">
|
||||
<circle cx="0" cy="0" r="10" fill="#cfcfcf" transform="scale(0.145187 0.145187)">
|
||||
<animateTransform attributeName="transform" type="scale" begin="-0.43333333333333335s"
|
||||
calcMode="spline"
|
||||
keySplines="0.3 0 0.7 1;0.3 0 0.7 1" values="0.5;1;0.5" keyTimes="0;0.5;1"
|
||||
dur="2.6s"
|
||||
repeatCount="indefinite"/>
|
||||
</circle>
|
||||
</g>
|
||||
<g transform="translate(75 50)">
|
||||
<circle cx="0" cy="0" r="10" fill="#cfcfcf" transform="scale(0.0339143 0.0339143)">
|
||||
<animateTransform attributeName="transform" type="scale" begin="0s" calcMode="spline"
|
||||
keySplines="0.3 0 0.7 1;0.3 0 0.7 1" values="0.5;1;0.5" keyTimes="0;0.5;1"
|
||||
dur="2.6s"
|
||||
repeatCount="indefinite"/>
|
||||
</circle>
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
|
||||
if (typeof this.props.url === "undefined") {
|
||||
return (
|
||||
<div className="wpmf-divi-container">
|
||||
<div id="divi-pdf-embed-placeholder" className="divi-pdf-embed-placeholder">
|
||||
<span className="wpmf-divi-message">
|
||||
{'Please select a PDF file to activate the preview'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (this.state.loading) {
|
||||
return (
|
||||
<div className="wpmf-divi-container">
|
||||
<div className={'wpmf-loading-wrapper'}>
|
||||
<i className={'wpmf-loading'}>{loadingIcon}</i>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!this.state.loading) {
|
||||
return (
|
||||
<div className="wpmf-pdf-embed-wrap" ref={this.wrap}
|
||||
dangerouslySetInnerHTML={{__html: this.state.html}}/>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default WpmfPdfEmbedDivi;
|
||||
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
|
||||
/**
|
||||
* Class WpmfPdfEmbedDivi
|
||||
*/
|
||||
class WpmfPdfEmbedDivi extends ET_Builder_Module
|
||||
{
|
||||
|
||||
/**
|
||||
* Module slug
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $slug = 'wpmf_pdf_embed';
|
||||
|
||||
/**
|
||||
* Whether module support visual builder. e.g `on` or `off`.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $vb_support = 'on';
|
||||
|
||||
/**
|
||||
* Credits of all custom modules.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $module_credits = array(
|
||||
'module_uri' => 'https://www.joomunited.com/',
|
||||
'author' => 'Joomunited',
|
||||
'author_uri' => 'https://www.joomunited.com/',
|
||||
);
|
||||
|
||||
/**
|
||||
* Init
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->name = esc_html__('WPMF PDF Embed', 'wpmf');
|
||||
}
|
||||
|
||||
/**
|
||||
* Advanced Fields Config
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_advanced_fields_config() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from ET_Builder_Module class
|
||||
{
|
||||
return array(
|
||||
'button' => false,
|
||||
'link_options' => false
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the settings fields data for this element.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_fields() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from ET_Builder_Module class
|
||||
{
|
||||
return array(
|
||||
'url' => array(
|
||||
'type' => 'upload',
|
||||
'data_type' => 'application/pdf',
|
||||
'option_category' => 'configuration',
|
||||
'upload_button_text' => esc_attr__('Select an PDF', 'wpmf'),
|
||||
'choose_text' => esc_attr__('Choose an PDF', 'wpmf'),
|
||||
'update_text' => esc_attr__('Set As PDF', 'wpmf'),
|
||||
'hide_metadata' => true,
|
||||
'affects' => array(
|
||||
'alt',
|
||||
'title_text',
|
||||
),
|
||||
'description' => esc_html__('Upload your desired PDF, or type in the URL to the image you would like to display.', 'wpmf'),
|
||||
),
|
||||
'embed' => array(
|
||||
'label' => esc_html__('Embed', 'wpmf'),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__('On', 'wpmf'),
|
||||
'off' => esc_html__('Off', 'wpmf'),
|
||||
),
|
||||
'default' => 'on',
|
||||
'default_on_front' => 'on'
|
||||
),
|
||||
'target' => array(
|
||||
'label' => esc_html__('Target', 'wpmf'),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'_blank' => esc_html__('New Window', 'wpmf'),
|
||||
'self' => esc_html__('Same Window', 'wpmf'),
|
||||
),
|
||||
'default_on_front' => 'self',
|
||||
'depends_show_if' => 'on'
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render content
|
||||
*
|
||||
* @param array $attrs List of attributes.
|
||||
* @param string $content Content being processed.
|
||||
* @param string $render_slug Slug of module that is used for rendering output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render($attrs, $content, $render_slug) // phpcs:ignore PEAR.Functions.ValidDefaultValue.NotAtEnd -- Method extends from ET_Builder_Module class
|
||||
{
|
||||
if (empty($this->props['url'])) {
|
||||
$html = '<div class="wpmf-divi-container">
|
||||
<div id="divi-pdf-embed-placeholder" class="divi-pdf-embed-placeholder">
|
||||
<span class="wpmf-divi-message">
|
||||
' . esc_html__('Please select a PDF file to activate the preview', 'wpmf') . '
|
||||
</span>
|
||||
</div>
|
||||
</div>';
|
||||
return $html;
|
||||
}
|
||||
$url = str_replace(array('-pdf.jpg', '-pdf.jpeg', '-pdf.png'), '.pdf', $this->props['url']);
|
||||
$width = (!empty($this->props['width']) && $this->props['width'] !== 'auto') ? $this->props['width'] : '100%';
|
||||
$height = (!empty($this->props['height']) && $this->props['height'] !== 'auto') ? $this->props['height'] : '800';
|
||||
return do_shortcode('[wpmfpdf url="' . esc_url($url) . '" width="'. $width .'" height="'. $height .'" embed="' . esc_attr($this->props['embed']) . '" target="' . esc_attr($this->props['target']) . '"]');
|
||||
}
|
||||
}
|
||||
|
||||
new WpmfPdfEmbedDivi;
|
||||
@@ -0,0 +1,5 @@
|
||||
import WpmfPdfEmbedDivi from './PdfEmbed/PdfEmbed';
|
||||
import WpmfFileDesignDivi from './FileDesign/FileDesign';
|
||||
import WpmfGalleryDivi from './Gallery/Gallery';
|
||||
import WpmfGalleryAddonDivi from "./GalleryAddon/GalleryAddon";
|
||||
export default [WpmfPdfEmbedDivi, WpmfFileDesignDivi, WpmfGalleryDivi, WpmfGalleryAddonDivi];
|
||||
1
wp/wp-content/plugins/wp-media-folder/class/divi-widgets/scripts/builder-bundle.min.js
vendored
Normal file
1
wp/wp-content/plugins/wp-media-folder/class/divi-widgets/scripts/builder-bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
wp/wp-content/plugins/wp-media-folder/class/divi-widgets/scripts/frontend-bundle.min.js
vendored
Normal file
1
wp/wp-content/plugins/wp-media-folder/class/divi-widgets/scripts/frontend-bundle.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(n){var t={};function r(e){if(t[e])return t[e].exports;var o=t[e]={i:e,l:!1,exports:{}};return n[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=n,r.c=t,r.d=function(n,t,e){r.o(n,t)||Object.defineProperty(n,t,{configurable:!1,enumerable:!0,get:e})},r.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(t,"a",t),t},r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.p="/",r(r.s=14)}([,,function(n,t){},function(n,t){},function(n,t){},function(n,t){},,,,,,,,,function(n,t,r){r(3),r(4),r(5),r(2),n.exports=r(15)},function(n,t){jQuery(function(n){})}]);
|
||||
@@ -0,0 +1,3 @@
|
||||
// This script is loaded both on the frontend page and in the Visual Builder.
|
||||
|
||||
jQuery(function($) {});
|
||||
1
wp/wp-content/plugins/wp-media-folder/class/divi-widgets/styles/backend-style.min.css
vendored
Normal file
1
wp/wp-content/plugins/wp-media-folder/class/divi-widgets/styles/backend-style.min.css
vendored
Normal file
@@ -0,0 +1 @@
|
||||
input.wpmf-input{background:#f1f5f9;max-height:30px;border:0;border-radius:3px;padding:7px 10px;box-sizing:border-box;transition:background .2s ease;color:#4c5866;font-family:Open Sans,Helvetica,Roboto,Arial,sans-serif;font-size:13px;font-weight:600;line-height:normal;display:block;width:100%}input.wpmf-input:focus{background:#e6ecf2}input.wpmf-input::-webkit-input-placeholder{color:#98a7b8}input.wpmf-input:-moz-placeholder,input.wpmf-input::-moz-placeholder{color:#98a7b8}input.wpmf-input:-ms-input-placeholder{color:#98a7b8}input.wpmf-input[readonly]{background:#fff!important;border:1px solid #eaedf0!important;cursor:not-allowed}
|
||||
1
wp/wp-content/plugins/wp-media-folder/class/divi-widgets/styles/style-dbp.min.css
vendored
Normal file
1
wp/wp-content/plugins/wp-media-folder/class/divi-widgets/styles/style-dbp.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
wp/wp-content/plugins/wp-media-folder/class/divi-widgets/styles/style.min.css
vendored
Normal file
1
wp/wp-content/plugins/wp-media-folder/class/divi-widgets/styles/style.min.css
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.gallery-columns-1 .wpmf-gallery-item{width:100%}.gallery-columns-2 .wpmf-gallery-item{width:50%}.gallery-columns-3 .wpmf-gallery-item{width:33.33333%}.gallery-columns-4 .wpmf-gallery-item{width:25%}.gallery-columns-5 .wpmf-gallery-item{width:20%}.gallery-columns-6 .wpmf-gallery-item{width:16.66667%}.gallery-columns-7 .wpmf-gallery-item{width:14.28571%}.gallery-columns-8 .wpmf-gallery-item{width:12.5%}.gallery-columns-9 .wpmf-gallery-item{width:11.11111%}.wpmf-has-border-radius-1 .wpmf-gallery-item .wpmf_overlay,.wpmf-has-border-radius-1 .wpmf-gallery-item img,.wpmf-has-border-radius-1.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon{border-radius:1px}.wpmf-has-border-radius-2 .wpmf-gallery-item .wpmf_overlay,.wpmf-has-border-radius-2 .wpmf-gallery-item img,.wpmf-has-border-radius-2.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon{border-radius:2px}.wpmf-has-border-radius-3 .wpmf-gallery-item .wpmf_overlay,.wpmf-has-border-radius-3 .wpmf-gallery-item img,.wpmf-has-border-radius-3.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon{border-radius:3px}.wpmf-has-border-radius-4 .wpmf-gallery-item .wpmf_overlay,.wpmf-has-border-radius-4 .wpmf-gallery-item img,.wpmf-has-border-radius-4.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon{border-radius:4px}.wpmf-has-border-radius-5 .wpmf-gallery-item .wpmf_overlay,.wpmf-has-border-radius-5 .wpmf-gallery-item img,.wpmf-has-border-radius-5.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon{border-radius:5px}.wpmf-has-border-radius-6 .wpmf-gallery-item .wpmf_overlay,.wpmf-has-border-radius-6 .wpmf-gallery-item img,.wpmf-has-border-radius-6.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon{border-radius:6px}.wpmf-has-border-radius-7 .wpmf-gallery-item .wpmf_overlay,.wpmf-has-border-radius-7 .wpmf-gallery-item img,.wpmf-has-border-radius-7.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon{border-radius:7px}.wpmf-has-border-radius-8 .wpmf-gallery-item .wpmf_overlay,.wpmf-has-border-radius-8 .wpmf-gallery-item img,.wpmf-has-border-radius-8.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon{border-radius:8px}.wpmf-has-border-radius-9 .wpmf-gallery-item .wpmf_overlay,.wpmf-has-border-radius-9 .wpmf-gallery-item img,.wpmf-has-border-radius-9.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon{border-radius:9px}.wpmf-has-border-radius-10 .wpmf-gallery-item .wpmf_overlay,.wpmf-has-border-radius-10 .wpmf-gallery-item img,.wpmf-has-border-radius-10.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon{border-radius:10px}.wpmf-has-border-radius-11 .wpmf-gallery-item .wpmf_overlay,.wpmf-has-border-radius-11 .wpmf-gallery-item img,.wpmf-has-border-radius-11.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon{border-radius:11px}.wpmf-has-border-radius-12 .wpmf-gallery-item .wpmf_overlay,.wpmf-has-border-radius-12 .wpmf-gallery-item img,.wpmf-has-border-radius-12.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon{border-radius:12px}.wpmf-has-border-radius-13 .wpmf-gallery-item .wpmf_overlay,.wpmf-has-border-radius-13 .wpmf-gallery-item img,.wpmf-has-border-radius-13.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon{border-radius:13px}.wpmf-has-border-radius-14 .wpmf-gallery-item .wpmf_overlay,.wpmf-has-border-radius-14 .wpmf-gallery-item img,.wpmf-has-border-radius-14.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon{border-radius:14px}.wpmf-has-border-radius-15 .wpmf-gallery-item .wpmf_overlay,.wpmf-has-border-radius-15 .wpmf-gallery-item img,.wpmf-has-border-radius-15.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon{border-radius:15px}.wpmf-has-border-radius-16 .wpmf-gallery-item .wpmf_overlay,.wpmf-has-border-radius-16 .wpmf-gallery-item img,.wpmf-has-border-radius-16.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon{border-radius:16px}.wpmf-has-border-radius-17 .wpmf-gallery-item .wpmf_overlay,.wpmf-has-border-radius-17 .wpmf-gallery-item img,.wpmf-has-border-radius-17.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon{border-radius:17px}.wpmf-has-border-radius-18 .wpmf-gallery-item .wpmf_overlay,.wpmf-has-border-radius-18 .wpmf-gallery-item img,.wpmf-has-border-radius-18.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon{border-radius:18px}.wpmf-has-border-radius-19 .wpmf-gallery-item .wpmf_overlay,.wpmf-has-border-radius-19 .wpmf-gallery-item img,.wpmf-has-border-radius-19.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon{border-radius:19px}.wpmf-has-border-radius-20 .wpmf-gallery-item .wpmf_overlay,.wpmf-has-border-radius-20 .wpmf-gallery-item img,.wpmf-has-border-radius-20.wpmfslick .wpmf-gallery-item .wpmf-gallery-icon{border-radius:20px}
|
||||
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
if (!defined('ABSPATH')) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Class WpmfFileDesignElementorWidget
|
||||
*/
|
||||
class WpmfFileDesignElementorWidget extends \Elementor\Widget_Base
|
||||
{
|
||||
|
||||
/**
|
||||
* Get widget name.
|
||||
*
|
||||
* Retrieve File Design widget name.
|
||||
*
|
||||
* @return string Widget name.
|
||||
*/
|
||||
public function get_name() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from \Elementor\Widget_Base class
|
||||
{
|
||||
return 'wpmf_file_design';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get widget title.
|
||||
*
|
||||
* Retrieve File Design widget title.
|
||||
*
|
||||
* @return string Widget title.
|
||||
*/
|
||||
public function get_title() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from \Elementor\Widget_Base class
|
||||
{
|
||||
return esc_html__('WPMF Media Download', 'wpmf');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get widget icon.
|
||||
*
|
||||
* Retrieve File Design widget icon.
|
||||
*
|
||||
* @return string Widget icon.
|
||||
*/
|
||||
public function get_icon() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from \Elementor\Widget_Base class
|
||||
{
|
||||
return 'fa wpmf-file-design-elementor-icon';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get widget categories.
|
||||
*
|
||||
* Retrieve the list of categories the File Design widget belongs to.
|
||||
*
|
||||
* @return array Widget categories.
|
||||
*/
|
||||
public function get_categories() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from \Elementor\Widget_Base class
|
||||
{
|
||||
return array('wpmf');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register File Design widget controls.
|
||||
*
|
||||
* Adds different input fields to allow the user to change and customize the widget settings.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function register_controls() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps, PSR2.Methods.MethodDeclaration.Underscore -- Method extends from \Elementor\Widget_Base class
|
||||
{
|
||||
$this->start_controls_section(
|
||||
'settings_section',
|
||||
array(
|
||||
'label' => esc_html__('Settings', 'wpmf'),
|
||||
'tab' => \Elementor\Controls_Manager::TAB_CONTENT
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_add_file_design',
|
||||
array(
|
||||
'label' => esc_html__('Choose file', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::BUTTON,
|
||||
'text' => esc_html__('Add a file', 'wpmf'),
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_responsive_control(
|
||||
'content_align',
|
||||
array(
|
||||
'label' => __('Alignment', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::CHOOSE,
|
||||
'options' => array(
|
||||
'left' => array(
|
||||
'title' => __('Left', 'wpmf'),
|
||||
'icon' => 'fa fa-align-left'
|
||||
),
|
||||
'center' => array(
|
||||
'title' => __('Center', 'wpmf'),
|
||||
'icon' => 'fa fa-align-center'
|
||||
),
|
||||
'right' => array(
|
||||
'title' => __('Right', 'wpmf'),
|
||||
'icon' => 'fa fa-align-right'
|
||||
)
|
||||
),
|
||||
'devices' => array('desktop', 'tablet'),
|
||||
'prefix_class' => 'content-align-%s',
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_file_design_id',
|
||||
array(
|
||||
'label' => esc_html__('File ID', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::NUMBER,
|
||||
)
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render File Design widget output on the frontend.
|
||||
*
|
||||
* Written in PHP and used to generate the final HTML.
|
||||
*
|
||||
* @return void|string
|
||||
*/
|
||||
protected function render()
|
||||
{
|
||||
$settings = $this->get_settings_for_display();
|
||||
$id = (isset($settings['wpmf_file_design_id']) && $settings['wpmf_file_design_id'] !== '') ? $settings['wpmf_file_design_id'] : 0;
|
||||
if (!empty($id)) {
|
||||
echo do_shortcode('[wpmffiledesign id="' . esc_attr($id) . '"]');
|
||||
} else {
|
||||
?>
|
||||
<div class="wpmf-elementor-placeholder" style="text-align: center">
|
||||
<img style="background: url(<?php echo esc_url(WPMF_PLUGIN_URL . 'assets/images/file_design_place_holder.svg'); ?>) no-repeat scroll center center #fafafa; height: 200px; border-radius: 2px; width: 100%; background-size: auto 60%;" src="<?php echo esc_url(WPMF_PLUGIN_URL . 'assets/images/t.gif'); ?>">
|
||||
<span style="position: absolute; bottom: 12px; width: 100%; left: 0;font-size: 13px; text-align: center;"><?php esc_html_e('WP Media Folder media download. Select a media and transform it into a download button', 'wpmf'); ?></span>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,642 @@
|
||||
<?php
|
||||
if (!defined('ABSPATH')) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Class WpmfGalleryElementorWidget
|
||||
*/
|
||||
class WpmfGalleryElementorWidget extends \Elementor\Widget_Base
|
||||
{
|
||||
/**
|
||||
* Get script depends
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_script_depends() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from \Elementor\Widget_Base class
|
||||
{
|
||||
return array(
|
||||
'wordpresscanvas-imagesloaded',
|
||||
'wpmf-gallery-popup',
|
||||
'jquery-masonry',
|
||||
'wpmf-slick-script',
|
||||
'wpmf-gallery'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get style depends
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_style_depends() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from \Elementor\Widget_Base class
|
||||
{
|
||||
return array(
|
||||
'wpmf-slick-style',
|
||||
'wpmf-slick-theme-style',
|
||||
'wpmf-gallery-popup-style',
|
||||
'wpmf-gallery-style'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get widget name.
|
||||
*
|
||||
* Retrieve Gallery widget name.
|
||||
*
|
||||
* @return string Widget name.
|
||||
*/
|
||||
public function get_name() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from \Elementor\Widget_Base class
|
||||
{
|
||||
return 'wpmf_gallery';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get widget title.
|
||||
*
|
||||
* Retrieve Gallery widget title.
|
||||
*
|
||||
* @return string Widget title.
|
||||
*/
|
||||
public function get_title() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from \Elementor\Widget_Base class
|
||||
{
|
||||
return esc_html__('WP Media Folder Gallery', 'wpmf');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get widget icon.
|
||||
*
|
||||
* Retrieve Gallery widget icon.
|
||||
*
|
||||
* @return string Widget icon.
|
||||
*/
|
||||
public function get_icon() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from \Elementor\Widget_Base class
|
||||
{
|
||||
return 'fa wpmf-gallery-elementor-icon';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get widget categories.
|
||||
*
|
||||
* Retrieve the list of categories the Gallery widget belongs to.
|
||||
*
|
||||
* @return array Widget categories.
|
||||
*/
|
||||
public function get_categories() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from \Elementor\Widget_Base class
|
||||
{
|
||||
return array('wpmf');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Gallery widget controls.
|
||||
*
|
||||
* Adds different input fields to allow the user to change and customize the widget settings.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function register_controls() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps, PSR2.Methods.MethodDeclaration.Underscore -- Method extends from \Elementor\Widget_Base class
|
||||
{
|
||||
$settings = wpmfGetOption('gallery_settings');
|
||||
$this->start_controls_section(
|
||||
'gallery_settings',
|
||||
array(
|
||||
'label' => esc_html__('Gallery Settings', 'wpmf'),
|
||||
'tab' => \Elementor\Controls_Manager::TAB_CONTENT
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_theme',
|
||||
array(
|
||||
'label' => esc_html__('Theme', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::SELECT,
|
||||
'options' => array(
|
||||
'default' => esc_html__('Default', 'wpmf'),
|
||||
'masonry' => esc_html__('Masonry', 'wpmf'),
|
||||
'portfolio' => esc_html__('Portfolio', 'wpmf'),
|
||||
'slider' => esc_html__('Slider', 'wpmf')
|
||||
),
|
||||
'default' => 'masonry'
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_gallery',
|
||||
array(
|
||||
'label' => esc_html__('Add Images', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::GALLERY,
|
||||
'default' => array()
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'aspect_ratio',
|
||||
array(
|
||||
'label' => esc_html__('Aspect ratio', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::SELECT,
|
||||
'options' => array(
|
||||
'default' => esc_html__('Default', 'wpmf'),
|
||||
'1_1' => '1:1',
|
||||
'3_2' => '3:2',
|
||||
'2_3' => '2:3',
|
||||
'4_3' => '4:3',
|
||||
'3_4' => '3:4',
|
||||
'16_9' => '16:9',
|
||||
'9_16' => '9:16',
|
||||
'21_9' => '21:9',
|
||||
'9_21' => '9:21'
|
||||
),
|
||||
'default' => 'default',
|
||||
'condition' => array(
|
||||
'wpmf_theme' => array('default', 'slider', 'portfolio')
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_gallery_columns',
|
||||
array(
|
||||
'label' => esc_html__('Columns', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::NUMBER,
|
||||
'default' => $settings['theme']['masonry_theme']['columns'],
|
||||
'min' => 1,
|
||||
'max' => 8,
|
||||
'step' => 1
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
\Elementor\Group_Control_Image_Size::get_type(),
|
||||
array(
|
||||
'name' => 'wpmf_gallery_size',
|
||||
'exclude' => array('custom'),
|
||||
'default' => $settings['theme']['masonry_theme']['size']
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_gallery_crop_image',
|
||||
array(
|
||||
'label' => esc_html__('Crop Image', 'wpmf'),
|
||||
'description' => esc_html__('Only use for slider theme', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::SWITCHER,
|
||||
'label_on' => __('Enable', 'wpmf'),
|
||||
'label_off' => __('Disable', 'wpmf'),
|
||||
'return_value' => 'yes',
|
||||
'default' => 'yes'
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_gallery_targetsize',
|
||||
array(
|
||||
'label' => esc_html__('Lightbox Size', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::SELECT,
|
||||
'options' => apply_filters('image_size_names_choose', array(
|
||||
'thumbnail' => __('Thumbnail', 'wpmf'),
|
||||
'medium' => __('Medium', 'wpmf'),
|
||||
'large' => __('Large', 'wpmf'),
|
||||
'full' => __('Full Size', 'wpmf'),
|
||||
)),
|
||||
'default' => $settings['theme']['masonry_theme']['targetsize']
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_gallery_action',
|
||||
array(
|
||||
'label' => esc_html__('Action On Click', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::SELECT,
|
||||
'options' => array(
|
||||
'file' => esc_html__('Lightbox', 'wpmf'),
|
||||
'post' => esc_html__('Attachment Page', 'wpmf'),
|
||||
'none' => esc_html__('None', 'wpmf'),
|
||||
),
|
||||
'default' => $settings['theme']['masonry_theme']['link']
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_gallery_orderby',
|
||||
array(
|
||||
'label' => esc_html__('Order by', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::SELECT,
|
||||
'options' => array(
|
||||
'post__in' => esc_html__('Custom', 'wpmf'),
|
||||
'rand' => esc_html__('Random', 'wpmf'),
|
||||
'title' => esc_html__('Title', 'wpmf'),
|
||||
'date' => esc_html__('Date', 'wpmf')
|
||||
),
|
||||
'default' => $settings['theme']['masonry_theme']['orderby']
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_gallery_order',
|
||||
array(
|
||||
'label' => esc_html__('Order', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::SELECT,
|
||||
'options' => array(
|
||||
'ASC' => esc_html__('Ascending', 'wpmf'),
|
||||
'DESC' => esc_html__('Descending', 'wpmf')
|
||||
),
|
||||
'default' => $settings['theme']['masonry_theme']['order']
|
||||
)
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
|
||||
// margin tab
|
||||
$this->start_controls_section(
|
||||
'wpmf_gallery_margin',
|
||||
array(
|
||||
'label' => esc_html__('Margin', 'wpmf'),
|
||||
'tab' => \Elementor\Controls_Manager::TAB_CONTENT
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_gallery_gutterwidth',
|
||||
array(
|
||||
'label' => esc_html__('Gutter', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::SELECT,
|
||||
'options' => array(
|
||||
'0' => 0,
|
||||
'5' => 5,
|
||||
'10' => 10,
|
||||
'15' => 15,
|
||||
'20' => 20,
|
||||
'25' => 25,
|
||||
'30' => 30,
|
||||
'35' => 35,
|
||||
'40' => 40,
|
||||
'45' => 45,
|
||||
'100' => 100,
|
||||
),
|
||||
'default' => 5
|
||||
)
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
|
||||
// border tab
|
||||
$this->start_controls_section(
|
||||
'wpmf_gallery_border',
|
||||
array(
|
||||
'label' => esc_html__('Border', 'wpmf'),
|
||||
'tab' => \Elementor\Controls_Manager::TAB_CONTENT
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_gallery_image_radius',
|
||||
array(
|
||||
'label' => esc_html__('Border Radius', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::NUMBER,
|
||||
'default' => 0,
|
||||
'min' => 0,
|
||||
'max' => 20,
|
||||
'step' => 1
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_gallery_border_type',
|
||||
array(
|
||||
'label' => esc_html__('Border Type', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::SELECT,
|
||||
'options' => array(
|
||||
'solid' => esc_html__('Solid', 'wpmf'),
|
||||
'double' => esc_html__('Double', 'wpmf'),
|
||||
'dotted' => esc_html__('Dotted', 'wpmf'),
|
||||
'dashed' => esc_html__('Dashed', 'wpmf'),
|
||||
'groove' => esc_html__('Groove', 'wpmf')
|
||||
),
|
||||
'default' => 'solid'
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_gallery_border_width',
|
||||
array(
|
||||
'label' => esc_html__('Border Width', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::NUMBER,
|
||||
'default' => 0,
|
||||
'min' => 0,
|
||||
'max' => 30,
|
||||
'step' => 1
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_gallery_border_color',
|
||||
array(
|
||||
'label' => esc_html__('Border Color', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::COLOR,
|
||||
'default' => '#cccccc'
|
||||
)
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
|
||||
// shadow tab
|
||||
$this->start_controls_section(
|
||||
'wpmf_gallery_shadow',
|
||||
array(
|
||||
'label' => esc_html__('Shadow', 'wpmf'),
|
||||
'tab' => \Elementor\Controls_Manager::TAB_CONTENT
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_gallery_enable_shadow',
|
||||
array(
|
||||
'label' => esc_html__('Enable', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::SWITCHER,
|
||||
'label_on' => __('Enable', 'wpmf'),
|
||||
'label_off' => __('Disable', 'wpmf'),
|
||||
'return_value' => 'yes',
|
||||
'default' => 'no'
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_gallery_shadow_color',
|
||||
array(
|
||||
'label' => esc_html__('Color', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::COLOR,
|
||||
'default' => '#cccccc'
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_gallery_shadow_horizontal',
|
||||
array(
|
||||
'label' => esc_html__('Horizontal', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::SLIDER,
|
||||
'size_units' => array('px'),
|
||||
'range' => array(
|
||||
'px' => array(
|
||||
'min' => -50,
|
||||
'max' => 50,
|
||||
'step' => 1
|
||||
)
|
||||
),
|
||||
'default' => array(
|
||||
'unit' => 'px',
|
||||
'size' => 0
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_gallery_shadow_vertical',
|
||||
array(
|
||||
'label' => esc_html__('Vertical', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::SLIDER,
|
||||
'size_units' => array('px'),
|
||||
'range' => array(
|
||||
'px' => array(
|
||||
'min' => -50,
|
||||
'max' => 50,
|
||||
'step' => 1
|
||||
)
|
||||
),
|
||||
'default' => array(
|
||||
'unit' => 'px',
|
||||
'size' => 0
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_gallery_shadow_blur',
|
||||
array(
|
||||
'label' => esc_html__('Blur', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::SLIDER,
|
||||
'size_units' => array('px'),
|
||||
'range' => array(
|
||||
'px' => array(
|
||||
'min' => 0,
|
||||
'max' => 50,
|
||||
'step' => 1
|
||||
)
|
||||
),
|
||||
'default' => array(
|
||||
'unit' => 'px',
|
||||
'size' => 0
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_gallery_shadow_spread',
|
||||
array(
|
||||
'label' => esc_html__('Spread', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::SLIDER,
|
||||
'size_units' => array('px'),
|
||||
'range' => array(
|
||||
'px' => array(
|
||||
'min' => 0,
|
||||
'max' => 50,
|
||||
'step' => 1
|
||||
)
|
||||
),
|
||||
'default' => array(
|
||||
'unit' => 'px',
|
||||
'size' => 0
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
|
||||
// media from folder tab
|
||||
$this->start_controls_section(
|
||||
'wpmf_gallery_from_folder',
|
||||
array(
|
||||
'label' => esc_html__('Gallery From Folder', 'wpmf'),
|
||||
'tab' => \Elementor\Controls_Manager::TAB_CONTENT
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_gallery_folder',
|
||||
array(
|
||||
'label' => esc_html__('Gallery From Folder', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::SWITCHER,
|
||||
'label_on' => __('Enable', 'wpmf'),
|
||||
'label_off' => __('Disable', 'wpmf'),
|
||||
'return_value' => 'yes',
|
||||
'default' => 'no'
|
||||
)
|
||||
);
|
||||
|
||||
$main_class = wpmfGetMainClass();
|
||||
$getFolders = $main_class->getAttachmentTerms('builder');
|
||||
$folders = $getFolders['attachment_terms'];
|
||||
$folders_order = $getFolders['attachment_terms_order'];
|
||||
$list_cloud = array();
|
||||
$list_local = array();
|
||||
$ai = 'a';
|
||||
foreach ($folders_order as $folder_order) {
|
||||
$folder = $folders[$folder_order];
|
||||
if ($folder['id'] !== 0) {
|
||||
if (!isset($folder['depth'])) {
|
||||
$folder['depth'] = 0;
|
||||
}
|
||||
|
||||
if (isset($folder['drive_type']) && $folder['drive_type'] !== '') {
|
||||
$list_cloud[$ai.'|'.$folder['slug']] = str_repeat(' ', $folder['depth']) . $folder['label'];
|
||||
} else {
|
||||
$list_local[$ai.'|'.$folder['slug']] = str_repeat(' ', $folder['depth']) . $folder['label'];
|
||||
}
|
||||
} else {
|
||||
$list_local[0] = $folder['label'];
|
||||
}
|
||||
$ai++;
|
||||
}
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_gallery_folder_id',
|
||||
array(
|
||||
'label' => esc_html__('Choose a Folder', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::SELECT,
|
||||
'options' => $list_local + $list_cloud,
|
||||
'default' => 0
|
||||
)
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render Gallery widget output on the frontend.
|
||||
*
|
||||
* Written in PHP and used to generate the final HTML.
|
||||
*
|
||||
* @return void|string
|
||||
*/
|
||||
protected function render()
|
||||
{
|
||||
$settings = $this->get_settings_for_display();
|
||||
$theme = (!empty($settings['wpmf_theme'])) ? $settings['wpmf_theme'] : 'default';
|
||||
$columns = (!empty($settings['wpmf_gallery_columns'])) ? $settings['wpmf_gallery_columns'] : 3;
|
||||
$size = (!empty($settings['wpmf_gallery_size_size'])) ? $settings['wpmf_gallery_size_size'] : 'thumbnail';
|
||||
$crop_image = (!empty($settings['wpmf_gallery_crop_image']) && $settings['wpmf_gallery_crop_image'] === 'yes') ? 1 : 0;
|
||||
$aspect_ratio = (!empty($settings['aspect_ratio'])) ? $settings['aspect_ratio'] : 'default';
|
||||
$targetsize = (!empty($settings['wpmf_gallery_targetsize'])) ? $settings['wpmf_gallery_targetsize'] : 'large';
|
||||
$action = (!empty($settings['wpmf_gallery_action'])) ? $settings['wpmf_gallery_action'] : 'file';
|
||||
$orderby = (!empty($settings['wpmf_gallery_orderby'])) ? $settings['wpmf_gallery_orderby'] : 'post__in';
|
||||
$order = (!empty($settings['wpmf_gallery_order'])) ? $settings['wpmf_gallery_order'] : 'ASC';
|
||||
$gutterwidth = (!empty($settings['wpmf_gallery_gutterwidth'])) ? $settings['wpmf_gallery_gutterwidth'] : 5;
|
||||
|
||||
$border_radius = (!empty($settings['wpmf_gallery_image_radius'])) ? $settings['wpmf_gallery_image_radius'] : 0;
|
||||
$border_style = (!empty($settings['wpmf_gallery_border_type'])) ? $settings['wpmf_gallery_border_type'] : 'solid';
|
||||
$border_color = (!empty($settings['wpmf_gallery_border_color'])) ? $settings['wpmf_gallery_border_color'] : 'transparent';
|
||||
$border_width = (!empty($settings['wpmf_gallery_border_width'])) ? $settings['wpmf_gallery_border_width'] : 0;
|
||||
$enable_gallery_shadow = (!empty($settings['wpmf_gallery_enable_shadow']) && $settings['wpmf_gallery_enable_shadow'] === 'yes') ? 1 : 0;
|
||||
$shadow_horizontal = !empty($settings['wpmf_gallery_shadow_horizontal']) ? $settings['wpmf_gallery_shadow_horizontal'] : 0;
|
||||
$shadow_vertical = !empty($settings['wpmf_gallery_shadow_vertical']) ? $settings['wpmf_gallery_shadow_vertical'] : 0;
|
||||
$shadow_blur = !empty($settings['wpmf_gallery_shadow_blur']) ? $settings['wpmf_gallery_shadow_blur'] : 0;
|
||||
$shadow_spread = !empty($settings['wpmf_gallery_shadow_spread']) ? $settings['wpmf_gallery_shadow_spread'] : 0;
|
||||
$shadow_color = (!empty($settings['wpmf_gallery_shadow_color'])) ? $settings['wpmf_gallery_shadow_color'] : '#cccccc';
|
||||
if (!empty($enable_gallery_shadow)) {
|
||||
$img_shadow = $shadow_horizontal['size'] . 'px ' . $shadow_vertical['size'] . 'px ' . $shadow_blur['size'] . 'px ' . $shadow_spread['size'] . 'px ' . $shadow_color;
|
||||
} else {
|
||||
$img_shadow = '';
|
||||
}
|
||||
|
||||
$enable_gallery_folder = (!empty($settings['wpmf_gallery_folder']) && $settings['wpmf_gallery_folder'] === 'yes') ? 1 : 0;
|
||||
$folder_slug = (!empty($settings['wpmf_gallery_folder_id'])) ? $settings['wpmf_gallery_folder_id'] : 0;
|
||||
$pos = strpos($folder_slug, '|');
|
||||
if ($pos) {
|
||||
$folder_slug = substr($folder_slug, $pos+1);
|
||||
}
|
||||
|
||||
$folder_id = 0;
|
||||
$folder = get_term_by('slug', $folder_slug, WPMF_TAXO);
|
||||
if (!empty($folder)) {
|
||||
$folder_id = $folder->term_id;
|
||||
} else {
|
||||
$folder = get_term_by('id', (int)$folder_slug, WPMF_TAXO);
|
||||
if (!empty($folder)) {
|
||||
$folder_id = $folder->term_id;
|
||||
}
|
||||
}
|
||||
|
||||
$gallery_items = $settings['wpmf_gallery'];
|
||||
$ids = array();
|
||||
foreach ($gallery_items as $gallery_item) {
|
||||
$ids[] = $gallery_item['id'];
|
||||
}
|
||||
if (is_admin()) {
|
||||
require_once(WP_MEDIA_FOLDER_PLUGIN_DIR . 'class/class-display-gallery.php');
|
||||
$gallery = new WpmfDisplayGallery();
|
||||
$style = '';
|
||||
switch ($theme) {
|
||||
case 'default':
|
||||
case 'masonry':
|
||||
if ($img_shadow !== '') {
|
||||
$style .= '.elementor-element-' . $this->get_id() . ' .wpmf-gallery-item img:hover {box-shadow: ' . $img_shadow . ' !important; transition: all 200ms ease;}';
|
||||
}
|
||||
|
||||
if ($border_style !== 'none') {
|
||||
$style .= '.elementor-element-' . $this->get_id() . ' .wpmf-gallery-item img {border: ' . $border_color . ' '. $border_width .'px '. $border_style .'}';
|
||||
}
|
||||
break;
|
||||
case 'portfolio':
|
||||
if ($img_shadow !== '') {
|
||||
$style .= '.elementor-element-' . $this->get_id() . ' .wpmf-gallery-item .wpmf_overlay:hover {box-shadow: ' . $img_shadow . ' !important; transition: all 200ms ease;}';
|
||||
}
|
||||
|
||||
if ($border_style !== 'none') {
|
||||
$style .= '.elementor-element-' . $this->get_id() . ' .wpmf-gallery-item img {border: ' . $border_color . ' '. $border_width .'px '. $border_style .'}';
|
||||
}
|
||||
break;
|
||||
case 'slider':
|
||||
$style = '';
|
||||
if ($img_shadow !== '') {
|
||||
if ((int) $columns > 1) {
|
||||
$style .= '.elementor-element-' . $this->get_id() . ' .wpmf-gallery-item:hover {box-shadow: ' . $img_shadow . ' !important; transition: all 200ms ease;}';
|
||||
}
|
||||
}
|
||||
|
||||
if ($border_style !== 'none') {
|
||||
if ((int) $columns === 1) {
|
||||
$style .= '.elementor-element-' . $this->get_id() . ' .wpmf-gallery-item img {border: ' . $border_color . ' '. $border_width .'px '. $border_style .';}';
|
||||
} else {
|
||||
$style .= '.elementor-element-' . $this->get_id() . ' .wpmf-gallery-item {border: ' . $border_color . ' '. $border_width .'px '. $border_style .';}';
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<style id="elementor-style-<?php echo esc_attr($this->get_id()) ?>">
|
||||
<?php echo $style; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Style inline ?>
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
var wpmfggr = '<?php echo json_encode($gallery->localizeScript()); ?>';
|
||||
wpmfggr = JSON.parse(wpmfggr);
|
||||
wpmfggr.slider_animation = 'slide';
|
||||
</script>
|
||||
<?php
|
||||
// phpcs:disable WordPress.WP.EnqueuedResources.NonEnqueuedScript -- Load script from file
|
||||
?>
|
||||
<script type="text/javascript" src="<?php echo esc_url(WPMF_PLUGIN_URL . 'assets/js/display-gallery/site_gallery.js?v=' . WPMF_VERSION) ?>"></script>
|
||||
<?php
|
||||
// phpcs:enable
|
||||
}
|
||||
|
||||
if (empty($settings['wpmf_gallery']) && empty($enable_gallery_folder) && empty($folder_id)) {
|
||||
?>
|
||||
<div class="wpmf-elementor-placeholder" style="text-align: center">
|
||||
<img style="background: url(<?php echo esc_url(WPMF_PLUGIN_URL . 'assets/images/gallery_place_holder.svg'); ?>) no-repeat scroll center center #fafafa; height: 200px; border-radius: 2px; width: 100%; background-size: auto 60%;" src="<?php echo esc_url(WPMF_PLUGIN_URL . 'assets/images/t.gif'); ?>">
|
||||
<span style="position: absolute; bottom: 12px; width: 100%; left: 0;font-size: 13px; text-align: center;"><?php esc_html_e('Please add some images to the gallery to activate the preview', 'wpmf'); ?></span>
|
||||
</div>
|
||||
<?php
|
||||
} else {
|
||||
echo do_shortcode('[wpmf_gallery include="'. esc_attr(implode(',', $ids)) .'" display="' . esc_attr($theme) . '" columns="' . esc_attr($columns) . '" size="' . esc_attr($size) . '" targetsize="' . esc_attr($targetsize) . '" link="' . esc_attr($action) . '" wpmf_orderby="' . esc_attr($orderby) . '" wpmf_order="' . esc_attr($order) . '" gutterwidth="' . esc_attr($gutterwidth) . '" border_width="' . esc_attr($border_width) . '" border_style="' . esc_attr($border_style) . '" border_color="' . esc_attr($border_color) . '" img_shadow="' . esc_attr($img_shadow) . '" img_border_radius="' . esc_attr($border_radius) . '" wpmf_autoinsert="' . esc_attr($enable_gallery_folder) . '" wpmf_folder_id="' . esc_attr($folder_id) . '" crop_image="'. $crop_image .'" aspect_ratio="' . esc_attr($aspect_ratio) . '"]');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
if (!defined('ABSPATH')) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Class WpmfPdfEmbedElementorWidget
|
||||
*/
|
||||
class WpmfPdfEmbedElementorWidget extends \Elementor\Widget_Base
|
||||
{
|
||||
/**
|
||||
* Get script depends
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_script_depends() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from \Elementor\Widget_Base class
|
||||
{
|
||||
return array(
|
||||
'wpmf_pdf_js',
|
||||
'wpmf_embed_pdf_js',
|
||||
'wpmf_compat_js'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get style depends
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_style_depends() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from \Elementor\Widget_Base class
|
||||
{
|
||||
return array(
|
||||
'pdfemb_embed_pdf_css'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get widget name.
|
||||
*
|
||||
* Retrieve PDF Embed widget name.
|
||||
*
|
||||
* @return string Widget name.
|
||||
*/
|
||||
public function get_name() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from \Elementor\Widget_Base class
|
||||
{
|
||||
return 'wpmf_pdf_embed';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get widget title.
|
||||
*
|
||||
* Retrieve PDF Embed widget title.
|
||||
*
|
||||
* @return string Widget title.
|
||||
*/
|
||||
public function get_title() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from \Elementor\Widget_Base class
|
||||
{
|
||||
return esc_html__('WP Media Folder PDF Embed', 'wpmf');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get widget icon.
|
||||
*
|
||||
* Retrieve PDF Embed widget icon.
|
||||
*
|
||||
* @return string Widget icon.
|
||||
*/
|
||||
public function get_icon() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from \Elementor\Widget_Base class
|
||||
{
|
||||
return 'fa wpmf-pdf-embed-elementor-icon';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get widget categories.
|
||||
*
|
||||
* Retrieve the list of categories the PDF Embed widget belongs to.
|
||||
*
|
||||
* @return array Widget categories.
|
||||
*/
|
||||
public function get_categories() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- Method extends from \Elementor\Widget_Base class
|
||||
{
|
||||
return array('wpmf');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register PDF Embed widget controls.
|
||||
*
|
||||
* Adds different input fields to allow the user to change and customize the widget settings.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function register_controls() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps, PSR2.Methods.MethodDeclaration.Underscore -- Method extends from \Elementor\Widget_Base class
|
||||
{
|
||||
$this->start_controls_section(
|
||||
'settings_section',
|
||||
array(
|
||||
'label' => esc_html__('Settings', 'wpmf'),
|
||||
'tab' => \Elementor\Controls_Manager::TAB_CONTENT
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_add_pdf',
|
||||
array(
|
||||
'label' => esc_html__('Choose PDF', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::BUTTON,
|
||||
'text' => esc_html__('SELECT PDF', 'wpmf')
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'embed',
|
||||
array(
|
||||
'label' => esc_html__('Embed', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::SELECT,
|
||||
'options' => array(
|
||||
'on' => esc_html__('On', 'wpmf'),
|
||||
'off' => esc_html__('Off', 'wpmf')
|
||||
),
|
||||
'default' => 'on'
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'target',
|
||||
array(
|
||||
'label' => esc_html__('Target', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::SELECT,
|
||||
'options' => array(
|
||||
'_blank' => esc_html__('New Window', 'wpmf'),
|
||||
'self' => esc_html__('Same Window', 'wpmf')
|
||||
),
|
||||
'default' => 'self'
|
||||
)
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'wpmf_pdf_id',
|
||||
array(
|
||||
'label' => esc_html__('PDF ID', 'wpmf'),
|
||||
'type' => \Elementor\Controls_Manager::NUMBER,
|
||||
)
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render PDF Embed widget output on the frontend.
|
||||
*
|
||||
* Written in PHP and used to generate the final HTML.
|
||||
*
|
||||
* @return void|string
|
||||
*/
|
||||
protected function render()
|
||||
{
|
||||
if (is_admin()) {
|
||||
require_once(WP_MEDIA_FOLDER_PLUGIN_DIR . 'class/class-pdf-embed.php');
|
||||
$pdf = new WpmfPdfEmbed();
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var wpmf_pdfemb_trans = '<?php echo json_encode($pdf->getTranslation()); ?>';
|
||||
wpmf_pdfemb_trans = JSON.parse(wpmf_pdfemb_trans);
|
||||
</script>
|
||||
<script type="text/javascript"
|
||||
src="<?php echo esc_url(WPMF_PLUGIN_URL . 'assets/js/pdf-embed/viewer.js?v=' . WPMF_VERSION) ?>"></script>
|
||||
<?php
|
||||
}
|
||||
$settings = $this->get_settings_for_display();
|
||||
$id = (isset($settings['wpmf_pdf_id']) && $settings['wpmf_pdf_id'] !== '') ? $settings['wpmf_pdf_id'] : 0;
|
||||
if (!empty($id)) {
|
||||
$embed = (isset($settings['embed']) && $settings['embed'] === 'on') ? 1 : 0;
|
||||
$target = (isset($settings['target'])) ? $settings['target'] : 'self';
|
||||
echo do_shortcode('[wpmfpdf id="' . esc_attr($id) . '" embed="' . esc_attr($embed) . '" target="' . esc_attr($target) . '"]');
|
||||
} else {
|
||||
?>
|
||||
<div class="wpmf-elementor-placeholder" style="text-align: center">
|
||||
<img style="background: url(<?php echo esc_url(WPMF_PLUGIN_URL . 'assets/images/pdf_embed_place_holder.svg'); ?>) no-repeat scroll center center #fafafa; height: 200px; border-radius: 2px; width: 100%; background-size: auto 60%;" src="<?php echo esc_url(WPMF_PLUGIN_URL . 'assets/images/t.gif'); ?>">
|
||||
<span style="position: absolute; bottom: 12px; width: 100%; left: 0;font-size: 13px; text-align: center;"><?php esc_html_e('Please select a PDF file to activate the preview', 'wpmf'); ?></span>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
(function ($) {
|
||||
$(document).ready(function () {
|
||||
/**
|
||||
* Open select logo watermark
|
||||
*/
|
||||
$(document).on("click", '.elementor-control-wpmf_add_pdf .elementor-button-default', function (e) {
|
||||
if (typeof frame !== "undefined") {
|
||||
frame.open();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the media frame.
|
||||
var frame = wp.media({
|
||||
// Tell the modal to show only images.
|
||||
library: {
|
||||
type: 'application/pdf'
|
||||
}
|
||||
});
|
||||
|
||||
frame.on('open',function() {
|
||||
var selection = frame.state().get('selection');
|
||||
var selected = $('.elementor-control-wpmf_pdf_id input[data-setting="wpmf_pdf_id"]').val(); // the id of the image
|
||||
if (selected && selected !== '') {
|
||||
selection.add(wp.media.attachment(selected));
|
||||
}
|
||||
});
|
||||
|
||||
frame.on('select', function () {
|
||||
// Grab the selected attachment.
|
||||
var attachment = frame.state().get('selection').first().toJSON();
|
||||
$('.elementor-control-wpmf_pdf_id input[data-setting="wpmf_pdf_id"]').val(attachment.id).trigger('input');
|
||||
});
|
||||
|
||||
frame.open();
|
||||
});
|
||||
|
||||
$(document).on("click", '.elementor-control-wpmf_add_file_design .elementor-button-default', function (e) {
|
||||
if (typeof frame !== "undefined") {
|
||||
frame.open();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the media frame.
|
||||
var frame = wp.media({
|
||||
library: {
|
||||
type: '*'
|
||||
}
|
||||
});
|
||||
|
||||
frame.on('open',function() {
|
||||
var selection = frame.state().get('selection');
|
||||
var selected = $('.elementor-control-wpmf_file_design_id input[data-setting="wpmf_file_design_id"]').val(); // the id of the image
|
||||
if (selected && selected !== '') {
|
||||
selection.add(wp.media.attachment(selected));
|
||||
}
|
||||
});
|
||||
|
||||
frame.on('select', function () {
|
||||
// Grab the selected attachment.
|
||||
var attachment = frame.state().get('selection').first().toJSON();
|
||||
$('.elementor-control-wpmf_file_design_id input[data-setting="wpmf_file_design_id"]').val(attachment.id).trigger('input');
|
||||
});
|
||||
|
||||
frame.open();
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Implementation for WordPress functions missing in older WordPress versions.
|
||||
*/
|
||||
|
||||
if (!function_exists('wp_slash_strings_only')) {
|
||||
/**
|
||||
* Adds slashes to only string values in an array of values.
|
||||
*
|
||||
* Compat for WordPress < 5.3.0.
|
||||
*
|
||||
* @param mixed $value Scalar or array of scalars.
|
||||
* @return mixed Slashes $value
|
||||
* @since 0.7.0
|
||||
*
|
||||
*/
|
||||
function wp_slash_strings_only($value)
|
||||
{
|
||||
return map_deep($value, 'addslashes_strings_only');
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('addslashes_strings_only')) {
|
||||
/**
|
||||
* Adds slashes only if the provided value is a string.
|
||||
*
|
||||
* Compat for WordPress < 5.3.0.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
* @since 0.7.0
|
||||
*
|
||||
*/
|
||||
function addslashes_strings_only($value)
|
||||
{
|
||||
return is_string($value) ? addslashes($value) : $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('map_deep')) {
|
||||
/**
|
||||
* Maps a function to all non-iterable elements of an array or an object.
|
||||
*
|
||||
* Compat for WordPress < 4.4.0.
|
||||
*
|
||||
* @param mixed $value The array, object, or scalar.
|
||||
* @param callable $callback The function to map onto $value.
|
||||
* @return mixed The value with the callback applied to all non-arrays and non-objects inside it.
|
||||
* @since 0.7.0
|
||||
*
|
||||
*/
|
||||
function map_deep($value, $callback)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $index => $item) {
|
||||
$value[$index] = map_deep($item, $callback);
|
||||
}
|
||||
} elseif (is_object($value)) {
|
||||
$object_vars = get_object_vars($value);
|
||||
foreach ($object_vars as $property_name => $property_value) {
|
||||
$value->$property_name = map_deep($property_value, $callback);
|
||||
}
|
||||
} else {
|
||||
$value = call_user_func($callback, $value);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* WordPress eXtended RSS file parser implementations
|
||||
*/
|
||||
|
||||
_deprecated_file(basename(__FILE__), '0.7.0');
|
||||
|
||||
/** WXR_Parser class */
|
||||
require_once dirname(__FILE__) . '/parsers/class-wxr-parser.php';
|
||||
|
||||
/** WXR_Parser_SimpleXML class */
|
||||
require_once dirname(__FILE__) . '/parsers/class-wxr-parser-simplexml.php';
|
||||
|
||||
/** WXR_Parser_XML class */
|
||||
require_once dirname(__FILE__) . '/parsers/class-wxr-parser-xml.php';
|
||||
|
||||
/** WXR_Parser_Regex class */
|
||||
require_once dirname(__FILE__) . '/parsers/class-wxr-parser-regex.php';
|
||||
@@ -0,0 +1,333 @@
|
||||
<?php
|
||||
/**
|
||||
* WordPress eXtended RSS file parser implementations
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Importer
|
||||
*/
|
||||
|
||||
/**
|
||||
* WXR Parser that uses regular expressions. Fallback for installs without an XML parser.
|
||||
*/
|
||||
class WXR_Parser_Regex
|
||||
{
|
||||
var $authors = array();
|
||||
var $posts = array();
|
||||
var $categories = array();
|
||||
var $tags = array();
|
||||
var $terms = array();
|
||||
var $base_url = '';
|
||||
var $base_blog_url = '';
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->has_gzip = is_callable('gzopen');
|
||||
}
|
||||
|
||||
function parse($file)
|
||||
{
|
||||
$wxr_version = $in_multiline = false;
|
||||
|
||||
$multiline_content = '';
|
||||
|
||||
$multiline_tags = array(
|
||||
'item' => array('posts', array($this, 'process_post')),
|
||||
'wp:category' => array('categories', array($this, 'process_category')),
|
||||
'wp:tag' => array('tags', array($this, 'process_tag')),
|
||||
'wp:term' => array('terms', array($this, 'process_term')),
|
||||
);
|
||||
|
||||
$fp = $this->fopen($file, 'r');
|
||||
if ($fp) {
|
||||
while (!$this->feof($fp)) {
|
||||
$importline = rtrim($this->fgets($fp));
|
||||
|
||||
if (!$wxr_version && preg_match('|<wp:wxr_version>(\d+\.\d+)</wp:wxr_version>|', $importline, $version))
|
||||
$wxr_version = $version[1];
|
||||
|
||||
if (false !== strpos($importline, '<wp:base_site_url>')) {
|
||||
preg_match('|<wp:base_site_url>(.*?)</wp:base_site_url>|is', $importline, $url);
|
||||
$this->base_url = $url[1];
|
||||
continue;
|
||||
}
|
||||
|
||||
if (false !== strpos($importline, '<wp:base_blog_url>')) {
|
||||
preg_match('|<wp:base_blog_url>(.*?)</wp:base_blog_url>|is', $importline, $blog_url);
|
||||
$this->base_blog_url = $blog_url[1];
|
||||
continue;
|
||||
} else {
|
||||
$this->base_blog_url = $this->base_url;
|
||||
}
|
||||
|
||||
if (false !== strpos($importline, '<wp:author>')) {
|
||||
preg_match('|<wp:author>(.*?)</wp:author>|is', $importline, $author);
|
||||
$a = $this->process_author($author[1]);
|
||||
$this->authors[$a['author_login']] = $a;
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($multiline_tags as $tag => $handler) {
|
||||
// Handle multi-line tags on a singular line
|
||||
if (preg_match('|<' . $tag . '>(.*?)</' . $tag . '>|is', $importline, $matches)) {
|
||||
$this->{$handler[0]}[] = call_user_func($handler[1], $matches[1]);
|
||||
|
||||
} elseif (false !== ($pos = strpos($importline, "<$tag>"))) {
|
||||
// Take note of any content after the opening tag
|
||||
$multiline_content = trim(substr($importline, $pos + strlen($tag) + 2));
|
||||
|
||||
// We don't want to have this line added to `$is_multiline` below.
|
||||
$importline = '';
|
||||
$in_multiline = $tag;
|
||||
|
||||
} elseif (false !== ($pos = strpos($importline, "</$tag>"))) {
|
||||
$in_multiline = false;
|
||||
$multiline_content .= trim(substr($importline, 0, $pos));
|
||||
|
||||
$this->{$handler[0]}[] = call_user_func($handler[1], $multiline_content);
|
||||
}
|
||||
}
|
||||
|
||||
if ($in_multiline && $importline) {
|
||||
$multiline_content .= $importline . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
$this->fclose($fp);
|
||||
}
|
||||
|
||||
if (!$wxr_version)
|
||||
return new WP_Error('WXR_parse_error', __('This does not appear to be a WXR file, missing/invalid WXR version number', 'wpmf'));
|
||||
|
||||
return array(
|
||||
'authors' => $this->authors,
|
||||
'posts' => $this->posts,
|
||||
'categories' => $this->categories,
|
||||
'tags' => $this->tags,
|
||||
'terms' => $this->terms,
|
||||
'base_url' => $this->base_url,
|
||||
'base_blog_url' => $this->base_blog_url,
|
||||
'version' => $wxr_version
|
||||
);
|
||||
}
|
||||
|
||||
function get_tag($string, $tag)
|
||||
{
|
||||
preg_match("|<$tag.*?>(.*?)</$tag>|is", $string, $return);
|
||||
if (isset($return[1])) {
|
||||
if (substr($return[1], 0, 9) == '<![CDATA[') {
|
||||
if (strpos($return[1], ']]]]><![CDATA[>') !== false) {
|
||||
preg_match_all('|<!\[CDATA\[(.*?)\]\]>|s', $return[1], $matches);
|
||||
$return = '';
|
||||
foreach ($matches[1] as $match)
|
||||
$return .= $match;
|
||||
} else {
|
||||
$return = preg_replace('|^<!\[CDATA\[(.*)\]\]>$|s', '$1', $return[1]);
|
||||
}
|
||||
} else {
|
||||
$return = $return[1];
|
||||
}
|
||||
} else {
|
||||
$return = '';
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
function process_category($c)
|
||||
{
|
||||
$term = array(
|
||||
'term_id' => $this->get_tag($c, 'wp:term_id'),
|
||||
'cat_name' => $this->get_tag($c, 'wp:cat_name'),
|
||||
'category_nicename' => $this->get_tag($c, 'wp:category_nicename'),
|
||||
'category_parent' => $this->get_tag($c, 'wp:category_parent'),
|
||||
'category_description' => $this->get_tag($c, 'wp:category_description'),
|
||||
);
|
||||
|
||||
$term_meta = $this->process_meta($c, 'wp:termmeta');
|
||||
if (!empty($term_meta)) {
|
||||
$term['termmeta'] = $term_meta;
|
||||
}
|
||||
|
||||
return $term;
|
||||
}
|
||||
|
||||
function process_tag($t)
|
||||
{
|
||||
$term = array(
|
||||
'term_id' => $this->get_tag($t, 'wp:term_id'),
|
||||
'tag_name' => $this->get_tag($t, 'wp:tag_name'),
|
||||
'tag_slug' => $this->get_tag($t, 'wp:tag_slug'),
|
||||
'tag_description' => $this->get_tag($t, 'wp:tag_description'),
|
||||
);
|
||||
|
||||
$term_meta = $this->process_meta($t, 'wp:termmeta');
|
||||
if (!empty($term_meta)) {
|
||||
$term['termmeta'] = $term_meta;
|
||||
}
|
||||
|
||||
return $term;
|
||||
}
|
||||
|
||||
function process_term($t)
|
||||
{
|
||||
$term = array(
|
||||
'term_id' => $this->get_tag($t, 'wp:term_id'),
|
||||
'term_taxonomy' => $this->get_tag($t, 'wp:term_taxonomy'),
|
||||
'slug' => $this->get_tag($t, 'wp:term_slug'),
|
||||
'term_parent' => $this->get_tag($t, 'wp:term_parent'),
|
||||
'term_name' => $this->get_tag($t, 'wp:term_name'),
|
||||
'term_description' => $this->get_tag($t, 'wp:term_description'),
|
||||
);
|
||||
|
||||
$term_meta = $this->process_meta($t, 'wp:termmeta');
|
||||
if (!empty($term_meta)) {
|
||||
$term['termmeta'] = $term_meta;
|
||||
}
|
||||
|
||||
return $term;
|
||||
}
|
||||
|
||||
function process_meta($string, $tag)
|
||||
{
|
||||
$parsed_meta = array();
|
||||
|
||||
preg_match_all("|<$tag>(.+?)</$tag>|is", $string, $meta);
|
||||
|
||||
if (!isset($meta[1])) {
|
||||
return $parsed_meta;
|
||||
}
|
||||
|
||||
foreach ($meta[1] as $m) {
|
||||
$parsed_meta[] = array(
|
||||
'key' => $this->get_tag($m, 'wp:meta_key'),
|
||||
'value' => $this->get_tag($m, 'wp:meta_value'),
|
||||
);
|
||||
}
|
||||
|
||||
return $parsed_meta;
|
||||
}
|
||||
|
||||
function process_author($a)
|
||||
{
|
||||
return array(
|
||||
'author_id' => $this->get_tag($a, 'wp:author_id'),
|
||||
'author_login' => $this->get_tag($a, 'wp:author_login'),
|
||||
'author_email' => $this->get_tag($a, 'wp:author_email'),
|
||||
'author_display_name' => $this->get_tag($a, 'wp:author_display_name'),
|
||||
'author_first_name' => $this->get_tag($a, 'wp:author_first_name'),
|
||||
'author_last_name' => $this->get_tag($a, 'wp:author_last_name'),
|
||||
);
|
||||
}
|
||||
|
||||
function process_post($post)
|
||||
{
|
||||
$post_id = $this->get_tag($post, 'wp:post_id');
|
||||
$post_title = $this->get_tag($post, 'title');
|
||||
$post_date = $this->get_tag($post, 'wp:post_date');
|
||||
$post_date_gmt = $this->get_tag($post, 'wp:post_date_gmt');
|
||||
$comment_status = $this->get_tag($post, 'wp:comment_status');
|
||||
$ping_status = $this->get_tag($post, 'wp:ping_status');
|
||||
$status = $this->get_tag($post, 'wp:status');
|
||||
$post_name = $this->get_tag($post, 'wp:post_name');
|
||||
$post_parent = $this->get_tag($post, 'wp:post_parent');
|
||||
$menu_order = $this->get_tag($post, 'wp:menu_order');
|
||||
$post_type = $this->get_tag($post, 'wp:post_type');
|
||||
$post_password = $this->get_tag($post, 'wp:post_password');
|
||||
$is_sticky = $this->get_tag($post, 'wp:is_sticky');
|
||||
$guid = $this->get_tag($post, 'guid');
|
||||
$post_author = $this->get_tag($post, 'dc:creator');
|
||||
|
||||
$post_excerpt = $this->get_tag($post, 'excerpt:encoded');
|
||||
$post_excerpt = preg_replace_callback('|<(/?[A-Z]+)|', array(&$this, '_normalize_tag'), $post_excerpt);
|
||||
$post_excerpt = str_replace('<br>', '<br />', $post_excerpt);
|
||||
$post_excerpt = str_replace('<hr>', '<hr />', $post_excerpt);
|
||||
|
||||
$post_content = $this->get_tag($post, 'content:encoded');
|
||||
$post_content = preg_replace_callback('|<(/?[A-Z]+)|', array(&$this, '_normalize_tag'), $post_content);
|
||||
$post_content = str_replace('<br>', '<br />', $post_content);
|
||||
$post_content = str_replace('<hr>', '<hr />', $post_content);
|
||||
|
||||
$postdata = compact('post_id', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_excerpt',
|
||||
'post_title', 'status', 'post_name', 'comment_status', 'ping_status', 'guid', 'post_parent',
|
||||
'menu_order', 'post_type', 'post_password', 'is_sticky'
|
||||
);
|
||||
|
||||
$attachment_url = $this->get_tag($post, 'wp:attachment_url');
|
||||
if ($attachment_url)
|
||||
$postdata['attachment_url'] = $attachment_url;
|
||||
|
||||
preg_match_all('|<category domain="([^"]+?)" nicename="([^"]+?)">(.+?)</category>|is', $post, $terms, PREG_SET_ORDER);
|
||||
foreach ($terms as $t) {
|
||||
$post_terms[] = array(
|
||||
'slug' => $t[2],
|
||||
'domain' => $t[1],
|
||||
'name' => str_replace(array('<![CDATA[', ']]>'), '', $t[3]),
|
||||
);
|
||||
}
|
||||
if (!empty($post_terms)) $postdata['terms'] = $post_terms;
|
||||
|
||||
preg_match_all('|<wp:comment>(.+?)</wp:comment>|is', $post, $comments);
|
||||
$comments = $comments[1];
|
||||
if ($comments) {
|
||||
foreach ($comments as $comment) {
|
||||
$post_comments[] = array(
|
||||
'comment_id' => $this->get_tag($comment, 'wp:comment_id'),
|
||||
'comment_author' => $this->get_tag($comment, 'wp:comment_author'),
|
||||
'comment_author_email' => $this->get_tag($comment, 'wp:comment_author_email'),
|
||||
'comment_author_IP' => $this->get_tag($comment, 'wp:comment_author_IP'),
|
||||
'comment_author_url' => $this->get_tag($comment, 'wp:comment_author_url'),
|
||||
'comment_date' => $this->get_tag($comment, 'wp:comment_date'),
|
||||
'comment_date_gmt' => $this->get_tag($comment, 'wp:comment_date_gmt'),
|
||||
'comment_content' => $this->get_tag($comment, 'wp:comment_content'),
|
||||
'comment_approved' => $this->get_tag($comment, 'wp:comment_approved'),
|
||||
'comment_type' => $this->get_tag($comment, 'wp:comment_type'),
|
||||
'comment_parent' => $this->get_tag($comment, 'wp:comment_parent'),
|
||||
'comment_user_id' => $this->get_tag($comment, 'wp:comment_user_id'),
|
||||
'commentmeta' => $this->process_meta($comment, 'wp:commentmeta'),
|
||||
);
|
||||
}
|
||||
}
|
||||
if (!empty($post_comments)) {
|
||||
$postdata['comments'] = $post_comments;
|
||||
}
|
||||
|
||||
$post_meta = $this->process_meta($post, 'wp:postmeta');
|
||||
if (!empty($post_meta)) {
|
||||
$postdata['postmeta'] = $post_meta;
|
||||
}
|
||||
|
||||
return $postdata;
|
||||
}
|
||||
|
||||
function _normalize_tag($matches)
|
||||
{
|
||||
return '<' . strtolower($matches[1]);
|
||||
}
|
||||
|
||||
function fopen($filename, $mode = 'r')
|
||||
{
|
||||
if ($this->has_gzip)
|
||||
return gzopen($filename, $mode);
|
||||
return fopen($filename, $mode);
|
||||
}
|
||||
|
||||
function feof($fp)
|
||||
{
|
||||
if ($this->has_gzip)
|
||||
return gzeof($fp);
|
||||
return feof($fp);
|
||||
}
|
||||
|
||||
function fgets($fp, $len = 8192)
|
||||
{
|
||||
if ($this->has_gzip)
|
||||
return gzgets($fp, $len);
|
||||
return fgets($fp, $len);
|
||||
}
|
||||
|
||||
function fclose($fp)
|
||||
{
|
||||
if ($this->has_gzip)
|
||||
return gzclose($fp);
|
||||
return fclose($fp);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
/**
|
||||
* WordPress eXtended RSS file parser implementations
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Importer
|
||||
*/
|
||||
|
||||
/**
|
||||
* WXR Parser that makes use of the SimpleXML PHP extension.
|
||||
*/
|
||||
class WXR_Parser_SimpleXML
|
||||
{
|
||||
function parse($file)
|
||||
{
|
||||
$authors = $posts = $categories = $tags = $terms = array();
|
||||
$internal_errors = libxml_use_internal_errors(true);
|
||||
$dom = new DOMDocument;
|
||||
$old_value = null;
|
||||
if (function_exists('libxml_disable_entity_loader')) {
|
||||
$old_value = libxml_disable_entity_loader(true);
|
||||
}
|
||||
$success = $dom->loadXML(file_get_contents($file));
|
||||
if (!is_null($old_value)) {
|
||||
libxml_disable_entity_loader($old_value);
|
||||
}
|
||||
|
||||
if (!$success || isset($dom->doctype)) {
|
||||
return new WP_Error('SimpleXML_parse_error', __('There was an error when reading this WXR file', 'wpmf'), libxml_get_errors());
|
||||
}
|
||||
|
||||
$xml = simplexml_import_dom($dom);
|
||||
unset($dom);
|
||||
|
||||
// halt if loading produces an error
|
||||
if (!$xml)
|
||||
return new WP_Error('SimpleXML_parse_error', __('There was an error when reading this WXR file', 'wpmf'), libxml_get_errors());
|
||||
|
||||
$wxr_version = $xml->xpath('/rss/channel/wp:wxr_version');
|
||||
if (!$wxr_version)
|
||||
return new WP_Error('WXR_parse_error', __('This does not appear to be a WXR file, missing/invalid WXR version number', 'wpmf'));
|
||||
|
||||
$wxr_version = (string)trim($wxr_version[0]);
|
||||
// confirm that we are dealing with the correct file format
|
||||
if (!preg_match('/^\d+\.\d+$/', $wxr_version))
|
||||
return new WP_Error('WXR_parse_error', __('This does not appear to be a WXR file, missing/invalid WXR version number', 'wpmf'));
|
||||
|
||||
$base_url = $xml->xpath('/rss/channel/wp:base_site_url');
|
||||
$base_url = (string)trim(isset($base_url[0]) ? $base_url[0] : '');
|
||||
|
||||
|
||||
$base_blog_url = $xml->xpath('/rss/channel/wp:base_blog_url');
|
||||
if ($base_blog_url) {
|
||||
$base_blog_url = (string)trim($base_blog_url[0]);
|
||||
} else {
|
||||
$base_blog_url = $base_url;
|
||||
}
|
||||
|
||||
$namespaces = $xml->getDocNamespaces();
|
||||
if (!isset($namespaces['wp']))
|
||||
$namespaces['wp'] = 'http://wordpress.org/export/1.1/';
|
||||
if (!isset($namespaces['excerpt']))
|
||||
$namespaces['excerpt'] = 'http://wordpress.org/export/1.1/excerpt/';
|
||||
|
||||
// grab authors
|
||||
foreach ($xml->xpath('/rss/channel/wp:author') as $author_arr) {
|
||||
$a = $author_arr->children($namespaces['wp']);
|
||||
$login = (string)$a->author_login;
|
||||
$authors[$login] = array(
|
||||
'author_id' => (int)$a->author_id,
|
||||
'author_login' => $login,
|
||||
'author_email' => (string)$a->author_email,
|
||||
'author_display_name' => (string)$a->author_display_name,
|
||||
'author_first_name' => (string)$a->author_first_name,
|
||||
'author_last_name' => (string)$a->author_last_name
|
||||
);
|
||||
}
|
||||
|
||||
// grab cats, tags and terms
|
||||
foreach ($xml->xpath('/rss/channel/wp:category') as $term_arr) {
|
||||
$t = $term_arr->children($namespaces['wp']);
|
||||
$category = array(
|
||||
'term_id' => (int)$t->term_id,
|
||||
'category_nicename' => (string)$t->category_nicename,
|
||||
'category_parent' => (string)$t->category_parent,
|
||||
'cat_name' => (string)$t->cat_name,
|
||||
'category_description' => (string)$t->category_description
|
||||
);
|
||||
|
||||
foreach ($t->termmeta as $meta) {
|
||||
$category['termmeta'][] = array(
|
||||
'key' => (string)$meta->meta_key,
|
||||
'value' => (string)$meta->meta_value
|
||||
);
|
||||
}
|
||||
|
||||
$categories[] = $category;
|
||||
}
|
||||
|
||||
foreach ($xml->xpath('/rss/channel/wp:tag') as $term_arr) {
|
||||
$t = $term_arr->children($namespaces['wp']);
|
||||
$tag = array(
|
||||
'term_id' => (int)$t->term_id,
|
||||
'tag_slug' => (string)$t->tag_slug,
|
||||
'tag_name' => (string)$t->tag_name,
|
||||
'tag_description' => (string)$t->tag_description
|
||||
);
|
||||
|
||||
foreach ($t->termmeta as $meta) {
|
||||
$tag['termmeta'][] = array(
|
||||
'key' => (string)$meta->meta_key,
|
||||
'value' => (string)$meta->meta_value
|
||||
);
|
||||
}
|
||||
|
||||
$tags[] = $tag;
|
||||
}
|
||||
|
||||
foreach ($xml->xpath('/rss/channel/wp:term') as $term_arr) {
|
||||
$t = $term_arr->children($namespaces['wp']);
|
||||
$term = array(
|
||||
'term_id' => (int)$t->term_id,
|
||||
'term_taxonomy' => (string)$t->term_taxonomy,
|
||||
'slug' => (string)$t->term_slug,
|
||||
'term_parent' => (string)$t->term_parent,
|
||||
'term_name' => (string)$t->term_name,
|
||||
'term_description' => (string)$t->term_description
|
||||
);
|
||||
|
||||
foreach ($t->termmeta as $meta) {
|
||||
$term['termmeta'][] = array(
|
||||
'key' => (string)$meta->meta_key,
|
||||
'value' => (string)$meta->meta_value
|
||||
);
|
||||
}
|
||||
|
||||
$terms[] = $term;
|
||||
}
|
||||
|
||||
// grab posts
|
||||
foreach ($xml->channel->item as $item) {
|
||||
$post = array(
|
||||
'post_title' => (string)$item->title,
|
||||
'guid' => (string)$item->guid,
|
||||
);
|
||||
|
||||
$dc = $item->children('http://purl.org/dc/elements/1.1/');
|
||||
$post['post_author'] = (string)$dc->creator;
|
||||
|
||||
$content = $item->children('http://purl.org/rss/1.0/modules/content/');
|
||||
$excerpt = $item->children($namespaces['excerpt']);
|
||||
$post['post_content'] = (string)$content->encoded;
|
||||
$post['post_excerpt'] = (string)$excerpt->encoded;
|
||||
|
||||
$wp = $item->children($namespaces['wp']);
|
||||
$post['post_id'] = (int)$wp->post_id;
|
||||
$post['post_date'] = (string)$wp->post_date;
|
||||
$post['post_date_gmt'] = (string)$wp->post_date_gmt;
|
||||
$post['comment_status'] = (string)$wp->comment_status;
|
||||
$post['ping_status'] = (string)$wp->ping_status;
|
||||
$post['post_name'] = (string)$wp->post_name;
|
||||
$post['status'] = (string)$wp->status;
|
||||
$post['post_parent'] = (int)$wp->post_parent;
|
||||
$post['menu_order'] = (int)$wp->menu_order;
|
||||
$post['post_type'] = (string)$wp->post_type;
|
||||
$post['post_password'] = (string)$wp->post_password;
|
||||
$post['is_sticky'] = (int)$wp->is_sticky;
|
||||
|
||||
if (isset($wp->attachment_url))
|
||||
$post['attachment_url'] = (string)$wp->attachment_url;
|
||||
|
||||
foreach ($item->category as $c) {
|
||||
$att = $c->attributes();
|
||||
if (isset($att['nicename']))
|
||||
$post['terms'][] = array(
|
||||
'name' => (string)$c,
|
||||
'slug' => (string)$att['nicename'],
|
||||
'domain' => (string)$att['domain']
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($wp->postmeta as $meta) {
|
||||
$post['postmeta'][] = array(
|
||||
'key' => (string)$meta->meta_key,
|
||||
'value' => (string)$meta->meta_value
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($wp->comment as $comment) {
|
||||
$meta = array();
|
||||
if (isset($comment->commentmeta)) {
|
||||
foreach ($comment->commentmeta as $m) {
|
||||
$meta[] = array(
|
||||
'key' => (string)$m->meta_key,
|
||||
'value' => (string)$m->meta_value
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$post['comments'][] = array(
|
||||
'comment_id' => (int)$comment->comment_id,
|
||||
'comment_author' => (string)$comment->comment_author,
|
||||
'comment_author_email' => (string)$comment->comment_author_email,
|
||||
'comment_author_IP' => (string)$comment->comment_author_IP,
|
||||
'comment_author_url' => (string)$comment->comment_author_url,
|
||||
'comment_date' => (string)$comment->comment_date,
|
||||
'comment_date_gmt' => (string)$comment->comment_date_gmt,
|
||||
'comment_content' => (string)$comment->comment_content,
|
||||
'comment_approved' => (string)$comment->comment_approved,
|
||||
'comment_type' => (string)$comment->comment_type,
|
||||
'comment_parent' => (string)$comment->comment_parent,
|
||||
'comment_user_id' => (int)$comment->comment_user_id,
|
||||
'commentmeta' => $meta,
|
||||
);
|
||||
}
|
||||
|
||||
$posts[] = $post;
|
||||
}
|
||||
|
||||
return array(
|
||||
'authors' => $authors,
|
||||
'posts' => $posts,
|
||||
'categories' => $categories,
|
||||
'tags' => $tags,
|
||||
'terms' => $terms,
|
||||
'base_url' => $base_url,
|
||||
'base_blog_url' => $base_blog_url,
|
||||
'version' => $wxr_version
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
/**
|
||||
* WordPress eXtended RSS file parser implementations
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Importer
|
||||
*/
|
||||
|
||||
/**
|
||||
* WXR Parser that makes use of the XML Parser PHP extension.
|
||||
*/
|
||||
class WXR_Parser_XML
|
||||
{
|
||||
var $wp_tags = array(
|
||||
'wp:post_id', 'wp:post_date', 'wp:post_date_gmt', 'wp:comment_status', 'wp:ping_status', 'wp:attachment_url',
|
||||
'wp:status', 'wp:post_name', 'wp:post_parent', 'wp:menu_order', 'wp:post_type', 'wp:post_password',
|
||||
'wp:is_sticky', 'wp:term_id', 'wp:category_nicename', 'wp:category_parent', 'wp:cat_name', 'wp:category_description',
|
||||
'wp:tag_slug', 'wp:tag_name', 'wp:tag_description', 'wp:term_taxonomy', 'wp:term_parent',
|
||||
'wp:term_name', 'wp:term_description', 'wp:author_id', 'wp:author_login', 'wp:author_email', 'wp:author_display_name',
|
||||
'wp:author_first_name', 'wp:author_last_name',
|
||||
);
|
||||
var $wp_sub_tags = array(
|
||||
'wp:comment_id', 'wp:comment_author', 'wp:comment_author_email', 'wp:comment_author_url',
|
||||
'wp:comment_author_IP', 'wp:comment_date', 'wp:comment_date_gmt', 'wp:comment_content',
|
||||
'wp:comment_approved', 'wp:comment_type', 'wp:comment_parent', 'wp:comment_user_id',
|
||||
);
|
||||
|
||||
function parse($file)
|
||||
{
|
||||
$this->wxr_version = $this->in_post = $this->cdata = $this->data = $this->sub_data = $this->in_tag = $this->in_sub_tag = false;
|
||||
$this->authors = $this->posts = $this->term = $this->category = $this->tag = array();
|
||||
|
||||
$xml = xml_parser_create('UTF-8');
|
||||
xml_parser_set_option($xml, XML_OPTION_SKIP_WHITE, 1);
|
||||
xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, 0);
|
||||
xml_set_object($xml, $this);
|
||||
xml_set_character_data_handler($xml, 'cdata');
|
||||
xml_set_element_handler($xml, 'tag_open', 'tag_close');
|
||||
|
||||
if (!xml_parse($xml, file_get_contents($file), true)) {
|
||||
$current_line = xml_get_current_line_number($xml);
|
||||
$current_column = xml_get_current_column_number($xml);
|
||||
$error_code = xml_get_error_code($xml);
|
||||
$error_string = xml_error_string($error_code);
|
||||
return new WP_Error('XML_parse_error', 'There was an error when reading this WXR file', array($current_line, $current_column, $error_string));
|
||||
}
|
||||
xml_parser_free($xml);
|
||||
|
||||
if (!preg_match('/^\d+\.\d+$/', $this->wxr_version))
|
||||
return new WP_Error('WXR_parse_error', __('This does not appear to be a WXR file, missing/invalid WXR version number', 'wpmf'));
|
||||
|
||||
return array(
|
||||
'authors' => $this->authors,
|
||||
'posts' => $this->posts,
|
||||
'categories' => $this->category,
|
||||
'tags' => $this->tag,
|
||||
'terms' => $this->term,
|
||||
'base_url' => $this->base_url,
|
||||
'base_blog_url' => $this->base_blog_url,
|
||||
'version' => $this->wxr_version
|
||||
);
|
||||
}
|
||||
|
||||
function tag_open($parse, $tag, $attr)
|
||||
{
|
||||
if (in_array($tag, $this->wp_tags)) {
|
||||
$this->in_tag = substr($tag, 3);
|
||||
return;
|
||||
}
|
||||
|
||||
if (in_array($tag, $this->wp_sub_tags)) {
|
||||
$this->in_sub_tag = substr($tag, 3);
|
||||
return;
|
||||
}
|
||||
|
||||
switch ($tag) {
|
||||
case 'category':
|
||||
if (isset($attr['domain'], $attr['nicename'])) {
|
||||
$this->sub_data['domain'] = $attr['domain'];
|
||||
$this->sub_data['slug'] = $attr['nicename'];
|
||||
}
|
||||
break;
|
||||
case 'item':
|
||||
$this->in_post = true;
|
||||
case 'title':
|
||||
if ($this->in_post) $this->in_tag = 'post_title';
|
||||
break;
|
||||
case 'guid':
|
||||
$this->in_tag = 'guid';
|
||||
break;
|
||||
case 'dc:creator':
|
||||
$this->in_tag = 'post_author';
|
||||
break;
|
||||
case 'content:encoded':
|
||||
$this->in_tag = 'post_content';
|
||||
break;
|
||||
case 'excerpt:encoded':
|
||||
$this->in_tag = 'post_excerpt';
|
||||
break;
|
||||
|
||||
case 'wp:term_slug':
|
||||
$this->in_tag = 'slug';
|
||||
break;
|
||||
case 'wp:meta_key':
|
||||
$this->in_sub_tag = 'key';
|
||||
break;
|
||||
case 'wp:meta_value':
|
||||
$this->in_sub_tag = 'value';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function cdata($parser, $cdata)
|
||||
{
|
||||
if (!trim($cdata))
|
||||
return;
|
||||
|
||||
if (false !== $this->in_tag || false !== $this->in_sub_tag) {
|
||||
$this->cdata .= $cdata;
|
||||
} else {
|
||||
$this->cdata .= trim($cdata);
|
||||
}
|
||||
}
|
||||
|
||||
function tag_close($parser, $tag)
|
||||
{
|
||||
switch ($tag) {
|
||||
case 'wp:comment':
|
||||
unset($this->sub_data['key'], $this->sub_data['value']); // remove meta sub_data
|
||||
if (!empty($this->sub_data))
|
||||
$this->data['comments'][] = $this->sub_data;
|
||||
$this->sub_data = false;
|
||||
break;
|
||||
case 'wp:commentmeta':
|
||||
$this->sub_data['commentmeta'][] = array(
|
||||
'key' => $this->sub_data['key'],
|
||||
'value' => $this->sub_data['value']
|
||||
);
|
||||
break;
|
||||
case 'category':
|
||||
if (!empty($this->sub_data)) {
|
||||
$this->sub_data['name'] = $this->cdata;
|
||||
$this->data['terms'][] = $this->sub_data;
|
||||
}
|
||||
$this->sub_data = false;
|
||||
break;
|
||||
case 'wp:postmeta':
|
||||
if (!empty($this->sub_data))
|
||||
$this->data['postmeta'][] = $this->sub_data;
|
||||
$this->sub_data = false;
|
||||
break;
|
||||
case 'item':
|
||||
$this->posts[] = $this->data;
|
||||
$this->data = false;
|
||||
break;
|
||||
case 'wp:category':
|
||||
case 'wp:tag':
|
||||
case 'wp:term':
|
||||
$n = substr($tag, 3);
|
||||
array_push($this->$n, $this->data);
|
||||
$this->data = false;
|
||||
break;
|
||||
case 'wp:termmeta':
|
||||
if (!empty($this->sub_data)) {
|
||||
$this->data['termmeta'][] = $this->sub_data;
|
||||
}
|
||||
$this->sub_data = false;
|
||||
break;
|
||||
case 'wp:author':
|
||||
if (!empty($this->data['author_login']))
|
||||
$this->authors[$this->data['author_login']] = $this->data;
|
||||
$this->data = false;
|
||||
break;
|
||||
case 'wp:base_site_url':
|
||||
$this->base_url = $this->cdata;
|
||||
if (!isset($this->base_blog_url)) {
|
||||
$this->base_blog_url = $this->cdata;
|
||||
}
|
||||
break;
|
||||
case 'wp:base_blog_url':
|
||||
$this->base_blog_url = $this->cdata;
|
||||
break;
|
||||
case 'wp:wxr_version':
|
||||
$this->wxr_version = $this->cdata;
|
||||
break;
|
||||
|
||||
default:
|
||||
if ($this->in_sub_tag) {
|
||||
$this->sub_data[$this->in_sub_tag] = !empty($this->cdata) ? $this->cdata : '';
|
||||
$this->in_sub_tag = false;
|
||||
} else if ($this->in_tag) {
|
||||
$this->data[$this->in_tag] = !empty($this->cdata) ? $this->cdata : '';
|
||||
$this->in_tag = false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->cdata = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* WordPress eXtended RSS file parser implementations
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Importer
|
||||
*/
|
||||
|
||||
/**
|
||||
* WordPress Importer class for managing parsing of WXR files.
|
||||
*/
|
||||
class WXR_Parser
|
||||
{
|
||||
function parse($file)
|
||||
{
|
||||
// Attempt to use proper XML parsers first
|
||||
if (extension_loaded('simplexml')) {
|
||||
$parser = new WXR_Parser_SimpleXML;
|
||||
$result = $parser->parse($file);
|
||||
|
||||
// If SimpleXML succeeds or this is an invalid WXR file then return the results
|
||||
if (!is_wp_error($result) || 'SimpleXML_parse_error' != $result->get_error_code())
|
||||
return $result;
|
||||
} else if (extension_loaded('xml')) {
|
||||
$parser = new WXR_Parser_XML;
|
||||
$result = $parser->parse($file);
|
||||
|
||||
// If XMLParser succeeds or this is an invalid WXR file then return the results
|
||||
if (!is_wp_error($result) || 'XML_parse_error' != $result->get_error_code())
|
||||
return $result;
|
||||
}
|
||||
|
||||
// We have a malformed XML file, so display the error and fallthrough to regex
|
||||
if (isset($result) && defined('IMPORT_DEBUG') && IMPORT_DEBUG) {
|
||||
echo '<pre>';
|
||||
if ('SimpleXML_parse_error' == $result->get_error_code()) {
|
||||
foreach ($result->get_error_data() as $error)
|
||||
echo $error->line . ':' . $error->column . ' ' . esc_html($error->message) . "\n";
|
||||
} else if ('XML_parse_error' == $result->get_error_code()) {
|
||||
$error = $result->get_error_data();
|
||||
echo $error[0] . ':' . $error[1] . ' ' . esc_html($error[2]);
|
||||
}
|
||||
echo '</pre>';
|
||||
echo '<p><strong>' . __('There was an error when reading this WXR file', 'wpmf') . '</strong><br />';
|
||||
echo __('Details are shown above. The importer will now try again with a different parser...', 'wpmf') . '</p>';
|
||||
}
|
||||
|
||||
// use regular expressions if nothing else available or this is bad XML
|
||||
$parser = new WXR_Parser_Regex;
|
||||
return $parser->parse($file);
|
||||
}
|
||||
}
|
||||
264
wp/wp-content/plugins/wp-media-folder/class/includes/export.php
Normal file
264
wp/wp-content/plugins/wp-media-folder/class/includes/export.php
Normal file
@@ -0,0 +1,264 @@
|
||||
<?php
|
||||
/**
|
||||
* WordPress Export Administration API
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Administration
|
||||
*/
|
||||
|
||||
/**
|
||||
* Wrap given string in XML CDATA tag.
|
||||
*
|
||||
* @param string $str String to wrap in XML CDATA tag.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function wxr_cdata($str)
|
||||
{
|
||||
if (!seems_utf8($str)) {
|
||||
$str = utf8_encode($str);
|
||||
}
|
||||
// $str = ent2ncr(esc_html($str));
|
||||
$str = '<![CDATA[' . str_replace(']]>', ']]]]><![CDATA[>', $str) . ']]>';
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the URL of the site
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @return string Site URL.
|
||||
*/
|
||||
function wxr_site_url()
|
||||
{
|
||||
// Multisite: the base URL.
|
||||
if (is_multisite()) {
|
||||
return network_home_url();
|
||||
} else {
|
||||
return get_bloginfo_rss('url');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a cat_name XML tag from a given category object
|
||||
*
|
||||
* @param object $category Category Object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wxr_cat_name($category)
|
||||
{
|
||||
if (empty($category->name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<wp:cat_name>' . wxr_cdata($category->name) . "</wp:cat_name>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a category_description XML tag from a given category object
|
||||
*
|
||||
* @param object $category Category Object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wxr_category_description($category)
|
||||
{
|
||||
if (empty($category->description)) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<wp:category_description>' . wxr_cdata($category->description) . "</wp:category_description>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a tag_name XML tag from a given tag object
|
||||
*
|
||||
* @param object $tag Tag Object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wxr_tag_name($tag)
|
||||
{
|
||||
if (empty($tag->name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<wp:tag_name>' . wxr_cdata($tag->name) . "</wp:tag_name>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a tag_description XML tag from a given tag object
|
||||
*
|
||||
* @param object $tag Tag Object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wxr_tag_description($tag)
|
||||
{
|
||||
if (empty($tag->description)) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<wp:tag_description>' . wxr_cdata($tag->description) . "</wp:tag_description>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a term_name XML tag from a given term object
|
||||
*
|
||||
* @param object $term Term Object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wxr_term_name($term)
|
||||
{
|
||||
if (empty($term->name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<wp:term_name>' . wxr_cdata($term->name) . "</wp:term_name>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a term_description XML tag from a given term object
|
||||
*
|
||||
* @param object $term Term Object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wxr_term_description($term)
|
||||
{
|
||||
if (empty($term->description)) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo "\t\t<wp:term_description>" . wxr_cdata($term->description) . "</wp:term_description>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Output term meta XML tags for a given term object.
|
||||
*
|
||||
* @param WP_Term $term Term object.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wxr_term_meta($term)
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
$termmeta = $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . $wpdb->termmeta . ' WHERE term_id = %d', $term->term_id));
|
||||
|
||||
foreach ($termmeta as $meta) {
|
||||
/**
|
||||
* Filters whether to selectively skip term meta used for WXR exports.
|
||||
*
|
||||
* Returning a truthy value to the filter will skip the current meta
|
||||
* object from being exported.
|
||||
*
|
||||
* @param boolean $skip Whether to skip the current piece of term meta. Default false.
|
||||
* @param string $meta_key Current meta key.
|
||||
* @param object $meta Current meta object.
|
||||
*/
|
||||
if (!apply_filters('wxr_export_skip_termmeta', false, $meta->meta_key, $meta)) {
|
||||
printf("\t\t<wp:termmeta>\n\t\t\t<wp:meta_key>%s</wp:meta_key>\n\t\t\t<wp:meta_value>%s</wp:meta_value>\n\t\t</wp:termmeta>\n", wxr_cdata($meta->meta_key), wxr_cdata($meta->meta_value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Output list of authors with posts
|
||||
*
|
||||
* @param array $post_ids Array of post IDs to filter the query by. Optional.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wxr_authors_list(array $post_ids = null)
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
if (!empty($post_ids)) {
|
||||
$post_ids = array_map('absint', $post_ids);
|
||||
$and = 'AND ID IN ( ' . implode(', ', $post_ids) . ')';
|
||||
} else {
|
||||
$and = '';
|
||||
}
|
||||
|
||||
$authors = array();
|
||||
$results = $wpdb->get_results('SELECT DISTINCT post_author FROM ' . $wpdb->posts . ' WHERE post_status != "auto-draft" ' . $and);
|
||||
foreach ((array) $results as $result) {
|
||||
$authors[] = get_userdata($result->post_author);
|
||||
}
|
||||
|
||||
$authors = array_filter($authors);
|
||||
|
||||
foreach ($authors as $author) {
|
||||
echo "\t<wp:author>";
|
||||
echo '<wp:author_id>' . intval($author->ID) . '</wp:author_id>';
|
||||
echo '<wp:author_login>' . wxr_cdata($author->user_login) . '</wp:author_login>';
|
||||
echo '<wp:author_email>' . wxr_cdata($author->user_email) . '</wp:author_email>';
|
||||
echo '<wp:author_display_name>' . wxr_cdata($author->display_name) . '</wp:author_display_name>';
|
||||
echo '<wp:author_first_name>' . wxr_cdata($author->first_name) . '</wp:author_first_name>';
|
||||
echo '<wp:author_last_name>' . wxr_cdata($author->last_name) . '</wp:author_last_name>';
|
||||
echo "</wp:author>\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Output all navigation menu terms
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wxr_nav_menu_terms()
|
||||
{
|
||||
$nav_menus = wp_get_nav_menus();
|
||||
if (empty($nav_menus) || !is_array($nav_menus)) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($nav_menus as $menu) {
|
||||
echo "\t<wp:term>";
|
||||
echo '<wp:term_id>' . intval($menu->term_id) . '</wp:term_id>';
|
||||
echo '<wp:term_taxonomy>nav_menu</wp:term_taxonomy>';
|
||||
echo '<wp:term_slug>' . wxr_cdata($menu->slug) . '</wp:term_slug>';
|
||||
wxr_term_name($menu);
|
||||
echo "</wp:term>\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Output list of taxonomy terms, in XML tag format, associated with a post
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wxr_post_taxonomy($post)
|
||||
{
|
||||
//$post = get_post();
|
||||
|
||||
$taxonomies = get_object_taxonomies($post->post_type);
|
||||
if (empty($taxonomies)) {
|
||||
return;
|
||||
}
|
||||
$terms = wp_get_object_terms($post->ID, $taxonomies);
|
||||
|
||||
foreach ((array) $terms as $term) {
|
||||
echo "\t\t<category domain=\"{$term->taxonomy}\" nicename=\"{$term->slug}\">" . wxr_cdata($term->name) . "</category>\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter postmeta
|
||||
*
|
||||
* @param boolean $return_me Return
|
||||
* @param string $meta_key Meta key
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function wxr_filter_postmeta($return_me, $meta_key)
|
||||
{
|
||||
if ('_edit_lock' === $meta_key) {
|
||||
$return_me = true;
|
||||
}
|
||||
return $return_me;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 290 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 90 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 301 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 631 KiB |
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
?>
|
||||
<form method="post">
|
||||
<?php wp_nonce_field('wpmf-setup-wizard', 'wizard_nonce'); ?>
|
||||
<div class="wizard-header large-content-width">
|
||||
<div class="title font-size-35"><?php esc_html_e('Additional Features', 'wpmf'); ?></div>
|
||||
<p class="description"><?php esc_html_e('We will guide you through the plugin main settings, You can also onfigure it later and skip the wizard', 'wpmf') ?></p>
|
||||
</div>
|
||||
<div class="wizard-content large-content-width">
|
||||
<div class="ju-settings-option cboption" style="height: 200px; overflow: hidden; text-overflow: ellipsis; margin-right: 20px">
|
||||
<div class="wpmf_row_full p-d-20">
|
||||
<input type="hidden" name="wpmf_option_mediafolder" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Load WP Media Folder files on frontend. Activate it if
|
||||
you want to use a frontend page builder along with the media manager', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('WP Media Folder on frontend', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="wpmf_option_mediafolder"
|
||||
value="1">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
<p class="description text_left p-d-20 border-top-e4e8ed">
|
||||
<?php esc_html_e('Load WP Media Folder files on frontend. Activate it if
|
||||
you want to use a frontend page builder along with the media manager', 'wpmf'); ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option cboption" style="height: 200px; overflow: hidden; text-overflow: ellipsis;">
|
||||
<div class="wpmf_row_full p-d-20">
|
||||
<input type="hidden" name="hide_remote_video" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Enable or disable remote video feature', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Enable remote video feature', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="hide_remote_video"
|
||||
value="1" checked>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
<p class="description text_left p-d-20 border-top-e4e8ed">
|
||||
<?php esc_html_e('Enable or disable remote video feature', 'wpmf'); ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option cboption" style="height: 200px; overflow: hidden; text-overflow: ellipsis; margin-right: 20px">
|
||||
<div class="wpmf_row_full p-d-20">
|
||||
<input type="hidden" name="wpmf_option_override" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Possibility to replace an existing file by another one.', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Override file', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="cb_option_override"
|
||||
name="wpmf_option_override" value="1" checked>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
<p class="description text_left p-d-20 border-top-e4e8ed">
|
||||
<?php esc_html_e('Possibility to replace an existing file by another one.', 'wpmf'); ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option cboption" style="height: 200px; overflow: hidden; text-overflow: ellipsis;">
|
||||
<div class="wpmf_row_full p-d-20">
|
||||
<input type="hidden" name="wpmf_option_duplicate" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Add a button to duplicate a media from the media manager', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Duplicate file', 'wpmf') ?>
|
||||
</label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="cb_option_duplicate"
|
||||
name="wpmf_option_duplicate" value="1" checked>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<p class="description text_left p-d-20 border-top-e4e8ed">
|
||||
<?php esc_html_e('Add a button to duplicate a media from the media manager', 'wpmf'); ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="wizard-footer">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="submit" value="<?php esc_html_e('Continue', 'wpmf'); ?>" class="m-tb-20"
|
||||
name="wpmf_save_step"/>
|
||||
</div>
|
||||
|
||||
<a href="<?php echo esc_url(admin_url('options-general.php?page=option-folder'))?>" class="go-to-dash"><span><?php esc_html_e('I know what I\'m doing, skip wizard', 'wpmf'); ?></span></a>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
$image_src = WPMF_PLUGIN_URL . 'class/install-wizard/content/checklist-icon.png';
|
||||
$srcset2x = WPMF_PLUGIN_URL . 'class/install-wizard/content/done/done-illustration@2x.png';
|
||||
$srcset3x = WPMF_PLUGIN_URL . 'class/install-wizard/content/done/done-illustration@3x.png';
|
||||
?>
|
||||
<div class="wizard-content-done">
|
||||
<div class="wizard-done">
|
||||
<div class="wizard-done-image">
|
||||
<img src="<?php echo esc_url(WPMF_PLUGIN_URL . 'class/install-wizard/content/done/done-illustration.png'); ?>"
|
||||
srcset="<?php echo esc_url($srcset2x); ?> 2x,<?php echo esc_url($srcset3x); ?> 3x" class="Illustration---Done">
|
||||
|
||||
</div>
|
||||
<div class="wizard-done-container">
|
||||
<div class="title"><?php esc_html_e('Done', 'wpmf') ?></div>
|
||||
<p class="description">
|
||||
<?php esc_html_e('You have now completed the plugin quick configuration', 'wpmf') ?>
|
||||
</p>
|
||||
</div>
|
||||
<div class="wizard-done-footer configuration-footer">
|
||||
<a href="<?php echo esc_url(admin_url('upload.php')) ?>" class="button">
|
||||
<?php esc_html_e('GO TO MEDIA LIBRARY', 'wpmf'); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
?>
|
||||
<form method="post">
|
||||
<?php wp_nonce_field('wpmf-setup-wizard', 'wizard_nonce'); ?>
|
||||
<div class="wizard-header">
|
||||
<div class="title font-size-35"><?php esc_html_e('Environment Check', 'wpmf'); ?></div>
|
||||
<p class="description">
|
||||
<?php esc_html_e('We have checked your server environment.
|
||||
If you see some warning below it means that some plugin features may not work properly.
|
||||
Reload the page to refresh the results', 'wpmf'); ?>
|
||||
</p>
|
||||
</div>
|
||||
<div class="wizard-content">
|
||||
<div class="version-container">
|
||||
<div class="label_text"><?php esc_html_e('PHP Version', 'wpmf'); ?></div>
|
||||
<div class="ju-settings-option wpmf_width_100">
|
||||
<div class="wpmf_row_full">
|
||||
<label class="ju-setting-label php_version">
|
||||
<?php esc_html_e('PHP ', 'wpmf'); ?>
|
||||
<?php echo esc_html(PHP_VERSION) ?>
|
||||
<?php esc_html_e('version', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<div class="right-checkbox">
|
||||
<?php if (version_compare(PHP_VERSION, '5.6', '<')) : ?>
|
||||
<img src="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-information/icon-information.png') ?>"
|
||||
srcset="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-information/icon-information@2x.png') ?> 2x, <?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-information/icon-information@3x.png') ?> 3x"
|
||||
class="img_warning">
|
||||
<?php else : ?>
|
||||
<input type="checkbox" checked disabled class="filled-in media_checkbox"/>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (version_compare(PHP_VERSION, '5.6', '<')) : ?>
|
||||
<p class="description text_left">
|
||||
<?php esc_html_e('Your PHP version is ', 'wpmf'); ?>
|
||||
<?php echo esc_html(PHP_VERSION) ?>
|
||||
<?php esc_html_e('. For performance and security reasons it better to run PHP 7.2+. Comparing to previous versions the execution time of PHP 7.X is more than twice as fast and has 30 percent lower memory consumption', 'wpmf'); ?>
|
||||
</p>
|
||||
<?php else : ?>
|
||||
<p class="description">
|
||||
<?php esc_html_e('Great ! Your PHP version is ', 'wpmf'); ?>
|
||||
<?php echo esc_html(PHP_VERSION) ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="other-container">
|
||||
<div class="label_text"><?php esc_html_e('PHP Extensions', 'wpmf'); ?></div>
|
||||
<div class="ju-settings-option wpmf_width_100">
|
||||
<div class="wpmf_row_full">
|
||||
<label class="ju-setting-label"><?php esc_html_e('Curl', 'wpmf'); ?></label>
|
||||
<div class="right-checkbox">
|
||||
<?php if (!in_array('curl', get_loaded_extensions())) : ?>
|
||||
<img src="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-information/icon-information.png') ?>"
|
||||
srcset="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-information/icon-information@2x.png') ?> 2x, <?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-information/icon-information@3x.png') ?> 3x"
|
||||
class="img_warning">
|
||||
<?php else : ?>
|
||||
<input type="checkbox" id="php_curl" name="php_curl" checked
|
||||
value="php_curl" disabled class="filled-in media_checkbox"/>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (!in_array('curl', get_loaded_extensions())) : ?>
|
||||
<p class="description text_left">
|
||||
<?php esc_html_e('PHP Curl extension has not been detected. You need to activate in order to load video in media library and for all the cloud connections (like Google Drive, Dropbox...)', 'wpmf'); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="ju-settings-option wpmf_width_100">
|
||||
<div class="wpmf_row_full">
|
||||
<label class="ju-setting-label"><?php esc_html_e('GD Library', 'wpmf'); ?></label>
|
||||
<div class="right-checkbox">
|
||||
<?php if (function_exists('gd_info')) : ?>
|
||||
<input type="checkbox" id="gd_info" name="gd_info" checked
|
||||
value="gd_info" disabled class="filled-in media_checkbox"/>
|
||||
<?php else : ?>
|
||||
<img src="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-information/icon-information.png') ?>"
|
||||
srcset="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-information/icon-information@2x.png') ?> 2x, <?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-information/icon-information@3x.png') ?> 3x"
|
||||
class="img_warning">
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (!function_exists('gd_info')) : ?>
|
||||
<p class="description text_left">
|
||||
<?php esc_html_e('GD library is not detected. GD is an open source library related to image creation. The Watermark feature won’t work.', 'wpmf'); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="label_text"><?php esc_html_e('PHP Settings', 'wpmf'); ?></div>
|
||||
<div class="ju-settings-option wpmf_width_100">
|
||||
<div class="wpmf_row_full">
|
||||
<label class="ju-setting-label"><?php esc_html_e('Allow URL open', 'wpmf'); ?></label>
|
||||
<div class="right-checkbox">
|
||||
<?php if (!ini_get('allow_url_fopen')) : ?>
|
||||
<img src="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-information/icon-information.png') ?>"
|
||||
srcset="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-information/icon-information@2x.png') ?> 2x, <?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-information/icon-information@3x.png') ?> 3x"
|
||||
class="img_warning">
|
||||
<?php else : ?>
|
||||
<input type="checkbox" id="php_allow_url_fopen" name="php_allow_url_fopen" checked
|
||||
value="php_allow_url_fopen" disabled class="filled-in media_checkbox"/>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (!ini_get('allow_url_fopen')) : ?>
|
||||
<p class="description text_left">
|
||||
<?php esc_html_e('Allow URL fopen setting has not been detected. You need to activate in order to use remote video feature', 'wpmf'); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wizard-footer">
|
||||
<input type="submit" value="<?php esc_html_e('Continue', 'wpmf'); ?>" class="" name="wpmf_save_step"/>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
$wizard = new WpmfInstallWizard();
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- View request, no action
|
||||
$step = isset($_GET['step']) ? sanitize_key($_GET['step']) : '';
|
||||
$next_link = $wizard->getNextLink($step);
|
||||
?>
|
||||
|
||||
<form method="post" id="quick-config-form">
|
||||
<?php wp_nonce_field('wpmf-setup-wizard', 'wizard_nonce'); ?>
|
||||
<input type="hidden" name="wpmf_save_step" value="1"/>
|
||||
<div class="wizard-header">
|
||||
<div class="title font-size-35"><?php esc_html_e('Image Configuration', 'wpmf'); ?></div>
|
||||
<p class="description"><?php esc_html_e('We will guide you through the plugin main settings. You can also configure it later and skip the wizard', 'wpmf') ?></p>
|
||||
</div>
|
||||
<div class="wizard-content">
|
||||
<div class="ju-settings-option wpmf_width_100 wpmf-no-shadow">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wpmf_usegellery" value="0">
|
||||
<label class="ju-setting-label text">
|
||||
<?php esc_html_e('WP Media Folder Galleries', 'wpmf') ?>
|
||||
</label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="wpmf_usegellery" value="1" checked>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
<p class="description text_left p-d-20">
|
||||
<?php esc_html_e('Enhance the Wordpress default gallery system by adding themes and additional parameters in the gallery manager', 'wpmf'); ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_width_100 wpmf-no-shadow">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wpmf_usegellery_lightbox" value="0">
|
||||
<label class="ju-setting-label text">
|
||||
<?php esc_html_e('Gallery Lightbox', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="wpmf_usegellery_lightbox" value="1" checked>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
<p class="description text_left p-d-20">
|
||||
<?php esc_html_e('Add lightbox to images in Wordpress default galleries', 'wpmf'); ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wizard-footer">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="submit" value="<?php esc_html_e('Continue', 'wpmf'); ?>" class="m-tb-20"
|
||||
name="wpmf_save_step"/>
|
||||
</div>
|
||||
|
||||
<a href="<?php echo esc_url(admin_url('options-general.php?page=option-folder'))?>" class="go-to-dash"><span><?php esc_html_e('I know what I\'m doing, skip wizard', 'wpmf'); ?></span></a>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
$image_src = WPMF_PLUGIN_URL . 'class/install-wizard/content/welcome-illustration.png';
|
||||
?>
|
||||
<form method="post">
|
||||
<div class="start-wizard">
|
||||
<div class="start-wizard-image">
|
||||
<img src="<?php echo esc_url($image_src); ?>"
|
||||
srcset=""
|
||||
class="Illustration---Done" />
|
||||
</div>
|
||||
<div class="start-wizard-container">
|
||||
<div class="title">
|
||||
<?php esc_html_e('Welcome to WP Media Folder Settings first configuration wizard!', 'wpmf') ?>
|
||||
</div>
|
||||
<p class="description">
|
||||
<?php esc_html_e('This wizard will help you with some server compatibility check and with plugin main configuration. Follow some simple steps and get a powerful media library in no time', 'wpmf') ?>
|
||||
</p>
|
||||
</div>
|
||||
<div class="start-wizard-footer configuration-footer">
|
||||
<a href="<?php echo esc_url(add_query_arg('step', 'environment', remove_query_arg('activate_error')))?>" class="next-button">
|
||||
<?php esc_html_e('Continue to environment check', 'wpmf'); ?>
|
||||
</a>
|
||||
|
||||
<a href="<?php echo esc_url(admin_url('options-general.php?page=option-folder'))?>" class="backup-button">
|
||||
<?php esc_html_e('I know what I\'m doing, skip wizard', 'wpmf'); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 102 KiB |
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class WpmfHandlerWizard
|
||||
*/
|
||||
class WpmfHandlerWizard
|
||||
{
|
||||
/**
|
||||
* WpmfHandlerWizard constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Environment handle
|
||||
*
|
||||
* @param string $current_step Current step
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function saveEvironment($current_step)
|
||||
{
|
||||
check_admin_referer('wpmf-setup-wizard', 'wizard_nonce');
|
||||
/*
|
||||
* Do no thing
|
||||
*/
|
||||
$wizard = new WpmfInstallWizard();
|
||||
wp_safe_redirect(esc_url_raw($wizard->getNextLink($current_step)));
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Quick configuration handle
|
||||
*
|
||||
* @param string $current_step Current step
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function saveImageConfiguration($current_step)
|
||||
{
|
||||
check_admin_referer('wpmf-setup-wizard', 'wizard_nonce');
|
||||
|
||||
WP_Filesystem();
|
||||
$options = array(
|
||||
'wpmf_usegellery' => 1,
|
||||
'wpmf_usegellery_lightbox' => 1
|
||||
);
|
||||
|
||||
foreach ($options as $name => $value) {
|
||||
if (isset($_POST[$name])) {
|
||||
update_option($name, $_POST[$name]);
|
||||
} else {
|
||||
update_option($name, $value);
|
||||
}
|
||||
}
|
||||
$wizard = new WpmfInstallWizard();
|
||||
wp_safe_redirect(esc_url_raw($wizard->getNextLink($current_step)));
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Main optimization handle
|
||||
*
|
||||
* @param string $current_step Current step
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function saveAdditionalFeatures($current_step)
|
||||
{
|
||||
WP_Filesystem();
|
||||
check_admin_referer('wpmf-setup-wizard', 'wizard_nonce');
|
||||
$options = array(
|
||||
'wpmf_option_mediafolder' => 0,
|
||||
'wpmf_option_override' => 0,
|
||||
'wpmf_option_duplicate' => 0
|
||||
);
|
||||
|
||||
if (isset($_POST['hide_remote_video'])) {
|
||||
wpmfSetOption('hide_remote_video', $_POST['hide_remote_video']);
|
||||
} else {
|
||||
wpmfSetOption('hide_remote_video', 1);
|
||||
}
|
||||
|
||||
foreach ($options as $name => $value) {
|
||||
if (isset($_POST[$name])) {
|
||||
update_option($name, $_POST[$name]);
|
||||
} else {
|
||||
update_option($name, $value);
|
||||
}
|
||||
}
|
||||
$wizard = new WpmfInstallWizard();
|
||||
wp_safe_redirect(esc_url_raw($wizard->getNextLink($current_step)));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,641 @@
|
||||
@import "https://fonts.googleapis.com/css?family=Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i&subset=cyrillic,cyrillic-ext,greek,greek-ext,latin-ext,vietnamese";
|
||||
body * {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-size: 28px;
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
font-stretch: normal;
|
||||
line-height: 1.61;
|
||||
letter-spacing: 1px;
|
||||
text-align: center;
|
||||
color: #404852;
|
||||
}
|
||||
/* CUSTOM CSS CHECKBOXES */
|
||||
|
||||
input[type="checkbox"], input[type="radio"] {
|
||||
border: 1px solid #b4b9be;
|
||||
background: #fff;
|
||||
color: #555;
|
||||
clear: none;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
line-height: 0;
|
||||
height: 16px;
|
||||
margin: -4px 4px 0 0;
|
||||
outline: 0;
|
||||
padding: 0 !important;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
width: 16px;
|
||||
min-width: 16px;
|
||||
-webkit-appearance: none;
|
||||
box-shadow: inset 0 1px 2px rgba( 0, 0, 0, 0.1 );
|
||||
transition: .05s border-color ease-in-out;
|
||||
}
|
||||
|
||||
input[type="checkbox"]:checked:before, input[type="radio"]:checked:before {
|
||||
float: left;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
width: 16px;
|
||||
font: normal 21px/1 dashicons;
|
||||
speak: none;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.media_checkbox {
|
||||
border: 2px solid #49bf88 !important;
|
||||
height: 20px !important;
|
||||
width: 20px !important;
|
||||
background: #fff;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.media_checkbox:checked {
|
||||
background: #49bf88;
|
||||
}
|
||||
|
||||
input[type="checkbox"]:checked:before {
|
||||
color: #fff;
|
||||
margin: -1px 0 0 -1px;
|
||||
font-size: 17px;
|
||||
content: "\f147";
|
||||
}
|
||||
|
||||
.right-checkbox {
|
||||
float: right;
|
||||
line-height: 50px;
|
||||
padding-right: 30px;
|
||||
}
|
||||
|
||||
/*// BODY*/
|
||||
body.wpmf-wizard-setup{
|
||||
width: auto;
|
||||
height: auto;
|
||||
background-color: #F3F6FA;
|
||||
}
|
||||
.wpmf-wizard-content {
|
||||
min-width: 640px;
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.wpmf-wizard-content .wpmf-wizard-steps {
|
||||
width: auto;
|
||||
margin: 30px 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.wpmf-wizard-steps ul.wizard-steps {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.wpmf-wizard-steps ul.wizard-steps li {
|
||||
list-style-type: none;
|
||||
padding-right: 60px;
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.wpmf-wizard-steps ul.wizard-steps li:last-child {
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.wpmf-wizard-steps ul.wizard-steps li:not(:last-child):before {
|
||||
content: '';
|
||||
border-bottom: 1px dashed #ccc;
|
||||
width: 60px;
|
||||
position: absolute;
|
||||
top: calc((100% - 1px) /2);
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.wpmf-wizard-steps ul.wizard-steps li .layer {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
line-height: 34px;
|
||||
text-align: center;
|
||||
border-radius: 100%;
|
||||
border: solid 0.5px #404852;
|
||||
cursor: default;
|
||||
font-style: normal;
|
||||
font-stretch: normal;
|
||||
letter-spacing: 0.5px;
|
||||
color: #404852;
|
||||
}
|
||||
|
||||
.wpmf-wizard-steps ul.wizard-steps li a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.wpmf-wizard-steps ul.wizard-steps li.actived .layer,
|
||||
.wpmf-wizard-steps ul.wizard-steps li.visited .layer {
|
||||
background-color: #7391ff;
|
||||
color : #fff;
|
||||
cursor: pointer;
|
||||
border: solid 0.5px #7391ff;
|
||||
}
|
||||
|
||||
/*Environment Content*/
|
||||
.wizard-header {
|
||||
text-align: center;
|
||||
width: 640px;
|
||||
margin: 0 auto;
|
||||
margin-bottom: 50px;
|
||||
}
|
||||
|
||||
.wizard-content {
|
||||
width: 640px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.large-content-width {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.wizard-content .version-container{
|
||||
float: left;
|
||||
width: 100%;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.wizard-content .version-container .details{
|
||||
width: auto;
|
||||
height: 60px;
|
||||
line-height: 60px;
|
||||
padding-left: 30px;
|
||||
margin-bottom: 10px;
|
||||
font-weight: bold;
|
||||
font-size: 18px;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.wizard-content .apache-container {
|
||||
float: left;
|
||||
}
|
||||
.wizard-content .apache-container table,
|
||||
.wizard-content .other-container table
|
||||
{
|
||||
border-collapse:separate;
|
||||
border-spacing: 0 1em;
|
||||
width: 100%;
|
||||
}
|
||||
.wizard-content .apache-container table tr td ,
|
||||
.wizard-content .other-container table tr td {
|
||||
height: 58px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.wizard-content .apache-container table tr ,
|
||||
.wizard-content .other-container table tr {
|
||||
background-color: #fff;
|
||||
|
||||
}
|
||||
|
||||
.wizard-content .apache-container label,
|
||||
.wizard-content .other-container label{
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
padding-left: 30px;
|
||||
}
|
||||
|
||||
.wizard-content table input {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.wizard-content .other-container {
|
||||
margin: 40px 0;
|
||||
float: left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.wizard-footer {
|
||||
margin-bottom: 42px;
|
||||
text-align: center;
|
||||
float: left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.wizard-footer input {
|
||||
width: 280px;
|
||||
height: 60px;
|
||||
background-color: #FF8538;
|
||||
border: 1px solid #FF8538;
|
||||
border-radius: 30px;
|
||||
text-transform: uppercase;
|
||||
cursor: pointer;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
font-stretch: normal;
|
||||
line-height: normal;
|
||||
letter-spacing: 1px;
|
||||
text-align: center;
|
||||
color: #ffffff;
|
||||
|
||||
}
|
||||
|
||||
.wizard-footer a{
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/*button switch*/
|
||||
.wizard-switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 21px;
|
||||
height: 31px;
|
||||
}
|
||||
|
||||
.wizard-switch input {display:none;}
|
||||
|
||||
.wizard-slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
.wizard-slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 27px;
|
||||
width: 27px;
|
||||
left: 2px;
|
||||
bottom: 2px;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
box-shadow: 0 3px 3px 0 rgba(0, 0, 0, 0.05), 0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 3px 1px 0 rgba(0, 0, 0, 0.05);
|
||||
background-color: #ffffff;
|
||||
border: solid 0.5px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
input:checked + .wizard-slider {
|
||||
background-color: #5dca70;
|
||||
}
|
||||
|
||||
input:focus + .wizard-slider {
|
||||
box-shadow: 0 0 1px #00CC00;
|
||||
}
|
||||
|
||||
input:checked + .wizard-slider:before {
|
||||
-webkit-transform: translateX(19px);
|
||||
-ms-transform: translateX(19px);
|
||||
transform: translateX(19px);
|
||||
}
|
||||
|
||||
/* Rounded sliders */
|
||||
.wizard-slider.round {
|
||||
border-radius: 30px;
|
||||
}
|
||||
|
||||
.wizard-slider.round:before {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
/*Wizard done*/
|
||||
.wizard-content-done {
|
||||
width: 450px;
|
||||
top: 0;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.wizard-done-image {
|
||||
width: 100%;
|
||||
height: 450px;
|
||||
margin: 0 auto;
|
||||
margin-top: 30px;
|
||||
margin-bottom: 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.wizard-done {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.wizard-done .wizard-done-footer {
|
||||
margin-top: 60px;
|
||||
margin-bottom: 320px;
|
||||
}
|
||||
|
||||
.wizard-done .wizard-done-footer a.button{
|
||||
font-family: 'Roboto', sans-serif;
|
||||
padding: 22px 83px;
|
||||
text-decoration: none;
|
||||
border-radius: 40px;
|
||||
text-transform: uppercase;
|
||||
background-color: #FF8538;
|
||||
border: 1px solid #FF8538;
|
||||
box-shadow: 10px 20px 20px 0 rgba(232, 182, 139, 0.27);
|
||||
font-size: 15px;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
font-stretch: normal;
|
||||
line-height: normal;
|
||||
letter-spacing: 1px;
|
||||
text-align: center;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
/*check list icon*/
|
||||
.start-wizard {
|
||||
width: 546px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.start-wizard .start-wizard-image {
|
||||
width: 450px;
|
||||
margin: 0 auto;
|
||||
margin-top: 30px;
|
||||
margin-bottom: 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.start-wizard-footer {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.start-wizard .start-wizard-footer a.next-button {
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
width: 390px;
|
||||
height: 65px;
|
||||
line-height: 65px;
|
||||
border-radius: 40px;
|
||||
text-transform: uppercase;
|
||||
margin: 80px auto;
|
||||
background-color: #FF8538;
|
||||
border: 1px solid #FF8538;
|
||||
box-shadow: 10px 20px 20px 0 rgba(232, 182, 139, 0.27);
|
||||
cursor: pointer;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
font-stretch: normal;
|
||||
letter-spacing: 1px;
|
||||
text-align: center;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.backup-button {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
text-decoration: none;
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
font-stretch: normal;
|
||||
line-height: normal;
|
||||
letter-spacing: 1px;
|
||||
text-align: center;
|
||||
color: #ff8726;
|
||||
}
|
||||
|
||||
.go-to-dash {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
font-stretch: normal;
|
||||
line-height: normal;
|
||||
letter-spacing: 2px;
|
||||
text-align: center;
|
||||
color: #ff8726;
|
||||
}
|
||||
|
||||
.ju-settings-option {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.ju-setting-label {
|
||||
float: left;
|
||||
display: inline-block;
|
||||
min-width: 150px;
|
||||
max-width: calc(100% - 150px);
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
-ms-text-overflow: ellipsis;
|
||||
text-overflow: ellipsis;
|
||||
margin: 0;
|
||||
line-height: 50px;
|
||||
cursor: pointer;
|
||||
font-weight: 500 !important;
|
||||
padding-left: 20px;
|
||||
font-size: 20px;
|
||||
letter-spacing: 0.7px;
|
||||
color: #404852;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
}
|
||||
|
||||
.php_version {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
font-stretch: normal;
|
||||
letter-spacing: 0.8px;
|
||||
color: #404852;
|
||||
}
|
||||
|
||||
.img_warning {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.description {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
font-weight: 300;
|
||||
font-style: normal;
|
||||
font-stretch: normal;
|
||||
line-height: 1.88;
|
||||
letter-spacing: 1px;
|
||||
color: #606c7b;
|
||||
}
|
||||
|
||||
.wizard-header .description,
|
||||
.wizard-done-container .description {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-size: 14px;
|
||||
font-weight: 300;
|
||||
font-style: normal;
|
||||
font-stretch: normal;
|
||||
line-height: 2.14;
|
||||
letter-spacing: 1px;
|
||||
text-align: center;
|
||||
color: #404852;
|
||||
}
|
||||
|
||||
.text_left {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.p-d-10 {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.p-d-20 {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.p-d-40 {
|
||||
padding: 40px;
|
||||
}
|
||||
|
||||
.m-tb-20 {
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.wpmf-no-margin {
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
.ju-settings-option {
|
||||
float: left;
|
||||
width: 49%;
|
||||
margin-bottom: 20px;
|
||||
background-color: #fff;
|
||||
-webkit-box-shadow: 0 10px 30px 0 rgba(160, 166, 190, 0.08);
|
||||
-moz-box-shadow: 0 10px 30px 0 rgba(160, 166, 190, 0.08);
|
||||
box-shadow: 0 10px 30px 0 rgba(160, 166, 190, 0.08);
|
||||
-webkit-border-radius: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.wpmf_width_100 {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.wpmf-no-shadow {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.wpmf_row_full {
|
||||
width: 100%;
|
||||
float: left;
|
||||
margin: 10px 0 10px 0;
|
||||
}
|
||||
|
||||
.ju-switch-button {
|
||||
float: right;
|
||||
margin-left: 10px;
|
||||
margin-right: 30px;
|
||||
}
|
||||
|
||||
.ju-switch-button .switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 50px;
|
||||
height: 30px;
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.ju-switch-button .switch input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.ju-switch-button .switch .slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
-webkit-transition: 0.4s;
|
||||
-moz-transition: 0.4s;
|
||||
-ms-transition: 0.4s;
|
||||
-o-transition: 0.4s;
|
||||
transition: 0.4s;
|
||||
-webkit-border-radius: 40px;
|
||||
-moz-border-radius: 40px;
|
||||
border-radius: 40px;
|
||||
}
|
||||
|
||||
.ju-switch-button .switch input:checked + .slider {
|
||||
background-color: #5dca70;
|
||||
}
|
||||
|
||||
.ju-switch-button .switch .slider:before {
|
||||
position: absolute;
|
||||
content: '';
|
||||
height: 27px;
|
||||
width: 27px;
|
||||
left: 2px;
|
||||
bottom: 2px;
|
||||
background-color: #fff;
|
||||
-webkit-transition: 0.4s;
|
||||
-moz-transition: 0.4s;
|
||||
-ms-transition: 0.4s;
|
||||
-o-transition: 0.4s;
|
||||
transition: 0.4s;
|
||||
-webkit-border-radius: 50%;
|
||||
-moz-border-radius: 50%;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.ju-switch-button .switch input:checked + .slider:before {
|
||||
-webkit-transform: translateX(20px);
|
||||
-moz-transform: translateX(20px);
|
||||
-ms-transform: translateX(20px);
|
||||
-o-transform: translateX(20px);
|
||||
transform: translateX(20px);
|
||||
}
|
||||
|
||||
input:checked + .slider:before {
|
||||
-webkit-transform: translateX(26px);
|
||||
-ms-transform: translateX(26px);
|
||||
transform: translateX(26px);
|
||||
}
|
||||
|
||||
.slider.round:before {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.label_text {
|
||||
color: #9ea7b2;
|
||||
font-size: 20px;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.7px;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
float: left;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.border-top-e4e8ed {
|
||||
border-top: #e4e8ed 0.5px solid;
|
||||
}
|
||||
|
||||
.wizard-content .description {
|
||||
margin-top: 10px;
|
||||
float: left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.font-size-35 {
|
||||
font-size: 35px;
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
require_once(WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/install-wizard/handler-wizard.php');
|
||||
/**
|
||||
* Class WpmfInstallWizard
|
||||
*/
|
||||
class WpmfInstallWizard
|
||||
{
|
||||
/**
|
||||
* Init step params
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $steps = array(
|
||||
'environment' => array(
|
||||
'name' => 'Environment Check',
|
||||
'view' => 'viewEvironment',
|
||||
'action' => 'saveEvironment'
|
||||
),
|
||||
'image_config' => array(
|
||||
'name' => 'Image Configuration',
|
||||
'view' => 'viewImageConfig',
|
||||
'action' => 'saveImageConfiguration'
|
||||
),
|
||||
'additional_features' => array(
|
||||
'name' => 'Additional Features',
|
||||
'view' => 'viewAdditionalFeatures',
|
||||
'action' => 'saveAdditionalFeatures',
|
||||
)
|
||||
);
|
||||
/**
|
||||
* Init current step params
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $current_step = array();
|
||||
/**
|
||||
* WpmfInstallWizard constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
/**
|
||||
* Filter check capability of current user to run first install plugin
|
||||
*
|
||||
* @param boolean The current user has the given capability
|
||||
* @param string Action name
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @ignore Hook already documented
|
||||
*/
|
||||
$wpmf_capability = apply_filters('wpmf_user_can', current_user_can('manage_options'), 'first_install_plugin');
|
||||
if ($wpmf_capability) {
|
||||
add_action('admin_menu', array($this, 'adminMenus'));
|
||||
add_action('admin_init', array($this, 'runWizard'));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Add admin menus/screens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function adminMenus()
|
||||
{
|
||||
add_dashboard_page('', '', 'manage_options', 'wpmf-setup', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute wizard
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function runWizard()
|
||||
{
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Recommended -- View request, no action
|
||||
wp_enqueue_style(
|
||||
'wpmf_wizard',
|
||||
WPMF_PLUGIN_URL . 'class/install-wizard/install-wizard.css',
|
||||
array(),
|
||||
WPMF_VERSION
|
||||
);
|
||||
|
||||
// Get step
|
||||
$this->steps = apply_filters('wpmf_setup_wizard_steps', $this->steps);
|
||||
$this->current_step = isset($_GET['step']) ? sanitize_key($_GET['step']) : current(array_keys($this->steps));
|
||||
|
||||
// Save action
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- No action, nonce is not required
|
||||
if (!empty($_POST['wpmf_save_step']) && isset($this->steps[$this->current_step]['action'])) {
|
||||
call_user_func(array('WpmfHandlerWizard', $this->steps[$this->current_step]['action']), $this->current_step);
|
||||
}
|
||||
|
||||
// Render
|
||||
$this->setHeader();
|
||||
if (!isset($_GET['step'])) {
|
||||
require_once(WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/install-wizard/content/viewWizard.php');
|
||||
} elseif (isset($_GET['step']) && $_GET['step'] === 'wizard_done') {
|
||||
require_once(WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/install-wizard/content/viewDone.php');
|
||||
} else {
|
||||
$this->setMenu();
|
||||
$this->setContent();
|
||||
}
|
||||
// phpcs:enable
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get next link step
|
||||
*
|
||||
* @param string $step Current step
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNextLink($step = '')
|
||||
{
|
||||
if (!$step) {
|
||||
$step = $this->current_step;
|
||||
}
|
||||
|
||||
$keys = array_keys($this->steps);
|
||||
|
||||
if (end($keys) === $step) {
|
||||
return add_query_arg('step', 'wizard_done', remove_query_arg('activate_error'));
|
||||
}
|
||||
|
||||
$step_index = array_search($step, $keys, true);
|
||||
if (false === $step_index) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return add_query_arg('step', $keys[$step_index + 1], remove_query_arg('activate_error'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the menu for the current step.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setMenu()
|
||||
{
|
||||
$output_steps = $this->steps;
|
||||
?>
|
||||
<div class="wpmf-wizard-steps">
|
||||
<ul class="wizard-steps">
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ($output_steps as $key => $step) {
|
||||
$position_current_step = array_search($this->current_step, array_keys($this->steps), true);
|
||||
$position_step = array_search($key, array_keys($this->steps), true);
|
||||
$is_visited = $position_current_step > $position_step;
|
||||
$i ++;
|
||||
if ($key === $this->current_step) {
|
||||
?>
|
||||
<li class="actived"><div class="layer"><?php echo esc_html($i) ?></div></li>
|
||||
<?php
|
||||
} elseif ($is_visited) {
|
||||
?>
|
||||
<li class="visited">
|
||||
<a href="<?php echo esc_url(add_query_arg('step', $key, remove_query_arg('activate_error'))); ?>">
|
||||
<div class="layer"><?php echo esc_html($i) ?></div></a>
|
||||
</li>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<li><div class="layer"><?php echo esc_html($i) ?></div></li>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Output the content for the current step.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setContent()
|
||||
{
|
||||
echo '<div class="">';
|
||||
if (!empty($this->steps[$this->current_step]['view'])) {
|
||||
require_once(WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/install-wizard/content/' . $this->steps[$this->current_step]['view'] . '.php');
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup Wizard Header.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setHeader()
|
||||
{
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html <?php language_attributes(); ?>>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title><?php esc_html_e('WP Media Folder › Setup Wizard', 'wpmf'); ?></title>
|
||||
<?php wp_admin_css('dashicons', true); ?>
|
||||
<?php wp_admin_css('wpmf_wizard', true); ?>
|
||||
</head>
|
||||
<body class="wpmf-wizard-setup wp-core-ui">
|
||||
<div class="wpmf-wizard-content p-d-20">
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup Wizard Footer.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setFooter()
|
||||
{
|
||||
?>
|
||||
</div>
|
||||
</body>
|
||||
<?php wp_print_footer_scripts(); ?>
|
||||
</html>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
new WpmfInstallWizard();
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
// phpcs:disable WordPress.Security.EscapeOutput -- Content already escaped in the method
|
||||
echo $default_theme;
|
||||
echo $portfolio_theme;
|
||||
echo $masonry_theme;
|
||||
echo $slider_theme;
|
||||
// phpcs:enable
|
||||
@@ -0,0 +1,311 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
if (empty($settings['aspect_ratio'])) {
|
||||
$settings['aspect_ratio'] = 'default';
|
||||
}
|
||||
?>
|
||||
<div class="ju-settings-option wpmf_width_100 p-lr-20">
|
||||
<div class="wpmf_row_full">
|
||||
<h3 class="settings_theme_name"><?php echo esc_html($theme_label); ?></h3>
|
||||
<div class="wpmf_glr_settings">
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20 p-d-10">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text wpmf_width_auto" data-wpmftippy="<?php esc_html_e('Number of columns
|
||||
by default in the gallery theme', 'wpmf'); ?>">
|
||||
<?php esc_html_e('Columns', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<select class="columns"
|
||||
name="wpmf_glr_settings[theme][<?php echo esc_html($theme_name) ?>][columns]">
|
||||
<?php for ($i = 1; $i <= 8; $i ++) { ?>
|
||||
<option value="<?php echo esc_html($i) ?>" <?php selected((int) $settings['columns'], (int) $i) ?> >
|
||||
<?php echo esc_html($i) ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20 p-d-10">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text wpmf_width_auto" data-wpmftippy="<?php esc_html_e('Image size to load
|
||||
by default as thumbnail', 'wpmf'); ?>">
|
||||
<?php esc_html_e('Gallery image size', 'wpmf'); ?>
|
||||
</label>
|
||||
<label class="size">
|
||||
<select class="size" name="wpmf_glr_settings[theme][<?php echo esc_html($theme_name) ?>][size]">
|
||||
<?php
|
||||
$sizes_value = json_decode(get_option('wpmf_gallery_image_size_value'));
|
||||
$sizes = apply_filters('image_size_names_choose', array(
|
||||
'thumbnail' => __('Thumbnail', 'wpmf'),
|
||||
'medium' => __('Medium', 'wpmf'),
|
||||
'large' => __('Large', 'wpmf'),
|
||||
'full' => __('Full Size', 'wpmf'),
|
||||
));
|
||||
?>
|
||||
|
||||
<?php foreach ($sizes_value as $key) : ?>
|
||||
<?php if (!empty($sizes[$key])) : ?>
|
||||
<option value="<?php echo esc_attr($key); ?>" <?php selected($settings['size'], $key); ?>>
|
||||
<?php echo esc_html($sizes[$key]); ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20 p-d-10">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text wpmf_width_auto" data-wpmftippy="<?php esc_html_e('Image size to load by default as full
|
||||
size (opened in the lightbox)', 'wpmf'); ?>">
|
||||
<?php esc_html_e('Lightbox size', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<select class="targetsize"
|
||||
name="wpmf_glr_settings[theme][<?php echo esc_html($theme_name) ?>][targetsize]">
|
||||
<?php
|
||||
$sizes = array(
|
||||
'thumbnail' => __('Thumbnail', 'wpmf'),
|
||||
'medium' => __('Medium', 'wpmf'),
|
||||
'large' => __('Large', 'wpmf'),
|
||||
'full' => __('Full Size', 'wpmf'),
|
||||
);
|
||||
?>
|
||||
|
||||
<?php foreach ($sizes as $key => $name) : ?>
|
||||
<option value="<?php echo esc_attr($key); ?>"
|
||||
<?php selected($settings['targetsize'], $key); ?>>
|
||||
<?php echo esc_html($name); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20 p-d-10">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text wpmf_width_auto" data-wpmftippy="<?php esc_html_e('Action when the user
|
||||
click on the image thumbnail', 'wpmf'); ?>">
|
||||
<?php esc_html_e('Action on click', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<select class="link-to" name="wpmf_glr_settings[theme][<?php echo esc_html($theme_name) ?>][link]">
|
||||
<option value="file" <?php selected($settings['link'], 'file'); ?>>
|
||||
<?php esc_html_e('Lightbox', 'wpmf'); ?>
|
||||
</option>
|
||||
<option value="post" <?php selected($settings['link'], 'post'); ?>>
|
||||
<?php esc_html_e('Attachment Page', 'wpmf'); ?>
|
||||
</option>
|
||||
<option value="none" <?php selected($settings['link'], 'none'); ?>>
|
||||
<?php esc_html_e('None', 'wpmf'); ?>
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20 p-d-10">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text wpmf_width_auto" data-wpmftippy="<?php esc_html_e('Image gallery
|
||||
default ordering', 'wpmf'); ?>">
|
||||
<?php esc_html_e('Order by', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<select class="wpmf_orderby"
|
||||
name="wpmf_glr_settings[theme][<?php echo esc_html($theme_name) ?>][orderby]">
|
||||
<option value="post__in" <?php selected($settings['orderby'], 'post__in'); ?>>
|
||||
<?php esc_html_e('Custom', 'wpmf'); ?>
|
||||
</option>
|
||||
<option value="rand" <?php selected($settings['orderby'], 'rand'); ?>>
|
||||
<?php esc_html_e('Random', 'wpmf'); ?>
|
||||
</option>
|
||||
<option value="title" <?php selected($settings['orderby'], 'title'); ?>>
|
||||
<?php esc_html_e('Title', 'wpmf'); ?>
|
||||
</option>
|
||||
<option value="date" <?php selected($settings['orderby'], 'date'); ?>>
|
||||
<?php esc_html_e('Date', 'wpmf'); ?>
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<?php if ($theme_name === 'slider_theme') : ?>
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20 p-d-10">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text wpmf_width_auto" data-wpmftippy="<?php esc_html_e('By default, use ascending
|
||||
or descending order', 'wpmf'); ?>">
|
||||
<?php esc_html_e('Order', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<select
|
||||
name="wpmf_glr_settings[theme][<?php echo esc_html($theme_name) ?>][order]">
|
||||
<option value="ASC" <?php selected($settings['order'], 'ASC'); ?>>
|
||||
<?php esc_html_e('Ascending', 'wpmf'); ?>
|
||||
</option>
|
||||
<option value="DESC" <?php selected($settings['order'], 'DESC'); ?>>
|
||||
<?php esc_html_e('Descending', 'wpmf'); ?>
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20 p-d-10">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text">
|
||||
<span class="text"><?php esc_html_e('Transition duration (ms)', 'wpmf'); ?></span>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<input type="number"
|
||||
name="wpmf_glr_settings[theme][<?php echo esc_html($theme_name) ?>][duration]"
|
||||
value="<?php echo esc_attr($settings['duration']) ?>">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20 p-d-10">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text wpmf_width_auto">
|
||||
<?php esc_html_e('Aspect ratio', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<select class="wpmf_orderby"
|
||||
name="wpmf_glr_settings[theme][<?php echo esc_html($theme_name) ?>][aspect_ratio]">
|
||||
<?php
|
||||
$aspect_ratios = array(
|
||||
'default' => esc_html__('Default', 'wpmf'),
|
||||
'1_1' => '1:1',
|
||||
'3_2' => '3:2',
|
||||
'2_3' => '2:3',
|
||||
'4_3' => '4:3',
|
||||
'3_4' => '3:4',
|
||||
'16_9' => '16:9',
|
||||
'9_16' => '9:16',
|
||||
'21_9' => '21:9',
|
||||
'9_21' => '9:21'
|
||||
);
|
||||
foreach ($aspect_ratios as $aspect_ratio_value => $aspect_ratio_label) :
|
||||
?>
|
||||
<option value="<?php echo esc_attr($aspect_ratio_value) ?>" <?php selected($settings['aspect_ratio'], $aspect_ratio_value); ?>>
|
||||
<?php echo esc_html($aspect_ratio_label) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option cboption wpmf-no-shadow wpmf_width_100 p-d-10">
|
||||
<h4><?php esc_html_e('Slider Animation', 'wpmf'); ?></h4>
|
||||
<div>
|
||||
<div data-value="fade" class="gallery-slider-animation ju-settings-option wpmf_width_20 wpmf-no-shadow <?php echo ($slider_animation === 'fade') ? 'animation_selected' : '' ?>">
|
||||
<div class="wpmf_row_full">
|
||||
<i class="material-icons wpmf_middle">
|
||||
blur_linear
|
||||
</i>
|
||||
<label class="wpmf_middle"><?php esc_html_e('Fade', 'wpmf') ?></label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-value="slide" class="gallery-slider-animation ju-settings-option wpmf_width_20 wpmf-no-shadow <?php echo ($slider_animation === 'slide') ? 'animation_selected' : '' ?>">
|
||||
<div class="wpmf_row_full">
|
||||
<?php if ($slider_animation === 'slide') { ?>
|
||||
<img class="wpmf_middle img_slide" src="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/slide_white.png') ?>">
|
||||
<?php } else { ?>
|
||||
<img class="wpmf_middle" src="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/slide.png') ?>">
|
||||
<?php } ?>
|
||||
<label class="wpmf_middle"><?php esc_html_e('Slide', 'wpmf') ?></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wpmfcard">
|
||||
<label class="radio">
|
||||
<input type="hidden" name="wpmf_slider_animation" class="wpmf_slider_animation"
|
||||
value="<?php echo esc_html($slider_animation) ?>">
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_100 p-d-10">
|
||||
<b class="ju-setting-label setting wpmf-no-padding text wpmf_left">
|
||||
<?php esc_html_e('Automatic animation', 'wpmf'); ?>
|
||||
</b>
|
||||
|
||||
<label class="wpmf_left">
|
||||
<input type="hidden"
|
||||
name="wpmf_glr_settings[theme][<?php echo esc_html($theme_name) ?>][auto_animation]"
|
||||
value="0">
|
||||
<span class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<?php if (isset($settings['auto_animation']) && (int) $settings['auto_animation'] === 1) : ?>
|
||||
<input type="checkbox"
|
||||
name="wpmf_glr_settings[theme][<?php echo esc_html($theme_name) ?>][auto_animation]"
|
||||
value="1" checked>
|
||||
<?php else : ?>
|
||||
<input type="checkbox"
|
||||
name="wpmf_glr_settings[theme][<?php echo esc_html($theme_name) ?>][auto_animation]"
|
||||
value="1">
|
||||
<?php endif; ?>
|
||||
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($theme_name !== 'slider_theme') : ?>
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20 p-d-10">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text wpmf_width_auto" data-wpmftippy="<?php esc_html_e('By default, use ascending
|
||||
or descending order', 'wpmf'); ?>">
|
||||
<?php esc_html_e('Order', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<select
|
||||
name="wpmf_glr_settings[theme][<?php echo esc_html($theme_name) ?>][order]">
|
||||
<option value="ASC" <?php selected($settings['order'], 'ASC'); ?>>
|
||||
<?php esc_html_e('Ascending', 'wpmf'); ?>
|
||||
</option>
|
||||
<option value="DESC" <?php selected($settings['order'], 'DESC'); ?>>
|
||||
<?php esc_html_e('Descending', 'wpmf'); ?>
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($theme_name === 'default_theme' || $theme_name === 'portfolio_theme') : ?>
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20 p-d-10">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text wpmf_width_auto">
|
||||
<?php esc_html_e('Aspect ratio', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<select class="wpmf_orderby"
|
||||
name="wpmf_glr_settings[theme][<?php echo esc_html($theme_name) ?>][aspect_ratio]">
|
||||
<?php
|
||||
$aspect_ratios = array(
|
||||
'default' => esc_html__('Default', 'wpmf'),
|
||||
'1_1' => '1:1',
|
||||
'3_2' => '3:2',
|
||||
'2_3' => '2:3',
|
||||
'4_3' => '4:3',
|
||||
'3_4' => '3:4',
|
||||
'16_9' => '16:9',
|
||||
'9_16' => '9:16',
|
||||
'21_9' => '21:9',
|
||||
'9_21' => '9:21'
|
||||
);
|
||||
foreach ($aspect_ratios as $aspect_ratio_value => $aspect_ratio_label) :
|
||||
?>
|
||||
<option value="<?php echo esc_attr($aspect_ratio_value) ?>" <?php selected($settings['aspect_ratio'], $aspect_ratio_value); ?>>
|
||||
<?php echo esc_html($aspect_ratio_label) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
?>
|
||||
<div id="advanced" class="tab-content">
|
||||
<div class="content-box content-wpmf-advanced">
|
||||
<div class="ju-settings-option">
|
||||
<div class="wpmf_row_full">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,377 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
?>
|
||||
<div id="google_drive_box" class="tab-content">
|
||||
<div class="wpmf_width_100 p-tb-20 wpmf_left top_bar">
|
||||
<h1 class="wpmf_left"><?php esc_html_e('Google Drive', 'wpmf') ?></h1>
|
||||
<?php
|
||||
do_action('cloudconnector_wpmf_display_ggd_connect_button');
|
||||
if (isset($googleconfig['googleClientId']) && $googleconfig['googleClientId'] !== ''
|
||||
&& isset($googleconfig['googleClientSecret']) && $googleconfig['googleClientSecret'] !== '') {
|
||||
if (empty($googleconfig['connected'])) {
|
||||
$urlGoogle = $googleDrive->getAuthorisationUrl();
|
||||
?>
|
||||
<div class="btn_wpmf_saves">
|
||||
<a class="ju-button orange-button waves-effect waves-light btndrive ggd-connector-button" href="#"
|
||||
onclick="window.location.assign('<?php echo esc_html($urlGoogle); ?>','foo','width=600,height=600');return false;">
|
||||
<?php esc_html_e('Connect Google Drive', 'wpmf') ?></a>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
} else {
|
||||
$url_logout = admin_url('options-general.php?page=option-folder&task=wpmf&function=wpmf_gglogout');
|
||||
?>
|
||||
<div class="btn_wpmf_saves">
|
||||
<a class="ju-button no-background orange-button waves-effect waves-light btndrive ggd-connector-button"
|
||||
href="<?php echo esc_html($url_logout) ?>">
|
||||
<?php esc_html_e('Disconnect Google Drive', 'wpmf') ?></a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
$config_mode = get_option('joom_cloudconnector_wpmf_ggd_connect_mode', 'manual');
|
||||
if ($config_mode && $config_mode === 'automatic') {
|
||||
echo '<div class="btn_wpmf_saves"><div class="ggd-connector-button"></div></div>';
|
||||
} else {
|
||||
echo '<div class="btn_wpmf_saves"><div class="ggd-connector-button"></div></div>';
|
||||
require WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/pages/settings/submit_button.php';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="content-box">
|
||||
<?php
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- View request, no action
|
||||
if (isset($_POST['btn_wpmf_save'])) {
|
||||
?>
|
||||
<div class="wpmf_width_100 top_bar saved_infos" style="padding: 20px 0">
|
||||
<?php
|
||||
require WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/pages/settings/saved_info.php';
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="wpmf_width_100 ju-settings-option">
|
||||
<div class="p-d-20">
|
||||
<?php
|
||||
if (is_plugin_active('wp-media-folder-addon/wp-media-folder-addon.php')) {
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput -- Content already escaped in the method
|
||||
echo $html_tabgoogle;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="google_photo" class="tab-content">
|
||||
<div class="wpmf_width_100 p-tb-20 wpmf_left top_bar">
|
||||
<h1 class="wpmf_left"><?php esc_html_e('Google Photos', 'wpmf') ?></h1>
|
||||
<?php
|
||||
do_action('cloudconnector_wpmf_display_gpt_connect_button');
|
||||
if (isset($google_photo_config['googleClientId']) && $google_photo_config['googleClientId'] !== ''
|
||||
&& isset($google_photo_config['googleClientSecret']) && $google_photo_config['googleClientSecret'] !== '') {
|
||||
if (empty($google_photo_config['connected'])) {
|
||||
$urlGooglePhoto = $googlePhoto->getAuthorisationUrl();
|
||||
?>
|
||||
<div class="btn_wpmf_saves">
|
||||
<a class="ju-button orange-button waves-effect waves-light btndrive gpt-connector-button" href="#"
|
||||
onclick="window.location.assign('<?php echo esc_html($urlGooglePhoto); ?>','foo','width=600,height=600');return false;">
|
||||
<?php esc_html_e('Connect Google Photo', 'wpmf') ?></a>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<div class="btn_wpmf_saves">
|
||||
<a class="ju-button no-background orange-button waves-effect waves-light btndrive gpt-connector-button"
|
||||
href="<?php echo esc_html(admin_url('options-general.php?page=option-folder&task=wpmf&function=wpmf_google_photo_logout')) ?>">
|
||||
<?php esc_html_e('Disconnect Google Photo', 'wpmf') ?></a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
$config_mode = get_option('joom_cloudconnector_wpmf_gpt_connect_mode', 'manual');
|
||||
if ($config_mode && $config_mode === 'automatic') {
|
||||
echo '<div class="btn_wpmf_saves"><div class="gpt-connector-button"></div></div>';
|
||||
} else {
|
||||
echo '<div class="btn_wpmf_saves"><div class="gpt-connector-button"></div></div>';
|
||||
require WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/pages/settings/submit_button.php';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="content-box">
|
||||
<?php
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- View request, no action
|
||||
if (isset($_POST['btn_wpmf_save'])) {
|
||||
?>
|
||||
<div class="wpmf_width_100 top_bar saved_infos" style="padding: 20px 0">
|
||||
<?php
|
||||
require WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/pages/settings/saved_info.php';
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="wpmf_width_100 ju-settings-option">
|
||||
<div class="p-d-20">
|
||||
<?php
|
||||
if (is_plugin_active('wp-media-folder-addon/wp-media-folder-addon.php')) {
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput -- Content already escaped in the method
|
||||
echo $html_google_photo;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="dropbox_box" class="tab-content">
|
||||
<div class="wpmf_width_100 p-tb-20 wpmf_left top_bar">
|
||||
<h1 class="wpmf_left"><?php esc_html_e('Dropbox', 'wpmf') ?></h1>
|
||||
<?php
|
||||
do_action('cloudconnector_wpmf_display_dropbox_connect_button');
|
||||
if (isset($dropboxconfig['dropboxKey']) && $dropboxconfig['dropboxKey'] !== ''
|
||||
&& isset($dropboxconfig['dropboxSecret']) && $dropboxconfig['dropboxSecret'] !== '') {
|
||||
if ($Dropbox->checkAuth()) {
|
||||
try {
|
||||
$urlDropbox = $Dropbox->getAuthorizeDropboxUrl();
|
||||
} catch (Exception $e) {
|
||||
$urlDropbox = '';
|
||||
}
|
||||
}
|
||||
if ($Dropbox->checkAuth()) {
|
||||
?>
|
||||
<div class="btn_wpmf_saves">
|
||||
<a class="ju-button orange-button waves-effect waves-light btndrive dropbox-connector-button" href="#"
|
||||
onclick="window.open('<?php echo esc_html($urlDropbox); ?>','foo','width=600,height=600');return false;">
|
||||
<?php esc_html_e('Connect Dropbox', 'wpmf') ?></a>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
} else { ?>
|
||||
<div class="btn_wpmf_saves">
|
||||
<a class="ju-button no-background orange-button waves-effect waves-light btndrive dropbox-connector-button"
|
||||
href="<?php echo esc_html(admin_url('options-general.php?page=option-folder&task=wpmf&function=wpmf_dropboxlogout')) ?>">
|
||||
<?php esc_html_e('Disconnect Dropbox', 'wpmf') ?></a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
$config_mode = get_option('joom_cloudconnector_wpmf_dropbox_connect_mode', 'manual');
|
||||
if ($config_mode && $config_mode === 'automatic') {
|
||||
echo '<div class="btn_wpmf_saves"><div class="dropbox-connector-button"></div></div>';
|
||||
} else {
|
||||
echo '<div class="btn_wpmf_saves"><div class="dropbox-connector-button"></div></div>';
|
||||
require WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/pages/settings/submit_button.php';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="content-box">
|
||||
<?php
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- View request, no action
|
||||
if (isset($_POST['btn_wpmf_save'])) {
|
||||
?>
|
||||
<div class="wpmf_width_100 top_bar saved_infos" style="padding: 20px 0">
|
||||
<?php
|
||||
require WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/pages/settings/saved_info.php';
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="wpmf_width_100 ju-settings-option">
|
||||
<div class="p-d-20">
|
||||
<?php
|
||||
if (is_plugin_active('wp-media-folder-addon/wp-media-folder-addon.php')) {
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput -- Content already escaped in the method
|
||||
echo $html_tabdropbox;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="one_drive_box" class="tab-content">
|
||||
<div class="wpmf_width_100 p-tb-20 wpmf_left top_bar">
|
||||
<h1 class="wpmf_left"><?php esc_html_e('OneDrive Personal', 'wpmf') ?></h1>
|
||||
<?php
|
||||
require WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/pages/settings/submit_button.php';
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="content-box">
|
||||
<?php
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- View request, no action
|
||||
if (isset($_POST['btn_wpmf_save'])) {
|
||||
?>
|
||||
<div class="wpmf_width_100 top_bar saved_infos" style="padding: 20px 0">
|
||||
<?php
|
||||
require WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/pages/settings/saved_info.php';
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="wpmf_width_100 ju-settings-option">
|
||||
<div class="p-d-20">
|
||||
<?php
|
||||
if (is_plugin_active('wp-media-folder-addon/wp-media-folder-addon.php')) {
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput -- Content already escaped in the method
|
||||
echo $html_onedrive_settings;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if (is_plugin_active('wp-media-folder-addon/wp-media-folder-addon.php')) :
|
||||
?>
|
||||
<h1 class="wpmf_left"><?php esc_html_e('OneDrive Business', 'wpmf') ?></h1>
|
||||
<div class="wpmf_width_100 ju-settings-option">
|
||||
<div class="p-d-20">
|
||||
<?php
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput -- Content already escaped in the method
|
||||
echo $html_onedrive_business_settings;
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="nextcloud" class="tab-content">
|
||||
<div class="wpmf_width_100 p-tb-20 wpmf_left top_bar">
|
||||
<h1 class="wpmf_left"><?php esc_html_e('Nextcloud', 'wpmf') ?></h1>
|
||||
<?php
|
||||
require WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/pages/settings/submit_button.php';
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="content-box">
|
||||
<?php
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- View request, no action
|
||||
if (isset($_POST['btn_wpmf_save'])) {
|
||||
?>
|
||||
<div class="wpmf_width_100 top_bar saved_infos" style="padding: 20px 0">
|
||||
<?php
|
||||
require WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/pages/settings/saved_info.php';
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="wpmf_width_100 ju-settings-option">
|
||||
<div class="p-d-20">
|
||||
<?php
|
||||
if (is_plugin_active('wp-media-folder-addon/wp-media-folder-addon.php')) {
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput -- Content already escaped in the method
|
||||
echo $html_nextcloud;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="storage_provider" class="tab-content">
|
||||
<div class="wpmf_width_100 p-tb-20 wpmf_left top_bar">
|
||||
<h1 class="wpmf_left">
|
||||
<?php
|
||||
$clouds = array(
|
||||
'aws3' => array('key' => 'aws3', 'name' => 'Amazon S3'),
|
||||
'digitalocean' => array('key' => 'digitalocean', 'name' => 'DigitalOcean'),
|
||||
'wasabi' => array('key' => 'wasabi', 'name' => 'Wasabi'),
|
||||
'google_cloud_storage' => array('key' => 'google_cloud_storage', 'name' => 'Google Cloud Storage'),
|
||||
'linode' => array('key' => 'linode', 'name' => 'Linode'),
|
||||
'bunny_cdn_edge' => array('key' => 'bunny_cdn_edge', 'name' => 'Bunny CDN Edge Storage')
|
||||
);
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- No action, nonce is not required
|
||||
if (isset($_GET['cloud'])) {
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- No action, nonce is not required
|
||||
$storage = $_GET['cloud'];
|
||||
} else {
|
||||
$storage = get_option('wpmf_cloud_endpoint');
|
||||
if (empty($storage)) {
|
||||
$storage = 'aws3';
|
||||
}
|
||||
}
|
||||
|
||||
echo esc_html($clouds[$storage]['name'])
|
||||
?>
|
||||
</h1>
|
||||
<?php
|
||||
require WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/pages/settings/submit_button.php';
|
||||
?>
|
||||
</div>
|
||||
<div class="content-box content-wpmf-general">
|
||||
<?php
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- View request, no action
|
||||
if (isset($_POST['btn_wpmf_save'])) {
|
||||
?>
|
||||
<div class="wpmf_width_100 top_bar saved_infos" style="padding: 20px 0">
|
||||
<?php
|
||||
require WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/pages/settings/saved_info.php';
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div>
|
||||
<div class="wpmf_row_full">
|
||||
<?php
|
||||
if (is_plugin_active('wp-media-folder-addon/wp-media-folder-addon.php')) {
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput -- Content already escaped in the method
|
||||
echo $html_tabaws3;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="synchronization" class="tab-content">
|
||||
<div class="wpmf_width_100 p-tb-20 wpmf_left top_bar">
|
||||
<h1 class="wpmf_left"><?php esc_html_e('Synchronization', 'wpmf') ?></h1>
|
||||
<?php
|
||||
require WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/pages/settings/submit_button.php';
|
||||
?>
|
||||
</div>
|
||||
<div class="content-box content-wpmf-general">
|
||||
<?php
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- View request, no action
|
||||
if (isset($_POST['btn_wpmf_save'])) {
|
||||
?>
|
||||
<div class="wpmf_width_100 top_bar saved_infos" style="padding: 20px 0">
|
||||
<?php
|
||||
require WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/pages/settings/saved_info.php';
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div>
|
||||
<div class="wpmf_row_full">
|
||||
<?php
|
||||
if (is_plugin_active('wp-media-folder-addon/wp-media-folder-addon.php')) {
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput -- Content already escaped in the method
|
||||
echo $synchronization;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,615 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
?>
|
||||
<div id="rename_on_upload" class="tab-content">
|
||||
<div class="content-box content-wpmf-files-folders">
|
||||
<div class="ju-settings-option">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wpmf_media_rename" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Tag available: {sitename} - {foldername} - {folderslug} - {date} - {original name} - {timestamp} .
|
||||
Note: # will be replaced by increasing numbers', 'wpmf') ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Activate media rename on upload', 'wpmf') ?>
|
||||
</label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="wpmf_media_rename" value="1"
|
||||
<?php
|
||||
if (isset($media_rename) && (int)$media_rename === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_right m-r-0">
|
||||
<div class="wpmf_row_full">
|
||||
<label for="wpmf_patern" class="ju-setting-label text"
|
||||
data-wpmftippy="<?php esc_html_e('Tag avaiable: {sitename} - {foldername} - {folderslug} - {date} - {original name} .
|
||||
Note: # will be replaced by increasing numbers', 'wpmf') ?>" style="min-width: 50px">
|
||||
<?php esc_html_e('Pattern', 'wpmf') ?>
|
||||
</label>
|
||||
<label class="line-height-50">
|
||||
<input type="text" name="wpmf_patern"
|
||||
id="wpmf_patern" class="regular-text wpmf_width_60"
|
||||
value="<?php echo esc_attr($wpmf_pattern); ?>">
|
||||
</label>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3 class="title_h3"><?php esc_html_e('Format Media Titles', 'wpmf'); ?></h3>
|
||||
<h4 class="title_h4">
|
||||
<label data-wpmftippy="<?php esc_html_e('Remove characters automatically on media upload', 'wpmf'); ?>"
|
||||
class="text"><?php esc_html_e('Remove Characters', 'wpmf') ?>
|
||||
</label>
|
||||
</h4>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="format_mediatitle" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Additionally to the file rename on upload pattern, you can apply rename options below', 'wpmf') ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Activate format media title', 'wpmf') ?>
|
||||
</label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="format_mediatitle" value="1"
|
||||
<?php
|
||||
if (isset($format_mediatitle) && (int)$format_mediatitle === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpmf_row_full wpmf-no-margin">
|
||||
<div class="wrap_left">
|
||||
<div class="wpmf-field-setting">
|
||||
<input type="hidden" name="wpmf_options_format_title[hyphen]" value="0">
|
||||
<div class="pure-checkbox">
|
||||
<input id="wpmf_hyphen" type="checkbox" name="wpmf_options_format_title[hyphen]"
|
||||
<?php checked($options_format_title['hyphen'], 1) ?> value="1">
|
||||
<label for="wpmf_hyphen" class="ju-setting-label"><?php esc_html_e('Hyphen', 'wpmf') ?>
|
||||
-</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpmf-field-setting">
|
||||
<div class="pure-checkbox">
|
||||
<input type="hidden" name="wpmf_options_format_title[period]" value="0">
|
||||
<input id="wpmf_period" type="checkbox"
|
||||
name="wpmf_options_format_title[period]"
|
||||
<?php checked($options_format_title['period'], 1) ?> value="1">
|
||||
<label for="wpmf_period" class="ju-setting-label"><?php esc_html_e('Period', 'wpmf') ?>
|
||||
.</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpmf-field-setting">
|
||||
<div class="pure-checkbox">
|
||||
<input type="hidden" name="wpmf_options_format_title[plus]" value="0">
|
||||
<input id="wpmf_plus" type="checkbox"
|
||||
name="wpmf_options_format_title[plus]"
|
||||
<?php checked($options_format_title['plus'], 1) ?> value="1">
|
||||
<label for="wpmf_plus" class="ju-setting-label"><?php esc_html_e('Plus', 'wpmf') ?> +</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpmf-field-setting">
|
||||
<div class="pure-checkbox">
|
||||
<input type="hidden" name="wpmf_options_format_title[ampersand]" value="0">
|
||||
<input id="wpmf_ampersand" type="checkbox"
|
||||
name="wpmf_options_format_title[ampersand]"
|
||||
<?php checked($options_format_title['ampersand'], 1) ?> value="1">
|
||||
<label for="wpmf_ampersand" class="ju-setting-label"><?php esc_html_e('Ampersand', 'wpmf') ?>
|
||||
@</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpmf-field-setting">
|
||||
<div class="pure-checkbox">
|
||||
<input type="hidden" name="wpmf_options_format_title[copyright]" value="0">
|
||||
<input id="wpmf_copyright" type="checkbox"
|
||||
name="wpmf_options_format_title[copyright]"
|
||||
<?php checked($options_format_title['copyright'], 1) ?> value="1">
|
||||
<label for="wpmf_copyright" class="ju-setting-label"><?php esc_html_e('Copyright', 'wpmf') ?>
|
||||
©</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpmf-field-setting">
|
||||
<div class="pure-checkbox">
|
||||
<input type="hidden" name="wpmf_options_format_title[square_brackets]" value="0">
|
||||
<input id="wpmf_square_brackets" type="checkbox"
|
||||
name="wpmf_options_format_title[square_brackets]"
|
||||
<?php checked($options_format_title['square_brackets'], 1) ?> value="1">
|
||||
<label for="wpmf_square_brackets"
|
||||
class="ju-setting-label"><?php esc_html_e('Square brackets', 'wpmf') ?> []</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpmf-field-setting">
|
||||
<div class="pure-checkbox">
|
||||
<input type="hidden" name="wpmf_options_format_title[curly_brackets]" value="0">
|
||||
<input id="wpmf_curly_brackets" type="checkbox"
|
||||
name="wpmf_options_format_title[curly_brackets]"
|
||||
<?php checked($options_format_title['curly_brackets'], 1) ?> value="1">
|
||||
<label for="wpmf_curly_brackets"
|
||||
class="ju-setting-label"><?php esc_html_e('Curly brackets', 'wpmf') ?> {}</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpmf-field-setting">
|
||||
<div class="pure-checkbox">
|
||||
<input type="hidden" name="wpmf_options_format_title[underscore]" value="0">
|
||||
<input id="wpmf_underscore" type="checkbox"
|
||||
name="wpmf_options_format_title[underscore]"
|
||||
<?php checked($options_format_title['underscore'], 1) ?> value="1">
|
||||
<label for="wpmf_underscore" class="ju-setting-label"><?php esc_html_e('Underscore', 'wpmf') ?>
|
||||
_</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wrap_right">
|
||||
<div class="wpmf-field-setting">
|
||||
<div class="pure-checkbox">
|
||||
<input type="hidden" name="wpmf_options_format_title[tilde]" value="0">
|
||||
<input id="wpmf_tilde" type="checkbox"
|
||||
name="wpmf_options_format_title[tilde]"
|
||||
<?php checked($options_format_title['tilde'], 1) ?> value="1">
|
||||
<label for="wpmf_tilde" class="ju-setting-label"><?php esc_html_e('Tilde', 'wpmf') ?> ~</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpmf-field-setting">
|
||||
<div class="pure-checkbox">
|
||||
<input type="hidden" name="wpmf_options_format_title[hash]" value="0">
|
||||
<input id="wpmf_hash" type="checkbox"
|
||||
name="wpmf_options_format_title[hash]"
|
||||
<?php checked($options_format_title['hash'], 1) ?> value="1">
|
||||
<label for="wpmf_hash" class="ju-setting-label"><?php esc_html_e('Hash/pound', 'wpmf') ?>
|
||||
#</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpmf-field-setting">
|
||||
<div class="pure-checkbox">
|
||||
<input type="hidden" name="wpmf_options_format_title[number]" value="0">
|
||||
<input id="wpmf_number" type="checkbox"
|
||||
name="wpmf_options_format_title[number]"
|
||||
<?php checked($options_format_title['number'], 1) ?> value="1">
|
||||
<label for="wpmf_number" class="ju-setting-label"><?php esc_html_e('All numbers', 'wpmf') ?>
|
||||
0-9</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpmf-field-setting">
|
||||
<div class="pure-checkbox">
|
||||
<input type="hidden" name="wpmf_options_format_title[round_brackets]" value="0">
|
||||
<input id="wpmf_round_brackets" type="checkbox"
|
||||
name="wpmf_options_format_title[round_brackets]"
|
||||
<?php checked($options_format_title['round_brackets'], 1) ?> value="1">
|
||||
<label for="wpmf_round_brackets"
|
||||
class="ju-setting-label"><?php esc_html_e('Round brackets', 'wpmf') ?> ()</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpmf-field-setting">
|
||||
<div class="pure-checkbox">
|
||||
<input type="hidden" name="wpmf_options_format_title[alt]" value="0">
|
||||
<input id="wpmf_alt" type="checkbox"
|
||||
name="wpmf_options_format_title[alt]"
|
||||
<?php checked($options_format_title['alt'], 1) ?> value="1">
|
||||
<label for="wpmf_alt"
|
||||
class="ju-setting-label"><?php esc_html_e('Copy title to Alternative Text Field?', 'wpmf') ?>
|
||||
(-)</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpmf-field-setting">
|
||||
<div class="pure-checkbox">
|
||||
<input type="hidden" name="wpmf_options_format_title[description]" value="0">
|
||||
<input id="wpmf_description" type="checkbox"
|
||||
name="wpmf_options_format_title[description]"
|
||||
<?php checked($options_format_title['description'], 1) ?> value="1">
|
||||
<label for="wpmf_description"
|
||||
class="ju-setting-label"><?php esc_html_e('Copy title to Description Field?', 'wpmf') ?>
|
||||
(.)</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpmf-field-setting">
|
||||
<div class="pure-checkbox">
|
||||
<input type="hidden" name="wpmf_options_format_title[caption]" value="0">
|
||||
<input id="wpmf_caption" type="checkbox"
|
||||
name="wpmf_options_format_title[caption]"
|
||||
<?php checked($options_format_title['caption'], 1) ?> value="1">
|
||||
<label for="wpmf_caption"
|
||||
class="ju-setting-label"><?php esc_html_e('Copy title to Caption Field?', 'wpmf') ?>
|
||||
(_)</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_width_100 p-lr-20 wpmf-no-shadow">
|
||||
<div class="wpmf_row_full">
|
||||
<h2>
|
||||
<label data-wpmftippy="<?php esc_html_e('Add capital letters automatically on media upload', 'wpmf'); ?>"
|
||||
class="text"><?php esc_html_e('Automatic capitalization', 'wpmf') ?>
|
||||
</label>
|
||||
</h2>
|
||||
|
||||
<label>
|
||||
<select name="wpmf_options_format_title[capita]" class="wpmf_width_100">
|
||||
<option <?php selected($options_format_title['capita'], 'cap_all') ?>
|
||||
value="cap_all"><?php esc_html_e('Capitalize All Words', 'wpmf'); ?></option>
|
||||
<option <?php selected($options_format_title['capita'], 'cap_first') ?>
|
||||
value="cap_first"><?php esc_html_e('Capitalize First Word Only', 'wpmf'); ?></option>
|
||||
<option <?php selected($options_format_title['capita'], 'all_lower') ?>
|
||||
value="all_lower"><?php esc_html_e('All Words Lower Case', 'wpmf'); ?></option>
|
||||
<option <?php selected($options_format_title['capita'], 'all_upper') ?>
|
||||
value="all_upper"><?php esc_html_e('All Words Upper Case', 'wpmf'); ?></option>
|
||||
<option <?php selected($options_format_title['capita'], 'dont_alter') ?>
|
||||
value="dont_alter"><?php esc_html_e('Don\'t Alter (title text isn\'t modified in any way)', 'wpmf'); ?></option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="watermark" class="tab-content">
|
||||
<div class="content-box content-wpmf-files-folders">
|
||||
<div class="ju-settings-option wpmf_width_100 p-lr-20">
|
||||
<div class="ju-settings-option wpmf_width_40 wpmf-no-shadow wpmf-no-padding wpmf-no-margin">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wpmf_option_image_watermark" value="0">
|
||||
<b data-wpmftippy="<?php esc_html_e('Watermark will be applied only after saving the
|
||||
settings and regenerate the thumnails (hit the regenerate thumnails button)', 'wpmf'); ?>"
|
||||
class="ju-setting-label text wpmf-no-padding"><?php esc_html_e('Images watermark', 'wpmf') ?></b>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="cb_option_image_watermark"
|
||||
name="wpmf_option_image_watermark" value="1"
|
||||
<?php
|
||||
if (isset($option_image_watermark) && (int)$option_image_watermark === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_width_100 wpmf-no-shadow">
|
||||
<div class="wpmf_row_full">
|
||||
<label data-wpmftippy="<?php esc_html_e('Select a picture that will be applied over your images', 'wpmf') ?>"
|
||||
class="p-b-20 wpmf_left text label_text">
|
||||
<?php esc_html_e('Select an image', 'wpmf') ?>
|
||||
</label>
|
||||
<div class="wpmf_width_100">
|
||||
<label for="wpmf_watermark_image"></label>
|
||||
<input type="text" readonly name="wpmf_watermark_image"
|
||||
id="wpmf_watermark_image" class="regular-text wpmf_width_70 wpmf-middle"
|
||||
value="<?php echo esc_attr($watermark_image); ?>">
|
||||
<input type="hidden" name="wpmf_watermark_image_id"
|
||||
id="wpmf_watermark_image_id" class="regular-text"
|
||||
value="<?php echo esc_attr($watermark_image_id); ?>">
|
||||
<div class="min-w-0 ju-button waves-effect waves-light wpmf_watermark_select_image">
|
||||
<?php esc_html_e('+ Select', 'wpmf') ?>
|
||||
</div>
|
||||
<div class="min-w-0 ju-button waves-effect waves-light wpmf_watermark_clear_image"><?php esc_html_e('Clear', 'wpmf') ?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<div class="wpmf_row_full">
|
||||
<label data-wpmftippy="<?php esc_html_e('Set the watermark opacity (0-100)', 'wpmf'); ?>"
|
||||
class="p-b-20 wpmf_left text label_text">
|
||||
<?php esc_html_e('Watermark opacity', 'wpmf') ?>
|
||||
</label>
|
||||
<div class="wrap_apply wpmf_width_100">
|
||||
<div>
|
||||
<label>
|
||||
<input type="number" class="small-text"
|
||||
name="watermark_opacity"
|
||||
value="<?php echo (int)$watermark_opacity ?>" min="0" max="100">
|
||||
</label>
|
||||
<label><?php esc_html_e('%', 'wpmf') ?></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<div class="wpmf_row_full">
|
||||
<label data-wpmftippy="<?php esc_html_e('Select the watermark image position', 'wpmf'); ?>"
|
||||
class="p-b-20 wpmf_left text label_text">
|
||||
<?php esc_html_e('Watermark position', 'wpmf') ?>
|
||||
</label>
|
||||
<label class="wpmf_width_100">
|
||||
<select name="wpmf_watermark_position" class="wpmf_width_50">
|
||||
<option
|
||||
<?php selected($watermark_position, 'center'); ?>
|
||||
value="center"><?php esc_html_e('Center', 'wpmf') ?></option>
|
||||
<option
|
||||
<?php selected($watermark_position, 'bottom_left'); ?>
|
||||
value="bottom_left"><?php esc_html_e('Bottom Left', 'wpmf') ?></option>
|
||||
<option
|
||||
<?php selected($watermark_position, 'bottom_right'); ?>
|
||||
value="bottom_right"><?php esc_html_e('Bottom Right', 'wpmf') ?></option>
|
||||
<option
|
||||
<?php selected($watermark_position, 'top_right'); ?>
|
||||
value="top_right"><?php esc_html_e('Top Right', 'wpmf') ?></option>
|
||||
<option
|
||||
<?php selected($watermark_position, 'top_left'); ?>
|
||||
value="top_left"><?php esc_html_e('Top Left', 'wpmf') ?></option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf-no-padding">
|
||||
<div class="wpmf_row_full">
|
||||
<label data-wpmftippy="<?php esc_html_e('Make a watermark fit each photo size, resize the width of the watermark', 'wpmf'); ?>"
|
||||
class="p-b-20 wpmf_left text label_text">
|
||||
<?php esc_html_e('Set size of watermark from picture', 'wpmf') ?>
|
||||
</label>
|
||||
<div class="wrap_apply wpmf_width_100">
|
||||
<div>
|
||||
<label>
|
||||
<input type="number" class="small-text"
|
||||
name="watermark_image_scaling"
|
||||
value="<?php echo (int)$watermark_image_scaling ?>">
|
||||
</label>
|
||||
<label><?php esc_html_e('%', 'wpmf') ?></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<div class="wpmf_row_full">
|
||||
<label data-wpmftippy="<?php esc_html_e('Select the watermark margin unit', 'wpmf'); ?>"
|
||||
class="p-b-20 wpmf_left text label_text">
|
||||
<?php esc_html_e('Margin unit', 'wpmf') ?>
|
||||
</label>
|
||||
<label class="wpmf_width_100">
|
||||
<select name="watermark_margin_unit" class="watermark_margin_unit">
|
||||
<option
|
||||
<?php selected($watermark_margin_unit, 'px'); ?>
|
||||
value="px"><?php esc_html_e('px', 'wpmf') ?></option>
|
||||
<option
|
||||
<?php selected($watermark_margin_unit, '%'); ?>
|
||||
value="%"><?php esc_html_e('%', 'wpmf') ?></option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_width_100 wpmf-no-shadow">
|
||||
<div class="wpmf_row_full">
|
||||
<label data-wpmftippy="<?php esc_html_e('Watermark image margin', 'wpmf'); ?>"
|
||||
class="p-b-20 wpmf_left text label_text">
|
||||
<?php esc_html_e('Image margin', 'wpmf') ?>
|
||||
</label>
|
||||
<div class="wpmf_width_100">
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_25 wpmf-no-margin">
|
||||
<label class="wtm-label-small-text label_text"><?php esc_html_e('Top', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input type="number" class="small-text"
|
||||
name="watermark_margin[top]"
|
||||
value="<?php echo (int)$watermark_margin['top'] ?>">
|
||||
</label>
|
||||
<label class="watermark_unit"><?php echo esc_html($watermark_margin_unit) ?></label>
|
||||
</div>
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_25 wpmf-no-margin">
|
||||
<label class="wtm-label-small-text label_text"><?php esc_html_e('Right', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input type="number" class="small-text"
|
||||
name="watermark_margin[right]"
|
||||
value="<?php echo (int)$watermark_margin['right'] ?>">
|
||||
</label>
|
||||
<label class="watermark_unit"><?php echo esc_html($watermark_margin_unit) ?></label>
|
||||
</div>
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_25 wpmf-no-margin">
|
||||
<label class="wtm-label-small-text label_text"><?php esc_html_e('Bottom', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input type="number" class="small-text"
|
||||
name="watermark_margin[bottom]"
|
||||
value="<?php echo (int)$watermark_margin['bottom'] ?>">
|
||||
</label>
|
||||
<label class="watermark_unit"><?php echo esc_html($watermark_margin_unit) ?></label>
|
||||
</div>
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_25 wpmf-no-margin">
|
||||
<label class="wtm-label-small-text label_text"><?php esc_html_e('Left', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input type="number" class="small-text"
|
||||
name="watermark_margin[left]"
|
||||
value="<?php echo (int)$watermark_margin['left'] ?>">
|
||||
</label>
|
||||
<label class="watermark_unit"><?php echo esc_html($watermark_margin_unit) ?></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_width_100 p-lr-20">
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<div class="wpmf_row_full">
|
||||
<h4 data-wpmftippy="<?php esc_html_e('Select the size where you want to apply the watermark', 'wpmf'); ?>"
|
||||
class="text title_h4 font-size-16 color-7f8a98"><?php esc_html_e('Apply watermark on', 'wpmf') ?></h4>
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_100">
|
||||
<div class="pure-checkbox ju-setting-label line-height-30">
|
||||
<input type="hidden" name="wpmf_image_watermark_apply[all_size]" value="0">
|
||||
<input id="wpmf_watermark_position_all" type="checkbox"
|
||||
name="wpmf_image_watermark_apply[all_size]"
|
||||
<?php checked($image_watermark_apply['all_size'], 1) ?> value="1">
|
||||
<label for="wpmf_watermark_position_all"><?php esc_html_e('All sizes', 'wpmf') ?></label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$sizes = apply_filters('image_size_names_choose', array(
|
||||
'thumbnail' => __('Thumbnail', 'wpmf'),
|
||||
'medium' => __('Medium', 'wpmf'),
|
||||
'large' => __('Large', 'wpmf'),
|
||||
'full' => __('Full Size', 'wpmf'),
|
||||
));
|
||||
foreach ($sizes as $ksize => $vsize) :
|
||||
?>
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_100">
|
||||
<div class="pure-checkbox ju-setting-label line-height-30">
|
||||
<input type="hidden" name="wpmf_image_watermark_apply[<?php echo esc_html($ksize) ?>]"
|
||||
value="0">
|
||||
<?php if (isset($image_watermark_apply[$ksize]) && (int)$image_watermark_apply[$ksize] === 1) : ?>
|
||||
<input id="wpmf_watermark_position_<?php echo esc_html($ksize) ?>"
|
||||
type="checkbox" class="wpmf_image_watermark_apply"
|
||||
name="wpmf_image_watermark_apply[<?php echo esc_html($ksize) ?>]"
|
||||
checked value="1">
|
||||
<?php else : ?>
|
||||
<input id="wpmf_watermark_position_<?php echo esc_html($ksize) ?>"
|
||||
type="checkbox" class="wpmf_image_watermark_apply"
|
||||
name="wpmf_image_watermark_apply[<?php echo esc_html($ksize) ?>]" value="1">
|
||||
<?php endif; ?>
|
||||
<label for="wpmf_watermark_position_<?php echo esc_html($ksize) ?>"><?php echo esc_html($vsize) ?></label>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (is_plugin_active('wp-media-folder-gallery-addon/wp-media-folder-gallery-addon.php')) : ?>
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_right m-r-0">
|
||||
<div class="wpmf_row_full">
|
||||
<h4 data-wpmftippy="<?php esc_html_e('Select the size where you want to apply the watermark', 'wpmf'); ?>"
|
||||
class="text title_h4 font-size-16 color-7f8a98"><?php esc_html_e('Watermark on photograph image', 'wpmf') ?></h4>
|
||||
<?php
|
||||
$sizes = array(
|
||||
'all_size' => array(
|
||||
'name' => esc_html__('All sizes', 'wpmf'),
|
||||
'width' => 0,
|
||||
'height' => 0
|
||||
)
|
||||
);
|
||||
$saved_sizes = wpmfGetOption('photograper_default_dimensions');
|
||||
$sizes = array_merge($sizes, $saved_sizes);
|
||||
$sizes['full'] = array(
|
||||
'name' => esc_html__('Original size', 'wpmf'),
|
||||
'width' => 0,
|
||||
'height' => 0
|
||||
);
|
||||
|
||||
foreach ($sizes as $ksize => $vsize) :
|
||||
?>
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_100">
|
||||
<div class="pure-checkbox ju-setting-label line-height-30">
|
||||
<input type="hidden"
|
||||
name="photograper_image_watermark_apply[<?php echo esc_html($ksize) ?>]"
|
||||
value="0">
|
||||
<?php if (isset($photograper_image_watermark_apply[$ksize]) && (int)$photograper_image_watermark_apply[$ksize] === 1) : ?>
|
||||
<input id="wpmf_watermark_position_<?php echo esc_html($ksize) ?>"
|
||||
type="checkbox"
|
||||
class="<?php echo ($ksize === 'all_size') ? 'wpmf_check_all_photograper_size' : 'wpmf_photograper_image_watermark_apply' ?>"
|
||||
name="photograper_image_watermark_apply[<?php echo esc_html($ksize) ?>]"
|
||||
checked value="1">
|
||||
<?php else : ?>
|
||||
<input id="wpmf_watermark_position_<?php echo esc_html($ksize) ?>"
|
||||
type="checkbox"
|
||||
class="<?php echo ($ksize === 'all_size') ? 'wpmf_check_all_photograper_size' : 'wpmf_photograper_image_watermark_apply' ?>"
|
||||
name="photograper_image_watermark_apply[<?php echo esc_html($ksize) ?>]"
|
||||
value="1">
|
||||
<?php endif; ?>
|
||||
<label for="wpmf_watermark_position_<?php echo esc_html($ksize) ?>"><?php echo esc_html($vsize['name']) ?></label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<div class="wpmf_row_full">
|
||||
<h4 data-wpmftippy="<?php esc_html_e('Exclude Folders', 'wpmf'); ?>"
|
||||
class="text title_h4 font-size-16 color-7f8a98"><?php esc_html_e('Exclude Folders', 'wpmf') ?></h4>
|
||||
<input type="hidden" name="wpmf_watermark_exclude_folders">
|
||||
<div class="wrap_apply">
|
||||
<div class="watermark_exclude_folders tree_option_folders">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (is_plugin_active('wp-media-folder-gallery-addon/wp-media-folder-gallery-addon.php')) : ?>
|
||||
<div class="ju-settings-option wpmf-transparent">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="watermark_exclude_public_gallery" value="0">
|
||||
<label class="ju-setting-label text"><?php esc_html_e('Exclude public galleries', 'wpmf') ?>
|
||||
</label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="watermark_exclude_public_gallery" value="1"
|
||||
<?php
|
||||
if (isset($watermark_exclude_public_gallery) && (int)$watermark_exclude_public_gallery === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-transparent">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="watermark_exclude_photograph_gallery" value="0">
|
||||
<label class="ju-setting-label text"><?php esc_html_e('Exclude photographer galleries', 'wpmf') ?>
|
||||
</label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="watermark_exclude_photograph_gallery" value="1"
|
||||
<?php
|
||||
if (isset($watermark_exclude_photograph_gallery) && (int)$watermark_exclude_photograph_gallery === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="wpmf_row_full">
|
||||
<label class="ju-setting-label text"></label>
|
||||
<button type="button"
|
||||
class="ju-button no-background orange-button waves-effect waves-light wpmf_watermark_regeneration"
|
||||
><?php esc_html_e('Thumbnail regeneration', 'wpmf') ?></button>
|
||||
<button type="button"
|
||||
class="ju-button orange-button no-background waves-effect waves-light btn_stop_watermark"
|
||||
><?php esc_html_e('Stop the process', 'wpmf') ?></button>
|
||||
<div class="wpmf-process-bar-full process_watermark_thumb_full">
|
||||
<div class="wpmf-process-bar process_watermark_thumb" data-w="0"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
?>
|
||||
<div id="galleryadd_default_settings" class="tab-content">
|
||||
<div class="content-box content-wpmf-general">
|
||||
<?php
|
||||
if (is_plugin_active('wp-media-folder-gallery-addon/wp-media-folder-gallery-addon.php')) {
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput -- Content already escaped in the method
|
||||
echo $gallery_settings_html;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="gallery_shortcode_generator" class="tab-content">
|
||||
<div class="content-box content-wpmf-general">
|
||||
<div class="wpmf_width_100 p-d-20 ju-settings-option">
|
||||
<?php
|
||||
if (is_plugin_active('wp-media-folder-gallery-addon/wp-media-folder-gallery-addon.php')) {
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput -- Content already escaped in the method
|
||||
echo $gallery_shortcode_html;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="gallery_social_sharing" class="tab-content">
|
||||
<div class="content-box content-wpmf-general">
|
||||
<div class="ju-settings-option">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="social_sharing" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Possibility to load social sharing buttons on hover to image in gallery', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Enable social sharing buttons', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="social_sharing" value="1"
|
||||
<?php
|
||||
if (isset($social_sharing) && (int) $social_sharing === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_width_100 p-lr-20">
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<div class="wpmf_row_full">
|
||||
<h4 class="text font-size-19 line-height-30">
|
||||
<img src="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/social/facebook/facebook.png') ?>"
|
||||
srcset="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/social/facebook/facebook@2x.png') ?> 2x, <?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/social/facebook/facebook@3x.png') ?> 3x"
|
||||
class="img_social">
|
||||
<label class="social-label wpmf_middle"><?php esc_html_e('Facebook', 'wpmf') ?></label>
|
||||
</h4>
|
||||
<input title="facebook" type="text" name="social_sharing_link[facebook]"
|
||||
class="regular-text" value="<?php echo esc_attr($social_sharing_link['facebook']); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<div class="wpmf_row_full">
|
||||
<h4 class="text font-size-19 line-height-30">
|
||||
<img src="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/social/twitter/twitter.png') ?>"
|
||||
srcset="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/social/twitter/twitter@2x.png') ?> 2x, <?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/social/twitter/twitter@3x.png') ?> 3x"
|
||||
class="img_social">
|
||||
<label class="social-label wpmf_middle"><?php esc_html_e('Twitter', 'wpmf') ?></label>
|
||||
</h4>
|
||||
<input title="twitter" type="text" name="social_sharing_link[twitter]"
|
||||
class="regular-text" value="<?php echo esc_attr($social_sharing_link['twitter']); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<div class="wpmf_row_full">
|
||||
<h4 class="text font-size-19 line-height-30">
|
||||
<img src="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/social/instagram/instagram.png') ?>"
|
||||
srcset="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/social/instagram/instagram@2x.png') ?> 2x, <?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/social/instagram/instagram@3x.png') ?> 3x"
|
||||
class="img_social">
|
||||
<label class="social-label wpmf_middle"><?php esc_html_e('Instagram', 'wpmf') ?></label>
|
||||
</h4>
|
||||
<input title="instagram" type="text" name="social_sharing_link[instagram]"
|
||||
class="regular-text" value="<?php echo esc_attr($social_sharing_link['instagram']); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<div class="wpmf_row_full">
|
||||
<h4 class="text font-size-19 line-height-30">
|
||||
<img src="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/social/pinterest/pinterest.png') ?>"
|
||||
srcset="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/social/pinterest/pinterest@2x.png') ?> 2x, <?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/social/pinterest/pinterest@3x.png') ?> 3x"
|
||||
class="img_social">
|
||||
<label class="social-label wpmf_middle"><?php esc_html_e('Pinterest', 'wpmf') ?></label>
|
||||
</h4>
|
||||
<input title="pinterest" type="text" name="social_sharing_link[pinterest]"
|
||||
class="regular-text" value="<?php echo esc_attr($social_sharing_link['pinterest']); ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
?>
|
||||
<div class="tab-content">
|
||||
<div class="content-box content-wpmf-general">
|
||||
<?php
|
||||
if (is_plugin_active('wp-media-folder-gallery-addon/wp-media-folder-gallery-addon.php')) {
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput -- Content already escaped in the method
|
||||
echo $gallery_photographer_settings_html;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,603 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
global $wpdb;
|
||||
$featured_image_folder = wpmfGetOption('featured_image_folder');
|
||||
?>
|
||||
<div id="additional_features" class="tab-content">
|
||||
<div class="content-box content-wpmf-general">
|
||||
<div class="ju-settings-option">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wpmf_option_mediafolder" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Load WP Media Folder files on frontend. Activate it if
|
||||
you want to use a frontend page builder along with the media manager', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('WP Media Folder on frontend', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="wpmf_option_mediafolder"
|
||||
value="1"
|
||||
<?php
|
||||
if (isset($option_mediafolder) && (int) $option_mediafolder === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_right m-r-0">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="show_folder_id" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Display and copy the folder ID by making a right click on the folder', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Display folder ID', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="cb_option_show_folder_id" name="show_folder_id" class="show_folder_id"
|
||||
value="1"
|
||||
<?php
|
||||
if (isset($show_folder_id) && (int) $show_folder_id === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="hide_tree" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Load a left folder tree on the left part of the media manager for a faster folder navigation', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Enable folder tree', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="hide_tree"
|
||||
value="1"
|
||||
<?php
|
||||
if (isset($hide_tree) && (int) $hide_tree === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_right m-r-0">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="enable_folders" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Enable or not the display of folders in the main view on top of the media', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Enable folders on top of media', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="enable_folders"
|
||||
value="1"
|
||||
<?php
|
||||
if (isset($enable_folders) && (int) $enable_folders === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wpmf_option_countfiles" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Display the number of media
|
||||
available in each folder, in the folder tree. This option is applied for administrator role only.', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Media count', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="cb_option_countfiles" name="wpmf_option_countfiles"
|
||||
value="1"
|
||||
<?php
|
||||
if (isset($option_countfiles) && (int) $option_countfiles === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_right m-r-0">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="root_media_count" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Display the number of media
|
||||
available in root folder, in the folder tree. This option is applied for administrator role only.', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Root media count', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="root_media_count"
|
||||
value="1"
|
||||
<?php
|
||||
if (isset($root_media_count) && (int) $root_media_count === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wpmf_option_override" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Possibility to replace an existing file by another one.', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Override file', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="cb_option_override"
|
||||
name="wpmf_option_override" value="1"
|
||||
<?php
|
||||
if (isset($option_override) && (int) $option_override === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_right m-r-0">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wpmf_option_duplicate" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Add a button to duplicate a media from the media manager', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Duplicate file', 'wpmf') ?>
|
||||
</label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="cb_option_duplicate"
|
||||
name="wpmf_option_duplicate" value="1"
|
||||
<?php
|
||||
if (isset($option_duplicate) && (int) $option_duplicate === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wpmf_option_hoverimg" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('On mouse hover on an image, a large preview is displayed', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Hover image', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="cb_option_hoverimg" name="wpmf_option_hoverimg" value="1"
|
||||
<?php
|
||||
if (isset($option_hoverimg) && (int) $option_hoverimg === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_right m-r-0">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wpmf_useorder" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Additional filters will be added in the media views.', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Enable the filter and order feature', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="wpmf_useorder" value="1"
|
||||
<?php
|
||||
if (isset($useorder) && (int) $useorder === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="load_gif" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Automatically play the GIF animation on page load. By default it’s a static image in WordPress', 'wpmf') ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Load GIF file on page load', 'wpmf') ?>
|
||||
</label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="load_gif" value="1"
|
||||
<?php
|
||||
if (isset($load_gif) && (int) $load_gif === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_right m-r-0">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wpmf_option_media_remove" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('When you remove a folder all media inside will also be
|
||||
removed if this option is activated. Use with caution.', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Remove a folder with its media', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="cb_option_media_remove"
|
||||
name="wpmf_option_media_remove" value="1"
|
||||
<?php
|
||||
if (isset($option_media_remove) && (int) $option_media_remove === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="search_file_include_childrent" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('If enabled, when you search file in a folder, it will search in its subfolders too', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Search file in a folder and its subfolder', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox"
|
||||
name="search_file_include_childrent" value="1"
|
||||
<?php
|
||||
if (isset($search_file_include_childrent) && (int) $search_file_include_childrent === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_right m-r-0">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="delete_all_datas" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Delete all data on uninstall (including addons)', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Delete all data on uninstall (including addons)', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="cb_option_delete_all_datas" name="delete_all_datas" class="delete_all_datas"
|
||||
value="1"
|
||||
<?php
|
||||
if (isset($delete_all_datas) && (int) $delete_all_datas === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
<?php if (isset($delete_all_datas) && (int) $delete_all_datas === 1) : ?>
|
||||
<p class="description delete_all_label show"><?php esc_html_e('Beware: If some cloud system are connected and some private links are added in your content, you will have media broken links', 'wpmf') ?></p>
|
||||
<?php else : ?>
|
||||
<p class="description delete_all_label hide"><?php esc_html_e('Beware: If some cloud system are connected and some private links are added in your content, you will have media broken links', 'wpmf') ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="hide_remote_video" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Remote video feature: include and manage remote video from Youtube Vimeo or Dailymotion', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Enable remote video feature', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="hide_remote_video"
|
||||
value="1"
|
||||
<?php
|
||||
if (isset($hide_remote_video) && (int) $hide_remote_video === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_right m-r-0">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="enable_download_media" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Right click on an image or file in the media manager to download it. Image original sized will be downloaded', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Enable download media', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="enable_download_media"
|
||||
value="1"
|
||||
<?php
|
||||
if (isset($enable_download_media) && (int) $enable_download_media === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="default_featured_image_wrap">
|
||||
<div class="featured_image_wrap">
|
||||
<input type="hidden" class="default_featured_image" name="default_featured_image" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Select a default image or a random image from a media folder to be loaded by default in any new post. The image can be replaced by editing it in the post of course', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Default featured image', 'wpmf') ?></label>
|
||||
<div class="radio_group">
|
||||
<label><input type="radio" class="radio_group_input" name="default_featured_image_type" <?php checked($default_featured_image_type, 'fixed', true) ?> value="fixed"> <?php esc_html_e('Specific image', 'wpmf') ?></label>
|
||||
<label><input type="radio" class="radio_group_input" name="default_featured_image_type" <?php checked($default_featured_image_type, 'random', true) ?> value="random"> <?php esc_html_e('Random image from folder', 'wpmf') ?></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wpmf_row_full">
|
||||
<div data-option="fixed" class="radion_option_content feature_image_fixed <?php echo ($default_featured_image_type === 'fixed') ? '' : 'hide' ?>">
|
||||
<div class="featured_image_img <?php echo (empty($default_featured_image)) ? 'hide' : '' ?>">
|
||||
<?php if (!empty($default_featured_image)) : ?>
|
||||
<img src="<?php echo esc_url(wp_get_attachment_image_url($default_featured_image, 'thumbnail')) ?>">
|
||||
<?php else : ?>
|
||||
<img src="">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php if (!empty($default_featured_image)) : ?>
|
||||
<input type="text" readonly="" class="regular-text wpmf_width_50 wpmf-middle default_featured_image_url" value="<?php echo esc_url(wp_get_attachment_image_url($default_featured_image, 'full')) ?>">
|
||||
<?php else : ?>
|
||||
<input type="text" readonly="" class="regular-text wpmf_width_50 wpmf-middle default_featured_image_url" value="">
|
||||
<?php endif; ?>
|
||||
<button type="button" class="ju-button waves-effect waves-light min-w-0 select_default_featured_image"><?php esc_html_e('+ Select', 'wpmf') ?></button>
|
||||
<button type="button" class="ju-button waves-effect waves-light min-w-0 wpmf-remove-featured-image"><?php esc_html_e('Clear', 'wpmf') ?></button>
|
||||
|
||||
</div>
|
||||
<div data-option="random" class="radion_option_content feature_image_dropdown <?php echo ($default_featured_image_type === 'random') ? '' : 'hide' ?>">
|
||||
<label data-wpmftippy="<?php esc_html_e('Use random image from a media folder to be loaded by default in any new post. The image can be replaced by editing it in the post of course', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Select a folder', 'wpmf') ?></label>
|
||||
<!--<select name="featured_image_folder" class="featured_image_folder" data-value="<?php /*echo (int)$featured_image_folder */?>"></select>-->
|
||||
<div class="feature_image_folders tree_option_folders" data-value="<?php echo (int)$featured_image_folder ?>">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--------------------------------------- filter and order ----------------------------------->
|
||||
<div id="media_filtering" class="tab-content">
|
||||
<div class="content-box wpmf-config-gallery">
|
||||
<div id="wpmf_filter_dimension" class="media_filter_block wpmf_left">
|
||||
<ul class="wpmf_filter_dimension wpmf-no-margin">
|
||||
<li class="div_list_child accordion-section control-section control-section-default open">
|
||||
<h3 class="accordion-section-title wpmf-section-title dimension_title"
|
||||
data-title="filldimension"
|
||||
tabindex="0"><?php esc_html_e('List default filter size', 'wpmf') ?>
|
||||
<i class="zmdi zmdi-chevron-up"></i>
|
||||
<i class="zmdi zmdi-chevron-down"></i>
|
||||
</h3>
|
||||
<ul class="content_list_filldimension">
|
||||
<?php
|
||||
if (count($a_dimensions) > 0) :
|
||||
foreach ($a_dimensions as $a_dimension) :
|
||||
?>
|
||||
<li class="wpmf_width_100 ju-settings-option customize-control customize-control-select item_dimension"
|
||||
style="display: list-item;" data-value="<?php echo esc_html($a_dimension); ?>" data-type="default">
|
||||
<div class="wpmf_row_full">
|
||||
<div class="pure-checkbox ju-setting-label">
|
||||
<input title id="<?php echo esc_attr($a_dimension) ?>" type="checkbox"
|
||||
name="dimension[]"
|
||||
value="<?php echo esc_attr($a_dimension) ?>"
|
||||
<?php
|
||||
if (in_array($a_dimension, $array_s_de)) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<label class="lb" for="<?php echo esc_html($a_dimension) ?>"><?php echo esc_html($a_dimension) ?></label>
|
||||
<label class="ju-switch-button">
|
||||
<i class="material-icons wpmf-md-edit"
|
||||
data-label="dimension"
|
||||
data-value="<?php echo esc_html($a_dimension); ?>"
|
||||
title="<?php esc_html_e('Edit dimension', 'wpmf'); ?>">
|
||||
border_color
|
||||
</i>
|
||||
|
||||
<i class="material-icons wpmf-delete" data-label="dimension"
|
||||
data-value="<?php echo esc_html($a_dimension); ?>"
|
||||
title="<?php esc_html_e('Remove dimension', 'wpmf'); ?>">delete_outline</i>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<?php
|
||||
endforeach;
|
||||
endif;
|
||||
?>
|
||||
|
||||
<li class="wpmf_width_100 p-d-20 ju-settings-option customize-control customize-control-select dimension"
|
||||
style="display: list-item;">
|
||||
<div class="wpmf_width_40 wpmf_left">
|
||||
<span class="label_text_bold"><?php esc_html_e('Width', 'wpmf'); ?></span>
|
||||
<label>
|
||||
<input name="wpmf_width_dimension" min="0"
|
||||
class="small-text wpmf_width_dimension"
|
||||
type="number">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="wpmf_width_50 wpmf_right wpmf_text_right">
|
||||
<span class="label_text_bold"><?php esc_html_e('Height', 'wpmf'); ?></span>
|
||||
<label>
|
||||
<input name="wpmf_height_dimension" min="0"
|
||||
class="small-text wpmf_height_dimension"
|
||||
type="number">
|
||||
</label>
|
||||
<span class="label_text_bold m-l-20"><?php esc_html_e('px', 'wpmf'); ?></span>
|
||||
</div>
|
||||
|
||||
<div class="wpmf_width_100">
|
||||
<span
|
||||
class="wpmf_width_100 m-t-30 ju-button no-background orange-button waves-effect waves-light add_dimension" data-type="default">
|
||||
<?php esc_html_e('Add new size', 'wpmf'); ?></span>
|
||||
<span data-label="dimension" id="edit_dimension"
|
||||
class="m-t-10 wpmf_left ju-button orange-button waves-effect waves-light wpmfedit edit_dimension"
|
||||
style="display: none;" data-type="default">
|
||||
<?php esc_html_e('Save', 'wpmf'); ?>
|
||||
</span>
|
||||
<span id="can_dimension"
|
||||
class="m-t-10 wpmf_right ju-button no-background orange-button waves-effect waves-light wpmf_can"
|
||||
data-label="dimension"
|
||||
style="display: none;"><?php esc_html_e('Cancel', 'wpmf'); ?></span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="description">
|
||||
<?php esc_html_e('Image dimension filtering available in filter.
|
||||
Display image with a dimension and above.', 'wpmf'); ?>
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="wpmf_filter_weights" class="media_filter_block wpmf_right">
|
||||
<ul class="wpmf_filter_weight wpmf-no-margin">
|
||||
<li class="div_list_child accordion-section control-section control-section-default open">
|
||||
<h3 class="accordion-section-title wpmf-section-title sizes_title"
|
||||
data-title="fillweight"
|
||||
tabindex="0"><?php esc_html_e('List default filter weight', 'wpmf') ?>
|
||||
<i class="zmdi zmdi-chevron-up"></i>
|
||||
<i class="zmdi zmdi-chevron-down"></i>
|
||||
</h3>
|
||||
<ul class="content_list_fillweight">
|
||||
<?php
|
||||
if (count($a_weights) > 0) :
|
||||
foreach ($a_weights as $a_weight) :
|
||||
$labels = explode('-', $a_weight[0]);
|
||||
if ($a_weight[1] === 'kB') {
|
||||
$label = ($labels[0] / 1024) . ' kB-' . ($labels[1] / 1024) . ' kB';
|
||||
} else {
|
||||
$label = $labels[0] / (1024 * 1024);
|
||||
$label .= ' MB-';
|
||||
$label .= $labels[1] / (1024 * 1024);
|
||||
$label .= ' MB';
|
||||
}
|
||||
?>
|
||||
|
||||
<li class="wpmf_width_100 ju-settings-option customize-control customize-control-select item_weight"
|
||||
style="display: list-item;" data-value="<?php echo esc_html($a_weight[0]); ?>"
|
||||
data-unit="<?php echo esc_html($a_weight[1]); ?>">
|
||||
<div class="wpmf_row_full">
|
||||
<div class="pure-checkbox ju-setting-label">
|
||||
<input title
|
||||
id="<?php echo esc_html($a_weight[0] . ',' . $a_weight[1]) ?>"
|
||||
type="checkbox" name="weight[]"
|
||||
value="<?php echo esc_attr($a_weight[0] . ',' . $a_weight[1]) ?>"
|
||||
data-unit="<?php echo esc_html($a_weight[1]); ?>"
|
||||
<?php
|
||||
if (in_array($a_weight, $array_s_we)) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<label class="lb" for="<?php echo esc_html($a_weight[0] . ',' . $a_weight[1]) ?>">
|
||||
<?php echo esc_html($label) ?>
|
||||
</label>
|
||||
<label class="ju-switch-button">
|
||||
<i class="material-icons wpmf-md-edit" data-label="weight"
|
||||
data-value="<?php echo esc_html($a_weight[0]); ?>"
|
||||
data-unit="<?php echo esc_html($a_weight[1]); ?>"
|
||||
title="<?php esc_html_e('Edit weight', 'wpmf'); ?>">border_color</i>
|
||||
<i class="material-icons wpmf-delete" data-label="weight"
|
||||
data-value="<?php echo esc_html($a_weight[0]); ?>"
|
||||
data-unit="<?php echo esc_html($a_weight[1]); ?>"
|
||||
title="<?php esc_html_e('Remove weight', 'wpmf'); ?>">delete_outline</i>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<?php
|
||||
endforeach;
|
||||
endif;
|
||||
?>
|
||||
|
||||
<li class="wpmf_width_100 p-d-20 ju-settings-option customize-control customize-control-select weight"
|
||||
style="display: list-item;">
|
||||
<div class="wpmf_width_40 wpmf_left">
|
||||
<span class="label_text_bold"><?php esc_html_e('Min', 'wpmf'); ?></span>
|
||||
<label>
|
||||
<input name="wpmf_min_weight" min="0" class="small-text wpmf_min_weight"
|
||||
type="number">
|
||||
</label>
|
||||
</div>
|
||||
<div class="wpmf_width_60 wpmf_right wpmf_text_right">
|
||||
<span class="label_text_bold"><?php esc_html_e('Max', 'wpmf'); ?></span>
|
||||
<label>
|
||||
<input name="wpmf_max_weight" min="0" class="small-text wpmf_max_weight"
|
||||
type="number">
|
||||
</label>
|
||||
<span class="label_text_bold m-l-20">
|
||||
<label>
|
||||
<select class="wpmfunit" data-label="weight">
|
||||
<option value="kB"><?php esc_html_e('kB', 'wpmf'); ?></option>
|
||||
<option value="MB"><?php esc_html_e('MB', 'wpmf'); ?></option>
|
||||
</select>
|
||||
</label>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="wpmf_width_100">
|
||||
<span id="add_weight"
|
||||
class="wpmf_width_100 m-t-30 ju-button no-background orange-button waves-effect waves-light add_weight"><?php esc_html_e('Add weight', 'wpmf'); ?></span>
|
||||
<span data-label="weight" id="edit_weight"
|
||||
class="m-t-10 wpmf_left ju-button orange-button waves-effect waves-light wpmfedit edit_weight"
|
||||
style="display: none;">
|
||||
<?php esc_html_e('Save', 'wpmf'); ?>
|
||||
</span>
|
||||
<span id="can_dimension"
|
||||
class="m-t-10 wpmf_right ju-button no-background orange-button waves-effect waves-light wpmf_can"
|
||||
data-label="weight"
|
||||
style="display: none">
|
||||
<?php esc_html_e('Cancel', 'wpmf'); ?></span>
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
<p class="description">
|
||||
<?php esc_html_e('Select weight range which you would
|
||||
like to display in media library filter', 'wpmf'); ?>
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,310 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
$slug = 'imagerecycle-pdf-image-compression';
|
||||
$plugin_file = 'imagerecycle-pdf-image-compression/wp-image-recycle.php';
|
||||
|
||||
if (isset($_GET['action'])) {
|
||||
if (!file_exists(WP_PLUGIN_DIR . '/imagerecycle-pdf-image-compression')) {
|
||||
$ac = 'install-plugin_' . $slug;
|
||||
} else {
|
||||
$ac = 'activate-plugin_' . $plugin_file;
|
||||
}
|
||||
|
||||
if (empty($_GET['_wpnonce'])
|
||||
|| !wp_verify_nonce($_GET['_wpnonce'], $ac)) {
|
||||
die();
|
||||
}
|
||||
|
||||
if (!defined('IFRAME_REQUEST') && in_array($_GET['action'], array(
|
||||
'update-selected',
|
||||
'activate-plugin',
|
||||
'update-selected-themes'
|
||||
))
|
||||
) {
|
||||
define('IFRAME_REQUEST', true);
|
||||
}
|
||||
|
||||
require_once(ABSPATH . 'wp-admin/admin.php');
|
||||
include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
|
||||
|
||||
$get_plugin = isset($_REQUEST['plugin']) ? trim($_REQUEST['plugin']) : '';
|
||||
$act = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
|
||||
if ('install-plugin' === $act) {
|
||||
/**
|
||||
* Filter check capability of current user to install plugin
|
||||
*
|
||||
* @param boolean The current user has the given capability
|
||||
* @param string Action name
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @ignore Hook already documented
|
||||
*/
|
||||
$wpmf_capability = apply_filters('wpmf_user_can', current_user_can('install_plugins'), 'install_imagerecycle_plugin');
|
||||
if (!$wpmf_capability) {
|
||||
wp_die(esc_html__('You do not have sufficient permissions to install plugins on this site.', 'wpmf'));
|
||||
}
|
||||
include_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); //for plugins_api..
|
||||
$setting_tab_value = 'wpmf-image-compression';
|
||||
check_admin_referer('install-plugin_' . $get_plugin);
|
||||
$api = plugins_api('plugin_information', array(
|
||||
'slug' => $get_plugin,
|
||||
'fields' => array(
|
||||
'short_description' => false,
|
||||
'sections' => false,
|
||||
'requires' => false,
|
||||
'rating' => false,
|
||||
'ratings' => false,
|
||||
'downloaded' => false,
|
||||
'last_updated' => false,
|
||||
'added' => false,
|
||||
'tags' => false,
|
||||
'compatibility' => false,
|
||||
'homepage' => false,
|
||||
'donate_link' => false,
|
||||
),
|
||||
));
|
||||
|
||||
if (is_wp_error($api)) {
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput -- Content already escaped in the method
|
||||
wp_die($api);
|
||||
}
|
||||
|
||||
// phpcs:disable WordPress.WP.GlobalVariablesOverride.Prohibited -- Use to merge params in Plugin_Installer_Skin construct
|
||||
$title = __('Plugin Install', 'wpmf');
|
||||
$parent_file = 'plugins.php';
|
||||
$submenu_file = 'plugin-install.php';
|
||||
$title = sprintf(__('Installing Plugin: %s', 'wpmf'), $api->name . ' ' . $api->version);
|
||||
$nonce = 'install-plugin_' . $get_plugin;
|
||||
$url = 'update.php?action=install-plugin&plugin=' . urlencode($get_plugin);
|
||||
if (isset($_GET['from'])) {
|
||||
$url .= '&from=' . urlencode(stripslashes($_GET['from']));
|
||||
}
|
||||
// phpcs:enable
|
||||
$upgrader = new Plugin_Upgrader(new Plugin_Installer_Skin(compact('title', 'url', 'nonce', 'plugin', 'api')));
|
||||
$upgrader->install($api->download_link);
|
||||
} elseif ('activate' === $act) {
|
||||
/**
|
||||
* Filter check capability of current user to active plugin
|
||||
*
|
||||
* @param boolean The current user has the given capability
|
||||
* @param string Action name
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @ignore Hook already documented
|
||||
*/
|
||||
$wpmf_capability = apply_filters('wpmf_user_can', current_user_can('activate_plugins'), 'active_imagerecycle_plugin');
|
||||
if (!$wpmf_capability) {
|
||||
wp_die(esc_html__('You do not have sufficient permissions to activate plugins for this site.', 'wpmf'));
|
||||
}
|
||||
|
||||
if (is_multisite() && !is_network_admin() && is_network_only_plugin($get_plugin)) {
|
||||
wp_redirect(self_admin_url('plugins.php?plugin_status=' . $status . '&paged=' . $page . '&s=' . $s));
|
||||
exit;
|
||||
}
|
||||
|
||||
check_admin_referer('activate-plugin_' . $get_plugin);
|
||||
|
||||
$result = activate_plugin(
|
||||
$get_plugin,
|
||||
self_admin_url('plugins.php?error=true&plugin=' . $get_plugin),
|
||||
is_network_admin()
|
||||
);
|
||||
if (is_wp_error($result)) {
|
||||
if ('unexpected_output' === $result->get_error_code()) {
|
||||
$u = 'plugins.php?error=true&charsout=' . strlen($result->get_error_data());
|
||||
$u .= '&plugin=' . $get_plugin . '&plugin_status=' . $status . '&paged=' . $page . '&s=' . $s;
|
||||
$redirect = self_admin_url($u);
|
||||
wp_redirect(
|
||||
add_query_arg(
|
||||
'_error_nonce',
|
||||
wp_create_nonce('plugin-activation-error_' . $get_plugin),
|
||||
$redirect
|
||||
)
|
||||
);
|
||||
exit;
|
||||
} else {
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput -- Content already escaped in the method
|
||||
wp_die($result);
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_network_admin()) {
|
||||
$recent = (array) get_option('recently_activated');
|
||||
unset($recent[$get_plugin]);
|
||||
update_option('recently_activated', $recent);
|
||||
} else {
|
||||
$recent = (array) get_site_option('recently_activated');
|
||||
unset($recent[$get_plugin]);
|
||||
update_site_option('recently_activated', $recent);
|
||||
}
|
||||
|
||||
if (isset($_GET['from']) && 'import' === $_GET['from']) {
|
||||
wp_redirect(self_admin_url('import.php?import=' . str_replace('-importer', '', dirname($get_plugin)))); // overrides the ?error=true one above and redirects to the Imports page, stripping the -importer suffix
|
||||
} else {
|
||||
// overrides the ?error=true one above
|
||||
wp_redirect(
|
||||
self_admin_url('options-general.php?page=option-folder')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="content-box content-wpmf-image-compression">
|
||||
<?php if (file_exists(WP_PLUGIN_DIR . '/imagerecycle-pdf-image-compression') && is_plugin_active($plugin_file)) : ?>
|
||||
<div class="main-presentation"
|
||||
style="margin: 0 auto 20px;max-width: 1200px;font-family: helvetica,arial,sans-serif;">
|
||||
<div class="main-textcontent" align="center">
|
||||
<a href="https://www.imagerecycle.com/" target="_blank"> <img
|
||||
src="https://www.imagerecycle.com/images/Notification-mail/logo-image-recycle.png"
|
||||
alt="logo image recycle" width="500" height="84" class="CToWUd"
|
||||
style="display: block; outline: medium none; text-decoration: none;
|
||||
margin-left: auto; margin-right: auto; margin-top:15px;">
|
||||
</a>
|
||||
<p style="background-color: #ffffff; color: #445566; font-family: helvetica,arial,sans-serif;
|
||||
font-size: 24px; line-height: 24px; padding-right: 10px; padding-left: 10px;"
|
||||
align="center"><strong>Great! ImageRecycle is installed<br></strong></p>
|
||||
<p style="background-color: #ffffff; color: #445566; font-family: helvetica,arial,sans-serif;
|
||||
font-size: 14px; line-height: 22px; padding-left: 20px; padding-right: 20px; text-align: center;">
|
||||
<strong>Speed optimization of your WordPress website is highly recommended for SEO. The image
|
||||
compression is one of the tools that help to reduce your page size significantly while
|
||||
preserving the image quality.<br/><br/>You can now manage all you images and compression from
|
||||
the ImageRecycle plugin, menu Media > ImageRecycle.<br/><br/></strong> ImageRecycle got a
|
||||
dedicated plugin for WordPress that run the images optimization automatically on your website &
|
||||
PDF
|
||||
<br/>In order to start the optimization process, please install the WordPress plugin. Enjoy!</p>
|
||||
<p></p>
|
||||
<p>
|
||||
<?php
|
||||
echo '<a style="width: 250px; float: right; background: #554766;
|
||||
line-height: 18px; text-align: center; margin-left:4px;color: #fff;
|
||||
font-size: 14px;text-decoration: none; text-transform: uppercase;
|
||||
padding: 8px 20px; font-weight:bold;"
|
||||
class="edit" href="upload.php?page=wp-image-recycle-page"
|
||||
aria-label="Activate ImageRecycle pdf & image compression">
|
||||
' . esc_html__('ImageRecycle is properly installed: manage images', 'wpmf') . '</a>';
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="main-presentation"
|
||||
style="margin: 0 auto 0;max-width: 1200px; background-color:#fff;
|
||||
font-family: helvetica,arial,sans-serif;">
|
||||
<div class="main-textcontent" align="center">
|
||||
<a href="https://www.imagerecycle.com/" target="_blank"> <img
|
||||
src="https://www.imagerecycle.com/images/Notification-mail/logo-image-recycle.png"
|
||||
alt="logo image recycle" width="500" height="84"
|
||||
style="display: block; outline: medium none; text-decoration: none;
|
||||
margin-left: auto; margin-right: auto; margin-top:15px;">
|
||||
</a>
|
||||
<p style="background-color: #ffffff; color: #445566;
|
||||
font-family: helvetica,arial,sans-serif; font-size: 24px; line-height: 24px;
|
||||
padding-right: 10px; padding-left: 10px;"
|
||||
align="center"><strong>Get faster with lightweight images!<br></strong></p>
|
||||
<p style="background-color: #ffffff; color: #445566;
|
||||
font-family: helvetica,arial,sans-serif; font-size: 14px; line-height: 22px;
|
||||
padding:20px; text-align: center;">
|
||||
<strong>Speed optimization of your WordPress website is highly recommended for SEO. The image
|
||||
compression is one of the tools that help to reduce your page size significantly while
|
||||
preserving the image quality.<br><img
|
||||
src="https://www.imagerecycle.com/images/No-compress/Optimization.gif"
|
||||
alt="optimization"
|
||||
style="display: block; outline: medium none; text-decoration: none;
|
||||
margin-left: auto; margin-right: auto; margin-top:15px;"><br>WP
|
||||
Media Folder is fully integrated with ImageRecycle service, you have a free trial with no
|
||||
engagement and we provide a 20% OFF coupon! Use the coupon here: <a
|
||||
href="https://www.imagerecycle.com/" target="_blank">www.imagerecycle.com</a></strong>
|
||||
</p>
|
||||
<div
|
||||
style="background-color:#fafafa; border: 2px dashed #ccc; border-left: 5px solid #A1B660;
|
||||
font-size: 30px; padding: 20px; line-height: 40px;">
|
||||
ImageRecycle 20% OFF, apply on all memberships: WPMF-20
|
||||
</div>
|
||||
<p style="background-color: #ffffff; color: #445566; font-family: helvetica,arial,sans-serif;
|
||||
font-size: 12px; line-height: 22px; padding-left: 20px; padding-right: 20px;
|
||||
text-align: center; font-style: italic;">
|
||||
ImageRecycle got a dedicated plugin for WordPress that run the images and PDF optimization
|
||||
automatically on your website.
|
||||
<br>In order to start the optimization process, please install the WordPress plugin. Enjoy!</p>
|
||||
<p></p>
|
||||
<p>
|
||||
<?php
|
||||
if (!file_exists(WP_PLUGIN_DIR . '/imagerecycle-pdf-image-compression')) {
|
||||
$url = wp_nonce_url(
|
||||
self_admin_url('options-general.php?page=option-folder&action=install-plugin&plugin=' . $slug),
|
||||
'install-plugin_' . $slug
|
||||
);
|
||||
if (is_multisite()) {
|
||||
/**
|
||||
* Filter check capability of current user to check install plugins on multiple site
|
||||
*
|
||||
* @param boolean The current user has the given capability
|
||||
* @param string Action name
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @ignore Hook already documented
|
||||
*/
|
||||
$wpmf_capability = apply_filters('wpmf_user_can', current_user_can('manage_network_plugins'), 'install_network_imagerecycle_plugins');
|
||||
if ($wpmf_capability) {
|
||||
echo '<a style="float: right; background: #554766;line-height: 18px; text-align: center;
|
||||
color: #fff;font-size: 14px;text-decoration: none; text-transform: uppercase;
|
||||
padding: 5px 20px; font-weight:bold;"
|
||||
target="_blank" class="edit" data-slug="imagerecycle-pdf-image-compression"
|
||||
href="' . esc_html($url) . '" aria-label="Install ImageRecycle pdf & image compression 2.1.1 now"
|
||||
data-name="ImageRecycle pdf & image compression 2.1.1">
|
||||
' . esc_html__('Install ImageRecycle plugin', 'wpmf') . '</a>';
|
||||
}
|
||||
} else {
|
||||
echo '<a style="float: right; background: #554766;line-height: 18px; text-align: center;
|
||||
color: #fff;font-size: 14px;text-decoration: none;
|
||||
text-transform: uppercase; padding: 5px 20px; font-weight:bold;"
|
||||
target="_blank" class="edit" data-slug="imagerecycle-pdf-image-compression"
|
||||
href="' . esc_html($url) . '" aria-label="Install ImageRecycle pdf & image compression 2.1.1 now"
|
||||
data-name="ImageRecycle pdf & image compression 2.1.1">
|
||||
' . esc_html__('Install ImageRecycle plugin', 'wpmf') . '</a>';
|
||||
}
|
||||
} else {
|
||||
if (!is_plugin_active($plugin_file)) {
|
||||
$url = wp_nonce_url(
|
||||
'options-general.php?page=option-folder&action=activate&plugin=' . $plugin_file,
|
||||
'activate-plugin_' . $plugin_file
|
||||
);
|
||||
if (is_multisite()) {
|
||||
/**
|
||||
* Filter check capability of current user to check active plugins on multiple site
|
||||
*
|
||||
* @param boolean The current user has the given capability
|
||||
* @param string Action name
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @ignore Hook already documented
|
||||
*/
|
||||
$wpmf_capability = apply_filters('wpmf_user_can', current_user_can('manage_network_plugins'), 'activate_network_imagerecycle_plugins');
|
||||
if ($wpmf_capability) {
|
||||
echo '<a style="float: right; background: #554766;line-height: 18px;
|
||||
text-align: center; color: #fff;font-size: 14px;text-decoration: none;
|
||||
text-transform: uppercase; padding: 5px 20px; font-weight:bold;"
|
||||
href="' . esc_html($url) . '" class="edit" aria-label="Activate ImageRecycle pdf & image compression">
|
||||
' . esc_html__('Activate Plugin', 'wpmf') . '</a>';
|
||||
}
|
||||
} else {
|
||||
echo '<a style="float: right; background: #554766; line-height: 18px;
|
||||
text-align: center;color: #fff;font-size: 14px;text-decoration: none;
|
||||
text-transform: uppercase; padding: 5px 20px; font-weight:bold;"
|
||||
href="' . esc_html($url) . '" class="edit" aria-label="Activate ImageRecycle pdf & image compression">
|
||||
' . esc_html__('Activate Plugin', 'wpmf') . '</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@@ -0,0 +1,375 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
wp_enqueue_style(
|
||||
'wpmf-mdl',
|
||||
WPMF_PLUGIN_URL . 'assets/css/modal-dialog/mdl-jquery-modal-dialog.css',
|
||||
array(),
|
||||
WPMF_VERSION
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'wpmf-deep_orange',
|
||||
WPMF_PLUGIN_URL . 'assets/css/modal-dialog/material.deep_orange-amber.min.css',
|
||||
array(),
|
||||
WPMF_VERSION
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'wpmf-mdl',
|
||||
WPMF_PLUGIN_URL . 'assets/js/modal-dialog/mdl-jquery-modal-dialog.js',
|
||||
array('jquery'),
|
||||
WPMF_VERSION
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'wpmf-notice-style',
|
||||
WPMF_PLUGIN_URL . 'assets/css/notice_style.css',
|
||||
array(),
|
||||
WPMF_VERSION
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'wpmf-import-external-cats',
|
||||
WPMF_PLUGIN_URL . 'assets/js/imports/import_eml.js',
|
||||
array('jquery'),
|
||||
WPMF_VERSION
|
||||
);
|
||||
$bytes = apply_filters('import_upload_size_limit', wp_max_upload_size());
|
||||
$size = size_format($bytes);
|
||||
?>
|
||||
<div id="wordpress_import" class="tab-content">
|
||||
<div id="server_export" class="wpmf_width_100">
|
||||
<div class="wpmf_width_100 top_bar">
|
||||
<h1><?php echo esc_html__('Library Import/Export', 'wpmf') ?></h1>
|
||||
<p class="import_export_desc description"><?php echo esc_html__('Export and Import your WP Media Folder library (folder and media)', 'wpmf') ?></p>
|
||||
</div>
|
||||
<div class="content-box">
|
||||
<div class="ju-settings-option wpmf_width_100 p-tb-20">
|
||||
<label data-wpmftippy="Select what do you want to export and run to generate a file that you will import on another website"
|
||||
class="ju-setting-label text wpmftippy"><?php esc_html_e('Export Media/Folders', 'wpmf'); ?></label>
|
||||
<select name="export_folder_type" class="ju-select export_folder_type">
|
||||
<option value="all" <?php selected($export_folder_type, 'all') ?>><?php esc_html_e('All folders and media', 'wpmf'); ?></option>
|
||||
<option value="only_folder" <?php selected($export_folder_type, 'only_folder') ?>><?php esc_html_e('Only the folder structure', 'wpmf'); ?></option>
|
||||
<option value="selection_folder" <?php selected($export_folder_type, 'selection_folder') ?>><?php esc_html_e('A selection of folders and media', 'wpmf'); ?></option>
|
||||
</select>
|
||||
<input type="hidden" name="wpmf_export_folders" class="wpmf_export_folders">
|
||||
<a href="#open_export_tree_folders"
|
||||
class="ju-button no-background open_export_tree_folders <?php echo ($export_folder_type === 'selection_folder') ? 'show' : 'hide' ?>"><?php esc_html_e('Select folders', 'wpmf'); ?></a>
|
||||
<a href="<?php echo esc_url(admin_url('options-general.php?page=option-folder&action=wpmf_export&wpmf_nonce=' . wp_create_nonce('wpmf_nonce') . '#server_export')) ?>"
|
||||
class="ju-button export_folder_btn no-background orange-button waves-effect waves-light"><?php esc_html_e('Run export', 'wpmf'); ?></a>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_width_100 p-tb-20">
|
||||
<div class="wpmf_width_100">
|
||||
<label data-wpmftippy="Browse and select the file you've previously exported to run the media & folders import"
|
||||
class="ju-setting-label text wpmftippy"><?php esc_html_e('Import Media/Folders', 'wpmf'); ?></label>
|
||||
<input type="file" name="import" class="wpmf_import_folders">
|
||||
<input type="hidden" name="max_file_size" value="<?php echo esc_attr($bytes); ?>"/>
|
||||
<button name="import_folders_btn" type="submit"
|
||||
class="ju-button import_folder_btn no-background orange-button waves-effect waves-light"
|
||||
data-path="<?php echo (!empty($path)) ? esc_attr($path) : '' ?>"
|
||||
data-id="<?php echo (!empty($id)) ? esc_attr($id) : '' ?>"
|
||||
data-import_only_folder="<?php echo (!empty($import_only_folder)) ? esc_attr($import_only_folder) : '' ?>">
|
||||
<?php esc_html_e('Run import', 'wpmf'); ?>
|
||||
</button>
|
||||
</div>
|
||||
<div class="wpmf_width_100 p-lr-20 info-export-wrap">
|
||||
<label class="wpmftippy"
|
||||
data-wpmftippy="<?php esc_html_e('Server values are upload_max_filesize and post_max_size', 'wpmf'); ?>">
|
||||
<?php
|
||||
printf(esc_html__('Maximum size, server value: %s', 'wpmf'), esc_html($size));
|
||||
?>
|
||||
</label>
|
||||
|
||||
<?php if (apply_filters('import_allow_import_only_folder', true)) : ?>
|
||||
<p>
|
||||
<input type="checkbox" value="1" name="import_only_folder" id="import-attachments" checked/>
|
||||
<label for="import-attachments"><?php esc_html_e('Import only folder structure (not media)', 'wpmf'); ?></label>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<div class="import_error_message_wrap">
|
||||
<?php
|
||||
if (isset($error_message) && $error_message !== '') {
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput -- Content already escaped in the method
|
||||
echo '<div class="import_error_message">' . $error_message . '</div>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="white-popup mfp-hide" id="open_export_tree_folders">
|
||||
<div class="export_tree_folders"></div>
|
||||
<button class="ju-button save_export_folders orange-button"><?php esc_html_e('Save', 'wpmf'); ?></button>
|
||||
<span class="spinner save_export_folders_spinner"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="wpmf_width_100 top_bar">
|
||||
<h1><?php echo esc_html__('Import server folders', 'wpmf') ?></h1>
|
||||
</div>
|
||||
<div class="content-box">
|
||||
<div class="ju-settings-option wpmf_width_100 p-d-20 btnoption">
|
||||
<p class="description">
|
||||
<?php esc_html_e('Import folder structure and media from your
|
||||
server in the standard WordPress media manager', 'wpmf'); ?>
|
||||
<br><span class="text-orange"
|
||||
style="word-break: break-all;"><?php echo esc_html($allow_sync_extensions) ?></span>
|
||||
</p>
|
||||
<div class="wpmf_row_full">
|
||||
<div id="wpmf_foldertree" class="wpmf-no-padding"></div>
|
||||
<div class="wpmf-process-bar-full process_import_ftp_full" style="">
|
||||
<div class="wpmf-process-bar process_import_ftp" data-w="0"></div>
|
||||
</div>
|
||||
<button type="button"
|
||||
class="ju-button no-background orange-button waves-effect waves-light import_ftp_button"
|
||||
style="padding: 8.5px 15px">
|
||||
<label style="line-height: 20px"><?php esc_html_e('Import Folder', 'wpmf'); ?></label>
|
||||
<span class="spinner" style="display:none; margin: 0; vertical-align: middle"></span>
|
||||
</button>
|
||||
<span class="info_import"><?php esc_html_e('Imported!', 'wpmf'); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
/**
|
||||
* Filter check capability of current user to show import categories button
|
||||
*
|
||||
* @param boolean The current user has the given capability
|
||||
* @param string Action name
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @ignore Hook already documented
|
||||
*/
|
||||
$wpmf_capability = apply_filters('wpmf_user_can', current_user_can('manage_options'), 'show_import_categories_button');
|
||||
if ($wpmf_capability) :
|
||||
?>
|
||||
<div id="server_import">
|
||||
<div class="wpmf_width_100 top_bar">
|
||||
<h1><?php echo esc_html__('Import WP media categories', 'wpmf') ?></h1>
|
||||
</div>
|
||||
<div class="content-box">
|
||||
<div class="ju-settings-option wpmf_width_100 p-d-20">
|
||||
<p class="description">
|
||||
<?php esc_html_e('Import current media and post categories as media folders', 'wpmf'); ?>
|
||||
</p>
|
||||
<p>
|
||||
<button type="button"
|
||||
class="ju-button no-background orange-button waves-effect waves-light wmpf_import_category"
|
||||
style="padding: 8.5px 15px">
|
||||
<label style="line-height: 20px"><?php esc_html_e('Import Now', 'wpmf'); ?></label>
|
||||
<span class="spinner" style="display:none; margin: 0; vertical-align: middle"></span>
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
$folders = array();
|
||||
?>
|
||||
<div id="other_plugin_import" class="tab-content">
|
||||
<?php
|
||||
$find = false;
|
||||
$total = $wpdb->get_var('SELECT COUNT(term_id) as total FROM ' . $wpdb->term_taxonomy . ' WHERE taxonomy = "media_category"');
|
||||
if ($total > 0) :
|
||||
$eml_categories = $wpdb->get_results('SELECT * FROM ' . $wpdb->terms . ' as t INNER JOIN ' . $wpdb->term_taxonomy . ' AS tt ON tt.term_id = t.term_id WHERE taxonomy = "media_category"');
|
||||
$eml_categories = Joomunited\WPMediaFolder\wpmfHelper::parentSort($eml_categories);
|
||||
$fs = Joomunited\WPMediaFolder\wpmfHelper::loadImportExternalCatsScript($eml_categories, 'media_category');
|
||||
$folders = array_merge($folders, $fs);
|
||||
$find = true;
|
||||
?>
|
||||
<div class="tab-content">
|
||||
<div class="wpmf_width_100 top_bar">
|
||||
<h1><?php echo esc_html__('Import Enhanced Media Library media and folders', 'wpmf') ?></h1>
|
||||
</div>
|
||||
<div class="content-box">
|
||||
<div class="ju-settings-option wpmf_width_100 p-d-20">
|
||||
<p class="description">
|
||||
<?php echo sprintf(esc_html__('We found that you have %d media folders in Enhanced Media Library plugin. Would you like to import media and folders in your media library?', 'wpmf'), esc_html($total)) ?>
|
||||
</p>
|
||||
<p>
|
||||
<button type="button"
|
||||
class="ju-button no-background orange-button waves-effect waves-light open_import_eml open_import_external_cats"
|
||||
style="margin-left: 0 !important;" data-cat-name="media_category"><?php esc_html_e('Import Now', 'wpmf'); ?></button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$total = $wpdb->get_var('SELECT COUNT(term_id) as total FROM ' . $wpdb->term_taxonomy . ' WHERE taxonomy = "happyfiles_category"');
|
||||
if ($total > 0) :
|
||||
$happy_categories = $wpdb->get_results('SELECT * FROM ' . $wpdb->terms . ' as t INNER JOIN ' . $wpdb->term_taxonomy . ' AS tt ON tt.term_id = t.term_id WHERE taxonomy = "happyfiles_category"');
|
||||
$happy_categories = Joomunited\WPMediaFolder\wpmfHelper::parentSort($happy_categories);
|
||||
$fs = Joomunited\WPMediaFolder\wpmfHelper::loadImportExternalCatsScript($happy_categories, 'happyfiles_category');
|
||||
$folders = array_merge($folders, $fs);
|
||||
$find = true;
|
||||
?>
|
||||
<div class="tab-content">
|
||||
<div class="wpmf_width_100 top_bar">
|
||||
<h1><?php echo esc_html__('Import HappyFiles media and folders', 'wpmf') ?></h1>
|
||||
</div>
|
||||
<div class="content-box">
|
||||
<div class="ju-settings-option wpmf_width_100 p-d-20">
|
||||
<p class="description">
|
||||
<?php echo sprintf(esc_html__('We found that you have %d media folders in HappyFiles plugin. Would you like to import media and folders in your media library?', 'wpmf'), esc_html($total)) ?>
|
||||
</p>
|
||||
<p>
|
||||
<button type="button"
|
||||
class="ju-button no-background orange-button waves-effect waves-light open_import_eml open_import_external_cats"
|
||||
style="margin-left: 0 !important;" data-cat-name="happyfiles_category"><?php esc_html_e('Import Now', 'wpmf'); ?></button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$table_name = $wpdb->prefix . 'realmedialibrary';
|
||||
if ($wpdb->get_var('show tables like "'. $wpdb->prefix .'realmedialibrary"') === $table_name) {
|
||||
$total = $wpdb->get_var('SELECT COUNT(id) as total FROM ' . $wpdb->prefix . 'realmedialibrary');
|
||||
if ($total > 0) :
|
||||
$rml_categories = $wpdb->get_results('SELECT id as term_id, name, parent FROM ' . $wpdb->prefix . 'realmedialibrary');
|
||||
$rml_categories = Joomunited\WPMediaFolder\wpmfHelper::parentSort($rml_categories);
|
||||
$fs = Joomunited\WPMediaFolder\wpmfHelper::loadImportExternalCatsScript($rml_categories, 'real_media_library');
|
||||
$folders = array_merge($folders, $fs);
|
||||
$find = true;
|
||||
?>
|
||||
<div class="wpmf_width_100">
|
||||
<div class="wpmf_width_100 top_bar">
|
||||
<h1><?php echo esc_html__('Import Real Media Library media and folders', 'wpmf') ?></h1>
|
||||
</div>
|
||||
<div class="content-box">
|
||||
<div class="ju-settings-option wpmf_width_100 p-d-20">
|
||||
<p class="description">
|
||||
<?php echo sprintf(esc_html__('We found that you have %d media folders in Real Media Library plugin. Would you like to import media and folders in your media library?', 'wpmf'), esc_html($total)) ?>
|
||||
</p>
|
||||
<p><button type="button" class="ju-button no-background orange-button waves-effect waves-light open_import_fbv open_import_external_cats" data-cat-name="rml_category" style="margin-left: 0 !important;"><?php esc_html_e('Import Now', 'wpmf'); ?></button></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
||||
<?php
|
||||
$table_name = $wpdb->prefix . 'fbv';
|
||||
if ($wpdb->get_var('show tables like "'. $wpdb->prefix .'fbv"') === $table_name) {
|
||||
$total = $wpdb->get_var('SELECT COUNT(id) as total FROM ' . $wpdb->prefix . 'fbv');
|
||||
if ($total > 0) :
|
||||
$fbv_categories = $wpdb->get_results('SELECT id as term_id, name, parent FROM ' . $wpdb->prefix . 'fbv');
|
||||
$fbv_categories = Joomunited\WPMediaFolder\wpmfHelper::parentSort($fbv_categories);
|
||||
$fs = Joomunited\WPMediaFolder\wpmfHelper::loadImportExternalCatsScript($fbv_categories, 'filebird');
|
||||
$folders = array_merge($folders, $fs);
|
||||
$find = true;
|
||||
?>
|
||||
<div class="wpmf_width_100">
|
||||
<div class="wpmf_width_100 top_bar">
|
||||
<h1><?php echo esc_html__('Import FileBird media and folders', 'wpmf') ?></h1>
|
||||
</div>
|
||||
<div class="content-box">
|
||||
<div class="ju-settings-option wpmf_width_100 p-d-20">
|
||||
<p class="description">
|
||||
<?php echo sprintf(esc_html__('We found that you have %d media folders in FileBird plugin. Would you like to import media and folders in your media library?', 'wpmf'), esc_html($total)) ?>
|
||||
</p>
|
||||
<p><button type="button" class="ju-button no-background orange-button waves-effect waves-light open_import_fbv open_import_external_cats" data-cat-name="filebird" style="margin-left: 0 !important;"><?php esc_html_e('Import Now', 'wpmf'); ?></button></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
||||
<?php
|
||||
$total = $wpdb->get_var('SELECT COUNT(term_id) as total FROM ' . $wpdb->term_taxonomy . ' WHERE taxonomy = "media_folder"');
|
||||
if ($total > 0) :
|
||||
$eml_categories = $wpdb->get_results('SELECT * FROM ' . $wpdb->terms . ' as t INNER JOIN ' . $wpdb->term_taxonomy . ' AS tt ON tt.term_id = t.term_id WHERE taxonomy = "media_folder"');
|
||||
$eml_categories = Joomunited\WPMediaFolder\wpmfHelper::parentSort($eml_categories);
|
||||
$fs = Joomunited\WPMediaFolder\wpmfHelper::loadImportExternalCatsScript($eml_categories, 'media_folder');
|
||||
$folders = array_merge($folders, $fs);
|
||||
$find = true;
|
||||
?>
|
||||
<div class="wpmf_width_100">
|
||||
<div class="wpmf_width_100 top_bar">
|
||||
<h1><?php echo esc_html__('Import Folders media and folders', 'wpmf') ?></h1>
|
||||
</div>
|
||||
<div class="content-box">
|
||||
<div class="ju-settings-option wpmf_width_100 p-d-20">
|
||||
<p class="description">
|
||||
<?php echo sprintf(esc_html__('We found that you have %d media folders in Folders plugin. Would you like to import media and folders in your media library?', 'wpmf'), esc_html($total)) ?>
|
||||
</p>
|
||||
<p><button type="button" class="ju-button no-background orange-button waves-effect waves-light open_import_fbv open_import_external_cats" data-cat-name="media_folder" style="margin-left: 0 !important;"><?php esc_html_e('Import Now', 'wpmf'); ?></button></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
/**
|
||||
* Filter check capability of current user to show import categories button
|
||||
*
|
||||
* @param boolean The current user has the given capability
|
||||
* @param string Action name
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @ignore Hook already documented
|
||||
*/
|
||||
$wpmf_capability = apply_filters('wpmf_user_can', current_user_can('manage_options'), 'show_import_nextgen_gallery_button');
|
||||
if ($wpmf_capability && defined('NGG_PLUGIN_VERSION')) :
|
||||
$find = true;
|
||||
?>
|
||||
<div id="server_import" class="tab-content">
|
||||
<div class="wpmf_width_100 top_bar">
|
||||
<h1><?php echo esc_html__('Sync/Import NextGEN galleries', 'wpmf') ?></h1>
|
||||
</div>
|
||||
<div class="content-box">
|
||||
<div class="ju-settings-option wpmf_width_100 p-d-20">
|
||||
<p class="description">
|
||||
<?php esc_html_e('Import nextGEN albums as image in folders in the media manager.
|
||||
You can then create new galleries from WordPress media manager', 'wpmf'); ?>
|
||||
</p>
|
||||
<p>
|
||||
<button type="button"
|
||||
class="ju-button no-background orange-button waves-effect waves-light btn_import_gallery"
|
||||
style="padding: 8.5px 15px">
|
||||
<label style="line-height: 20px"><?php esc_html_e('Import Now', 'wpmf'); ?></label>
|
||||
<span class="spinner" style="display:none; margin: 0; vertical-align: middle"></span>
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
if (!$find) {
|
||||
echo '<p class="description" style="text-align: center">'. esc_html__('No supported plugin detected, plugin supported are: WP Real media library, Filebird, Folders, Media library plus, HappyFiles plugins', 'wpmf') .'</p>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
global $pagenow;
|
||||
$vars = array(
|
||||
'ajaxurl' => admin_url('admin-ajax.php'),
|
||||
'pagenow' => $pagenow,
|
||||
'wpmf_nonce' => wp_create_nonce('wpmf_nonce')
|
||||
);
|
||||
|
||||
|
||||
$params = array('l18n' => array(
|
||||
'import_all_label' => esc_html__('Import All', 'wpmf'),
|
||||
'import_selected_label' => esc_html__('Import selected', 'wpmf'),
|
||||
'cancel_label' => esc_html__('Cancel', 'wpmf'),
|
||||
'eml_label_dialog' => esc_html__('Import categories from Enhanced Media Library plugin', 'wpmf'),
|
||||
'happyfiles_label_dialog' => esc_html__('Import categories from HappyFiles plugin', 'wpmf'),
|
||||
'rml_label_dialog' => esc_html__('Import categories from Real Media Library plugin', 'wpmf'),
|
||||
'fbv_label_dialog' => esc_html__('Import categories from FileBird plugin', 'wpmf'),
|
||||
'mf_label_dialog' => esc_html__('Import categories from Folders plugin', 'wpmf'),
|
||||
), 'vars' => array_merge($vars, $folders));
|
||||
wp_localize_script('wpmf-import-external-cats', 'import_external_cats_objects', $params);
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
?>
|
||||
<div style="margin: 0; float: left">
|
||||
<?php \Joomunited\WPMediaFolder\Jutranslation\Jutranslation::getInput(); ?>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,333 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
?>
|
||||
<div id="user_media_access" class="tab-content">
|
||||
<div class="content-box content-wpmf-media-access">
|
||||
<div class="ju-settings-option">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wpmf_active_media" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Once user upload some media, he will have a
|
||||
personal folder, can be per User or per User Role', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Media access by User or User Role', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="wpmf_active_media" value="1"
|
||||
<?php
|
||||
if (isset($active_media) && (int)$active_media === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_right m-r-0">
|
||||
<div class="wpmf_row_full">
|
||||
<label data-wpmftippy="<?php esc_html_e('Automatically create a
|
||||
folder per User or per WordPress User Role', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Folder automatic creation', 'wpmf') ?></label>
|
||||
<label class="line-height-50 wpmf_right p-r-20">
|
||||
<select name="wpmf_create_folder">
|
||||
<option
|
||||
<?php selected($create_folder, 'user'); ?> value="user">
|
||||
<?php esc_html_e('By user', 'wpmf') ?>
|
||||
</option>
|
||||
<option
|
||||
<?php selected($create_folder, 'role'); ?> value="role">
|
||||
<?php esc_html_e('By role', 'wpmf') ?>
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option">
|
||||
<h4 data-wpmftippy="<?php esc_html_e('Select the root folder to store all user media and
|
||||
folders (only if Media by User or User Role is activated above)', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('User media folder root', 'wpmf') ?></h4>
|
||||
<div class="wpmf_row_full">
|
||||
<span id="wpmfjaouser"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_right m-r-0">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="all_media_in_user_root" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('If activated the user will also be able to see the media uploaded by others in his own folder (additionally to his own media). If not activated, he\'ll see only his own media', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Display all media in user folder', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="all_media_in_user_root" value="1"
|
||||
<?php
|
||||
if (isset($all_media_in_user_root) && (int)$all_media_in_user_root === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="file_design" class="tab-content">
|
||||
<div class="content-box content-wpmf-media-access">
|
||||
<div class="ju-settings-option">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wpmf_option_singlefile" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('When enabling this option you will have the possibility to transform media file links (like .pdf, .doc... into a nice download button. Setup the button design below', 'wpmf'); ?>"
|
||||
class="ju-setting-label text">
|
||||
<?php esc_html_e('Single media download', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="wpmf_option_singlefile"
|
||||
value="1"
|
||||
<?php
|
||||
if (isset($option_singlefile) && (int)$option_singlefile === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="p-d-20 ju-settings-option wpmf_width_100">
|
||||
<h4 style="font-size: 20px"><?php esc_html_e('Color Theme', 'wpmf') ?></h4>
|
||||
<div class="wpmf_width_100">
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text"
|
||||
for="singlebg"><?php esc_html_e('Background color', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input name="wpmf_color_singlefile[bgdownloadlink]" type="text"
|
||||
value="<?php echo esc_attr($media_download['bgdownloadlink']) ?>"
|
||||
class="inputbox input-block-level wp-color-field-bg wp-color-picker">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text"
|
||||
for="singlebg"><?php esc_html_e('Hover color', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input name="wpmf_color_singlefile[hvdownloadlink]" type="text"
|
||||
value="<?php echo esc_attr($media_download['hvdownloadlink']) ?>"
|
||||
class="inputbox input-block-level wp-color-field-hv wp-color-picker">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_width_20 wpmf-no-shadow">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text"
|
||||
for="singlebg"><?php esc_html_e('Font color', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input name="wpmf_color_singlefile[fontdownloadlink]" type="text"
|
||||
value="<?php echo esc_attr($media_download['fontdownloadlink']) ?>"
|
||||
class="inputbox input-block-level wp-color-field-font wp-color-picker">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_width_20 wpmf-no-shadow">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text"
|
||||
for="singlebg"><?php esc_html_e('Hover font color', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input name="wpmf_color_singlefile[hoverfontcolor]" type="text"
|
||||
value="<?php echo esc_attr($media_download['hoverfontcolor']) ?>"
|
||||
class="inputbox input-block-level wp-color-field-hvfont wp-color-picker">
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="p-d-20 ju-settings-option wpmf_width_100">
|
||||
<h4 style="font-size: 20px"><?php esc_html_e('Icon', 'wpmf') ?></h4>
|
||||
<div class="wpmf_width_100 m-b-20">
|
||||
<?php
|
||||
$media_icons = array(
|
||||
'download_style_0' => array('label' => esc_html__('Default', 'wpmf'), 'url' => WPMF_PLUGIN_URL . 'assets/images/setting_download_style_0.svg'),
|
||||
'download_style_1' => array('label' => esc_html__('Style 1', 'wpmf'), 'url' => WPMF_PLUGIN_URL . 'assets/images/setting_download_style_1.svg'),
|
||||
'download_style_2' => array('label' => esc_html__('Style 2', 'wpmf'), 'url' => WPMF_PLUGIN_URL . 'assets/images/setting_download_style_2.svg'),
|
||||
'download_style_3' => array('label' => esc_html__('Style 3', 'wpmf'), 'url' => WPMF_PLUGIN_URL . 'assets/images/setting_download_style_3.svg'),
|
||||
'download_style_4' => array('label' => esc_html__('Style 4', 'wpmf'), 'url' => WPMF_PLUGIN_URL . 'assets/images/setting_download_style_4.svg')
|
||||
);
|
||||
foreach ($media_icons as $media_icon => $media_icon_url) :
|
||||
?>
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20 wpmf-media-icons">
|
||||
<div class="wpmf-media-icon">
|
||||
<img src="<?php echo esc_url($media_icon_url['url']) ?>">
|
||||
<div class="wpmf-media-icon-radio">
|
||||
<label class="radio">
|
||||
<input name="wpmf_color_singlefile[icon_image]" type="radio"
|
||||
value="<?php echo esc_attr($media_icon) ?>"
|
||||
class="inputbox input-block-level" <?php checked($media_download['icon_image'], $media_icon) ?>>
|
||||
<span class="outer"><span
|
||||
class="inner"></span></span><?php echo esc_html($media_icon_url['label']) ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="wpmf_width_100">
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text"
|
||||
for="singlebg"><?php esc_html_e('Icon color', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input name="wpmf_color_singlefile[icon_color]" type="text"
|
||||
value="<?php echo esc_attr($media_download['icon_color']) ?>"
|
||||
class="inputbox input-block-level wp-color-field-icon-color wp-color-picker">
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="p-d-20 ju-settings-option wpmf_width_100">
|
||||
<h4 style="font-size: 20px"><?php esc_html_e('Border', 'wpmf') ?></h4>
|
||||
<div class="wpmf_width_100">
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text"
|
||||
for="singlebg"><?php esc_html_e('Border radius', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input name="wpmf_color_singlefile[border_radius]" type="number"
|
||||
value="<?php echo esc_attr($media_download['border_radius']) ?>"
|
||||
class="inputbox input-block-level">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text"
|
||||
for="singlebg"><?php esc_html_e('Border width', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input name="wpmf_color_singlefile[border_width]" type="number"
|
||||
value="<?php echo esc_attr($media_download['border_width']) ?>"
|
||||
class="inputbox input-block-level">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text"
|
||||
for="singlebg"><?php esc_html_e('Border type', 'wpmf') ?></label>
|
||||
<label>
|
||||
<select name="wpmf_color_singlefile[border_type]">
|
||||
<option value="solid" <?php selected($media_download['border_type'], 'solid') ?>><?php esc_html_e('Solid', 'wpmf') ?></option>
|
||||
<option value="double" <?php selected($media_download['border_type'], 'double') ?>><?php esc_html_e('Double', 'wpmf') ?></option>
|
||||
<option value="dotted" <?php selected($media_download['border_type'], 'dotted') ?>><?php esc_html_e('Dotted', 'wpmf') ?></option>
|
||||
<option value="dashed" <?php selected($media_download['border_type'], 'dashed') ?>><?php esc_html_e('Dashed', 'wpmf') ?></option>
|
||||
<option value="groove" <?php selected($media_download['border_type'], 'groove') ?>><?php esc_html_e('Groove', 'wpmf') ?></option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text"
|
||||
for="singlebg"><?php esc_html_e('Border color', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input name="wpmf_color_singlefile[border_color]" type="text"
|
||||
value="<?php echo esc_attr($media_download['border_color']) ?>"
|
||||
class="inputbox input-block-level wp-color-field-border-color wp-color-picker">
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="p-d-20 ju-settings-option wpmf_width_100">
|
||||
<h4 style="font-size: 20px"><?php esc_html_e('Margin', 'wpmf') ?></h4>
|
||||
<div class="wpmf_width_100">
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text"
|
||||
for="singlebg"><?php esc_html_e('Margin top', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input name="wpmf_color_singlefile[margin_top]" type="number"
|
||||
value="<?php echo esc_attr($media_download['margin_top']) ?>"
|
||||
class="inputbox input-block-level">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text"
|
||||
for="singlebg"><?php esc_html_e('Margin right', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input name="wpmf_color_singlefile[margin_right]" type="number"
|
||||
value="<?php echo esc_attr($media_download['margin_right']) ?>"
|
||||
class="inputbox input-block-level">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text"
|
||||
for="singlebg"><?php esc_html_e('Margin bottom', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input name="wpmf_color_singlefile[margin_bottom]" type="number"
|
||||
value="<?php echo esc_attr($media_download['margin_bottom']) ?>"
|
||||
class="inputbox input-block-level">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text"
|
||||
for="singlebg"><?php esc_html_e('Margin left', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input name="wpmf_color_singlefile[margin_left]" type="number"
|
||||
value="<?php echo esc_attr($media_download['margin_left']) ?>"
|
||||
class="inputbox input-block-level">
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="p-d-20 ju-settings-option wpmf_width_100">
|
||||
<h4 style="font-size: 20px"><?php esc_html_e('Padding', 'wpmf') ?></h4>
|
||||
<div class="wpmf_width_100">
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text"
|
||||
for="singlebg"><?php esc_html_e('Padding top', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input name="wpmf_color_singlefile[padding_top]" type="number"
|
||||
value="<?php echo esc_attr($media_download['padding_top']) ?>"
|
||||
class="inputbox input-block-level">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text"
|
||||
for="singlebg"><?php esc_html_e('Padding right', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input name="wpmf_color_singlefile[padding_right]" type="number"
|
||||
value="<?php echo esc_attr($media_download['padding_right']) ?>"
|
||||
class="inputbox input-block-level">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text"
|
||||
for="singlebg"><?php esc_html_e('Padding bottom', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input name="wpmf_color_singlefile[padding_bottom]" type="number"
|
||||
value="<?php echo esc_attr($media_download['padding_bottom']) ?>"
|
||||
class="inputbox input-block-level">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow wpmf_width_20">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text"
|
||||
for="singlebg"><?php esc_html_e('Padding left', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input name="wpmf_color_singlefile[padding_left]" type="number"
|
||||
value="<?php echo esc_attr($media_download['padding_left']) ?>"
|
||||
class="inputbox input-block-level">
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
wp_enqueue_style('wp-color-picker');
|
||||
wp_enqueue_script('wp-color-picker');
|
||||
?>
|
||||
@@ -0,0 +1,205 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
include_once WP_MEDIA_FOLDER_PLUGIN_DIR . 'class/physical-folder' . DIRECTORY_SEPARATOR . 'helper.php';
|
||||
global $wpdb;
|
||||
// phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared -- No variable needs to be prepared
|
||||
$folder_fields = JUQueueHelper::getDbColumns(true);
|
||||
$tables = wpmfGetOption('wp-media-folder-tables');
|
||||
$folder_options = get_option('wpmf_queue_options');
|
||||
if (empty($folder_options)) {
|
||||
$folder_options = array(
|
||||
'enable_physical_folders' => 0,
|
||||
'auto_detect_tables' => 1,
|
||||
'replace_relative_paths' => (get_option('uploads_use_yearmonth_folders')) ? 1 : 0,
|
||||
'search_full_database' => 0,
|
||||
'mode_debug' => 0
|
||||
);
|
||||
}
|
||||
?>
|
||||
<div id="physical_server_folders" class="tab-content">
|
||||
<div class="content-box">
|
||||
<div id="wpmf-disclaimer">
|
||||
<h2><?php esc_html_e('Please read this disclaimer first', 'wpmf') ?></h2>
|
||||
<p>
|
||||
<?php esc_html_e('This feature will move WordPress media inside real folders and edit filenames.
|
||||
In its default version it will allow you to edit the file path and name through the image edition in the
|
||||
WordPress default media manager.', 'wpmf') ?>
|
||||
</p>
|
||||
<h2><?php esc_html_e('Important restrictions', 'wpmf') ?></h2>
|
||||
<p>
|
||||
<?php esc_html_e('WordPress has not been designed to allow changing the path of files. You should use this feature only if
|
||||
you
|
||||
really need it but note that:', 'wpmf') ?>
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<strong><?php esc_html_e('Moving images won\'t help your SEO', 'wpmf') ?></strong> <?php esc_html_e('like other would expect you to believe, file name and Alt information are far more important.', 'wpmf') ?>
|
||||
</li>
|
||||
<li>
|
||||
<?php esc_html_e('Even if the plugin will try its best to find and replace URLs of files in your database, depending on how other plugins deals with URLs, it may fail', 'wpmf') ?>
|
||||
</li>
|
||||
<li><?php esc_html_e('The process of replacing requires strong server performances and the more content you have the more powerful your server has to be', 'wpmf') ?>
|
||||
</li>
|
||||
<li><strong><?php esc_html_e('Always make backups of your website before any modification', 'wpmf') ?></strong></li>
|
||||
</ul>
|
||||
<h2><?php esc_html_e('Important features restrictions', 'wpmf') ?></h2>
|
||||
<p><?php esc_html_e('Instead of using WordPress custom taxonomy, create physical folders for your media. This setting needs to activated only by experienced users as it breaks compatibility with other plugin features like', 'wpmf') ?></p>
|
||||
<ul>
|
||||
<li><?php esc_html_e('Keeping link to media when renaming folder and files', 'wpmf') ?></li>
|
||||
<li><?php esc_html_e('Large folder move', 'wpmf') ?></li>
|
||||
<li><?php esc_html_e('Media and folder import and synchronization', 'wpmf') ?></li>
|
||||
<li><?php esc_html_e('Media multiple folder', 'wpmf') ?></li>
|
||||
<li><?php esc_html_e('Undo modification...', 'wpmf') ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wp-media-folder-options[enable_physical_folders]" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('WARNING: Instead of using WordPress custom taxonomy, create physical folders for your media. Some features of the plugin will be disabled as they\'re not compatible with the setting! (Read more above)', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Enable physical folders', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="wp-media-folder-options[enable_physical_folders]"
|
||||
value="1"
|
||||
<?php
|
||||
echo (!empty($folder_options['enable_physical_folders'])) ? 'checked' : '';
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="ju-settings-option wpmf_right m-r-0">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wp-media-folder-options[auto_detect_tables]" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('The plugin will auto select the tables and columns where the replacement of attachments (media) URLs should be proceeded. This is the better option if you want to make sure to not lose replacements. Disable this option if you know what you’re doing and want to select custom data set to optimize the process.', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Detect media tables to replace content', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="wp-media-folder-options[auto_detect_tables]"
|
||||
value="1"
|
||||
<?php
|
||||
if (!empty($folder_options['auto_detect_tables'])) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="table_replace"
|
||||
style="<?php echo !empty($folder_options['auto_detect_tables']) ? 'display:none' : ''; ?>">
|
||||
<p>
|
||||
<strong><?php esc_html_e('Tables to replace content into', 'wpmf'); ?></strong><br/>
|
||||
<?php esc_html_e('Select the tables which you want the images url to be replaced into', 'wpmf'); ?>
|
||||
</p>
|
||||
<div class="container">
|
||||
<?php
|
||||
$last_table = '';
|
||||
foreach ($folder_fields as $field) :
|
||||
if ($last_table !== $field->TABLE_NAME) :
|
||||
if ($last_table !== '') {
|
||||
echo '</div>';
|
||||
}
|
||||
$last_table = $field->TABLE_NAME; ?>
|
||||
<div class="database-table"><h2><?php echo esc_html($last_table); ?></h2>
|
||||
<?php endif; ?>
|
||||
<div class="database-field">
|
||||
<span><?php echo esc_html($field->COLUMN_NAME); ?></span>
|
||||
<span><input
|
||||
type="checkbox"
|
||||
name="wp-media-folder-tables[<?php echo esc_html($last_table); ?>][<?php echo esc_html($field->COLUMN_NAME); ?>]"
|
||||
<?php echo isset($tables[$last_table][$field->COLUMN_NAME]) ? 'checked' : ''; ?>
|
||||
/></span>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_width_100">
|
||||
<div class="wpmf_row_full">
|
||||
<label data-wpmftippy="<?php esc_html_e('Additionally to the folder creation as physical folder, all the current folder structure and media will be transformed as WordPress physical folders', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Transform current media folders', 'wpmf'); ?></label>
|
||||
<button id="sync_wpmf"
|
||||
class="ju-button no-background orange-button waves-effect waves-light" <?php echo defined('WPMF_TAXO') ? '' : ('disabled="disabled" title="' . esc_html__('This functionnality requires WP Media Folder from Joomunited plugin', 'wpmf') . '"'); ?>>
|
||||
<?php esc_html_e('Move existing media', 'wpmf'); ?>
|
||||
</button>
|
||||
<p id="sync_wpmf_doing"
|
||||
style="display: none"><?php esc_html_e('Media will be moved asynchronously as a background task, please activate the top status bar to see the progression', 'wpmf'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option full_search"
|
||||
style="<?php echo empty($folder_options['auto_detect_tables']) ? 'display:none' : ''; ?>">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wp-media-folder-options[search_full_database]" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('If checked, the plugin will not only replace content in your wordpress tables but in all the tables it will find in the database. It could be useful if you use your attachments links in another cms or custom script. If you don\'t specifically need it, leave this option unchecked.', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php printf(esc_html__('Search into full database instead of only "%s" prefixed tables', 'wpmf'), esc_html($wpdb->prefix)) ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="wp-media-folder-options[search_full_database]"
|
||||
value="1"
|
||||
<?php
|
||||
if (!empty($folder_options['search_full_database'])) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option full_search wpmf_right m-r-0"
|
||||
style="<?php echo empty($folder_options['auto_detect_tables']) ? 'display:none' : ''; ?>">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wp-media-folder-options[replace_relative_paths]" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('By default WordPress uses absolutes urls, but some plugins may use relative path. If checked, the plugin will try to replace also relative path in database, instead of only absolute urls. Replacements in database may fail in particular cases (files with the same name) if this option is used while you\'re not using the default year/month upload folders option in WordPress settings.', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Replace relative paths in database', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="wp-media-folder-options[replace_relative_paths]"
|
||||
value="1"
|
||||
<?php
|
||||
if (!empty($folder_options['replace_relative_paths'])) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ju-settings-option">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wp-media-folder-options[mode_debug]" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('When enabled, all actions made by the plugin will be stored into a log file in the plugin folder', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Mode debug activated', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="wp-media-folder-options[mode_debug]"
|
||||
value="1"
|
||||
<?php
|
||||
if (!empty($folder_options['mode_debug'])) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
?>
|
||||
<div class="content-box content-wpmf-regen-thumbnail">
|
||||
<div class="ju-settings-option wpmf_width_100 p-d-20">
|
||||
<div style="width: 30%;text-align: center;float:left; max-height:500px; overflow: hidden;">
|
||||
<img class="img_thumbnail" src="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/default.png') ?>">
|
||||
</div>
|
||||
|
||||
|
||||
<div class="right_wrap_render_thumbnail wpmf_width_100 wpmf-no-margin">
|
||||
<button type="button"
|
||||
class="ju-button orange-button waves-effect wpmf_width_100 waves-light btn_regenerate_thumbnails stop"><?php esc_html_e('Regenerate all image thumbnails', 'wpmf') ?></button>
|
||||
<button type="button"
|
||||
class="ju-button orange-button no-background waves-effect waves-light btn_stop_regenerate_thumbnails"
|
||||
><?php esc_html_e('Stop the process', 'wpmf') ?></button>
|
||||
|
||||
<div class="wpmf-process-bar-full process_gennerate_thumb_full" style="">
|
||||
<div class="wpmf-process-bar process_gennerate_thumb" data-w="0"></div>
|
||||
<span>0%</span>
|
||||
</div>
|
||||
|
||||
<div class="result_gennerate_thumb">
|
||||
<h3><?php esc_html_e('Information', 'wpmf') ?></h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
?>
|
||||
<div class="success updated wpmf-notice wpmf-is-dismissible">
|
||||
<p><strong><?php esc_html_e('Saved successfully', 'wpmf'); ?></strong></p>
|
||||
<button type="button" class="wpmf-notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button>
|
||||
</div>
|
||||
@@ -0,0 +1,212 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
|
||||
$iptcHeaderArray = getIptcHeader();
|
||||
?>
|
||||
<div id="server_folder_sync" class="tab-content">
|
||||
<div class="wpmf_width_100 top_bar">
|
||||
<h1><?php echo esc_html__('Server Folder Sync', 'wpmf') ?></h1>
|
||||
<?php
|
||||
require WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/pages/settings/submit_button.php';
|
||||
?>
|
||||
</div>
|
||||
<div class="content-box content-wpmf-media-sync">
|
||||
<div class="ju-settings-option btnoption">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wpmf_option_sync_media" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Activate the sync from External folder to WordPress media library', 'wpmf') ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Activate the sync', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="cb_option_sync_media"
|
||||
name="wpmf_option_sync_media" value="1"
|
||||
<?php
|
||||
if (isset($option_sync_media) && (int) $option_sync_media === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option btnoption wpmf_right m-r-0">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wpmf_option_sync_media_external" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Also activate the sync from
|
||||
WordPress media library to external folders', 'wpmf') ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Activate 2 ways sync', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="cb_option_sync_media_external"
|
||||
name="wpmf_option_sync_media_external" value="1"
|
||||
<?php
|
||||
if (isset($option_sync_media_external) && (int) $option_sync_media_external === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option btnoption">
|
||||
<div class="wpmf_row_full p-lr-20">
|
||||
<label data-wpmftippy="<?php esc_html_e('Launch an automatic synchronization between the media folders selected below, each X minutes', 'wpmf') ?>" class="setting-label-bold p-r-20"><?php esc_html_e('Sync delay', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input type="text" name="input_time_sync" class="input_time_sync"
|
||||
value="<?php echo esc_attr($time_sync) ?>">
|
||||
</label>
|
||||
<label class="setting-label-bold"><?php esc_html_e('minutes', 'wpmf') ?></label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_width_100 btnoption">
|
||||
<div class="wpmf_row_full">
|
||||
<div>
|
||||
<div class="wrap_dir_name_ftp wpmf_left">
|
||||
<div id="wpmf_foldertree_sync"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wrap_dir_name_categories wpmf_left">
|
||||
<div id="wpmf_foldertree_categories"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="wpmf_width_100 p-lr-20">
|
||||
<div class="input_dir">
|
||||
<input type="text" name="dir_name_ftp" class="input_sync dir_name_ftp wpmf_left" readonly
|
||||
value="">
|
||||
<input type="text" name="dir_name_categories" class="input_sync dir_name_categories wpmf_left"
|
||||
readonly
|
||||
data-id_category="0" value="">
|
||||
</div>
|
||||
|
||||
<button type="button"
|
||||
class="m-t-10 ju-button no-background orange-button waves-effect waves-light btn_addsync_media"><?php esc_html_e('Add', 'wpmf') ?></button>
|
||||
<button type="button"
|
||||
class="m-t-10 ju-button no-background orange-button waves-effect waves-light btn_deletesync_media"><?php esc_html_e('Delete selected', 'wpmf') ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_width_100 btnoption">
|
||||
<table class="wp-list-table widefat striped wp-list-table-sync">
|
||||
<thead>
|
||||
<tr>
|
||||
<td style="width: 1%"><label for="cb-select-all-sync-item"></label><input id="cb-select-all-sync-items" class="media_checkbox cb-select-all-sync-items" type="checkbox"></td>
|
||||
<td style="font-weight: bold; text-transform: uppercase"><?php esc_html_e('Server folder', 'wpmf') ?></td>
|
||||
<td style="font-weight: bold; text-transform: uppercase"><?php esc_html_e('Media Library', 'wpmf') ?></td>
|
||||
<td style="width: 300px"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (!empty($wpmf_list_sync_media)) : ?>
|
||||
<?php foreach ($wpmf_list_sync_media as $k => $v) : ?>
|
||||
<tr data-ftp="<?php echo esc_attr($v['folder_ftp']) ?>" data-id="<?php echo esc_html($k) ?>">
|
||||
<td>
|
||||
<label for="cb-select-<?php echo esc_html($k) ?>"></label>
|
||||
<input class="media_checkbox check-sync-item" id="cb-select-<?php echo esc_html($k) ?>"
|
||||
type="checkbox" name="post[]" value="<?php echo esc_html($k) ?>">
|
||||
</td>
|
||||
<td><?php echo esc_html($v['folder_ftp']) ?></td>
|
||||
<td><?php echo esc_html($this->breadcrumb_category[$k]) ?></td>
|
||||
<td>
|
||||
<button class="button ju-small-button add-syncftp-queue m-r-10" type="button"><?php esc_html_e('Add to queue', 'wpmf') ?><span class="wpmf_spinner"></span></button>
|
||||
<button class="button ju-small-button delete-syncftp-item" type="button"><?php esc_html_e('Delete', 'wpmf') ?></button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="server_sync_settings" class="tab-content">
|
||||
<div class="wpmf_width_100 top_bar">
|
||||
<h1><?php echo esc_html__('Settings', 'wpmf') ?></h1>
|
||||
<?php
|
||||
require WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/pages/settings/submit_button.php';
|
||||
?>
|
||||
</div>
|
||||
<div class="content-box">
|
||||
<div class="ju-settings-option wpmf_width_100 p-lr-20">
|
||||
<div class="wpmf_row_full">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text">
|
||||
<?php esc_html_e('File type to include in import and synchronization', 'wpmf') ?></label>
|
||||
<label class="wpmf_width_100">
|
||||
<textarea name="allow_sync_extensions" class="wpmf_width_100 allow_sync_extensions"><?php echo esc_html($allow_sync_extensions) ?></textarea>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_width_100">
|
||||
<div style="margin: 10px 0 0 0; width: 50%">
|
||||
<input type="hidden" name="import_iptc_meta" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('When an image is imported, synchronized or uploaded to the WordPress media library, keep the IPTC metadata attached to the image file', 'wpmf'); ?>"
|
||||
class="wpmftippy ju-setting-label text"><?php esc_html_e('Enable import IPTC metadata', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="cb_option_import_iptc_meta" name="import_iptc_meta" class="import_iptc_meta"
|
||||
value="1"
|
||||
<?php
|
||||
if (isset($import_iptc_meta) && (int) $import_iptc_meta === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="iptc_fields_wrap p-lr-20">
|
||||
<label class="ju-setting-label wpmf_width_100 wpmf-no-padding text" style="line-height: 40px"><?php esc_html_e('IPTC fields', 'wpmf') ?></label>
|
||||
<div class="iptc_field pure-checkbox m-b-20">
|
||||
<input type="hidden" name="iptc_fields[title]" value="0">
|
||||
<input type="checkbox" id="iptc_title" name="iptc_fields[title]"
|
||||
class="wpmf_checkbox_tree" value="1" <?php checked($iptc_fields['title'], 1) ?>>
|
||||
<label for="iptc_title"><?php esc_html_e('Title', 'wpmf') ?></label>
|
||||
</div>
|
||||
|
||||
<div class="iptc_field pure-checkbox">
|
||||
<input type="hidden" name="iptc_fields[alt]" value="0">
|
||||
<input type="checkbox" id="iptc_alt" name="iptc_fields[alt]"
|
||||
class="wpmf_checkbox_tree" value="1" <?php checked($iptc_fields['alt'], 1) ?>>
|
||||
<label for="iptc_alt"><?php esc_html_e('Alt', 'wpmf') ?></label>
|
||||
</div>
|
||||
|
||||
<div class="iptc_field pure-checkbox">
|
||||
<input type="hidden" name="iptc_fields[description]" value="0">
|
||||
<input type="checkbox" id="iptc_description" name="iptc_fields[description]"
|
||||
class="wpmf_checkbox_tree" value="1" <?php checked($iptc_fields['description'], 1) ?>>
|
||||
<label for="iptc_description"><?php esc_html_e('Description', 'wpmf') ?></label>
|
||||
</div>
|
||||
|
||||
<div class="iptc_field pure-checkbox">
|
||||
<input type="hidden" name="iptc_fields[caption]" value="0">
|
||||
<input type="checkbox" id="iptc_caption" name="iptc_fields[caption]"
|
||||
class="wpmf_checkbox_tree" value="1" <?php checked($iptc_fields['caption'], 1) ?>>
|
||||
<label for="iptc_caption"><?php esc_html_e('Caption', 'wpmf') ?></label>
|
||||
</div>
|
||||
|
||||
<?php foreach ($iptcHeaderArray as $code => $iptcHeader) : ?>
|
||||
<div class="iptc_field pure-checkbox">
|
||||
<input type="hidden" name="iptc_fields[<?php echo esc_attr($code) ?>]" value="0">
|
||||
<input type="checkbox" id="iptc_<?php echo esc_attr($code) ?>" name="iptc_fields[<?php echo esc_attr($code) ?>]"
|
||||
class="wpmf_checkbox_tree" value="1" <?php checked($iptc_fields[$code], 1) ?>>
|
||||
<label for="iptc_<?php echo esc_attr($code) ?>"><?php echo esc_html($iptcHeader) ?></label>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
$allow_tabs_submit = array(
|
||||
'general',
|
||||
'media_access',
|
||||
'wordpress_gallery',
|
||||
'sync_media',
|
||||
'gallery_addon',
|
||||
'files_folders',
|
||||
'server_sync',
|
||||
'physical_server_folders',
|
||||
'gallery_photographer_addon'
|
||||
);
|
||||
?>
|
||||
<?php if (in_array($ju_tab['id'], $allow_tabs_submit)) : ?>
|
||||
<div class="btn_wpmf_saves">
|
||||
<button type="submit" name="btn_wpmf_save"
|
||||
class="btn_wpmf_save ju-button orange-button waves-effect waves-light"><?php esc_html_e('Save Changes', 'wpmf'); ?></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
?>
|
||||
<div class="content-box wpmf_width_80">
|
||||
<p class="description text_center" style="margin: 0">
|
||||
<?php esc_html_e('We have checked your server environment.
|
||||
If you see some warning below it means that some plugin features may not work properly.
|
||||
Reload the page to refresh the results', 'wpmf'); ?>
|
||||
</p>
|
||||
<div class="wpmf_width_100 p-tb-20 wpmf_left text label_text"><?php esc_html_e('PHP Version', 'wpmf'); ?></div>
|
||||
<div class="wpmf-field-setting">
|
||||
<label class="ju-setting-label php_version">
|
||||
<?php esc_html_e('PHP ', 'wpmf'); ?>
|
||||
<?php echo esc_html(PHP_VERSION) ?>
|
||||
<?php esc_html_e('version', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<div class="right-checkbox">
|
||||
<?php
|
||||
if (version_compare(PHP_VERSION, '7.2.0', '>=')) {
|
||||
echo '<i class="material-icons system-checkbox material-icons-success">check_circle</i>';
|
||||
} elseif (version_compare(PHP_VERSION, '7.2.0', '<') &&
|
||||
version_compare(PHP_VERSION, '7.0.0', '>=')) {
|
||||
echo '<img src="' . esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-notification.png') . '" class="img_notification">';
|
||||
} else {
|
||||
echo '<i class="material-icons system-checkbox material-icons-info">info</i>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (version_compare(PHP_VERSION, '7.2.0', '<')) : ?>
|
||||
<p class="description text_left p_warning">
|
||||
<?php esc_html_e('Your PHP version is ', 'wpmf'); ?>
|
||||
<?php echo esc_html(PHP_VERSION) ?>
|
||||
<?php esc_html_e('. For performance and security reasons it better to run PHP 7.2+. Comparing to previous versions the execution time of PHP 7.X is more than twice as fast and has 30 percent lower memory consumption', 'wpmf'); ?>
|
||||
</p>
|
||||
<?php else : ?>
|
||||
<p class="description text_center">
|
||||
<?php esc_html_e('Great ! Your PHP version is ', 'wpmf'); ?>
|
||||
<?php echo esc_html(PHP_VERSION) ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<div class="wpmf_width_100 p-tb-20 wpmf_left text label_text"><?php esc_html_e('PHP Extensions', 'wpmf'); ?></div>
|
||||
<div class="wpmf-field-setting">
|
||||
<label class="ju-setting-label"><?php esc_html_e('Curl', 'wpmf'); ?></label>
|
||||
<div class="right-checkbox">
|
||||
<?php if (!in_array('curl', get_loaded_extensions())) : ?>
|
||||
<img src="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-information/icon-information.png') ?>"
|
||||
srcset="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-information/icon-information@2x.png') ?> 2x, <?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-information/icon-information@3x.png') ?> 3x"
|
||||
class="img_warning">
|
||||
<?php else : ?>
|
||||
<input type="checkbox" id="php_curl" name="php_curl" checked
|
||||
value="php_curl" disabled class="filled-in media_checkbox"/>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (!in_array('curl', get_loaded_extensions())) : ?>
|
||||
<p class="description p_warning">
|
||||
<?php esc_html_e('PHP Curl extension has not been detected. You need to activate in order to load video in media library and for all the cloud connections (like Google Drive, Dropbox...)', 'wpmf'); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<div class="wpmf-field-setting">
|
||||
<label class="ju-setting-label"><?php esc_html_e('GD Library', 'wpmf'); ?></label>
|
||||
<div class="right-checkbox">
|
||||
<?php if (function_exists('gd_info')) : ?>
|
||||
<input type="checkbox" id="gd_info" name="gd_info" checked
|
||||
value="gd_info" disabled class="filled-in media_checkbox"/>
|
||||
<?php else : ?>
|
||||
<img src="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-information/icon-information.png') ?>"
|
||||
srcset="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-information/icon-information@2x.png') ?> 2x, <?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-information/icon-information@3x.png') ?> 3x"
|
||||
class="img_warning">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (!function_exists('gd_info')) : ?>
|
||||
<p class="description p_warning">
|
||||
<?php esc_html_e('GD library is not detected. GD is an open source library related to image creation. The Watermark feature won’t work.', 'wpmf'); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="wpmf_width_100 p-tb-20 wpmf_left text label_text"><?php esc_html_e('PHP Settings', 'wpmf'); ?></div>
|
||||
<div class="wpmf-field-setting">
|
||||
<label class="ju-setting-label"><?php esc_html_e('Allow URL open', 'wpmf'); ?></label>
|
||||
<div class="right-checkbox">
|
||||
<?php if (!ini_get('allow_url_fopen')) : ?>
|
||||
<img src="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-information/icon-information.png') ?>"
|
||||
srcset="<?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-information/icon-information@2x.png') ?> 2x, <?php echo esc_url(WPMF_PLUGIN_URL . '/assets/images/icon-information/icon-information@3x.png') ?> 3x"
|
||||
class="img_warning">
|
||||
<?php else : ?>
|
||||
<input type="checkbox" id="php_allow_url_fopen" name="php_allow_url_fopen" checked
|
||||
value="php_allow_url_fopen" disabled class="filled-in media_checkbox"/>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (!ini_get('allow_url_fopen')) : ?>
|
||||
<p class="description p_warning">
|
||||
<?php esc_html_e('Allow URL fopen setting has not been detected. You need to activate in order to use remote video feature', 'wpmf'); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@@ -0,0 +1,645 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
$wp_gallery_configs = wpmfGetOption('gallery_shortcode_cf');
|
||||
$wp_gallery_themes = array(
|
||||
'default' => esc_html__('Default', 'wpmf'),
|
||||
'masonry' => esc_html__('Masonry', 'wpmf'),
|
||||
'portfolio' => esc_html__('Portfolio', 'wpmf'),
|
||||
'slider' => esc_html__('Slider', 'wpmf')
|
||||
);
|
||||
?>
|
||||
<div id="gallery_features" class="tab-content">
|
||||
<div class="content-box">
|
||||
<div class="content-wpmf-gallery">
|
||||
<div class="ju-settings-option">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wpmf_usegellery" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Enhance the WordPress default gallery system
|
||||
by adding themes and additional parameters in the gallery manager', 'wpmf'); ?>"
|
||||
class="ju-setting-label text">
|
||||
<?php esc_html_e('Enable the gallery feature', 'wpmf') ?>
|
||||
</label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="wpmf_usegellery" value="1"
|
||||
<?php
|
||||
if (isset($usegellery) && (int) $usegellery === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_right m-r-0">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wpmf_option_lightboximage" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Add a lightbox option on each image of your WordPress content', 'wpmf'); ?>"
|
||||
class="ju-setting-label text"><?php esc_html_e('Enable the single image lightbox feature', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="wpmf_option_lightboximage"
|
||||
id="cb_option_lightboximage" value="1"
|
||||
<?php
|
||||
if (isset($option_lightboximage) && (int) $option_lightboximage === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="wpmf_usegellery_lightbox" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Add lightbox to images in WordPress default galleries', 'wpmf'); ?>"
|
||||
class="ju-setting-label text">
|
||||
<?php esc_html_e('Lightbox in galleries', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="wpmf_usegellery_lightbox" value="1"
|
||||
<?php
|
||||
if (isset($usegellery_lightbox) && (int) $usegellery_lightbox === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf_right m-r-0">
|
||||
<div class="wpmf_row_full">
|
||||
<input type="hidden" name="caption_lightbox_gallery" value="0">
|
||||
<label data-wpmftippy="<?php esc_html_e('Use caption of images on lightbox instead title', 'wpmf'); ?>"
|
||||
class="ju-setting-label text">
|
||||
<?php esc_html_e('Caption on lightbox', 'wpmf') ?></label>
|
||||
<div class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="caption_lightbox_gallery" value="1"
|
||||
<?php
|
||||
if (isset($caption_lightbox_gallery) && (int) $caption_lightbox_gallery === 1) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpmf_row_full">
|
||||
<div class="wrap_left">
|
||||
<div id="gallery_image_size" class="div_list media_filter_block wpmf_width_100">
|
||||
<ul class="image_size">
|
||||
<li class="div_list_child accordion-section control-section control-section-default open">
|
||||
<h3 class="accordion-section-title wpmf-section-title"
|
||||
data-title="sizes"
|
||||
tabindex="0"><?php esc_html_e('List default filter size', 'wpmf') ?>
|
||||
<i class="zmdi zmdi-chevron-up"></i>
|
||||
<i class="zmdi zmdi-chevron-down"></i>
|
||||
</h3>
|
||||
<ul class="content_list_sizes">
|
||||
<?php
|
||||
$sizes = apply_filters('image_size_names_choose', array(
|
||||
'thumbnail' => __('Thumbnail', 'wpmf'),
|
||||
'medium' => __('Medium', 'wpmf'),
|
||||
'large' => __('Large', 'wpmf'),
|
||||
'full' => __('Full Size', 'wpmf'),
|
||||
));
|
||||
foreach ($sizes as $key => $size) :
|
||||
?>
|
||||
|
||||
<li class="wpmf-field-setting customize-control customize-control-select item_dimension" data-value="<?php echo esc_html($a_dimension); ?>">
|
||||
<div class="pure-checkbox ju-setting-label">
|
||||
<input title="" id="<?php echo esc_attr($key) ?>" type="checkbox"
|
||||
name="size_value[]"
|
||||
value="<?php echo esc_attr($key) ?>"
|
||||
<?php
|
||||
if (in_array($key, $size_selected)) {
|
||||
echo 'checked';
|
||||
}
|
||||
?>
|
||||
>
|
||||
<label for="<?php echo esc_html($key) ?>"><?php echo esc_html($size) ?></label>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<p class="description">
|
||||
<?php esc_html_e('Select the image size you can load in galleries.
|
||||
Custom image size available here can be generated by 3rd party plugins', 'wpmf'); ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="wrap_right">
|
||||
<!-- setting padding -->
|
||||
<div id="gallery_image_padding" class="div_list media_filter_block wpmf_width_100">
|
||||
<ul class="image_size">
|
||||
<li class="div_list_child accordion-section control-section control-section-default open">
|
||||
<h3 class="accordion-section-title wpmf-section-title padding_title"
|
||||
data-title="padding" tabindex="0">
|
||||
<?php esc_html_e('Gallery themes settings', 'wpmf') ?>
|
||||
<i class="zmdi zmdi-chevron-up"></i>
|
||||
<i class="zmdi zmdi-chevron-down"></i>
|
||||
</h3>
|
||||
<div class="content_list_padding">
|
||||
<div class="wpmf-field-setting ju-settings-option customize-control customize-control-select">
|
||||
<div class="wpmf_row_full">
|
||||
<span><?php esc_html_e('Masonry Theme', 'wpmf'); ?></span>
|
||||
<label><?php esc_html_e('Space between images (padding)', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input name="padding_gallery[wpmf_padding_masonry]"
|
||||
class="padding_gallery small-text"
|
||||
type="number" min="0" max="30"
|
||||
value="<?php echo esc_attr($padding_masonry) ?>">
|
||||
</label>
|
||||
<label><?php esc_html_e('px', 'wpmf') ?></label>
|
||||
</div>
|
||||
|
||||
<div class="wpmf_row_full">
|
||||
<span><?php esc_html_e('Portfolio Theme', 'wpmf'); ?></span>
|
||||
<label><?php esc_html_e('Space between images (padding)', 'wpmf') ?></label>
|
||||
<label>
|
||||
<input name="padding_gallery[wpmf_padding_portfolio]"
|
||||
class="padding_gallery small-text"
|
||||
type="number" min="0" max="30"
|
||||
value="<?php echo esc_attr($padding_portfolio) ?>">
|
||||
</label>
|
||||
<label><?php esc_html_e('px', 'wpmf') ?></label>
|
||||
</div>
|
||||
</div>
|
||||
<p class="description"><?php esc_html_e('Determine the space between images', 'wpmf'); ?></p>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="default_settings" class="tab-content">
|
||||
<div class="content-box usegellery content-wpmf-gallery">
|
||||
<?php
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput -- Content already escaped in the method
|
||||
echo $glrdefault_settings_html;
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wp_gallery_shortcode" class="tab-content">
|
||||
<div class="content-box">
|
||||
<div class="wp_gallery_shortcode_settings_wrap">
|
||||
<h2><?php esc_html_e('GALLERIES FROM FOLDER SHORTCODE GENERATOR', 'wpmf') ?></h2>
|
||||
<div class="wpmf_width_100">
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<div class="wpmf_row_full">
|
||||
<div class="wpmf_gallery_shortcode_cf_settings">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text">
|
||||
<?php esc_html_e('Gallery from folder', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<?php
|
||||
$folder_args = array(
|
||||
'show_option_none' => __('Select a folder', 'wpmf'),
|
||||
'option_none_value' => 0,
|
||||
'hide_empty' => false,
|
||||
'hierarchical' => true,
|
||||
'orderby' => 'name',
|
||||
'taxonomy' => WPMF_TAXO,
|
||||
'class' => 'wp_gallery_shortcode_field wp_shortcode_gallery_folder_id',
|
||||
'name' => 'wpmf_gallery_shortcode_cf[wpmf_folder_id]',
|
||||
'selected' => (int) $wp_gallery_configs['wpmf_folder_id']
|
||||
);
|
||||
|
||||
$root_id = get_option('wpmf_folder_root_id');
|
||||
if (isset($root_id)) {
|
||||
$folder_args['exclude'] = array((int) $root_id);
|
||||
}
|
||||
|
||||
wp_dropdown_categories($folder_args);
|
||||
?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<div class="wpmf_row_full">
|
||||
<div class="wpmf_gallery_shortcode_cf_settings">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text">
|
||||
<?php esc_html_e('Choose a theme', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<select class="wp_gallery_shortcode_field" name="wpmf_gallery_shortcode_cf[display]" data-param="display">
|
||||
<option value="default"><?php esc_html_e('Choose a theme', 'wpmf') ?></option>
|
||||
<?php foreach ($wp_gallery_themes as $theme_key => $theme_label) { ?>
|
||||
<?php if (isset($wp_gallery_configs['display'])
|
||||
&& $wp_gallery_configs['display'] === $theme_key) : ?>
|
||||
<option value="<?php echo esc_html($theme_key) ?>" selected>
|
||||
<?php echo esc_html($theme_label) ?>
|
||||
</option>
|
||||
<?php else : ?>
|
||||
<option value="<?php echo esc_html($theme_key) ?>">
|
||||
<?php echo esc_html($theme_label) ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php } ?>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text wpmf_width_auto" data-wpmftippy="<?php esc_html_e('Number of columns
|
||||
by default in the gallery theme', 'wpmf'); ?>">
|
||||
<?php esc_html_e('Columns', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<select class="columns wp_gallery_shortcode_field" data-param="columns"
|
||||
name="wpmf_gallery_shortcode_cf[columns]">
|
||||
<?php for ($i = 1; $i <= 9; $i ++) { ?>
|
||||
<option value="<?php echo esc_html($i) ?>" <?php selected((int) $wp_gallery_configs['columns'], (int) $i) ?> >
|
||||
<?php echo esc_html($i) ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text wpmf_width_auto" data-wpmftippy="<?php esc_html_e('Image size to load
|
||||
by default as thumbnail', 'wpmf'); ?>">
|
||||
<?php esc_html_e('Gallery image size', 'wpmf'); ?>
|
||||
</label>
|
||||
<label class="size">
|
||||
<select class="wp_gallery_shortcode_field" data-param="size"
|
||||
name="wpmf_gallery_shortcode_cf[size]">
|
||||
<?php
|
||||
$sizes_value = json_decode(get_option('wpmf_gallery_image_size_value'));
|
||||
$sizes = apply_filters('image_size_names_choose', array(
|
||||
'thumbnail' => __('Thumbnail', 'wpmf'),
|
||||
'medium' => __('Medium', 'wpmf'),
|
||||
'large' => __('Large', 'wpmf'),
|
||||
'full' => __('Full Size', 'wpmf'),
|
||||
));
|
||||
?>
|
||||
|
||||
<?php foreach ($sizes_value as $key) : ?>
|
||||
<?php if (!empty($sizes[$key])) : ?>
|
||||
<option value="<?php echo esc_attr($key); ?>" <?php selected($wp_gallery_configs['size'], $key); ?>>
|
||||
<?php echo esc_html($sizes[$key]); ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text wpmf_width_auto" data-wpmftippy="<?php esc_html_e('Image size to load by default as full
|
||||
size (opened in the lightbox)', 'wpmf'); ?>">
|
||||
<?php esc_html_e('Lightbox size', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<select class="wp_gallery_shortcode_field" data-param="targetsize"
|
||||
name="wpmf_gallery_shortcode_cf[targetsize]">
|
||||
<?php
|
||||
$sizes = array(
|
||||
'thumbnail' => __('Thumbnail', 'wpmf'),
|
||||
'medium' => __('Medium', 'wpmf'),
|
||||
'large' => __('Large', 'wpmf'),
|
||||
'full' => __('Full Size', 'wpmf'),
|
||||
);
|
||||
?>
|
||||
|
||||
<?php foreach ($sizes as $key => $name) : ?>
|
||||
<option value="<?php echo esc_attr($key); ?>"
|
||||
<?php selected($wp_gallery_configs['targetsize'], $key); ?>>
|
||||
<?php echo esc_html($name); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text wpmf_width_auto" data-wpmftippy="<?php esc_html_e('Action when the user
|
||||
click on the image thumbnail', 'wpmf'); ?>">
|
||||
<?php esc_html_e('Action on click', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<select class="wp_gallery_shortcode_field" data-param="link"
|
||||
name="wpmf_gallery_shortcode_cf[link]">
|
||||
<option value="file" <?php selected($wp_gallery_configs['link'], 'file'); ?>>
|
||||
<?php esc_html_e('Lightbox', 'wpmf'); ?>
|
||||
</option>
|
||||
<option value="post" <?php selected($wp_gallery_configs['link'], 'post'); ?>>
|
||||
<?php esc_html_e('Attachment Page', 'wpmf'); ?>
|
||||
</option>
|
||||
<option value="none" <?php selected($wp_gallery_configs['link'], 'none'); ?>>
|
||||
<?php esc_html_e('None', 'wpmf'); ?>
|
||||
</option>
|
||||
<option value="custom" <?php selected($wp_gallery_configs['link'], 'custom'); ?>>
|
||||
<?php esc_html_e('Custom link', 'wpmf'); ?>
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text wpmf_width_auto" data-wpmftippy="<?php esc_html_e('Image gallery
|
||||
default ordering', 'wpmf'); ?>">
|
||||
<?php esc_html_e('Order by', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<select class="wp_gallery_shortcode_field" data-param="wpmf_orderby"
|
||||
name="wpmf_gallery_shortcode_cf[wpmf_orderby]">
|
||||
<option value="post__in" <?php selected($wp_gallery_configs['wpmf_orderby'], 'post__in'); ?>>
|
||||
<?php esc_html_e('Custom', 'wpmf'); ?>
|
||||
</option>
|
||||
<option value="rand" <?php selected($wp_gallery_configs['wpmf_orderby'], 'rand'); ?>>
|
||||
<?php esc_html_e('Random', 'wpmf'); ?>
|
||||
</option>
|
||||
<option value="title" <?php selected($wp_gallery_configs['wpmf_orderby'], 'title'); ?>>
|
||||
<?php esc_html_e('Title', 'wpmf'); ?>
|
||||
</option>
|
||||
<option value="date" <?php selected($wp_gallery_configs['wpmf_orderby'], 'date'); ?>>
|
||||
<?php esc_html_e('Date', 'wpmf'); ?>
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text wpmf_width_auto" data-wpmftippy="<?php esc_html_e('By default, use ascending
|
||||
or descending order', 'wpmf'); ?>">
|
||||
<?php esc_html_e('Order', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<select class="wp_gallery_shortcode_field" data-param="wpmf_order"
|
||||
name="wpmf_gallery_shortcode_cf[wpmf_order]">
|
||||
<option value="ASC" <?php selected($wp_gallery_configs['wpmf_order'], 'ASC'); ?>>
|
||||
<?php esc_html_e('Ascending', 'wpmf'); ?>
|
||||
</option>
|
||||
<option value="DESC" <?php selected($wp_gallery_configs['wpmf_order'], 'DESC'); ?>>
|
||||
<?php esc_html_e('Descending', 'wpmf'); ?>
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text">
|
||||
<?php esc_html_e('Margin', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<input type="number" min="0" max="50" step="5" name="wpmf_gallery_shortcode_cf[gutterwidth]" class="wp_gallery_shortcode_field" data-param="gutterwidth" value="<?php echo esc_attr($wp_gallery_configs['gutterwidth']) ?>">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- Border settings -->
|
||||
<div class="wpmf_width_100">
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text">
|
||||
<?php esc_html_e('Border style', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<select class="wp_gallery_shortcode_field" name="wpmf_gallery_shortcode_cf[border_style]" data-param="border_style">
|
||||
<option value="none" <?php selected($wp_gallery_configs['border_style'], 'none'); ?>><?php esc_html_e('None', 'wpmf'); ?></option>
|
||||
<option value="solid" <?php selected($wp_gallery_configs['border_style'], 'solid'); ?>><?php esc_html_e('Solid', 'wpmf'); ?></option>
|
||||
<option value="dotted" <?php selected($wp_gallery_configs['border_style'], 'dotted'); ?>><?php esc_html_e('Dotted', 'wpmf'); ?></option>
|
||||
<option value="dashed" <?php selected($wp_gallery_configs['border_style'], 'dashed'); ?>><?php esc_html_e('Dashed', 'wpmf'); ?></option>
|
||||
<option value="double" <?php selected($wp_gallery_configs['border_style'], 'double'); ?>><?php esc_html_e('Double', 'wpmf'); ?></option>
|
||||
<option value="groove" <?php selected($wp_gallery_configs['border_style'], 'groove'); ?>><?php esc_html_e('Groove', 'wpmf'); ?></option>
|
||||
<option value="ridge" <?php selected($wp_gallery_configs['border_style'], 'ridge'); ?>><?php esc_html_e('Ridge', 'wpmf'); ?></option>
|
||||
<option value="inset" <?php selected($wp_gallery_configs['border_style'], 'inset'); ?>><?php esc_html_e('Inset', 'wpmf'); ?></option>
|
||||
<option value="outset" <?php selected($wp_gallery_configs['border_style'], 'outset'); ?>><?php esc_html_e('Outset', 'wpmf'); ?></option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text">
|
||||
<?php esc_html_e('Border radius', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<input type="number" min="0" max="20" step="1" name="wpmf_gallery_shortcode_cf[img_border_radius]" class="wp_gallery_shortcode_field" data-param="img_border_radius" value="<?php echo esc_attr($wp_gallery_configs['img_border_radius']) ?>">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text">
|
||||
<?php esc_html_e('Border width', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<input type="number" min="0" max="10" step="1" name="wpmf_gallery_shortcode_cf[border_width]" class="wp_gallery_shortcode_field" data-param="border_width" value="<?php echo esc_attr($wp_gallery_configs['border_width']) ?>">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text">
|
||||
<?php esc_html_e('Border color', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<input name="wpmf_gallery_shortcode_cf[border_color]" type="text"
|
||||
value="<?php echo esc_attr($wp_gallery_configs['border_color']) ?>"
|
||||
class="inputbox input-block-level wp-color-field-hv wp-color-picker wp_gallery_shortcode_field" data-param="border_color">
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Shadow settings -->
|
||||
<div class="wpmf_width_100">
|
||||
<?php
|
||||
$img_shadow = $wp_gallery_configs['img_shadow'];
|
||||
$shadows = explode(' ', $img_shadow);
|
||||
?>
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text">
|
||||
<?php esc_html_e('Shadow H offset', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<input type="number" min="-50" max="50" class="wp_gallery_shadow_field wp_gallery_shadow_h_field" value="<?php echo esc_attr(str_replace('px', '', $shadows[0])) ?>">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text">
|
||||
<?php esc_html_e('Shadow V offset', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<input type="number" min="-50" max="50" class="wp_gallery_shadow_field wp_gallery_shadow_v_field" value="<?php echo esc_attr(str_replace('px', '', $shadows[1])) ?>">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text">
|
||||
<?php esc_html_e('Shadow blur', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<input type="number" min="0" max="50" class="wp_gallery_shadow_field wp_gallery_shadow_blur_field" value="<?php echo esc_attr(str_replace('px', '', $shadows[2])) ?>">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text">
|
||||
<?php esc_html_e('Shadow spread', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<input type="number" min="0" max="50" class="wp_gallery_shadow_field wp_gallery_shadow_spread_field" value="<?php echo esc_attr(str_replace('px', '', $shadows[3])) ?>">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="ju-settings-option wpmf-no-shadow">
|
||||
<label class="wpmf_width_100 p-b-20 wpmf_left text label_text">
|
||||
<?php esc_html_e('Shadow Color', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<input type="text"
|
||||
value="<?php echo esc_attr($shadows[4]) ?>"
|
||||
class="inputbox input-block-level wp-color-field-hv wp-color-picker wp_gallery_shadow_field wp_gallery_shadow_color_field">
|
||||
</label>
|
||||
</div>
|
||||
<input type="hidden" class="wp_gallery_shortcode_field" name="wpmf_gallery_shortcode_cf[img_shadow]" data-param="img_shadow" value="<?php echo esc_attr($img_shadow) ?>">
|
||||
</div>
|
||||
|
||||
<!-- Automatic animation -->
|
||||
<div class="wpmf_width_100">
|
||||
<label class="ju-setting-label setting wpmf-no-padding text wpmf-bold wpmf_left">
|
||||
<?php esc_html_e('Autoplay', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label class="wpmf_left">
|
||||
<input type="hidden" data-param="autoplay"
|
||||
name="wpmf_gallery_shortcode_cf[autoplay]"
|
||||
value="0">
|
||||
<span class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<?php if (isset($wp_gallery_configs['autoplay']) && (int) $wp_gallery_configs['autoplay'] === 1) : ?>
|
||||
<input type="checkbox" class="wp_gallery_shortcode_field" data-param="autoplay"
|
||||
name="wpmf_gallery_shortcode_cf[autoplay]"
|
||||
value="1" checked>
|
||||
<?php else : ?>
|
||||
<input type="checkbox" class="wp_gallery_shortcode_field" data-param="autoplay"
|
||||
name="wpmf_gallery_shortcode_cf[autoplay]"
|
||||
value="1">
|
||||
<?php endif; ?>
|
||||
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="wpmf_width_100">
|
||||
<label class="ju-setting-label setting wpmf-no-padding text wpmf-bold wpmf_left">
|
||||
<?php esc_html_e('Crop image', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label class="wpmf_left">
|
||||
<input type="hidden" data-param="crop_image"
|
||||
name="wpmf_gallery_shortcode_cf[crop_image]"
|
||||
value="0">
|
||||
<span class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<?php if (!isset($wp_gallery_configs['crop_image']) || (int)$wp_gallery_configs['crop_image'] === 1) : ?>
|
||||
<input type="checkbox" class="wp_gallery_shortcode_field" data-param="crop_image"
|
||||
name="wpmf_gallery_shortcode_cf[crop_image]"
|
||||
value="1" checked>
|
||||
<?php else : ?>
|
||||
<input type="checkbox" class="wp_gallery_shortcode_field" data-param="crop_image"
|
||||
name="wpmf_gallery_shortcode_cf[crop_image]"
|
||||
value="1">
|
||||
<?php endif; ?>
|
||||
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="wpmf_width_100">
|
||||
<label class="ju-setting-label setting wpmf-no-padding text wpmf-bold wpmf_left">
|
||||
<?php esc_html_e('Include images in subfolder', 'wpmf'); ?>
|
||||
</label>
|
||||
|
||||
<label class="wpmf_left">
|
||||
<input type="hidden" data-param="include_children"
|
||||
name="wpmf_gallery_shortcode_cf[include_children]"
|
||||
value="0">
|
||||
<span class="ju-switch-button">
|
||||
<label class="switch">
|
||||
<?php if (isset($wp_gallery_configs['include_children']) && (int) $wp_gallery_configs['include_children'] === 1) : ?>
|
||||
<input type="checkbox" class="wp_gallery_shortcode_field" data-param="include_children"
|
||||
name="wpmf_gallery_shortcode_cf[include_children]"
|
||||
value="1" checked>
|
||||
<?php else : ?>
|
||||
<input type="checkbox" class="wp_gallery_shortcode_field" data-param="include_children"
|
||||
name="wpmf_gallery_shortcode_cf[include_children]"
|
||||
value="1">
|
||||
<?php endif; ?>
|
||||
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="wpmf_width_100 m-t-30">
|
||||
<div class="wpmf_row_full" style="margin: 0 0 10px 0; position: relative;">
|
||||
<label class="wpmf_left text label_text" style="position: absolute; left: 0; bottom: 0;">
|
||||
<?php esc_html_e('Shortcode', 'wpmf') ?>
|
||||
</label>
|
||||
<div class="wpmf_copy_shortcode" data-input="wp_gallery_shortcode_input" style="margin: 0">
|
||||
<i data-wpmftippy="<?php esc_html_e('Copy shortcode', 'wpmf'); ?>"
|
||||
class="material-icons copy_wp_gallery_icon wpmftippy">content_copy</i>
|
||||
<label><?php esc_html_e('COPY', 'wpmf'); ?></label>
|
||||
</div>
|
||||
</div>
|
||||
<input title type="text" name="wpmf_gallery_shortcode_cf[value]"
|
||||
class="wp_gallery_shortcode_input regular-text"
|
||||
value="<?php echo esc_attr(stripslashes($wp_gallery_configs['value'])) ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,272 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
$tabs_data = array(
|
||||
array(
|
||||
'id' => 'general',
|
||||
'title' => __('General', 'wpmf'),
|
||||
'icon' => 'home',
|
||||
'sub_tabs' => array(
|
||||
'additional_features' => __('Main settings', 'wpmf'),
|
||||
'media_filtering' => __('Media filtering', 'wpmf'),
|
||||
// 'advanced' => __('Advanced', 'wpmf')
|
||||
)
|
||||
),
|
||||
array(
|
||||
'id' => 'wordpress_gallery',
|
||||
'title' => __('Wordpress Gallery', 'wpmf'),
|
||||
'icon' => 'image',
|
||||
'sub_tabs' => array(
|
||||
'gallery_features' => __('Gallery features', 'wpmf'),
|
||||
'default_settings' => __('Default settings', 'wpmf'),
|
||||
'wp_gallery_shortcode' => __('Shortcode', 'wpmf')
|
||||
)
|
||||
),
|
||||
array(
|
||||
'id' => 'gallery_addon',
|
||||
'title' => __('Galleries Addon', 'wpmf'),
|
||||
'icon' => 'add_photo_alternate',
|
||||
'sub_tabs' => array(
|
||||
'galleryadd_default_settings' => __('Default settings', 'wpmf'),
|
||||
'gallery_shortcode_generator' => __('Shortcode generator', 'wpmf'),
|
||||
'gallery_social_sharing' => __('Social sharing', 'wpmf')
|
||||
)
|
||||
),
|
||||
array(
|
||||
'id' => 'gallery_photographer_addon',
|
||||
'title' => __('Photographer', 'wpmf'),
|
||||
'icon' => 'camera_alt'
|
||||
),
|
||||
array(
|
||||
'id' => 'media_access',
|
||||
'title' => __('Access & design', 'wpmf'),
|
||||
'icon' => 'format_color_fill',
|
||||
'sub_tabs' => array(
|
||||
'user_media_access' => __('Media access', 'wpmf'),
|
||||
'file_design' => __('File Design', 'wpmf')
|
||||
)
|
||||
),
|
||||
array(
|
||||
'id' => 'files_folders',
|
||||
'title' => __('Rename & Watermark', 'wpmf'),
|
||||
'icon' => 'picture_in_picture_alt',
|
||||
'sub_tabs' => array(
|
||||
'rename_on_upload' => __('Rename on upload', 'wpmf'),
|
||||
'watermark' => __('Watermark', 'wpmf'),
|
||||
)
|
||||
),
|
||||
array(
|
||||
'id' => 'import_export',
|
||||
'title' => __('Import/Export', 'wpmf'),
|
||||
'icon' => 'import_export',
|
||||
'sub_tabs' => array(
|
||||
'wordpress_import' => __('Wordpress', 'wpmf'),
|
||||
'other_plugin_import' => __('Other plugins', 'wpmf')
|
||||
)
|
||||
),
|
||||
array(
|
||||
'id' => 'server_sync',
|
||||
'title' => __('Server Folder Sync', 'wpmf'),
|
||||
'icon' => 'import_export',
|
||||
'sub_tabs' => array(
|
||||
'server_folder_sync' => __('Folder Sync', 'wpmf'),
|
||||
'server_sync_settings' => __('Filters', 'wpmf')
|
||||
)
|
||||
),
|
||||
array(
|
||||
'id' => 'regenerate_thumbnails',
|
||||
'title' => __('Regenerate Thumb', 'wpmf'),
|
||||
'icon' => 'update',
|
||||
'sub_tabs' => array()
|
||||
),
|
||||
array(
|
||||
'id' => 'physical_server_folders',
|
||||
'title' => __('Physical folders', 'wpmf'),
|
||||
'icon' => 'folder',
|
||||
'sub_tabs' => array()
|
||||
),
|
||||
array(
|
||||
'id' => 'image_compression',
|
||||
'title' => __('Image compression', 'wpmf'),
|
||||
'icon' => 'compare',
|
||||
'sub_tabs' => array()
|
||||
)
|
||||
);
|
||||
|
||||
if (!is_plugin_active('wp-media-folder-gallery-addon/wp-media-folder-gallery-addon.php')) {
|
||||
unset($tabs_data[2]);
|
||||
unset($tabs_data[3]);
|
||||
}
|
||||
|
||||
if (is_plugin_active('wp-media-folder-addon/wp-media-folder-addon.php')) {
|
||||
$tabs_data[] = array(
|
||||
'id' => 'cloud',
|
||||
'title' => __('Cloud', 'wpmf'),
|
||||
'icon' => 'cloud_queue',
|
||||
'sub_tabs' => array(
|
||||
'google_drive_box' => __('Google Drive', 'wpmf'),
|
||||
'google_photo' => __('Google Photo', 'wpmf'),
|
||||
'dropbox_box' => __('Dropbox', 'wpmf'),
|
||||
'one_drive_box' => __('OneDrive', 'wpmf'),
|
||||
'nextcloud' => __('Nextcloud', 'wpmf'),
|
||||
'storage_provider' => __('Offload Media', 'wpmf'),
|
||||
'synchronization' => __('Synchronization', 'wpmf')
|
||||
)
|
||||
);
|
||||
}
|
||||
$tabs_data[] = array(
|
||||
'id' => 'jutranslation',
|
||||
'title' => __('Translation', 'wpmf'),
|
||||
'icon' => 'format_color_text',
|
||||
'sub_tabs' => array()
|
||||
);
|
||||
|
||||
$tabs_data[] = array(
|
||||
'id' => 'system_check',
|
||||
'title' => __('System Check', 'wpmf'),
|
||||
'content' => 'system-check',
|
||||
'icon' => 'verified_user',
|
||||
'sub_tabs' => array()
|
||||
);
|
||||
|
||||
$dropbox_config = get_option('_wpmfAddon_dropbox_config');
|
||||
$google_config = get_option('_wpmfAddon_cloud_config');
|
||||
$onedrive_config = get_option('_wpmfAddon_onedrive_config');
|
||||
$onedrive_business_config = get_option('_wpmfAddon_onedrive_business_config');
|
||||
|
||||
?>
|
||||
<div class="ju-main-wrapper">
|
||||
<div class="ju-left-panel-toggle">
|
||||
<i class="dashicons dashicons-leftright ju-left-panel-toggle-icon"></i>
|
||||
</div>
|
||||
<div class="ju-left-panel">
|
||||
<div class="ju-logo">
|
||||
<a href="https://www.joomunited.com/" target="_blank">
|
||||
<img src="<?php echo esc_url(WPMF_PLUGIN_URL . 'assets/wordpress-css-framework/images/logo-joomUnited-white.png') ?>"
|
||||
alt="<?php esc_html_e('JoomUnited logo', 'wpmf') ?>">
|
||||
</a>
|
||||
</div>
|
||||
<div class="ju-menu-search">
|
||||
<i class="material-icons ju-menu-search-icon">
|
||||
search
|
||||
</i>
|
||||
|
||||
<input type="text" class="ju-menu-search-input"
|
||||
placeholder="<?php esc_html_e('Search settings', 'wpmf') ?>"
|
||||
>
|
||||
</div>
|
||||
<ul class="tabs ju-menu-tabs">
|
||||
<?php foreach ($tabs_data as $ju_tab) : ?>
|
||||
<li class="tab" data-tab-title="<?php echo esc_attr($ju_tab['title']) ?>">
|
||||
<a href="#<?php echo esc_attr($ju_tab['id']) ?>"
|
||||
class="link-tab white-text <?php echo (empty($ju_tab['sub_tabs'])) ? 'no-submenus' : 'with-submenus' ?>"
|
||||
>
|
||||
<i class="material-icons menu-tab-icon"><?php echo esc_html($ju_tab['icon']) ?></i>
|
||||
<span class="tab-title" title="<?php echo esc_attr($ju_tab['title']) ?>"><?php echo esc_html($ju_tab['title']) ?></span>
|
||||
|
||||
<?php
|
||||
if ($ju_tab['id'] === 'system_check') {
|
||||
if (version_compare(PHP_VERSION, '7.2.0', '<') || !in_array('curl', get_loaded_extensions()) || !function_exists('gd_info')) {
|
||||
echo '<i class="material-icons system-checkbox material-icons-menu-alert" style="float: right;vertical-align: text-bottom;">info</i>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ju-right-panel">
|
||||
<div id="profiles-container">
|
||||
<?php
|
||||
if (!get_option('wpmf_cloud_connection_notice', false)) :
|
||||
if (!empty($dropbox_config['dropboxToken'])
|
||||
|| (!empty($google_config['connected']) && !empty($google_config['googleBaseFolder']))
|
||||
|| (!empty($onedrive_config['connected']) && !empty($onedrive_config['onedriveBaseFolder']['id']))
|
||||
|| (!empty($onedrive_business_config['connected']) && !empty($onedrive_business_config['onedriveBaseFolder']['id']))) :
|
||||
?>
|
||||
<div class="error wpmf_cloud_connection_notice" id="wpmf_error">
|
||||
<p><?php esc_html_e('WP Media Folder plugin has updated its cloud connection system, it\'s now fully integrated in the media library. It requires to make a synchronization', 'wpmf') ?>
|
||||
<button class="button button-primary btn-run-sync-cloud" style="margin: 0 5px;">
|
||||
<?php esc_html_e('RUN NOW', 'wpmf') ?><span class="spinner spinner-cloud-sync"
|
||||
style="display:none; visibility:visible"></span>
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<form enctype="multipart/form-data" name="form1" action="" method="post">
|
||||
<input type="hidden" name="wpmf_nonce"
|
||||
value="<?php echo esc_html(wp_create_nonce('wpmf_nonce')) ?>">
|
||||
<?php foreach ($tabs_data as $ju_tab) : ?>
|
||||
<div class="ju-content-wrapper" id="<?php echo esc_attr($ju_tab['id']) ?>" style="display: none">
|
||||
<?php
|
||||
if (!empty($ju_tab['sub_tabs'])) :
|
||||
?>
|
||||
<div class="ju-top-tabs-wrapper">
|
||||
<ul class="tabs ju-top-tabs">
|
||||
<?php
|
||||
foreach ($ju_tab['sub_tabs'] as $tab_id => $tab_label) :
|
||||
?>
|
||||
|
||||
<li class="tab">
|
||||
<a href="#<?php echo esc_html($tab_id) ?>"
|
||||
class="link-tab waves-effect waves-light">
|
||||
<?php echo esc_html($tab_label) ?>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<?php
|
||||
endforeach;
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<?php if ($ju_tab['id'] !== 'image_compression' && $ju_tab['id'] !== 'cloud' && $ju_tab['id'] !== 'import_export' && $ju_tab['id'] !== 'server_sync') : ?>
|
||||
<div class="wpmf_width_100 top_bar">
|
||||
<h1><?php echo esc_html($ju_tab['title']) ?></h1>
|
||||
<?php
|
||||
require WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/pages/settings/submit_button.php';
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- View request, no action
|
||||
if (isset($_POST['btn_wpmf_save']) && $ju_tab['id'] !== 'cloud') {
|
||||
?>
|
||||
<div class="wpmf_width_100 top_bar saved_infos">
|
||||
<?php
|
||||
require WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/pages/settings/saved_info.php';
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<?php include_once(WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/pages/settings/' . $ju_tab['id'] . '.php'); ?>
|
||||
<?php
|
||||
require WP_MEDIA_FOLDER_PLUGIN_DIR . '/class/pages/settings/submit_button.php';
|
||||
?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<input type="hidden" class="setting_tab_value" name="setting_tab_value" value="wpmf-general">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function ($) {
|
||||
$(function () {
|
||||
jQuery('.wp-color-field-bg').wpColorPicker({width: 180, defaultColor: '#202231'});
|
||||
jQuery('.wp-color-field-hv').wpColorPicker({width: 180, defaultColor: '#1c1e2a'});
|
||||
jQuery('.wp-color-field-font').wpColorPicker({width: 180, defaultColor: '#f4f6ff'});
|
||||
jQuery('.wp-color-field-hvfont').wpColorPicker({width: 180, defaultColor: '#ffffff'});
|
||||
jQuery('.wp-color-field-icon-color').wpColorPicker({width: 180, defaultColor: '#f4f6ff'});
|
||||
jQuery('.wp-color-field-border-color').wpColorPicker({width: 180, defaultColor: '#f4f6ff'});
|
||||
});
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,837 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
use Joomunited\WPMediaFolder\WpmfHelper;
|
||||
use Joomunited\Queue\JuMainQueue;
|
||||
|
||||
/**
|
||||
* Class JUQueueHelper
|
||||
*/
|
||||
class JUQueueHelper
|
||||
{
|
||||
|
||||
/**
|
||||
* All WPMF terms
|
||||
* Variable used as a cache to not retrieved terms each time the
|
||||
* method is called
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
protected static $terms = null;
|
||||
|
||||
/**
|
||||
* Update folder name and move files
|
||||
*
|
||||
* @param integer $folder_id Folder id
|
||||
* @param string $folder_name Folder name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function updateFolderName($folder_id, $folder_name)
|
||||
{
|
||||
// Get children folders
|
||||
$folders = self::getChildTerms($folder_id);
|
||||
|
||||
$folders[] = (int)$folder_id;
|
||||
|
||||
foreach ($folders as $folder) {
|
||||
// Get attachments in this folder
|
||||
$attachments = get_posts(array(
|
||||
'post_type' => 'attachment',
|
||||
'numberposts' => -1,
|
||||
'tax_query' => array(
|
||||
array(
|
||||
'taxonomy' => WPMF_TAXO,
|
||||
'field' => 'id',
|
||||
'terms' => $folder,
|
||||
'include_children' => false
|
||||
)
|
||||
),
|
||||
'meta_query' => array(
|
||||
'relation' => 'AND',
|
||||
array(
|
||||
'key' => 'wpmf_drive_id',
|
||||
'compare' => 'NOT EXISTS'
|
||||
),
|
||||
array(
|
||||
'key' => 'wpmf_awsS3_info',
|
||||
'compare' => 'NOT EXISTS'
|
||||
)
|
||||
)
|
||||
));
|
||||
|
||||
$folders_path = self::getParentTerms($folder);
|
||||
$folders_path_string = implode(DIRECTORY_SEPARATOR, $folders_path);
|
||||
$wpmfQueue = JuMainQueue::getInstance('wpmf');
|
||||
foreach ($attachments as $attachment) {
|
||||
$datas = array(
|
||||
'post_id' => $attachment->ID,
|
||||
'destination' => $folders_path_string,
|
||||
'with_filename' => false,
|
||||
'delete_folder' => true,
|
||||
'update_database' => true,
|
||||
'action' => 'wpmf_physical_folders'
|
||||
);
|
||||
$wpmfQueue->addToQueue($datas);
|
||||
}
|
||||
$wpmfQueue->proceedQueueAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get recursively all child terms of a given term
|
||||
*
|
||||
* @param integer $parent Term we want to find the children of
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function getChildTerms($parent)
|
||||
{
|
||||
// get all direct decendents of the $parent
|
||||
$terms = get_terms(array(
|
||||
'taxonomy' => WPMF_TAXO,
|
||||
'parent' => $parent,
|
||||
'hide_empty' => false
|
||||
));
|
||||
$children = array();
|
||||
|
||||
// go through all the direct decendents of $parent
|
||||
foreach ($terms as $term) {
|
||||
// recurse to get the direct decendents of the current term
|
||||
$children = array_merge($children, self::getChildTerms($term->term_id));
|
||||
|
||||
$children[] = $term->term_id;
|
||||
}
|
||||
|
||||
return $children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all WPMF terms
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getAllTerms()
|
||||
{
|
||||
// Retrieve all folders
|
||||
$wpterms = get_terms(
|
||||
array(
|
||||
'taxonomy' => WPMF_TAXO,
|
||||
'hide_empty' => false
|
||||
)
|
||||
);
|
||||
|
||||
// Associate folders by term id
|
||||
$terms = array();
|
||||
foreach ($wpterms as $term) {
|
||||
$terms[$term->term_id] = $term;
|
||||
}
|
||||
|
||||
return $terms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all parent terms
|
||||
*
|
||||
* @param integer $term Term we want to find parents of
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getParentTerms($term)
|
||||
{
|
||||
if ($term === 0) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// Retrieve all WPMF terms
|
||||
self::$terms = self::getAllTerms();
|
||||
// Initialize array that will contain all parent folders
|
||||
$folders = array();
|
||||
$current_folder = $term;
|
||||
// Retrieve parents one by one
|
||||
do {
|
||||
$current_term = self::$terms[$current_folder];
|
||||
$folders[] = $current_term->name;
|
||||
$current_folder = $current_term->parent;
|
||||
} while ($current_term->parent);
|
||||
|
||||
return array_reverse($folders);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a file and its thumbnails physically
|
||||
*
|
||||
* @param array $datas Data details
|
||||
* @param boolean $is_wpml_translation Is this file a wpml translation of another moved file?
|
||||
*
|
||||
* @return boolean|WP_Error true on success or WP_ERROR
|
||||
*/
|
||||
public static function moveFile($datas = array(), $is_wpml_translation = false)
|
||||
{
|
||||
WP_Filesystem();
|
||||
global $wp_filesystem;
|
||||
global $wpdb;
|
||||
|
||||
// Sanitize destination path
|
||||
foreach ($datas as $param => $data) {
|
||||
${$param} = $data;
|
||||
}
|
||||
$destination = self::sanitizePath($destination);
|
||||
if ($with_filename && !strlen(trim($destination, '/'))) {
|
||||
JuMainQueue::log('Error : destination file empty');
|
||||
return true;
|
||||
}
|
||||
|
||||
$related_files = array('original' => array(), 'thumbnails' => array(), 'backups' => array());
|
||||
|
||||
$wp_uploads = wp_upload_dir();
|
||||
|
||||
// Retrieve attachment full path
|
||||
$related_files['original']['path'] = get_attached_file($post_id, 1);
|
||||
$related_files['original']['url'] = wp_get_attachment_url($post_id);
|
||||
if (!$related_files['original']['path'] || !$related_files['original']['url']) {
|
||||
JuMainQueue::log('Error : Attachment %s not found', $$post_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Remove file name from path and url
|
||||
$base_path = pathinfo($related_files['original']['path'], PATHINFO_DIRNAME);
|
||||
$url_parts = explode('/', $related_files['original']['url']);
|
||||
unset($url_parts[count($url_parts)-1]); // Remove the filename from parts
|
||||
$base_url = implode('/', $url_parts);
|
||||
|
||||
// Check that the file is located inside the WordPress upload dir
|
||||
if (strpos($base_url, $wp_uploads['baseurl']) !== 0 || strpos($base_path, $wp_uploads['basedir']) !== 0) {
|
||||
JuMainQueue::log('Error : file is not int the upload folder %s', $base_path);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Make url and path relative to the wordpress installation
|
||||
$base_path = str_replace($wp_uploads['basedir'], '', $base_path);
|
||||
$base_url = str_replace($wp_uploads['baseurl'], '', $base_url);
|
||||
|
||||
// Replace windows
|
||||
$base_path = str_replace(DIRECTORY_SEPARATOR, '/', $base_path);
|
||||
|
||||
// Apply relative path to the original file and url
|
||||
$related_files['original']['path'] = str_replace($wp_uploads['basedir'], '', $related_files['original']['path']);
|
||||
$related_files['original']['url'] = str_replace($wp_uploads['baseurl'], '', $related_files['original']['url']);
|
||||
|
||||
// Retrieve file extension from thumbnail name
|
||||
$extension = explode('.', $related_files['original']['path']);
|
||||
$extension = $extension[count($extension)-1];
|
||||
|
||||
if ($with_filename) {
|
||||
$filename = $destination . '.' . $extension;
|
||||
} else {
|
||||
$filename = $destination . '/' . pathinfo($related_files['original']['path'], PATHINFO_BASENAME);
|
||||
}
|
||||
$related_files['original']['new_path'] = '/' . ltrim($filename, '/');
|
||||
$related_files['original']['new_url'] = '/' . ltrim($filename, '/');
|
||||
|
||||
// Retrieve all meta to extract the tumbnails
|
||||
$meta = wp_get_attachment_metadata($post_id);
|
||||
if (isset($meta['sizes']) && is_array($meta['sizes'])) {
|
||||
foreach ($meta['sizes'] as &$size) {
|
||||
// Add to array original url and path
|
||||
$file = array(
|
||||
'path' => $base_path . '/' . $size['file'],
|
||||
'url' => $base_url . '/' . $size['file']
|
||||
);
|
||||
|
||||
// Retrieve file extension from thumbnail name
|
||||
$extension = explode('.', $size['file']);
|
||||
$extension = $extension[count($extension) - 1];
|
||||
|
||||
if ($with_filename) {
|
||||
$filename = $destination . '-' . (int)$size['width'] . 'x' . (int)$size['height'] . '.' . $extension;
|
||||
|
||||
// Update meta filename
|
||||
$size['file'] = pathinfo($filename, PATHINFO_BASENAME);
|
||||
} else {
|
||||
$filename = $destination . '/' . $size['file'];
|
||||
}
|
||||
$file['new_path'] = '/' . ltrim($filename, '/');
|
||||
$file['new_url'] = '/' . ltrim($filename, '/');
|
||||
|
||||
$related_files['thumbnails'][] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($meta['file'])) {
|
||||
$meta['file'] = ltrim($related_files['original']['new_path'], '/');
|
||||
}
|
||||
|
||||
// Retrieve the backups of the images
|
||||
$backup_sizes = get_post_meta($post_id, '_wp_attachment_backup_sizes', true);
|
||||
if ($backup_sizes && is_array($backup_sizes)) {
|
||||
foreach ($backup_sizes as $backup_size) {
|
||||
$destination_folder = $destination;
|
||||
if ($with_filename) {
|
||||
// Remove filename from destination var
|
||||
$destination_folder = explode('/', $destination_folder);
|
||||
unset($destination_folder[count($destination_folder)-1]);
|
||||
$destination_folder = implode('/', $destination_folder);
|
||||
}
|
||||
|
||||
$related_files['backups'][] = array(
|
||||
'path' => $base_path . '/' . $backup_size['file'],
|
||||
'url' => $base_url . '/' . $backup_size['file'],
|
||||
'new_path' => '/' . $destination_folder . '/' . $backup_size['file'],
|
||||
'new_url' => '/' . $destination_folder . '/' . $backup_size['file']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// get original image
|
||||
if (isset($meta['original_image'])) {
|
||||
// Add to array original url and path
|
||||
$file = array(
|
||||
'path' => $base_path . '/' . $meta['original_image'],
|
||||
'url' => $base_url . '/' . $meta['original_image']
|
||||
);
|
||||
|
||||
// Retrieve file extension from thumbnail name
|
||||
$filename = $destination . '/' . $meta['original_image'];
|
||||
$file['new_path'] = '/' . ltrim($filename, '/');
|
||||
$file['new_url'] = '/' . ltrim($filename, '/');
|
||||
$file['width'] = $meta['width'];
|
||||
$file['height'] = $meta['height'];
|
||||
$file['filesize'] = $meta['filesize'];
|
||||
$related_files['backups'][] = $file;
|
||||
}
|
||||
|
||||
$original_file = $wp_uploads['basedir'] . $related_files['original']['path'];
|
||||
$new_file = $wp_uploads['basedir'] . $related_files['original']['new_path'];
|
||||
$override = (defined('WPMF_PHYSICAL_OVERRIDE')) ? true : false;
|
||||
// Check if source file exists
|
||||
if (file_exists($original_file) && is_file($original_file)) {
|
||||
if (realpath($original_file) !== realpath($new_file)) {
|
||||
// Check is there is already a destination file with this name
|
||||
if (!$override) {
|
||||
if (file_exists($new_file)) {
|
||||
JuMainQueue::log('Error : file is %s already exists', $new_file);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (file_exists($new_file)) {
|
||||
$current_file_id = attachment_url_to_postid($wp_uploads['baseurl'] . $related_files['original']['new_path']);
|
||||
if (!empty($current_file_id)) {
|
||||
WpmfHelper::replace($current_file_id, $new_file, $original_file);
|
||||
$folders = get_the_terms($current_file_id, WPMF_TAXO);
|
||||
if (!empty($folders)) {
|
||||
$folder = $folders[0]->term_id;
|
||||
$parents = self::getParentTerms($folder);
|
||||
$destination = implode(DIRECTORY_SEPARATOR, $parents);
|
||||
}
|
||||
|
||||
$meta_data = wp_get_attachment_metadata($current_file_id);
|
||||
$dirname = _wp_get_attachment_relative_path($meta_data['file']);
|
||||
if ($dirname) {
|
||||
$dirname = trailingslashit($dirname);
|
||||
}
|
||||
|
||||
if ($dirname === '') {
|
||||
$meta_data['file'] = $destination . '/' . $meta_data['file'];
|
||||
} else {
|
||||
$meta_data['file'] = str_replace($dirname, $destination . '/', $meta_data['file']);
|
||||
}
|
||||
|
||||
wp_update_attachment_metadata($current_file_id, $meta_data);
|
||||
if (!$datas['update_database'] && (int)$current_file_id !== (int)$post_id) {
|
||||
$datas = array(
|
||||
'post_id' => $post_id,
|
||||
'action' => 'wpmf_delete_attachment'
|
||||
);
|
||||
$wpmfQueue = JuMainQueue::getInstance('wpmf');
|
||||
$wpmfQueue->addToQueue($datas);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Create directory
|
||||
$dir = pathinfo($new_file, PATHINFO_DIRNAME);
|
||||
if (!file_exists($dir)) {
|
||||
wp_mkdir_p($dir);
|
||||
}
|
||||
|
||||
// Move actual file
|
||||
if (!$wp_filesystem->move(
|
||||
$original_file,
|
||||
$new_file,
|
||||
$override
|
||||
)) {
|
||||
JuMainQueue::log('Error : moving file %s to %s went wrong', $original_file, $new_file);
|
||||
return true;
|
||||
}
|
||||
JuMainQueue::log('Info : file moved from %s to %s', $original_file, $new_file);
|
||||
} elseif (!$is_wpml_translation) {
|
||||
JuMainQueue::log('Error : source and destination file are the same %s', $new_file);
|
||||
return true;
|
||||
}
|
||||
} elseif (!$is_wpml_translation) {
|
||||
JuMainQueue::log('Error : file %s does not exist', $original_file);
|
||||
return true;
|
||||
}
|
||||
// if file is a wpml translation, the file may have already been moved by the calling function
|
||||
// Update file meta (_wp_attached_file)
|
||||
if (ltrim($related_files['original']['path'], '/') !== ltrim($related_files['original']['new_path'], '/')) {
|
||||
if (update_post_meta($post_id, '_wp_attached_file', ltrim($related_files['original']['new_path'], '/')) !== true) {
|
||||
JuMainQueue::log('Error : updating post meta failed %s %s', $post_id, ltrim($related_files['original']['new_path'], '/'));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Todo update guid via sql query ???
|
||||
// Array containing all actually moved files to be replaced in db
|
||||
$done_files = array();
|
||||
$done_files[] = $related_files['original'];
|
||||
|
||||
// Move all thumbnails and backup files
|
||||
foreach (array($related_files['thumbnails'], $related_files['backups']) as $file_type) {
|
||||
foreach ($file_type as $file) {
|
||||
$original_file = $wp_uploads['basedir'] . $file['path'];
|
||||
$new_file = $wp_uploads['basedir'] . $file['new_path'];
|
||||
if (file_exists($original_file)) {
|
||||
if (!$wp_filesystem->move($original_file, $new_file, $override)) {
|
||||
JuMainQueue::log('Error : related file move failed from %s to %s', $original_file, $new_file);
|
||||
continue;
|
||||
}
|
||||
} elseif (!$is_wpml_translation) {
|
||||
JuMainQueue::log('Error: related file doesn not exist %s', $original_file);
|
||||
continue;
|
||||
}
|
||||
|
||||
$done_files[] = $file;
|
||||
JuMainQueue::log('Info : related file moved from %s to %s', $original_file, $new_file);
|
||||
}
|
||||
}
|
||||
|
||||
// Update thumbnails meta
|
||||
if (!empty($meta)) {
|
||||
wp_update_attachment_metadata($post_id, $meta);
|
||||
}
|
||||
|
||||
// Update wpml translation attachments and thumbnails
|
||||
if (!$is_wpml_translation && function_exists('icl_object_id')) {
|
||||
$post_translations = array();
|
||||
|
||||
$query = 'SELECT * FROM `' . $wpdb->prefix . 'icl_translations` WHERE trid=(SELECT trid FROM `' . $wpdb->prefix . 'icl_translations` WHERE element_type="post_attachment" AND element_id=' . (int)$post_id . ') AND element_id<>' . (int)$post_id;
|
||||
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Query escaped previously
|
||||
$post_translations = $wpdb->get_results($query, ARRAY_A);
|
||||
|
||||
foreach ($post_translations as $translation) {
|
||||
$translation_post_meta = get_post_meta($translation['element_id'], '_wp_attached_file', true);
|
||||
|
||||
if ($translation_post_meta === ltrim($related_files['original']['path'], '/')) {
|
||||
// This is the same exact file
|
||||
|
||||
// Update _wp_attached_file key
|
||||
if (update_post_meta($translation['element_id'], '_wp_attached_file', ltrim($related_files['original']['new_path'], '/')) !== true) {
|
||||
JuMainQueue::log('Error : updating post meta failed %s %s', $translation['element_id'], ltrim($related_files['original']['new_path'], '/'));
|
||||
continue;
|
||||
}
|
||||
|
||||
$translation_meta = wp_get_attachment_metadata($translation['element_id']);
|
||||
if (isset($translation_meta['file']) && $translation_meta['file'] === ltrim($related_files['original']['path'], '/')) {
|
||||
$translation_meta['file'] = ltrim($related_files['original']['new_path'], '/');
|
||||
}
|
||||
|
||||
// Only basename is saved in the _wp_attachment_metadata sizes col, no need to do anything if we only change the folder
|
||||
if ($with_filename && isset($translation_meta['sizes']) && is_array($translation_meta['sizes'])) {
|
||||
// Loop over the sizes of this translation attachment
|
||||
foreach ($translation_meta['sizes'] as &$size) {
|
||||
// Loop over the thumbnails already moved to see if this one of them
|
||||
foreach ($related_files['thumbnails'] as $thumbnail) {
|
||||
if (pathinfo($thumbnail['path'], PATHINFO_BASENAME) === $size['file'] &&
|
||||
pathinfo($translation_post_meta, PATHINFO_DIRNAME) === pathinfo(ltrim($thumbnail['path'], '/'), PATHINFO_DIRNAME)) { // Make this thumbnail is not a thumbnail in another folder
|
||||
// Update meta filename
|
||||
$size['file'] = pathinfo($thumbnail['new_path'], PATHINFO_BASENAME);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
preg_match('/(do_action|apply_filters)\(.*\);/', $match, $hook_matches);
|
||||
|
||||
if (!empty($translation_meta)) {
|
||||
wp_update_attachment_metadata($translation['element_id'], $translation_meta);
|
||||
}
|
||||
} else {
|
||||
// This is not the same file but still it has to be in the same folder, lets move all of them (main file, thumbnails, backups)
|
||||
$new_path = pathinfo($related_files['original']['new_path'], PATHINFO_DIRNAME);
|
||||
self::moveFile(array(
|
||||
'post_id' => $translation['element_id'],
|
||||
'destination' => $new_path,
|
||||
'with_filename' => false,
|
||||
'delete_folder' => $delete_folder,
|
||||
'update_database' => $update_database,
|
||||
'action' => 'wpmf_physical_folders'
|
||||
), true);
|
||||
|
||||
if ($with_filename) {
|
||||
// At this points backups have been moved but still it has to be renamed in the db
|
||||
$backup_sizes = get_post_meta($translation['element_id'], '_wp_attachment_backup_sizes', true);
|
||||
|
||||
if (!empty($backup_sizes) &&
|
||||
isset($backup_sizes['full-orig']) &&
|
||||
$backup_sizes['full-orig']['file'] === ltrim($related_files['original']['path'], '/')) {
|
||||
foreach ($backup_sizes as $backup_name => &$backup_size) {
|
||||
if ($backup_name === 'full-orig') {
|
||||
$backup_size['file'] = ltrim($related_files['original']['new_path'], '/');
|
||||
} else {
|
||||
// Retrieve file extension from thumbnail name
|
||||
$extension = explode('.', $backup_size['file']);
|
||||
$extension = $extension[count($extension) - 1];
|
||||
|
||||
$backup_size['file'] = $destination . '-' . (int)$backup_size['width'] . 'x' . (int)$backup_size['height'] . '.' . $extension;
|
||||
}
|
||||
}
|
||||
|
||||
update_post_meta($translation['element_id'], '_wp_attachment_backup_sizes', $backup_sizes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($delete_folder) {
|
||||
$dir = pathinfo($wp_uploads['basedir'] . '/' . $related_files['original']['path'], PATHINFO_DIRNAME);
|
||||
self::deleteDirectory($dir);
|
||||
}
|
||||
|
||||
// Replace in database file url
|
||||
$options = get_option('wpmf_queue_options');
|
||||
|
||||
if (!empty($options['auto_detect_tables'])) {
|
||||
$tables = self::getDefaultDbColumns();
|
||||
} else {
|
||||
$tables = wpmfGetOption('wp-media-folder-tables');
|
||||
}
|
||||
|
||||
if (!$update_database) {
|
||||
JuMainQueue::log('Info : Database update not required');
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach ($done_files as $done_file) {
|
||||
foreach ($tables as $table => &$columns) {
|
||||
if (!count($columns)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the primary key of the table
|
||||
$key = $wpdb->get_row('SHOW KEYS FROM ' . esc_sql($table) . ' WHERE Key_name = "PRIMARY"');
|
||||
|
||||
// No primary key, we can't do anything in this table
|
||||
if ($key === null) {
|
||||
JuMainQueue::log('No primary key in table', $table);
|
||||
continue;
|
||||
}
|
||||
|
||||
$key = $key->Column_name;
|
||||
|
||||
$count_records = $wpdb->get_var('SELECT COUNT(' . esc_sql($key) . ') FROM ' . esc_sql($table));
|
||||
$limit = 200;
|
||||
$total_pages = ceil($count_records/$limit);
|
||||
for ($i = 1; $i <= $total_pages; $i++) {
|
||||
$datas = array(
|
||||
'table' => $table,
|
||||
'columns' => $columns,
|
||||
'page' => (int)$i,
|
||||
'limit' => (int)$limit,
|
||||
'key' => $key,
|
||||
'done_file' => $done_file,
|
||||
'action' => 'wpmf_replace_physical_url'
|
||||
);
|
||||
$row = JuMainQueue::checkQueueExist(json_encode($datas));
|
||||
if (!$row) {
|
||||
JuMainQueue::addToQueue($datas);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace physical URL in database
|
||||
*
|
||||
* @param boolean $result Result
|
||||
* @param array $datas Data details
|
||||
* @param integer $element_id ID of queue element
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function replacePhysicalUrl($result, $datas, $element_id)
|
||||
{
|
||||
global $wpdb;
|
||||
$table = $datas['table'];
|
||||
$columns = $datas['columns'];
|
||||
$key = $datas['key'];
|
||||
$done_file = $datas['done_file'];
|
||||
$offset = ((int)$datas['page'] - 1)*(int)$datas['limit'];
|
||||
$wp_uploads = wp_upload_dir();
|
||||
foreach ($columns as $column => $column_value) {
|
||||
// Search for serialized strings
|
||||
$query = 'SELECT ' . esc_sql($key) . ',' . esc_sql($column) . ' FROM ' . esc_sql($table). ' WHERE
|
||||
' . esc_sql($column) . ' REGEXP \'s:[0-9]+:".*(' . esc_sql(preg_quote($wp_uploads['baseurl'] . $done_file['url'])) . '|' . esc_sql(preg_quote($done_file['url'])) . ').*";\' LIMIT '. esc_sql($datas['limit']) .' OFFSET ' . esc_sql($offset);
|
||||
|
||||
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Query escaped previously
|
||||
$results = $wpdb->get_results($query, ARRAY_N);
|
||||
|
||||
if (count($results)) {
|
||||
foreach ($results as $result) {
|
||||
$unserialized_var = unserialize($result[1]);
|
||||
if ($unserialized_var !== false) {
|
||||
// We're sure this is a serialized value, proceed it here
|
||||
unset($columns[$column]);
|
||||
// Actually replace string in all available strin array and properties
|
||||
$unserialized_var = self::replaceStringRecursive($unserialized_var, $done_file['url'], $done_file['new_url']);
|
||||
$unserialized_var = self::replaceStringRecursive($unserialized_var, $wp_uploads['baseurl'] . $done_file['url'], $wp_uploads['baseurl'] . $done_file['new_url']);
|
||||
// Serialize it back
|
||||
$serialized_var = serialize($unserialized_var);
|
||||
|
||||
// Update the database with new serialized value
|
||||
$nb_rows = $wpdb->query($wpdb->prepare(
|
||||
'UPDATE ' . esc_sql($table) . ' SET ' . esc_sql($column) . '=%s WHERE ' . esc_sql($key) . '=%s AND meta_key NOT IN("_wp_attached_file", "_wp_attachment_metadata")',
|
||||
array($serialized_var, $result[0])
|
||||
));
|
||||
JuMainQueue::log('Update serialized data (%s row affected) : %s', $nb_rows, $query);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($columns)) {
|
||||
$columns_query = array();
|
||||
|
||||
foreach ($columns as $column => $column_value) {
|
||||
if (!empty($options['replace_relative_paths'])) {
|
||||
// Relative urls
|
||||
$columns_query[] = '`' . $column . '` = replace(`' . esc_sql($column) . '`, "' . esc_sql($done_file['url']) . '", "' . esc_sql($done_file['new_url']) . '")';
|
||||
}
|
||||
$columns_query[] = '`' . $column . '` = replace(`' . esc_sql($column) . '`, "' . esc_sql($wp_uploads['baseurl'] . $done_file['url']) . '", "' . esc_sql($wp_uploads['baseurl'] . $done_file['new_url']) . '")';
|
||||
}
|
||||
|
||||
$query = 'UPDATE `' . esc_sql($table) . '` SET ' . implode(',', $columns_query);
|
||||
|
||||
// Ignore attachments meta column
|
||||
if ($table === $wpdb->prefix . 'postmeta') {
|
||||
$query .= ' WHERE meta_key NOT IN("_wp_attached_file", "_wp_attachment_metadata")';
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Query escaped previously
|
||||
$nb_rows = $wpdb->query($query);
|
||||
JuMainQueue::log('Query (%s row affected) : %s', $nb_rows, $query);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively parse a variable to replace a string
|
||||
*
|
||||
* @param mixed $var Variable to replace string into
|
||||
* @param string $search String to search
|
||||
* @param string $replace String to replace with
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private static function replaceStringRecursive($var, $search, $replace)
|
||||
{
|
||||
switch (gettype($var)) {
|
||||
case 'string':
|
||||
return str_replace($search, $replace, $var);
|
||||
|
||||
case 'array':
|
||||
foreach ($var as &$property) {
|
||||
$property = self::replaceStringRecursive($property, $search, $replace);
|
||||
}
|
||||
return $var;
|
||||
|
||||
case 'object':
|
||||
foreach (get_object_vars($var) as $property_name => $property_value) {
|
||||
$var->{$property_name} = self::replaceStringRecursive($property_value, $search, $replace);
|
||||
}
|
||||
return $var;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize a file path
|
||||
*
|
||||
* @param string $path Path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function sanitizePath($path)
|
||||
{
|
||||
// Replace non unix space separators by /
|
||||
$path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
|
||||
|
||||
$path = explode('/', $path);
|
||||
|
||||
$stack = array();
|
||||
foreach ($path as $seg) {
|
||||
// Remove all dots segments
|
||||
if ($seg === '..' || $seg === '.') {
|
||||
// Ignore this segment
|
||||
continue;
|
||||
}
|
||||
|
||||
// Remove all non matching characters
|
||||
$seg = sanitize_file_name($seg);
|
||||
|
||||
if (strlen($seg)) {
|
||||
$stack[] = $seg;
|
||||
}
|
||||
}
|
||||
|
||||
return implode('/', $stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list the main image and all thumbnails of the attachment
|
||||
*
|
||||
* @param integer $post_id Attachment id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private static function getAllImagesUrl($post_id)
|
||||
{
|
||||
$images = array();
|
||||
|
||||
// Add main image
|
||||
$images['original'] = wp_get_attachment_url($post_id);
|
||||
|
||||
foreach (get_intermediate_image_sizes() as $size) {
|
||||
$image = image_downsize($post_id, $size);
|
||||
|
||||
if ($image !== false && $image[3] === true) {
|
||||
$images[$image[1] . 'x' . $image[2]] = $image[0];
|
||||
}
|
||||
}
|
||||
return array_unique($images);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all text assimilated columns from database
|
||||
*
|
||||
* @param boolean $all Retrive only prefix tables or not
|
||||
*
|
||||
* @return array|null|object
|
||||
*/
|
||||
public static function getDbColumns($all)
|
||||
{
|
||||
global $wpdb;
|
||||
$extra_query = '';
|
||||
|
||||
// Not forced to retrieve all tables
|
||||
if (!$all) {
|
||||
// If option not set to look for all tables
|
||||
$options = get_option('wpmf_queue_options');
|
||||
if (empty($options['search_full_database'])) {
|
||||
$extra_query = ' AND TABLE_NAME LIKE "'.$wpdb->prefix.'%" ';
|
||||
}
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Nothing to prepare
|
||||
return $wpdb->get_results('SELECT TABLE_NAME, COLUMN_NAME, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE IN ("varchar", "text", "tinytext", "mediumtext", "longtext") AND TABLE_SCHEMA = "'.DB_NAME.'" '.$extra_query.' ORDER BY TABLE_NAME', OBJECT);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the columns that can contain images
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getDefaultDbColumns()
|
||||
{
|
||||
$columns = self::getDbColumns(false);
|
||||
|
||||
$final_columns = array();
|
||||
|
||||
foreach ($columns as $column) {
|
||||
$matches = array();
|
||||
preg_match('/varchar\(([0-9]+)\)/', $column->COLUMN_TYPE, $matches);
|
||||
|
||||
if (count($matches) && (int)$matches[1] < 40) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($final_columns[$column->TABLE_NAME])) {
|
||||
$final_columns[$column->TABLE_NAME] = array();
|
||||
}
|
||||
$final_columns[$column->TABLE_NAME][$column->COLUMN_NAME] = 1;
|
||||
}
|
||||
|
||||
return $final_columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a random string
|
||||
*
|
||||
* @param integer $length Length of the returned string
|
||||
*
|
||||
* @author https://stackoverflow.com/questions/4356289/php-random-string-generator#answer-4356295
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getRandomString($length = 20)
|
||||
{
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a folder
|
||||
*
|
||||
* @param WP_Term $folder_term Detail of folder
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function deleteFolder($folder_term)
|
||||
{
|
||||
// Sanitize folder path
|
||||
$folders_path = array();
|
||||
if ($folder_term->parent !== 0) {
|
||||
$folders_path = self::getParentTerms($folder_term->parent);
|
||||
}
|
||||
$folders_path[] = $folder_term->name;
|
||||
$folders_path_string = implode(DIRECTORY_SEPARATOR, $folders_path);
|
||||
|
||||
$wp_uploads = wp_upload_dir();
|
||||
$directory = $wp_uploads['basedir'] . DIRECTORY_SEPARATOR . self::sanitizePath($folders_path_string);
|
||||
self::deleteDirectory($directory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an actual directory if it's empty
|
||||
*
|
||||
* @param string $directory Directory
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function deleteDirectory($directory)
|
||||
{
|
||||
if (!file_exists($directory)) {
|
||||
JuMainQueue::log('Info : Directory doesn\'t exist ' . $directory);
|
||||
return;
|
||||
}
|
||||
$dir_files = glob($directory . DIRECTORY_SEPARATOR . '*');
|
||||
if (!empty($dir_files)) {
|
||||
JuMainQueue::log('Info : Directory not empty ' . $directory);
|
||||
} else {
|
||||
JuMainQueue::log('Info : Removing empty directory ' . $directory);
|
||||
rmdir($directory);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,287 @@
|
||||
<?php
|
||||
/* Prohibit direct script loading */
|
||||
defined('ABSPATH') || die('No direct script access allowed!');
|
||||
use Joomunited\Queue\JuMainQueue;
|
||||
|
||||
/**
|
||||
* Class JUQueueActions
|
||||
*/
|
||||
class JUQueueActions
|
||||
{
|
||||
|
||||
/**
|
||||
* All WPMF terms
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $terms = null;
|
||||
|
||||
/**
|
||||
* JUQueueActions constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
add_filter(
|
||||
'wpmf_physical_folders',
|
||||
function ($result, $datas, $element_id) {
|
||||
$result = JUQueueHelper::moveFile($datas);
|
||||
$wpmfQueue = JuMainQueue::getInstance('wpmf');
|
||||
$wpmfQueue->updateQueuePostMeta((int)$datas['post_id'], (int)$element_id);
|
||||
return $result;
|
||||
},
|
||||
10,
|
||||
3
|
||||
);
|
||||
|
||||
add_filter(
|
||||
'wpmf_replace_physical_url',
|
||||
function ($result, $datas, $element_id) {
|
||||
$result = JUQueueHelper::replacePhysicalUrl($result, $datas, $element_id);
|
||||
return $result;
|
||||
},
|
||||
10,
|
||||
3
|
||||
);
|
||||
|
||||
/**
|
||||
* Add an input to allow changing file path
|
||||
*/
|
||||
add_filter(
|
||||
'attachment_fields_to_edit',
|
||||
function ($form_fields, $post) {
|
||||
$url = wp_get_attachment_url($post->ID);
|
||||
|
||||
$uploads = wp_upload_dir();
|
||||
|
||||
if (strpos($url, $uploads['baseurl'])!==0) {
|
||||
$html = __('This file is not in the allowed upload folder', 'wpmf');
|
||||
} else {
|
||||
$path = str_replace($uploads['baseurl'], '', $url);
|
||||
|
||||
$file_extension = pathinfo($path, PATHINFO_EXTENSION);
|
||||
|
||||
$path = substr($path, 0, -(strlen($file_extension)+1));
|
||||
|
||||
$html = '<input name="attachments['.$post->ID.'][file_path]" id="attachments['.$post->ID.'][file_path]" value="'.htmlentities($path, ENT_COMPAT, 'UTF-8').'" /> . '.$file_extension;
|
||||
}
|
||||
|
||||
$form_fields['file_path'] = array(
|
||||
'label' => esc_html__('File path', 'wpmf'),
|
||||
'input' => 'html',
|
||||
'html' => $html,
|
||||
'helps' => esc_html__('File path and name related to upload folder', 'wpmf') . '/' . substr($uploads['basedir'], strlen(get_home_path()))
|
||||
);
|
||||
|
||||
return $form_fields;
|
||||
},
|
||||
10,
|
||||
2
|
||||
);
|
||||
|
||||
/**
|
||||
* Save modification made on media page
|
||||
*/
|
||||
add_filter(
|
||||
'attachment_fields_to_save',
|
||||
function ($post, $attachment) {
|
||||
if (isset($attachment['file_path'])) {
|
||||
$datas = array(
|
||||
'post_id' => $post['ID'],
|
||||
'destination' => $attachment['file_path'],
|
||||
'with_filename' => true,
|
||||
'delete_folder' => false,
|
||||
'update_database' => true,
|
||||
'action' => 'wpmf_physical_folders'
|
||||
);
|
||||
$wpmfQueue = JuMainQueue::getInstance('wpmf');
|
||||
$result = $wpmfQueue->addToQueue($datas);
|
||||
|
||||
if (is_wp_error($result)) {
|
||||
$post['errors']['file_path']['errors'][] = $result->get_error_message();
|
||||
return $post;
|
||||
}
|
||||
}
|
||||
|
||||
return $post;
|
||||
},
|
||||
10,
|
||||
2
|
||||
);
|
||||
|
||||
/**
|
||||
* Hook on the set attachment folder action
|
||||
*/
|
||||
add_action(
|
||||
'wpmf_attachment_set_folder',
|
||||
function ($attachment_id, $folder, $extra) {
|
||||
$update_db = true;
|
||||
if (is_array($extra) && !empty($extra['trigger']) && $extra['trigger'] === 'upload') {
|
||||
$update_db = false;
|
||||
// do not use queue process when upload a new file
|
||||
return;
|
||||
}
|
||||
$folders = JUQueueHelper::getParentTerms($folder);
|
||||
$destination = implode(DIRECTORY_SEPARATOR, $folders);
|
||||
$destination = apply_filters('wpmf_update_actual_folder_name', $destination);
|
||||
$datas = array(
|
||||
'post_id' => $attachment_id,
|
||||
'destination' => $destination,
|
||||
'with_filename' => false,
|
||||
'delete_folder' => false,
|
||||
'update_database' => $update_db,
|
||||
'action' => 'wpmf_physical_folders'
|
||||
);
|
||||
$wpmfQueue = JuMainQueue::getInstance('wpmf');
|
||||
$wpmfQueue->addToQueue($datas);
|
||||
// Move files at the end of the script to avoid thumbnails generation issues
|
||||
add_action('shutdown', function () {
|
||||
$wpmfQueue = JuMainQueue::getInstance('wpmf');
|
||||
$wpmfQueue->proceedQueueAsync();
|
||||
});
|
||||
},
|
||||
10,
|
||||
3
|
||||
);
|
||||
|
||||
/**
|
||||
* Delete file
|
||||
*/
|
||||
add_filter(
|
||||
'wpmf_delete_attachment',
|
||||
function ($result, $datas, $element_id) {
|
||||
wp_delete_attachment($datas['post_id']);
|
||||
return true;
|
||||
},
|
||||
10,
|
||||
3
|
||||
);
|
||||
|
||||
/**
|
||||
* Move file to physical folder after upload file and generate meta data
|
||||
*/
|
||||
add_filter(
|
||||
'wp_generate_attachment_metadata',
|
||||
function ($data, $attachment_id) {
|
||||
$folders = get_the_terms($attachment_id, WPMF_TAXO);
|
||||
if (!empty($folders)) {
|
||||
$folder = $folders[0]->term_id;
|
||||
$parents = JUQueueHelper::getParentTerms($folder);
|
||||
$destination = implode(DIRECTORY_SEPARATOR, $parents);
|
||||
$destination = apply_filters('wpmf_update_actual_folder_name', $destination);
|
||||
$datas = array(
|
||||
'post_id' => $attachment_id,
|
||||
'destination' => $destination,
|
||||
'with_filename' => false,
|
||||
'delete_folder' => false,
|
||||
'update_database' => false,
|
||||
'action' => 'wpmf_physical_folders'
|
||||
);
|
||||
JUQueueHelper::moveFile($datas);
|
||||
}
|
||||
|
||||
if (isset($data['file'])) {
|
||||
$dirname = _wp_get_attachment_relative_path($data['file']);
|
||||
if ($dirname) {
|
||||
$dirname = trailingslashit($dirname);
|
||||
}
|
||||
if ($dirname === '') {
|
||||
$data['file'] = $destination . '/' . $data['file'];
|
||||
} else {
|
||||
$data['file'] = str_replace($dirname, $destination . '/', $data['file']);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
},
|
||||
10,
|
||||
2
|
||||
);
|
||||
/**
|
||||
* Hook on the add attachment action
|
||||
*
|
||||
* @todo : hook on wpmf_after_attachment_import to trigger the peoceedQueueAsync
|
||||
*/
|
||||
add_action(
|
||||
'wpmf_add_attachment',
|
||||
function ($attachment_id, $folder_id) {
|
||||
$folders = JUQueueHelper::getParentTerms($folder_id);
|
||||
$destination = implode(DIRECTORY_SEPARATOR, $folders);
|
||||
$destination = apply_filters('wpmf_update_actual_folder_name', $destination);
|
||||
$datas = array(
|
||||
'post_id' => $attachment_id,
|
||||
'destination' => $destination,
|
||||
'with_filename' => false,
|
||||
'delete_folder' => false,
|
||||
'update_database' => false,
|
||||
'action' => 'wpmf_physical_folders'
|
||||
);
|
||||
$wpmfQueue = JuMainQueue::getInstance('wpmf');
|
||||
$wpmfQueue->addToQueue($datas);
|
||||
},
|
||||
10,
|
||||
2
|
||||
);
|
||||
|
||||
/**
|
||||
* Hook on the move folder action
|
||||
*/
|
||||
add_action(
|
||||
'wpmf_move_folder',
|
||||
function ($folder_id, $destination_folder_id) {
|
||||
$term = get_term($destination_folder_id, WPMF_TAXO);
|
||||
JUQueueHelper::updateFolderName($folder_id, $term->name);
|
||||
},
|
||||
2,
|
||||
2
|
||||
);
|
||||
|
||||
/**
|
||||
* Hook on the update folder name action
|
||||
*/
|
||||
add_action(
|
||||
'wpmf_update_folder_name',
|
||||
function ($folder_id, $folder_name) {
|
||||
JUQueueHelper::updateFolderName($folder_id, $folder_name);
|
||||
},
|
||||
2,
|
||||
2
|
||||
);
|
||||
|
||||
/**
|
||||
* Hook on the delete folder action
|
||||
*/
|
||||
add_action(
|
||||
'wpmf_delete_folder',
|
||||
function ($folder_term) {
|
||||
JUQueueHelper::deleteFolder($folder_term);
|
||||
},
|
||||
2,
|
||||
2
|
||||
);
|
||||
|
||||
/**
|
||||
* Ajax syncchonize folders
|
||||
*/
|
||||
add_action('wp_ajax_wpmf_import_wpmf', function () {
|
||||
check_ajax_referer('wpmf_nonce', 'nonce');
|
||||
|
||||
JUQueueHelper::updateFolderName(0, '');
|
||||
$wpmfQueue = JuMainQueue::getInstance('wpmf');
|
||||
$wpmfQueue->proceedQueueAsync();
|
||||
|
||||
exit(0);
|
||||
});
|
||||
|
||||
add_filter(
|
||||
'http_request_args',
|
||||
function ($r, $url) {
|
||||
if (is_array($r['body']) && !empty($r['body']['action']) && $r['body']['action'] === 'wp_async_wp_generate_attachment_metadata' && is_array($r['body']['metadata'])) {
|
||||
unset($r['body']['metadata']);
|
||||
}
|
||||
return $r;
|
||||
},
|
||||
10,
|
||||
2
|
||||
);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user