khaihihi
This commit is contained in:
1282
wp-content/plugins/redux-framework/ReduxCore/inc/browser.php
Normal file
1282
wp-content/plugins/redux-framework/ReduxCore/inc/browser.php
Normal file
File diff suppressed because it is too large
Load Diff
303
wp-content/plugins/redux-framework/ReduxCore/inc/class.p.php
Normal file
303
wp-content/plugins/redux-framework/ReduxCore/inc/class.p.php
Normal file
@@ -0,0 +1,303 @@
|
||||
<?php
|
||||
|
||||
class Redux_P {
|
||||
|
||||
public function __construct() {
|
||||
|
||||
add_action( "wp_ajax_nopriv_redux_p", array( $this, 'proxy' ) );
|
||||
add_action( "wp_ajax_redux_p", array( $this, 'proxy' ) );
|
||||
}
|
||||
|
||||
public function proxy() {
|
||||
|
||||
if ( ! isset( $_GET['nonce'] ) || ( isset( $_GET['nonce'] ) && ! wp_verify_nonce( $_GET['nonce'], "redux-ads-nonce" ) ) ) {
|
||||
die();
|
||||
}
|
||||
|
||||
// Script: Simple PHP Proxy: Get external HTML, JSON and more!
|
||||
//
|
||||
// *Version: 1.6, Last updated: 1/24/2009*
|
||||
//
|
||||
// Project Home - http://benalman.com/projects/php-simple-proxy/
|
||||
// GitHub - http://github.com/cowboy/php-simple-proxy/
|
||||
// Source - http://github.com/cowboy/php-simple-proxy/raw/master/ba-simple-proxy.php
|
||||
//
|
||||
// About: License
|
||||
//
|
||||
// Copyright (c) 2010 "Cowboy" Ben Alman,
|
||||
// Dual licensed under the MIT and GPL licenses.
|
||||
// http://benalman.com/about/license/
|
||||
//
|
||||
// About: Examples
|
||||
//
|
||||
// This working example, complete with fully commented code, illustrates one way
|
||||
// in which this PHP script can be used.
|
||||
//
|
||||
// Simple - http://benalman.com/code/projects/php-simple-proxy/examples/simple/
|
||||
//
|
||||
// About: Release History
|
||||
//
|
||||
// 1.6 - (1/24/2009) Now defaults to JSON mode, which can now be changed to
|
||||
// native mode by specifying ?mode=native. Native and JSONP modes are
|
||||
// disabled by default because of possible XSS vulnerability issues, but
|
||||
// are configurable in the PHP script along with a url validation regex.
|
||||
// 1.5 - (12/27/2009) Initial release
|
||||
//
|
||||
// Topic: GET Parameters
|
||||
//
|
||||
// Certain GET (query string) parameters may be passed into ba-simple-proxy.php
|
||||
// to control its behavior, this is a list of these parameters.
|
||||
//
|
||||
// url - The remote URL resource to fetch. Any GET parameters to be passed
|
||||
// through to the remote URL resource must be urlencoded in this parameter.
|
||||
// mode - If mode=native, the response will be sent using the same content
|
||||
// type and headers that the remote URL resource returned. If omitted, the
|
||||
// response will be JSON (or JSONP). <Native requests> and <JSONP requests>
|
||||
// are disabled by default, see <Configuration Options> for more information.
|
||||
// callback - If specified, the response JSON will be wrapped in this named
|
||||
// function call. This parameter and <JSONP requests> are disabled by
|
||||
// default, see <Configuration Options> for more information.
|
||||
// user_agent - This value will be sent to the remote URL request as the
|
||||
// `User-Agent:` HTTP request header. If omitted, the browser user agent
|
||||
// will be passed through.
|
||||
// send_cookies - If send_cookies=1, all cookies will be forwarded through to
|
||||
// the remote URL request.
|
||||
// send_session - If send_session=1 and send_cookies=1, the SID cookie will be
|
||||
// forwarded through to the remote URL request.
|
||||
// full_headers - If a JSON request and full_headers=1, the JSON response will
|
||||
// contain detailed header information.
|
||||
// full_status - If a JSON request and full_status=1, the JSON response will
|
||||
// contain detailed cURL status information, otherwise it will just contain
|
||||
// the `http_code` property.
|
||||
//
|
||||
// Topic: POST Parameters
|
||||
//
|
||||
// All POST parameters are automatically passed through to the remote URL
|
||||
// request.
|
||||
//
|
||||
// Topic: JSON requests
|
||||
//
|
||||
// This request will return the contents of the specified url in JSON format.
|
||||
//
|
||||
// Request:
|
||||
//
|
||||
// > ba-simple-proxy.php?url=http://example.com/
|
||||
//
|
||||
// Response:
|
||||
//
|
||||
// > { "contents": "<html>...</html>", "headers": {...}, "status": {...} }
|
||||
//
|
||||
// JSON object properties:
|
||||
//
|
||||
// contents - (String) The contents of the remote URL resource.
|
||||
// headers - (Object) A hash of HTTP headers returned by the remote URL
|
||||
// resource.
|
||||
// status - (Object) A hash of status codes returned by cURL.
|
||||
//
|
||||
// Topic: JSONP requests
|
||||
//
|
||||
// This request will return the contents of the specified url in JSONP format
|
||||
// (but only if $enable_jsonp is enabled in the PHP script).
|
||||
//
|
||||
// Request:
|
||||
//
|
||||
// > ba-simple-proxy.php?url=http://example.com/&callback=foo
|
||||
//
|
||||
// Response:
|
||||
//
|
||||
// > foo({ "contents": "<html>...</html>", "headers": {...}, "status": {...} })
|
||||
//
|
||||
// JSON object properties:
|
||||
//
|
||||
// contents - (String) The contents of the remote URL resource.
|
||||
// headers - (Object) A hash of HTTP headers returned by the remote URL
|
||||
// resource.
|
||||
// status - (Object) A hash of status codes returned by cURL.
|
||||
//
|
||||
// Topic: Native requests
|
||||
//
|
||||
// This request will return the contents of the specified url in the format it
|
||||
// was received in, including the same content-type and other headers (but only
|
||||
// if $enable_native is enabled in the PHP script).
|
||||
//
|
||||
// Request:
|
||||
//
|
||||
// > ba-simple-proxy.php?url=http://example.com/&mode=native
|
||||
//
|
||||
// Response:
|
||||
//
|
||||
// > <html>...</html>
|
||||
//
|
||||
// Topic: Notes
|
||||
//
|
||||
// * Assumes magic_quotes_gpc = Off in php.ini
|
||||
//
|
||||
// Topic: Configuration Options
|
||||
//
|
||||
// These variables can be manually edited in the PHP file if necessary.
|
||||
//
|
||||
// $enable_jsonp - Only enable <JSONP requests> if you really need to. If you
|
||||
// install this script on the same server as the page you're calling it
|
||||
// from, plain JSON will work. Defaults to false.
|
||||
// $enable_native - You can enable <Native requests>, but you should only do
|
||||
// this if you also whitelist specific URLs using $valid_url_regex, to avoid
|
||||
// possible XSS vulnerabilities. Defaults to false.
|
||||
// $valid_url_regex - This regex is matched against the url parameter to
|
||||
// ensure that it is valid. This setting only needs to be used if either
|
||||
// $enable_jsonp or $enable_native are enabled. Defaults to '/.*/' which
|
||||
// validates all URLs.
|
||||
//
|
||||
// ############################################################################
|
||||
|
||||
|
||||
$_GET['mode'] = "native";
|
||||
$_GET['full_headers'] = 1;
|
||||
$_GET['full_status'] = 1;
|
||||
$_GET['send_cookies'] = 1;
|
||||
|
||||
|
||||
// Change these configuration options if needed, see above descriptions for info.
|
||||
$enable_jsonp = false;
|
||||
$enable_native = true;
|
||||
$valid_url_regex = '/.*/';
|
||||
|
||||
// ############################################################################
|
||||
$url = $_GET['url'];
|
||||
|
||||
if ( isset( $_GET['nonce'] ) ) {
|
||||
$url = str_replace( 'nonce=' . $_GET['nonce'] . '&', '', $url );
|
||||
}
|
||||
|
||||
|
||||
if ( ! $url ) {
|
||||
|
||||
// Passed url not specified.
|
||||
$contents = 'ERROR: url not specified';
|
||||
$status = array( 'http_code' => 'ERROR' );
|
||||
|
||||
} else if ( ! preg_match( $valid_url_regex, $url ) ) {
|
||||
|
||||
// Passed url doesn't match $valid_url_regex.
|
||||
$contents = 'ERROR: invalid url';
|
||||
$status = array( 'http_code' => 'ERROR' );
|
||||
|
||||
} else {
|
||||
$url = urldecode( $url );
|
||||
if ( isset( $_GET['proxy'] ) ) {
|
||||
$url .= '&proxy=' . $_GET['proxy'];
|
||||
}
|
||||
|
||||
// Ad URL rewrite
|
||||
if ( strpos( $url, 'http' ) === false ) {
|
||||
$url = 'http:' . $url;
|
||||
}
|
||||
|
||||
if ( isset( $_GET['callback'] ) ) {
|
||||
foreach ( $_GET as $key => $value ) {
|
||||
if ( in_array( $key, array( 'url', 'mode', 'full_headers', 'full_status', 'send_cookies' ) ) ) {
|
||||
continue;
|
||||
}
|
||||
$url .= "&" . $key . '=' . $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$args = array(
|
||||
'user-agent' => isset( $_GET['user_agent'] ) ? $_GET['user_agent'] : $_SERVER['HTTP_USER_AGENT'],
|
||||
'method' => 'GET',
|
||||
);
|
||||
|
||||
if ( isset( $_GET['send_cookies'] ) && $_GET['send_cookies'] ) {
|
||||
$cookie = array();
|
||||
foreach ( $_COOKIE as $key => $value ) {
|
||||
$cookie[] = $key . '=' . $value;
|
||||
}
|
||||
if ( isset( $_GET['send_session'] ) && $_GET['send_session'] ) {
|
||||
$cookie[] = SID;
|
||||
}
|
||||
$args['cookies'] = $cookie;
|
||||
|
||||
}
|
||||
if ( strtolower( $_SERVER['REQUEST_METHOD'] ) == 'post' ) {
|
||||
$args['body'] = $_POST;
|
||||
$args['method'] = 'POST';
|
||||
|
||||
}
|
||||
|
||||
|
||||
$response = wp_remote_request(
|
||||
$url,
|
||||
$args
|
||||
);
|
||||
|
||||
if ( ! is_wp_error( $response ) ) {
|
||||
$status = $response['response']['code'];
|
||||
$contents = $response['body'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ( isset( $_GET['mode'] ) && $_GET['mode'] == 'native' ) {
|
||||
if ( ! $enable_native ) {
|
||||
$contents = 'ERROR: invalid mode';
|
||||
$status = array( 'http_code' => 'ERROR' );
|
||||
}
|
||||
|
||||
if ( ! is_wp_error( $response ) && isset( $response['headers']['content-type'] ) ) {
|
||||
header( 'Content-Type: ' . $response['headers']['content-type'] );
|
||||
}
|
||||
if ( ! is_wp_error( $response ) && isset( $response['headers']['content-language'] ) ) {
|
||||
header( 'Content-Language: ' . $response['headers']['content-language'] );
|
||||
}
|
||||
if ( ! is_wp_error( $response ) && isset( $response['headers']['set-cookie'] ) ) {
|
||||
header( 'Set-Cookie: ' . $response['headers']['set-cookie'] );
|
||||
}
|
||||
|
||||
if ( isset( $contents ) ) {
|
||||
print str_replace( 'ads.redux.io', 'look.redux.io', $contents );
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// $data will be serialized into JSON data.
|
||||
$data = array();
|
||||
|
||||
// Propagate all HTTP headers into the JSON data object.
|
||||
if ( isset( $_GET['full_headers'] ) && $_GET['full_headers'] ) {
|
||||
$data['headers'] = array();
|
||||
|
||||
}
|
||||
|
||||
// Propagate all cURL request / response info to the JSON data object.
|
||||
if ( isset( $_GET['full_status'] ) && $_GET['full_status'] ) {
|
||||
$data['status'] = $status;
|
||||
} else {
|
||||
$data['status'] = array();
|
||||
$data['status']['http_code'] = $status['http_code'];
|
||||
}
|
||||
|
||||
// Set the JSON data object contents, decoding it from JSON if possible.
|
||||
$decoded_json = json_decode( $contents );
|
||||
$data['contents'] = str_replace( 'e(window).width()', 'window.innerWidth||e(window).width()', $decoded_json ? $decoded_json : $contents );
|
||||
|
||||
// Generate appropriate content-type header.
|
||||
|
||||
$is_xhr = isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) ? strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) : 'xmlhttprequest';
|
||||
header( 'Content-type: application/' . ( $is_xhr ? 'json' : 'x-javascript' ) );
|
||||
|
||||
// Get JSONP callback.
|
||||
$jsonp_callback = $enable_jsonp && isset( $_GET['callback'] ) ? $_GET['callback'] : null;
|
||||
|
||||
// Generate JSON/JSONP string
|
||||
$json = json_encode( $data );
|
||||
|
||||
print $jsonp_callback ? "$jsonp_callback($json)" : $json;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
new Redux_P();
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Redux Framework Admin Notice Class
|
||||
* Makes instantiating a Redux object an absolute piece of cake.
|
||||
*
|
||||
* @package Redux_Framework
|
||||
* @author Kevin Provance
|
||||
* @author Dovy Paukstys
|
||||
* @subpackage Core
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Don't duplicate me!
|
||||
if ( ! class_exists( 'Redux_Admin_Notices' ) ) {
|
||||
|
||||
/**
|
||||
* Redux API Class
|
||||
* Simple API for Redux Framework
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Redux_Admin_Notices {
|
||||
|
||||
static public $_parent;
|
||||
|
||||
public static function load() {
|
||||
add_action( 'wp_ajax_redux_hide_admin_notice', array(
|
||||
'Redux_Admin_Notices',
|
||||
'dismissAdminNoticeAJAX'
|
||||
) );
|
||||
}
|
||||
|
||||
public static function set_notice($data) {
|
||||
extract($data);
|
||||
|
||||
$parent->admin_notices[$parent->args['page_slug']][] = array(
|
||||
'type' => $type,
|
||||
'msg' => $msg,
|
||||
'id' => $id . '_' . $parent->args['opt_name'],
|
||||
'dismiss' => $dismiss,
|
||||
'color' => isset($color) ? $color : '#00A2E3'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* adminNotices - Evaluates user dismiss option for displaying admin notices
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public static function adminNotices($parent, $notices = array() ) {
|
||||
global $current_user, $pagenow, $wp_version;;
|
||||
|
||||
// Check for an active admin notice array
|
||||
if ( ! empty( $notices ) ) {
|
||||
|
||||
if (isset($_GET) && isset($_GET['page']) && $_GET['page'] == $parent->args['page_slug']) {
|
||||
|
||||
// Enum admin notices
|
||||
foreach ( $notices[$parent->args['page_slug']] as $notice ) {
|
||||
|
||||
$add_style = '';
|
||||
if ( strpos( $notice['type'], 'redux-message' ) != false ) {
|
||||
$add_style = 'style="border-left: 4px solid ' . esc_attr( $notice['color'] ) . '!important;"';
|
||||
}
|
||||
|
||||
if ( true == $notice['dismiss'] ) {
|
||||
|
||||
// Get user ID
|
||||
$userid = $current_user->ID;
|
||||
|
||||
if ( ! get_user_meta( $userid, 'ignore_' . $notice['id'] ) ) {
|
||||
|
||||
// Check if we are on admin.php. If we are, we have
|
||||
// to get the current page slug and tab, so we can
|
||||
// feed it back to Wordpress. Why> admin.php cannot
|
||||
// be accessed without the page parameter. We add the
|
||||
// tab to return the user to the last panel they were
|
||||
// on.
|
||||
$pageName = '';
|
||||
$curTab = '';
|
||||
|
||||
if ( $pagenow == 'admin.php' || $pagenow == 'themes.php' ) {
|
||||
|
||||
// Get the current page. To avoid errors, we'll set
|
||||
// the redux page slug if the GET is empty.
|
||||
$pageName = empty( $_GET['page'] ) ? '&page=' . $parent->args['page_slug'] : '&page=' . esc_attr( $_GET['page'] );
|
||||
|
||||
// Ditto for the current tab.
|
||||
$curTab = empty( $_GET['tab'] ) ? '&tab=0' : '&tab=' . esc_attr( $_GET['tab'] );
|
||||
}
|
||||
|
||||
// Print the notice with the dismiss link
|
||||
if ( version_compare( $wp_version, '4.2', '>' ) ) {
|
||||
$output = "";
|
||||
$css_id = esc_attr( $notice['id'] ) . $pageName . $curTab;
|
||||
$css_class = esc_attr( $notice['type'] ) . ' redux-notice notice is-dismissible redux-notice';
|
||||
$output .= "<div {$add_style} id='$css_id' class='$css_class'> \n";
|
||||
$nonce = wp_create_nonce( $notice['id'] . $userid . 'nonce' );
|
||||
$output .= "<input type='hidden' class='dismiss_data' id='" . esc_attr( $notice['id'] ) . $pageName . $curTab . "' value='{$nonce}'> \n";
|
||||
$output .= '<p>' . wp_kses_post( $notice['msg'] ) . '</p>';
|
||||
$output .= "</div> \n";
|
||||
echo $output;
|
||||
} else {
|
||||
echo '<div ' . $add_style . ' class="' . esc_attr( $notice['type'] ) . ' notice is-dismissable"><p>' . wp_kses_post( $notice['msg'] ) . ' <a href="?dismiss=true&id=' . esc_attr( $notice['id'] ) . $pageName . $curTab . '">' . esc_html__( 'Dismiss', 'redux-framework' ) . '</a>.</p></div>';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Standard notice
|
||||
echo '<div ' . $add_style . ' class="' . esc_attr( $notice['type'] ) . ' notice"><p>' . wp_kses_post( $notice['msg'] ) . '</a>.</p></div>';
|
||||
}
|
||||
?>
|
||||
<script>
|
||||
jQuery( document ).ready(
|
||||
function( $ ) {
|
||||
$( 'body' ).on(
|
||||
'click', '.redux-notice.is-dismissible .notice-dismiss', function( event ) {
|
||||
var $data = $( this ).parent().find( '.dismiss_data' );
|
||||
$.post(
|
||||
ajaxurl, {
|
||||
action: 'redux_hide_admin_notice',
|
||||
id: $data.attr( 'id' ),
|
||||
nonce: $data.val()
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the admin notice array
|
||||
$parent->admin_notices[$parent->args['opt_name']] = array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* dismissAdminNotice - Updates user meta to store dismiss notice preference
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public static function dismissAdminNotice() {
|
||||
global $current_user;
|
||||
|
||||
// Verify the dismiss and id parameters are present.
|
||||
if ( isset( $_GET['dismiss'] ) && isset( $_GET['id'] ) ) {
|
||||
if ( 'true' == $_GET['dismiss'] || 'false' == $_GET['dismiss'] ) {
|
||||
|
||||
// Get the user id
|
||||
$userid = $current_user->ID;
|
||||
|
||||
// Get the notice id
|
||||
$id = esc_attr( $_GET['id'] );
|
||||
$val = esc_attr( $_GET['dismiss'] );
|
||||
|
||||
// Add the dismiss request to the user meta.
|
||||
update_user_meta( $userid, 'ignore_' . $id, $val );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* dismissAdminNotice - Updates user meta to store dismiss notice preference
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public static function dismissAdminNoticeAJAX() {
|
||||
global $current_user;
|
||||
|
||||
// Get the notice id
|
||||
$id = explode( '&', $_POST['id'] );
|
||||
$id = $id[0];
|
||||
// Get the user id
|
||||
$userid = $current_user->ID;
|
||||
|
||||
if ( ! wp_verify_nonce( $_POST['nonce'], $id . $userid . 'nonce' ) ) {
|
||||
die( 0 );
|
||||
} else {
|
||||
// Add the dismiss request to the user meta.
|
||||
update_user_meta( $userid, 'ignore_' . $id, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Redux_Admin_Notices::load();
|
||||
}
|
||||
@@ -0,0 +1,668 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Redux Framework API Class
|
||||
* Makes instantiating a Redux object an absolute piece of cake.
|
||||
*
|
||||
* @package Redux_Framework
|
||||
* @author Dovy Paukstys
|
||||
* @subpackage Core
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Don't duplicate me!
|
||||
if ( ! class_exists( 'Redux' ) ) {
|
||||
|
||||
/**
|
||||
* Redux API Class
|
||||
* Simple API for Redux Framework
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Redux {
|
||||
|
||||
public static $fields = array();
|
||||
public static $sections = array();
|
||||
public static $help = array();
|
||||
public static $args = array();
|
||||
public static $priority = array();
|
||||
public static $errors = array();
|
||||
public static $init = array();
|
||||
public static $extensions = array();
|
||||
public static $uses_extensions = array();
|
||||
|
||||
public function __call( $closure, $args ) {
|
||||
return call_user_func_array( $this->{$closure}->bindTo( $this ), $args );
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
return call_user_func( $this->{"__toString"}->bindTo( $this ) );
|
||||
}
|
||||
|
||||
public static function load() {
|
||||
add_action( 'after_setup_theme', array( 'Redux', 'createRedux' ));
|
||||
add_action( 'init', array( 'Redux', 'createRedux' ));
|
||||
add_action( 'switch_theme', array( 'Redux', 'createRedux' ));
|
||||
}
|
||||
|
||||
public static function init( $opt_name = "" ) {
|
||||
if ( ! empty( $opt_name ) ) {
|
||||
self::loadRedux( $opt_name );
|
||||
remove_action( 'setup_theme', array( 'Redux', 'createRedux' ) );
|
||||
}
|
||||
}
|
||||
|
||||
public static function loadExtensions( $ReduxFramework ) {
|
||||
if ( $instanceExtensions = self::getExtensions( $ReduxFramework->args['opt_name'], "" ) ) {
|
||||
foreach ( $instanceExtensions as $name => $extension ) {
|
||||
if ( ! class_exists( $extension['class'] ) ) {
|
||||
// In case you wanted override your override, hah.
|
||||
$extension['path'] = apply_filters( 'redux/extension/' . $ReduxFramework->args['opt_name'] . '/' . $name, $extension['path'] );
|
||||
if ( file_exists( $extension['path'] ) ) {
|
||||
require_once $extension['path'];
|
||||
}
|
||||
}
|
||||
if ( ! isset( $ReduxFramework->extensions[ $name ] ) ) {
|
||||
if ( class_exists( $extension['class'] ) ) {
|
||||
$ReduxFramework->extensions[ $name ] = new $extension['class']( $ReduxFramework );
|
||||
//if (isset($ReduxFramework->extensions[ $name ]->min_redux_version)) {
|
||||
//var_dump($ReduxFramework->extensions[ $name ]->min_redux_version);
|
||||
//}
|
||||
|
||||
} else {
|
||||
echo '<div id="message" class="error"><p>No class named <strong>' . $extension['class'] . '</strong> exists. Please verify your extension path.</p></div>';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function extensionPath( $extension, $folder = true ) {
|
||||
if ( ! isset( Redux::$extensions[ $extension ] ) ) {
|
||||
return;
|
||||
}
|
||||
$path = end( Redux::$extensions[ $extension ] );
|
||||
if ( ! $folder ) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
return str_replace( 'extension_' . $extension . '.php', '', $path );
|
||||
}
|
||||
|
||||
|
||||
public static function loadRedux( $opt_name = "" ) {
|
||||
|
||||
if ( empty( $opt_name ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$check = ReduxFrameworkInstances::get_instance( $opt_name );
|
||||
|
||||
if ( isset( $check->apiHasRun ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$args = self::constructArgs( $opt_name );
|
||||
$sections = self::constructSections( $opt_name );
|
||||
if ( ! class_exists( 'ReduxFramework' ) ) {
|
||||
echo '<div id="message" class="error"><p>Redux Framework is <strong>not installed</strong>. Please install it.</p></div>';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset( self::$uses_extensions[ $opt_name ] ) && ! empty( self::$uses_extensions[ $opt_name ] ) ) {
|
||||
add_action( "redux/extensions/{$opt_name}/before", array( 'Redux', 'loadExtensions' ), 0 );
|
||||
}
|
||||
|
||||
$redux = new ReduxFramework( $sections, $args );
|
||||
$redux->apiHasRun = 1;
|
||||
self::$init[ $opt_name ] = 1;
|
||||
if ( isset( $redux->args['opt_name'] ) && $redux->args['opt_name'] != $opt_name ) {
|
||||
self::$init[ $redux->args['opt_name'] ] = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function createRedux() {
|
||||
foreach ( self::$sections as $opt_name => $theSections ) {
|
||||
if ( ! self::$init[ $opt_name ] ) {
|
||||
self::loadRedux( $opt_name );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function constructArgs( $opt_name ) {
|
||||
$args = isset( self::$args[ $opt_name ] ) ? self::$args[ $opt_name ] : array();
|
||||
|
||||
$args['opt_name'] = $opt_name;
|
||||
if ( ! isset( $args['menu_title'] ) ) {
|
||||
$args['menu_title'] = ucfirst( $opt_name ) . ' Options';
|
||||
}
|
||||
if ( ! isset( $args['page_title'] ) ) {
|
||||
$args['page_title'] = ucfirst( $opt_name ) . ' Options';
|
||||
}
|
||||
if ( ! isset( $args['page_slug'] ) ) {
|
||||
$args['page_slug'] = $opt_name . '_options';
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
public static function constructSections( $opt_name ) {
|
||||
$sections = array();
|
||||
if ( ! isset( self::$sections[ $opt_name ] ) ) {
|
||||
return $sections;
|
||||
|
||||
}
|
||||
foreach ( self::$sections[ $opt_name ] as $section_id => $section ) {
|
||||
$section['fields'] = self::constructFields( $opt_name, $section_id );
|
||||
$p = $section['priority'];
|
||||
while ( isset( $sections[ $p ] ) ) {
|
||||
$p++;
|
||||
}
|
||||
$sections[ $p ] = $section;
|
||||
}
|
||||
ksort( $sections );
|
||||
|
||||
return $sections;
|
||||
}
|
||||
|
||||
public static function constructFields( $opt_name = "", $section_id = "" ) {
|
||||
$fields = array();
|
||||
if ( ! empty( self::$fields[ $opt_name ] ) ) {
|
||||
foreach ( self::$fields[ $opt_name ] as $key => $field ) {
|
||||
if ( $field['section_id'] == $section_id ) {
|
||||
$p = $field['priority'];
|
||||
while ( isset( $fields[ $p ] ) ) {
|
||||
echo $p ++;
|
||||
}
|
||||
$fields[ $p ] = $field;
|
||||
}
|
||||
}
|
||||
}
|
||||
ksort( $fields );
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
public static function getSection( $opt_name = '', $id = '' ) {
|
||||
self::check_opt_name( $opt_name );
|
||||
if ( ! empty( $opt_name ) && ! empty( $id ) ) {
|
||||
if ( ! isset( self::$sections[ $opt_name ][ $id ] ) ) {
|
||||
$id = strtolower( sanitize_html_class( $id ) );
|
||||
}
|
||||
|
||||
return isset( self::$sections[ $opt_name ][ $id ] ) ? self::$sections[ $opt_name ][ $id ] : false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function setSections( $opt_name = '', $sections = array() ) {
|
||||
self::check_opt_name( $opt_name );
|
||||
if ( ! empty( $sections ) ) {
|
||||
foreach ( $sections as $section ) {
|
||||
Redux::setSection( $opt_name, $section );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getSections( $opt_name = '' ) {
|
||||
self::check_opt_name( $opt_name );
|
||||
if ( ! empty( self::$sections[ $opt_name ] ) ) {
|
||||
return self::$sections[ $opt_name ];
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
public static function removeSection( $opt_name = '', $id = "", $fields = false ) {
|
||||
if ( ! empty( $opt_name ) && ! empty( $id ) ) {
|
||||
if ( isset( self::$sections[ $opt_name ][ $id ] ) ) {
|
||||
$priority = '';
|
||||
|
||||
foreach ( self::$sections[ $opt_name ] as $key => $section ) {
|
||||
if ( $key == $id ) {
|
||||
$priority = $section['priority'];
|
||||
self::$priority[ $opt_name ]['sections'] --;
|
||||
unset( self::$sections[ $opt_name ][ $id ] );
|
||||
continue;
|
||||
}
|
||||
if ( $priority != "" ) {
|
||||
$newPriority = $section['priority'];
|
||||
$section['priority'] = $priority;
|
||||
self::$sections[ $opt_name ][ $key ] = $section;
|
||||
$priority = $newPriority;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( self::$fields[ $opt_name ] ) && ! empty( self::$fields[ $opt_name ] ) && $fields == true ) {
|
||||
foreach ( self::$fields[ $opt_name ] as $key => $field ) {
|
||||
if ( $field['section_id'] == $id ) {
|
||||
unset( self::$fields[ $opt_name ][ $key ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function setSection( $opt_name = '', $section = array() ) {
|
||||
|
||||
self::check_opt_name( $opt_name );
|
||||
if ( empty( $section ) ) {
|
||||
return;
|
||||
}
|
||||
if ( ! isset( $section['id'] ) ) {
|
||||
if ( isset( $section['type'] ) && $section['type'] == "divide" ) {
|
||||
$section['id'] = time();
|
||||
} else {
|
||||
if ( isset( $section['title'] ) ) {
|
||||
$section['id'] = strtolower( sanitize_title( $section['title'] ) );
|
||||
} else {
|
||||
$section['id'] = time();
|
||||
}
|
||||
}
|
||||
if ( ! isset( $section['id'] ) ) {
|
||||
print_r( $section );
|
||||
echo "DOVY";
|
||||
}
|
||||
|
||||
if ( isset( self::$sections[ $opt_name ][ $section['id'] ] ) ) {
|
||||
$orig = $section['id'];
|
||||
$i = 0;
|
||||
while ( isset( self::$sections[ $opt_name ][ $section['id'] ] ) ) {
|
||||
$section['id'] = $orig . '_' . $i;
|
||||
|
||||
$i ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $opt_name ) && is_array( $section ) && ! empty( $section ) ) {
|
||||
if ( ! isset( $section['id'] ) && ! isset( $section['title'] ) ) {
|
||||
self::$errors[ $opt_name ]['section']['missing_title'] = "Unable to create a section due to missing id and title.";
|
||||
|
||||
return;
|
||||
}
|
||||
if ( ! isset( $section['priority'] ) ) {
|
||||
$section['priority'] = self::getPriority( $opt_name, 'sections' );
|
||||
}
|
||||
if ( isset( $section['fields'] ) ) {
|
||||
if ( ! empty( $section['fields'] ) && is_array( $section['fields'] ) ) {
|
||||
self::processFieldsArray( $opt_name, $section['id'], $section['fields'] );
|
||||
}
|
||||
unset( $section['fields'] );
|
||||
}
|
||||
self::$sections[ $opt_name ][ $section['id'] ] = $section;
|
||||
} else {
|
||||
self::$errors[ $opt_name ]['section']['empty'] = "Unable to create a section due an empty section array or the section variable passed was not an array.";
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static function hideSection( $opt_name = '', $id = '', $hide = true ) {
|
||||
self::check_opt_name( $opt_name );
|
||||
|
||||
if ( ! empty( $opt_name ) && ! empty( $id ) ) {
|
||||
if ( isset ( self::$sections[ $opt_name ][ $id ] ) ) {
|
||||
self::$sections[ $opt_name ][ $id ]['hidden'] = $hide;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function processFieldsArray( $opt_name = "", $section_id = "", $fields = array() ) {
|
||||
if ( ! empty( $opt_name ) && ! empty( $section_id ) && is_array( $fields ) && ! empty( $fields ) ) {
|
||||
foreach ( $fields as $field ) {
|
||||
if ( ! is_array( $field ) ) {
|
||||
continue;
|
||||
}
|
||||
$field['section_id'] = $section_id;
|
||||
self::setField( $opt_name, $field );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getField( $opt_name = '', $id = '' ) {
|
||||
self::check_opt_name( $opt_name );
|
||||
if ( ! empty( $opt_name ) && ! empty( $id ) ) {
|
||||
return isset( self::$fields[ $opt_name ][ $id ] ) ? self::$fields[ $opt_name ][ $id ] : false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function hideField( $opt_name = '', $id = '', $hide = true ) {
|
||||
self::check_opt_name( $opt_name );
|
||||
|
||||
if ( ! empty( $opt_name ) && ! empty( $id ) ) {
|
||||
if ( isset ( self::$fields[ $opt_name ][ $id ] ) ) {
|
||||
if ( ! $hide ) {
|
||||
self::$fields[ $opt_name ][ $id ]['class'] = str_replace( 'hidden', '', self::$fields[ $opt_name ][ $id ]['class'] );
|
||||
} else {
|
||||
self::$fields[ $opt_name ][ $id ]['class'] .= 'hidden';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function setField( $opt_name = '', $field = array() ) {
|
||||
self::check_opt_name( $opt_name );
|
||||
|
||||
if ( ! empty( $opt_name ) && is_array( $field ) && ! empty( $field ) ) {
|
||||
|
||||
if ( ! isset( $field['priority'] ) ) {
|
||||
$field['priority'] = self::getPriority( $opt_name, 'fields' );
|
||||
}
|
||||
if ( isset( $field['id'] ) ) {
|
||||
self::$fields[ $opt_name ][ $field['id'] ] = $field;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function removeField( $opt_name = '', $id = '' ) {
|
||||
self::check_opt_name( $opt_name );
|
||||
|
||||
if ( ! empty( $opt_name ) && ! empty( $id ) ) {
|
||||
if ( isset( self::$fields[ $opt_name ][ $id ] ) ) {
|
||||
foreach ( self::$fields[ $opt_name ] as $key => $field ) {
|
||||
if ( $key == $id ) {
|
||||
$priority = $field['priority'];
|
||||
self::$priority[ $opt_name ]['fields'] --;
|
||||
unset( self::$fields[ $opt_name ][ $id ] );
|
||||
continue;
|
||||
}
|
||||
if ( isset( $priority ) && $priority != "" ) {
|
||||
$newPriority = $field['priority'];
|
||||
$field['priority'] = $priority;
|
||||
self::$fields[ $opt_name ][ $key ] = $field;
|
||||
$priority = $newPriority;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function setHelpTab( $opt_name = "", $tab = array() ) {
|
||||
self::check_opt_name( $opt_name );
|
||||
if ( ! empty( $opt_name ) && ! empty( $tab ) ) {
|
||||
if ( ! isset( self::$args[ $opt_name ]['help_tabs'] ) ) {
|
||||
self::$args[ $opt_name ]['help_tabs'] = array();
|
||||
}
|
||||
if ( isset( $tab['id'] ) ) {
|
||||
self::$args[ $opt_name ]['help_tabs'][] = $tab;
|
||||
} else if ( is_array( end( $tab ) ) ) {
|
||||
foreach ( $tab as $tab_item ) {
|
||||
self::$args[ $opt_name ]['help_tabs'][] = $tab_item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function setHelpSidebar( $opt_name = "", $content = "" ) {
|
||||
self::check_opt_name( $opt_name );
|
||||
if ( ! empty( $opt_name ) && ! empty( $content ) ) {
|
||||
self::$args[ $opt_name ]['help_sidebar'] = $content;
|
||||
}
|
||||
}
|
||||
|
||||
public static function setArgs( $opt_name = "", $args = array() ) {
|
||||
self::check_opt_name( $opt_name );
|
||||
if ( ! empty( $opt_name ) && ! empty( $args ) && is_array( $args ) ) {
|
||||
if ( isset( self::$args[ $opt_name ] ) && isset( self::$args[ $opt_name ]['clearArgs'] ) ) {
|
||||
self::$args[ $opt_name ] = array();
|
||||
}
|
||||
self::$args[ $opt_name ] = wp_parse_args( $args, self::$args[ $opt_name ] );
|
||||
}
|
||||
}
|
||||
|
||||
public static function getArgs( $opt_name = "" ) {
|
||||
self::check_opt_name( $opt_name );
|
||||
if ( ! empty( $opt_name ) && ! empty( self::$args[ $opt_name ] ) ) {
|
||||
return self::$args[ $opt_name ];
|
||||
}
|
||||
}
|
||||
|
||||
public static function getArg( $opt_name = "", $key = "" ) {
|
||||
self::check_opt_name( $opt_name );
|
||||
if ( ! empty( $opt_name ) && ! empty( $key ) && ! empty( self::$args[ $opt_name ] ) ) {
|
||||
return self::$args[ $opt_name ][ $key ];
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getOption( $opt_name = "", $key = "" ) {
|
||||
self::check_opt_name( $opt_name );
|
||||
|
||||
if ( ! empty( $opt_name ) && ! empty( $key ) ) {
|
||||
$redux = get_option( $opt_name );
|
||||
|
||||
if ( isset( $redux[ $key ] ) ) {
|
||||
return $redux[ $key ];
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static function setOption( $opt_name = "", $key = "", $option = "" ) {
|
||||
self::check_opt_name( $opt_name );
|
||||
|
||||
if ( ! empty( $opt_name ) && ! empty( $key ) ) {
|
||||
$redux = get_option( $opt_name );
|
||||
$redux[ $key ] = $option;
|
||||
|
||||
return update_option( $opt_name, $redux );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getPriority( $opt_name, $type ) {
|
||||
$priority = self::$priority[ $opt_name ][ $type ];
|
||||
self::$priority[ $opt_name ][ $type ] += 1;
|
||||
|
||||
return $priority;
|
||||
}
|
||||
|
||||
public static function check_opt_name( $opt_name = "" ) {
|
||||
if ( empty( $opt_name ) || is_array( $opt_name ) ) {
|
||||
return;
|
||||
}
|
||||
if ( ! isset( self::$sections[ $opt_name ] ) ) {
|
||||
self::$sections[ $opt_name ] = array();
|
||||
self::$priority[ $opt_name ]['sections'] = 1;
|
||||
}
|
||||
if ( ! isset( self::$args[ $opt_name ] ) ) {
|
||||
self::$args[ $opt_name ] = array();
|
||||
self::$priority[ $opt_name ]['args'] = 1;
|
||||
}
|
||||
if ( ! isset( self::$fields[ $opt_name ] ) ) {
|
||||
self::$fields[ $opt_name ] = array();
|
||||
self::$priority[ $opt_name ]['fields'] = 1;
|
||||
}
|
||||
if ( ! isset( self::$help[ $opt_name ] ) ) {
|
||||
self::$help[ $opt_name ] = array();
|
||||
self::$priority[ $opt_name ]['help'] = 1;
|
||||
}
|
||||
if ( ! isset( self::$errors[ $opt_name ] ) ) {
|
||||
self::$errors[ $opt_name ] = array();
|
||||
}
|
||||
if ( ! isset( self::$init[ $opt_name ] ) ) {
|
||||
self::$init[ $opt_name ] = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve metadata from a file. Based on WP Core's get_file_data function
|
||||
*
|
||||
* @since 2.1.1
|
||||
*
|
||||
* @param string $file Path to the file
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getFileVersion( $file ) {
|
||||
$data = get_file_data( $file, array( 'version' ), 'plugin' );
|
||||
|
||||
return $data[0];
|
||||
}
|
||||
|
||||
public static function checkExtensionClassFile( $opt_name, $name = "", $class_file = "", $instance = "" ) {
|
||||
if ( file_exists( $class_file ) ) {
|
||||
|
||||
self::$uses_extensions[ $opt_name ] = isset( self::$uses_extensions[ $opt_name ] ) ? self::$uses_extensions[ $opt_name ] : array();
|
||||
if ( ! in_array( $name, self::$uses_extensions[ $opt_name ] ) ) {
|
||||
self::$uses_extensions[ $opt_name ][] = $name;
|
||||
}
|
||||
|
||||
self::$extensions[ $name ] = isset( self::$extensions[ $name ] ) ? self::$extensions[ $name ] : array();
|
||||
$version = Redux_Helpers::get_template_version( $class_file );
|
||||
if ( empty( $version ) && ! empty( $instance ) ) {
|
||||
if ( isset( $instance->version ) ) {
|
||||
$version = $instance->version;
|
||||
}
|
||||
}
|
||||
self::$extensions[ $name ][ $version ] = isset( self::$extensions[ $name ][ $version ] ) ? self::$extensions[ $name ][ $version ] : $class_file;
|
||||
|
||||
$api_check = str_replace( 'extension_' . $name, $name . '_api', $class_file );
|
||||
if ( file_exists( $api_check ) && ! class_exists( 'Redux_' . ucfirst( $name ) ) ) {
|
||||
include_once( $api_check );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function setExtensions( $opt_name, $path ) {
|
||||
if ( is_dir( $path ) ) {
|
||||
$path = trailingslashit( $path );
|
||||
$folder = str_replace( '.php', '', basename( $path ) );
|
||||
if ( file_exists( $path . 'extension_' . $folder . '.php' ) ) {
|
||||
self::checkExtensionClassFile( $opt_name, $folder, $path . 'extension_' . $folder . '.php' );
|
||||
} else {
|
||||
$folders = scandir( $path, 1 );
|
||||
foreach ( $folders as $folder ) {
|
||||
if ( $folder === '.' or $folder === '..' or $folder[0] == "." ) {
|
||||
continue;
|
||||
}
|
||||
if ( file_exists( $path . $folder . '/extension_' . $folder . '.php' ) ) {
|
||||
self::checkExtensionClassFile( $opt_name, $folder, $path . $folder . '/extension_' . $folder . '.php' );
|
||||
} else if ( is_dir( $path . $folder ) ) {
|
||||
self::setExtensions( $opt_name, $path . $folder );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ( file_exists( $path ) ) {
|
||||
$name = explode( 'extension_', basename( $path ) );
|
||||
if ( isset( $name[1] ) && ! empty( $name[1] ) ) {
|
||||
$name = str_replace( '.php', '', $name[1] );
|
||||
self::checkExtensionClassFile( $opt_name, $name, $path );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to disables Redux demo mode popup.
|
||||
*/
|
||||
public static function disable_demo() {
|
||||
add_action('ReduxFrameworkPlugin_admin_notice', 'Redux::remove_demo', 0);
|
||||
add_action('redux_framework_plugin_admin_notice', 'Redux::remove_demo', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback used by Redux::disable_demo() to remove the demo mode notice from Redux.
|
||||
*/
|
||||
function remove_demo() {
|
||||
update_option('ReduxFrameworkPlugin_ACTIVATED_NOTICES', '');
|
||||
}
|
||||
|
||||
public static function getAllExtensions() {
|
||||
$redux = ReduxFrameworkInstances::get_all_instances();
|
||||
foreach ( $redux as $instance ) {
|
||||
if ( ! empty( self::$uses_extensions[ $instance['args']['opt_name'] ] ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( ! empty( $instance['extensions'] ) ) {
|
||||
|
||||
Redux::getInstanceExtensions( $instance['args']['opt_name'], $instance );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getInstanceExtensions( $opt_name, $instance = array() ) {
|
||||
if ( ! empty( self::$uses_extensions[ $opt_name ] ) ) {
|
||||
return;
|
||||
}
|
||||
if ( empty( $instance ) ) {
|
||||
$instance = ReduxFrameworkInstances::get_instance( $opt_name );
|
||||
}
|
||||
if ( empty( $instance ) || empty( $instance->extensions ) ) {
|
||||
return;
|
||||
}
|
||||
foreach ( $instance->extensions as $name => $extension ) {
|
||||
if ( $name == "widget_areas" ) {
|
||||
$new = new Redux_Widget_Areas( $instance );
|
||||
}
|
||||
if ( isset( self::$uses_extensions[ $opt_name ][ $name ] ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( isset( $extension->extension_dir ) ) {
|
||||
Redux::setExtensions( $opt_name, str_replace( $name, '', $extension->extension_dir ) );
|
||||
|
||||
} else if ( isset( $extension->_extension_dir ) ) {
|
||||
Redux::setExtensions( $opt_name, str_replace( $name, '', $extension->_extension_dir ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getExtensions( $opt_name = "", $key = "" ) {
|
||||
|
||||
if ( empty( $opt_name ) ) {
|
||||
Redux::getAllExtensions();
|
||||
if ( empty( $key ) ) {
|
||||
return self::$extension_paths;
|
||||
} else {
|
||||
if ( isset( self::$extension_paths[ $key ] ) ) {
|
||||
return self::$extension_paths[ $key ];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( empty( self::$uses_extensions[ $opt_name ] ) ) {
|
||||
Redux::getInstanceExtensions( $opt_name );
|
||||
}
|
||||
|
||||
if ( empty( self::$uses_extensions[ $opt_name ] ) ) {
|
||||
return false;
|
||||
}
|
||||
$instanceExtensions = array();
|
||||
foreach ( self::$uses_extensions[ $opt_name ] as $extension ) {
|
||||
$class_file = end( self::$extensions[ $extension ] );
|
||||
$name = str_replace( '.php', '', basename( $extension ) );
|
||||
$extension_class = 'ReduxFramework_Extension_' . $name;
|
||||
$instanceExtensions[ $extension ] = array(
|
||||
'path' => $class_file,
|
||||
'class' => $extension_class,
|
||||
'version' => Redux_Helpers::get_template_version( $class_file )
|
||||
);
|
||||
}
|
||||
|
||||
return $instanceExtensions;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Redux::load();
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Redux Framework CDN Container Class
|
||||
*
|
||||
* @author Kevin Provance (kprovance)
|
||||
* @package Redux_Framework
|
||||
* @subpackage Core
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'Redux_CDN' ) ) {
|
||||
class Redux_CDN {
|
||||
static public $_parent;
|
||||
static private $_set;
|
||||
|
||||
private static function is_enqueued( $handle, $list = 'enqueued', $is_script ) {
|
||||
if ( $is_script ) {
|
||||
wp_script_is( $handle, $list );
|
||||
} else {
|
||||
wp_style_is( $handle, $list );
|
||||
}
|
||||
}
|
||||
|
||||
private static function _register( $handle, $src_cdn, $deps, $ver, $footer_or_media, $is_script = true ) {
|
||||
if ( $is_script ) {
|
||||
wp_register_script( $handle, $src_cdn, $deps, $ver, $footer_or_media );
|
||||
} else {
|
||||
wp_register_style( $handle, $src_cdn, $deps, $ver, $footer_or_media );
|
||||
}
|
||||
}
|
||||
|
||||
private static function _enqueue( $handle, $src_cdn, $deps, $ver, $footer_or_media, $is_script = true ) {
|
||||
if ( $is_script ) {
|
||||
wp_enqueue_script( $handle, $src_cdn, $deps, $ver, $footer_or_media );
|
||||
} else {
|
||||
wp_enqueue_style( $handle, $src_cdn, $deps, $ver, $footer_or_media );
|
||||
}
|
||||
}
|
||||
|
||||
private static function _cdn( $register = true, $handle, $src_cdn, $deps, $ver, $footer_or_media, $is_script = true ) {
|
||||
$tran_key = '_style_cdn_is_up';
|
||||
if ( $is_script ) {
|
||||
$tran_key = '_script_cdn_is_up';
|
||||
}
|
||||
|
||||
$cdn_is_up = get_transient( $handle . $tran_key );
|
||||
if ( $cdn_is_up ) {
|
||||
if ( $register ) {
|
||||
self::_register( $handle, $src_cdn, $deps, $ver, $footer_or_media, $is_script );
|
||||
} else {
|
||||
self::_enqueue( $handle, $src_cdn, $deps, $ver, $footer_or_media, $is_script );
|
||||
}
|
||||
} else {
|
||||
|
||||
$prefix = $src_cdn[1] == "/" ? 'http:' : '';
|
||||
$cdn_response = @wp_remote_get( $prefix . $src_cdn );
|
||||
|
||||
if ( is_wp_error( $cdn_response ) || wp_remote_retrieve_response_code( $cdn_response ) != '200' ) {
|
||||
if ( class_exists( 'Redux_VendorURL' ) ) {
|
||||
$src = Redux_VendorURL::get_url( $handle );
|
||||
|
||||
if ( $register ) {
|
||||
self::_register( $handle, $src, $deps, $ver, $footer_or_media, $is_script );
|
||||
} else {
|
||||
self::_enqueue( $handle, $src, $deps, $ver, $footer_or_media, $is_script );
|
||||
}
|
||||
} else {
|
||||
if ( ! self::is_enqueued( $handle, 'enqueued', $is_script ) ) {
|
||||
$msg = __( 'Please wait a few minutes, then try refreshing the page. Unable to load some remotely hosted scripts.', 'redux-framework' );
|
||||
if ( self::$_parent->args['dev_mode'] ) {
|
||||
$msg = sprintf( __( 'If you are developing offline, please download and install the <a href="%s" target="_blank">Redux Vendor Support</a> plugin/extension to bypass the our CDN and avoid this warning', 'redux-framework' ), 'https://github.com/reduxframework/redux-vendor-support' );
|
||||
}
|
||||
|
||||
$msg = '<strong>' . __( 'Redux Framework Warning', 'redux-framework' ) . '</strong><br/>' . sprintf( __( '%s CDN unavailable. Some controls may not render properly.', 'redux-framework' ), $handle ) . ' ' . $msg;
|
||||
|
||||
$data = array(
|
||||
'parent' => self::$_parent,
|
||||
'type' => 'error',
|
||||
'msg' => $msg,
|
||||
'id' => $handle . $tran_key,
|
||||
'dismiss' => false
|
||||
);
|
||||
|
||||
Redux_Admin_Notices::set_notice($data);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
set_transient( $handle . $tran_key, true, MINUTE_IN_SECONDS * self::$_parent->args['cdn_check_time'] );
|
||||
|
||||
if ( $register ) {
|
||||
self::_register( $handle, $src_cdn, $deps, $ver, $footer_or_media, $is_script );
|
||||
} else {
|
||||
self::_enqueue( $handle, $src_cdn, $deps, $ver, $footer_or_media, $is_script );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function _vendor_plugin( $register = true, $handle, $src_cdn, $deps, $ver, $footer_or_media, $is_script = true ) {
|
||||
if ( class_exists( 'Redux_VendorURL' ) ) {
|
||||
$src = Redux_VendorURL::get_url( $handle );
|
||||
|
||||
if ( $register ) {
|
||||
self::_register( $handle, $src, $deps, $ver, $footer_or_media, $is_script );
|
||||
} else {
|
||||
self::_enqueue( $handle, $src, $deps, $ver, $footer_or_media, $is_script );
|
||||
}
|
||||
} else {
|
||||
if ( ! self::$_set ) {
|
||||
$msg = sprintf( __( 'The <a href="%s">Vendor Support plugin</a> (or extension) is either not installed or not activated and thus, some controls may not render properly. Please ensure that it is installed and <a href="%s">activated</a>', 'redux-framework' ), 'https://github.com/reduxframework/redux-vendor-support', admin_url( 'plugins.php' ) );
|
||||
|
||||
$data = array(
|
||||
'parent' => self::$_parent,
|
||||
'type' => 'error',
|
||||
'msg' => $msg,
|
||||
'id' => $handle,
|
||||
'dismiss' => false
|
||||
);
|
||||
|
||||
Redux_Admin_Notices::set_notice($data);
|
||||
|
||||
self::$_set = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function register_style( $handle, $src_cdn = false, $deps = array(), $ver = false, $media = 'all' ) {
|
||||
if ( self::$_parent->args['use_cdn'] ) {
|
||||
self::_cdn( true, $handle, $src_cdn, $deps, $ver, $media, $is_script = false );
|
||||
} else {
|
||||
self::_vendor_plugin( true, $handle, $src_cdn, $deps, $ver, $media, $is_script = false );
|
||||
}
|
||||
}
|
||||
|
||||
public static function register_script( $handle, $src_cdn = false, $deps = array(), $ver = false, $in_footer = false ) {
|
||||
if ( self::$_parent->args['use_cdn'] ) {
|
||||
self::_cdn( true, $handle, $src_cdn, $deps, $ver, $in_footer, $is_script = true );
|
||||
} else {
|
||||
self::_vendor_plugin( true, $handle, $src_cdn, $deps, $ver, $in_footer, $is_script = true );
|
||||
}
|
||||
}
|
||||
|
||||
public static function enqueue_style( $handle, $src_cdn = false, $deps = array(), $ver = false, $media = 'all' ) {
|
||||
if ( self::$_parent->args['use_cdn'] ) {
|
||||
self::_cdn( false, $handle, $src_cdn, $deps, $ver, $media, $is_script = false );
|
||||
} else {
|
||||
self::_vendor_plugin( false, $handle, $src_cdn, $deps, $ver, $media, $is_script = false );
|
||||
}
|
||||
}
|
||||
|
||||
public static function enqueue_script( $handle, $src_cdn = false, $deps = array(), $ver = false, $in_footer = false ) {
|
||||
if ( self::$_parent->args['use_cdn'] ) {
|
||||
self::_cdn( false, $handle, $src_cdn, $deps, $ver, $in_footer, $is_script = true );
|
||||
} else {
|
||||
self::_vendor_plugin( false, $handle, $src_cdn, $deps, $ver, $in_footer, $is_script = true );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
<?php
|
||||
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'Redux_Filesystem' ) ) {
|
||||
class Redux_Filesystem {
|
||||
|
||||
/**
|
||||
* Instance of this class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @var object
|
||||
*/
|
||||
protected static $instance = null;
|
||||
|
||||
protected static $direct = null;
|
||||
|
||||
private $creds = array();
|
||||
|
||||
public $fs_object = null;
|
||||
|
||||
public $parent = null;
|
||||
|
||||
/**
|
||||
* Return an instance of this class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @return object A single instance of this class.
|
||||
*/
|
||||
public static function get_instance( $parent = null ) {
|
||||
|
||||
// If the single instance hasn't been set, set it now.
|
||||
if ( null == self::$instance ) {
|
||||
self::$instance = new self;
|
||||
}
|
||||
|
||||
if ( $parent !== null ) {
|
||||
self::$instance->parent = $parent;
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function ftp_form() {
|
||||
if ( isset( $this->parent->ftp_form ) && ! empty( $this->parent->ftp_form ) ) {
|
||||
echo '<div class="wrap"><div class="error"><p>';
|
||||
echo '<strong>' . __( 'File Permission Issues', 'redux-framework' ) . '</strong><br/>' . sprintf( __( 'We were unable to modify required files. Please ensure that <code>%1s</code> has the proper read-write permissions, or modify your wp-config.php file to contain your FTP login credentials as <a href="%2s" target="_blank">outlined here</a>.', 'redux-framework' ), Redux_Helpers::cleanFilePath( trailingslashit( WP_CONTENT_DIR ) ) . '/uploads/', 'https://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants' );
|
||||
echo '</p></div><h2></h2>' . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
function filesystem_init( $form_url, $method = '', $context = false, $fields = null ) {
|
||||
global $wp_filesystem;
|
||||
|
||||
if ( ! empty( $this->creds ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
/* first attempt to get credentials */
|
||||
if ( false === ( $this->creds = request_filesystem_credentials( $form_url, $method, false, $context ) ) ) {
|
||||
$this->creds = array();
|
||||
$this->parent->ftp_form = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
/**
|
||||
* if we comes here - we don't have credentials
|
||||
* so the request for them is displaying
|
||||
* no need for further processing
|
||||
**/
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* now we got some credentials - try to use them*/
|
||||
if ( ! WP_Filesystem( $this->creds ) ) {
|
||||
$this->creds = array();
|
||||
/* incorrect connection data - ask for credentials again, now with error message */
|
||||
request_filesystem_credentials( $form_url, '', true, $context );
|
||||
$this->parent->ftp_form = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function load_direct() {
|
||||
if ( self::$direct === null ) {
|
||||
require_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php';
|
||||
require_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php';
|
||||
self::$direct = new WP_Filesystem_Direct( array() );
|
||||
}
|
||||
}
|
||||
|
||||
public function execute( $action, $file = '', $params = '' ) {
|
||||
|
||||
if ( empty( $this->parent->args ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! empty ( $params ) ) {
|
||||
extract( $params );
|
||||
}
|
||||
|
||||
// Setup the filesystem with creds
|
||||
require_once ABSPATH . '/wp-admin/includes/template.php';
|
||||
require_once ABSPATH . '/wp-includes/pluggable.php';
|
||||
require_once ABSPATH . '/wp-admin/includes/file.php';
|
||||
|
||||
if ( $this->parent->args['menu_type'] == 'submenu' ) {
|
||||
$page_parent = $this->parent->args['page_parent'];
|
||||
$base = $page_parent . '?page=' . $this->parent->args['page_slug'];
|
||||
} else {
|
||||
$base = 'admin.php?page=' . $this->parent->args['page_slug'];
|
||||
}
|
||||
|
||||
$url = wp_nonce_url( $base, 'redux-options' );
|
||||
|
||||
$this->filesystem_init( $url, 'direct', dirname( $file ) );
|
||||
|
||||
if ( ! file_exists( ReduxFramework::$_upload_dir ) ) {
|
||||
$this->do_action( 'mkdir', ReduxFramework::$_upload_dir );
|
||||
}
|
||||
|
||||
$hash_path = trailingslashit( ReduxFramework::$_upload_dir ) . 'hash';
|
||||
if ( ! file_exists( $hash_path ) ) {
|
||||
$this->do_action( 'put_contents', $hash_path, array(
|
||||
'content' => md5( network_site_url() . '-' . $_SERVER['REMOTE_ADDR'] )
|
||||
)
|
||||
);
|
||||
}
|
||||
$version_path = trailingslashit( ReduxFramework::$_upload_dir ) . 'version';
|
||||
if ( ! file_exists( $version_path ) ) {
|
||||
$this->do_action( 'put_contents', $version_path, array(
|
||||
'content' => ReduxFramework::$_version
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$index_path = trailingslashit( ReduxFramework::$_upload_dir ) . 'index.php';
|
||||
if ( ! file_exists( $index_path ) ) {
|
||||
$this->do_action( 'put_contents', $index_path, array(
|
||||
'content' => '<?php' . PHP_EOL . '// Silence is golden.'
|
||||
) );
|
||||
}
|
||||
|
||||
return $this->do_action( $action, $file, $params );
|
||||
}
|
||||
|
||||
public function do_action( $action, $file = '', $params = '' ) {
|
||||
|
||||
if ( ! empty ( $params ) ) {
|
||||
extract( $params );
|
||||
}
|
||||
|
||||
global $wp_filesystem;
|
||||
|
||||
if ( ! isset( $params['chmod'] ) || ( isset( $params['chmod'] ) && empty( $params['chmod'] ) ) ) {
|
||||
if ( defined( 'FS_CHMOD_FILE' ) ) {
|
||||
$chmod = FS_CHMOD_FILE;
|
||||
} else {
|
||||
$chmod = 0644;
|
||||
}
|
||||
}
|
||||
$res = false;
|
||||
if ( ! isset( $recursive ) ) {
|
||||
$recursive = false;
|
||||
}
|
||||
|
||||
//$target_dir = $wp_filesystem->find_folder( dirname( $file ) );
|
||||
|
||||
// Do unique stuff
|
||||
if ( $action == 'mkdir' ) {
|
||||
|
||||
if ( defined( 'FS_CHMOD_DIR' ) ) {
|
||||
$chmod = FS_CHMOD_DIR;
|
||||
} else {
|
||||
$chmod = 0755;
|
||||
}
|
||||
$res = $wp_filesystem->mkdir( $file );
|
||||
if ( ! $res ) {
|
||||
wp_mkdir_p( $file );
|
||||
|
||||
$res = file_exists( $file );
|
||||
if ( ! $res ) {
|
||||
mkdir( $file, $chmod, true );
|
||||
$res = file_exists( $file );
|
||||
}
|
||||
}
|
||||
$index_path = trailingslashit( $file ) . 'index.php';
|
||||
if ( ! file_exists( $index_path ) ) {
|
||||
$wp_filesystem->put_contents(
|
||||
$index_path,
|
||||
'<?php' . PHP_EOL . '// Silence is golden.',
|
||||
FS_CHMOD_FILE // predefined mode settings for WP files
|
||||
);
|
||||
}
|
||||
} elseif ( $action == 'rmdir' ) {
|
||||
$res = $wp_filesystem->rmdir( $file, $recursive );
|
||||
} elseif ( $action == 'copy' && ! isset( $this->filesystem->killswitch ) ) {
|
||||
if ( isset( $this->parent->ftp_form ) && ! empty( $this->parent->ftp_form ) ) {
|
||||
$res = copy( $file, $destination );
|
||||
if ( $res ) {
|
||||
chmod( $destination, $chmod );
|
||||
}
|
||||
} else {
|
||||
$res = $wp_filesystem->copy( $file, $destination, $overwrite, $chmod );
|
||||
}
|
||||
} elseif ( $action == 'move' && ! isset( $this->filesystem->killswitch ) ) {
|
||||
$res = $wp_filesystem->copy( $file, $destination, $overwrite );
|
||||
} elseif ( $action == 'delete' ) {
|
||||
$res = $wp_filesystem->delete( $file, $recursive );
|
||||
} elseif ( $action == 'rmdir' ) {
|
||||
$res = $wp_filesystem->rmdir( $file, $recursive );
|
||||
} elseif ( $action == 'dirlist' ) {
|
||||
if ( ! isset( $include_hidden ) ) {
|
||||
$include_hidden = true;
|
||||
}
|
||||
$res = $wp_filesystem->dirlist( $file, $include_hidden, $recursive );
|
||||
} elseif ( $action == 'put_contents' && ! isset( $this->filesystem->killswitch ) ) {
|
||||
// Write a string to a file
|
||||
if ( isset( $this->parent->ftp_form ) && ! empty( $this->parent->ftp_form ) ) {
|
||||
self::load_direct();
|
||||
$res = self::$direct->put_contents( $file, $content, $chmod );
|
||||
} else {
|
||||
$res = $wp_filesystem->put_contents( $file, $content, $chmod );
|
||||
}
|
||||
} elseif ( $action == 'chown' ) {
|
||||
// Changes file owner
|
||||
if ( isset( $owner ) && ! empty( $owner ) ) {
|
||||
$res = $wp_filesystem->chmod( $file, $chmod, $recursive );
|
||||
}
|
||||
} elseif ( $action == 'owner' ) {
|
||||
// Gets file owner
|
||||
$res = $wp_filesystem->owner( $file );
|
||||
} elseif ( $action == 'chmod' ) {
|
||||
|
||||
if ( ! isset( $params['chmod'] ) || ( isset( $params['chmod'] ) && empty( $params['chmod'] ) ) ) {
|
||||
$chmod = false;
|
||||
}
|
||||
|
||||
$res = $wp_filesystem->chmod( $file, $chmod, $recursive );
|
||||
|
||||
} elseif ( $action == 'get_contents' ) {
|
||||
// Reads entire file into a string
|
||||
if ( isset( $this->parent->ftp_form ) && ! empty( $this->parent->ftp_form ) ) {
|
||||
self::load_direct();
|
||||
$res = self::$direct->get_contents( $file );
|
||||
} else {
|
||||
$res = $wp_filesystem->get_contents( $file );
|
||||
}
|
||||
} elseif ( $action == 'get_contents_array' ) {
|
||||
// Reads entire file into an array
|
||||
$res = $wp_filesystem->get_contents_array( $file );
|
||||
} elseif ( $action == 'object' ) {
|
||||
$res = $wp_filesystem;
|
||||
} elseif ( $action == 'unzip' ) {
|
||||
$unzipfile = unzip_file( $file, $destination );
|
||||
if ( $unzipfile ) {
|
||||
$res = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $res ) {
|
||||
if ( $action == 'dirlist' ) {
|
||||
if ( empty( $res ) || $res == false || $res == '' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( is_array( $res ) && empty( $res ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! is_array( $res ) ) {
|
||||
if ( count( glob( "$file*" ) ) == 0 ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->killswitch = true;
|
||||
|
||||
$msg = '<strong>' . __( 'File Permission Issues', 'redux-framework' ) . '</strong><br/>' . sprintf( __( 'We were unable to modify required files. Please ensure that <code>%1s</code> has the proper read-write permissions, or modify your wp-config.php file to contain your FTP login credentials as <a href="%2s" target="_blank">outlined here</a>.', 'redux-framework' ), Redux_Helpers::cleanFilePath( trailingslashit( WP_CONTENT_DIR ) ) . '/uploads/', 'https://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants' );
|
||||
|
||||
$data = array(
|
||||
'parent' => self::$instance->parent,
|
||||
'type' => 'error',
|
||||
'msg' => $msg,
|
||||
'id' => 'redux-wp-login',
|
||||
'dismiss' => false
|
||||
);
|
||||
|
||||
Redux_Admin_Notices::set_notice($data);
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
Redux_Filesystem::get_instance();
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Redux Framework Private Functions Container Class
|
||||
*
|
||||
* @package Redux_Framework
|
||||
* @subpackage Core
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Don't duplicate me!
|
||||
if ( ! class_exists( 'Redux_Functions' ) ) {
|
||||
|
||||
/**
|
||||
* Redux Functions Class
|
||||
* Class of useful functions that can/should be shared among all Redux files.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Redux_Functions {
|
||||
|
||||
static public $_parent;
|
||||
|
||||
public static function isMin() {
|
||||
$min = '';
|
||||
|
||||
if ( false == self::$_parent->args['dev_mode'] ) {
|
||||
$min = '.min';
|
||||
}
|
||||
|
||||
return $min;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a cookie.
|
||||
* Do nothing if unit testing.
|
||||
*
|
||||
* @since 3.5.4
|
||||
* @access public
|
||||
* @return void
|
||||
*
|
||||
* @param string $name The cookie name.
|
||||
* @param string $value The cookie value.
|
||||
* @param integer $expire Expiry time.
|
||||
* @param string $path The cookie path.
|
||||
* @param string $domain The cookie domain.
|
||||
* @param boolean $secure HTTPS only.
|
||||
* @param boolean $httponly Only set cookie on HTTP calls.
|
||||
*/
|
||||
public static function setCookie( $name, $value, $expire = 0, $path, $domain = null, $secure = false, $httponly = false ) {
|
||||
if ( ! defined( 'WP_TESTS_DOMAIN' ) ) {
|
||||
setcookie( $name, $value, $expire, $path, $domain, $secure, $httponly );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse CSS from output/compiler array
|
||||
*
|
||||
* @since 3.2.8
|
||||
* @access private
|
||||
* @return $css CSS string
|
||||
*/
|
||||
public static function parseCSS( $cssArray = array(), $style = '', $value = '' ) {
|
||||
|
||||
// Something wrong happened
|
||||
if ( count( $cssArray ) == 0 ) {
|
||||
return;
|
||||
} else { //if ( count( $cssArray ) >= 1 ) {
|
||||
$css = '';
|
||||
|
||||
foreach ( $cssArray as $element => $selector ) {
|
||||
|
||||
// The old way
|
||||
if ( $element === 0 ) {
|
||||
$css = self::theOldWay( $cssArray, $style );
|
||||
|
||||
return $css;
|
||||
}
|
||||
|
||||
// New way continued
|
||||
$cssStyle = $element . ':' . $value . ';';
|
||||
|
||||
$css .= $selector . '{' . $cssStyle . '}';
|
||||
}
|
||||
}
|
||||
|
||||
return $css;
|
||||
}
|
||||
|
||||
private static function theOldWay( $cssArray, $style ) {
|
||||
$keys = implode( ",", $cssArray );
|
||||
$css = $keys . "{" . $style . '}';
|
||||
|
||||
return $css;
|
||||
}
|
||||
|
||||
/**
|
||||
* initWpFilesystem - Initialized the Wordpress filesystem, if it already isn't.
|
||||
*
|
||||
* @since 3.2.3
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public static function initWpFilesystem() {
|
||||
global $wp_filesystem;
|
||||
|
||||
// Initialize the Wordpress filesystem, no more using file_put_contents function
|
||||
if ( empty( $wp_filesystem ) ) {
|
||||
require_once ABSPATH . '/wp-includes/pluggable.php';
|
||||
require_once ABSPATH . '/wp-admin/includes/file.php';
|
||||
WP_Filesystem();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* verFromGit - Retrives latest Redux version from GIT
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @access private
|
||||
* @return string $ver
|
||||
*/
|
||||
private static function verFromGit() {
|
||||
// Get the raw framework.php from github
|
||||
$gitpage = wp_remote_get(
|
||||
'https://raw.github.com/ReduxFramework/redux-framework/master/ReduxCore/framework.php', array(
|
||||
'headers' => array(
|
||||
'Accept-Encoding' => ''
|
||||
),
|
||||
'sslverify' => true,
|
||||
'timeout' => 300
|
||||
) );
|
||||
|
||||
// Is the response code the corect one?
|
||||
if ( ! is_wp_error( $gitpage ) ) {
|
||||
if ( isset( $gitpage['body'] ) ) {
|
||||
// Get the page text.
|
||||
$body = $gitpage['body'];
|
||||
|
||||
// Find version line in framework.php
|
||||
$needle = 'public static $_version =';
|
||||
$pos = strpos( $body, $needle );
|
||||
|
||||
// If it's there, continue. We don't want errors if $pos = 0.
|
||||
if ( $pos > 0 ) {
|
||||
|
||||
// Look for the semi-colon at the end of the version line
|
||||
$semi = strpos( $body, ";", $pos );
|
||||
|
||||
// Error avoidance. If the semi-colon is there, continue.
|
||||
if ( $semi > 0 ) {
|
||||
|
||||
// Extract the version line
|
||||
$text = substr( $body, $pos, ( $semi - $pos ) );
|
||||
|
||||
// Find the first quote around the veersion number.
|
||||
$quote = strpos( $body, "'", $pos );
|
||||
|
||||
// Extract the version number
|
||||
$ver = substr( $body, $quote, ( $semi - $quote ) );
|
||||
|
||||
// Strip off quotes.
|
||||
$ver = str_replace( "'", '', $ver );
|
||||
|
||||
return $ver;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* updateCheck - Checks for updates to Redux Framework
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @access public
|
||||
*
|
||||
* @param string $curVer Current version of Redux Framework
|
||||
*
|
||||
* @return void - Admin notice is diaplyed if new version is found
|
||||
*/
|
||||
public static function updateCheck( $parent, $curVer ) {
|
||||
|
||||
// If no cookie, check for new ver
|
||||
if ( ! isset( $_COOKIE['redux_update_check'] ) ) { // || 1 == strcmp($_COOKIE['redux_update_check'], self::$_version)) {
|
||||
// actual ver number from git repo
|
||||
$ver = self::verFromGit();
|
||||
|
||||
// hour long cookie.
|
||||
setcookie( "redux_update_check", $ver, time() + 3600, '/' );
|
||||
} else {
|
||||
|
||||
// saved value from cookie. If it's different from current ver
|
||||
// we can still show the update notice.
|
||||
$ver = $_COOKIE['redux_update_check'];
|
||||
}
|
||||
|
||||
// Set up admin notice on new version
|
||||
//if ( 1 == strcmp( $ver, $curVer ) ) {
|
||||
if ( version_compare( $ver, $curVer, '>' ) ) {
|
||||
$msg = '<strong>A new build of Redux is now available!</strong><br/><br/>Your version: <strong>' . $curVer . '</strong><br/>New version: <strong><span style="color: red;">' . $ver . '</span></strong><br/><br/><em>If you are not a developer, your theme/plugin author shipped with <code>dev_mode</code> on. Contact them to fix it, but in the meantime you can use our <a href="' . 'https://' . 'wordpress.org/plugins/redux-developer-mode-disabler/" target="_blank">dev_mode disabler</a>.</em><br /><br /><a href="' . 'https://' . 'github.com/ReduxFramework/redux-framework">Get it now</a> |';
|
||||
|
||||
$data = array(
|
||||
'parent' => $parent,
|
||||
'type' => 'updated',
|
||||
'msg' => $msg,
|
||||
'id' => 'dev_notice_' . $ver,
|
||||
'dismiss' => true
|
||||
);
|
||||
|
||||
Redux_Admin_Notices::set_notice($data);
|
||||
}
|
||||
}
|
||||
|
||||
public static function tru( $string, $opt_name ) {
|
||||
$redux = ReduxFrameworkInstances::get_instance( $opt_name );
|
||||
$check = get_user_option( 'r_tru_u_x', array() );
|
||||
if ( ! empty( $check ) && ( isset( $check['expires'] ) < time() ) ) {
|
||||
$check = array();
|
||||
}
|
||||
|
||||
//if ( isset( $redux->args['dev_mode'] ) && $redux->args['dev_mode'] == true && ! ( isset( $redux->args['forced_dev_mode_off'] ) && $redux->args['forced_dev_mode_off'] == true ) ) {
|
||||
if ( isset( $redux->args['dev_mode'] ) && $redux->args['dev_mode'] == true ) {
|
||||
update_user_option( get_current_user_id(), 'r_tru_u_x', array(
|
||||
'id' => '',
|
||||
'expires' => 60 * 60 * 24
|
||||
) );
|
||||
return apply_filters( 'redux/' . $opt_name . '/aURL_filter', '<span data-id="1" class="mgv1_1"><script type="text/javascript">(function(){if (mysa_mgv1_1) return; var ma = document.createElement("script"); ma.type = "text/javascript"; ma.async = true; ma.src = "' . $string . '"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ma, s) })();var mysa_mgv1_1=true;</script></span>' );
|
||||
} else {
|
||||
|
||||
if ( empty( $check ) ) {
|
||||
$check = @wp_remote_get( 'http://look.redux.io/status.php?p=' . ReduxFramework::$_is_plugin );
|
||||
$check = json_decode( wp_remote_retrieve_body( $check ), true );
|
||||
|
||||
if ( ! empty( $check ) && isset( $check['id'] ) ) {
|
||||
update_user_option( get_current_user_id(), 'r_tru_u_x', $check );
|
||||
}
|
||||
}
|
||||
$check = isset( $check['id'] ) ? $check['id'] : $check;
|
||||
if ( ! empty( $check ) ) {
|
||||
return apply_filters( 'redux/' . $opt_name . '/aURL_filter', '<span data-id="' . $check . '" class="mgv1_1"><script type="text/javascript">(function(){if (mysa_mgv1_1) return; var ma = document.createElement("script"); ma.type = "text/javascript"; ma.async = true; ma.src = "' . $string . '"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ma, s) })();var mysa_mgv1_1=true;</script></span>' );
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function dat($fname, $opt_name){
|
||||
$name = apply_filters('redux/' . $opt_name . '/aDBW_filter', $fname);
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
public static function bub($fname, $opt_name){
|
||||
$name = apply_filters('redux/' . $opt_name . '/aNF_filter', $fname);
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
public static function yo($fname, $opt_name){
|
||||
$name = apply_filters('redux/' . $opt_name . '/aNFM_filter', $fname);
|
||||
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,728 @@
|
||||
<?php
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Don't duplicate me!
|
||||
if ( ! class_exists( 'Redux_Helpers' ) ) {
|
||||
|
||||
/**
|
||||
* Redux Helpers Class
|
||||
* Class of useful functions that can/should be shared among all Redux files.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Redux_Helpers {
|
||||
|
||||
public static function tabFromField( $parent, $field ) {
|
||||
foreach ( $parent->sections as $k => $section ) {
|
||||
if ( ! isset( $section['title'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( isset( $section['fields'] ) && ! empty( $section['fields'] ) ) {
|
||||
if ( Redux_Helpers::recursive_array_search( $field, $section['fields'] ) ) {
|
||||
return $k;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function isFieldInUseByType( $fields, $field = array() ) {
|
||||
foreach ( $field as $name ) {
|
||||
if ( array_key_exists( $name, $fields ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function isFieldInUse( $parent, $field ) {
|
||||
foreach ( $parent->sections as $k => $section ) {
|
||||
if ( ! isset( $section['title'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( isset( $section['fields'] ) && ! empty( $section['fields'] ) ) {
|
||||
if ( Redux_Helpers::recursive_array_search( $field, $section['fields'] ) ) {
|
||||
return true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function major_version( $v ) {
|
||||
$version = explode( '.', $v );
|
||||
if ( count( $version ) > 1 ) {
|
||||
return $version[0] . '.' . $version[1];
|
||||
} else {
|
||||
return $v;
|
||||
}
|
||||
}
|
||||
|
||||
public static function isLocalHost() {
|
||||
return ( isset($_SERVER['REMOTE_ADDR']) && ($_SERVER['REMOTE_ADDR'] === '127.0.0.1' || $_SERVER['REMOTE_ADDR'] === 'localhost' )) ? 1 : 0;
|
||||
}
|
||||
|
||||
public static function isWpDebug() {
|
||||
return ( defined( 'WP_DEBUG' ) && WP_DEBUG == true );
|
||||
}
|
||||
|
||||
public static function getTrackingObject() {
|
||||
global $wpdb;
|
||||
|
||||
$hash = md5( network_site_url() . '-' . $_SERVER['REMOTE_ADDR'] );
|
||||
|
||||
global $blog_id, $wpdb;
|
||||
$pts = array();
|
||||
|
||||
foreach ( get_post_types( array( 'public' => true ) ) as $pt ) {
|
||||
$count = wp_count_posts( $pt );
|
||||
$pts[ $pt ] = $count->publish;
|
||||
}
|
||||
|
||||
$comments_count = wp_count_comments();
|
||||
$theme_data = wp_get_theme();
|
||||
$theme = array(
|
||||
'version' => $theme_data->Version,
|
||||
'name' => $theme_data->Name,
|
||||
'author' => $theme_data->Author,
|
||||
'template' => $theme_data->Template,
|
||||
);
|
||||
|
||||
if ( ! function_exists( 'get_plugin_data' ) ) {
|
||||
if ( file_exists( ABSPATH . 'wp-admin/includes/plugin.php' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
}
|
||||
if ( file_exists( ABSPATH . 'wp-admin/includes/admin.php' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/admin.php';
|
||||
}
|
||||
}
|
||||
|
||||
$plugins = array();
|
||||
foreach ( get_option( 'active_plugins', array() ) as $plugin_path ) {
|
||||
$plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin_path );
|
||||
|
||||
$slug = str_replace( '/' . basename( $plugin_path ), '', $plugin_path );
|
||||
$plugins[ $slug ] = array(
|
||||
'version' => $plugin_info['Version'],
|
||||
'name' => $plugin_info['Name'],
|
||||
'plugin_uri' => $plugin_info['PluginURI'],
|
||||
'author' => $plugin_info['AuthorName'],
|
||||
'author_uri' => $plugin_info['AuthorURI'],
|
||||
);
|
||||
}
|
||||
if ( is_multisite() ) {
|
||||
foreach ( get_option( 'active_sitewide_plugins', array() ) as $plugin_path ) {
|
||||
$plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin_path );
|
||||
$slug = str_replace( '/' . basename( $plugin_path ), '', $plugin_path );
|
||||
$plugins[ $slug ] = array(
|
||||
'version' => $plugin_info['Version'],
|
||||
'name' => $plugin_info['Name'],
|
||||
'plugin_uri' => $plugin_info['PluginURI'],
|
||||
'author' => $plugin_info['AuthorName'],
|
||||
'author_uri' => $plugin_info['AuthorURI'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$version = explode( '.', PHP_VERSION );
|
||||
$version = array(
|
||||
'major' => $version[0],
|
||||
'minor' => $version[0] . '.' . $version[1],
|
||||
'release' => PHP_VERSION
|
||||
);
|
||||
|
||||
$user_query = new WP_User_Query( array( 'blog_id' => $blog_id, 'count_total' => true, ) );
|
||||
$comments_query = new WP_Comment_Query();
|
||||
|
||||
$data = array(
|
||||
'_id' => $hash,
|
||||
'localhost' => ( $_SERVER['REMOTE_ADDR'] === '127.0.0.1' ) ? 1 : 0,
|
||||
'php' => $version,
|
||||
'site' => array(
|
||||
'hash' => $hash,
|
||||
'version' => get_bloginfo( 'version' ),
|
||||
'multisite' => is_multisite(),
|
||||
'users' => $user_query->get_total(),
|
||||
'lang' => get_locale(),
|
||||
'wp_debug' => ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? true : false : false ),
|
||||
'memory' => WP_MEMORY_LIMIT,
|
||||
),
|
||||
'pts' => $pts,
|
||||
'comments' => array(
|
||||
'total' => $comments_count->total_comments,
|
||||
'approved' => $comments_count->approved,
|
||||
'spam' => $comments_count->spam,
|
||||
'pings' => $comments_query->query( array( 'count' => true, 'type' => 'pingback' ) ),
|
||||
),
|
||||
'options' => apply_filters( 'redux/tracking/options', array() ),
|
||||
'theme' => $theme,
|
||||
'redux' => array(
|
||||
'mode' => ReduxFramework::$_is_plugin ? 'plugin' : 'theme',
|
||||
'version' => ReduxFramework::$_version,
|
||||
'demo_mode' => get_option( 'ReduxFrameworkPlugin' ),
|
||||
),
|
||||
'developer' => apply_filters( 'redux/tracking/developer', array() ),
|
||||
'plugins' => $plugins,
|
||||
);
|
||||
|
||||
$parts = explode( ' ', $_SERVER['SERVER_SOFTWARE'] );
|
||||
$software = array();
|
||||
foreach ( $parts as $part ) {
|
||||
if ( $part[0] == "(" ) {
|
||||
continue;
|
||||
}
|
||||
if ( strpos( $part, '/' ) !== false ) {
|
||||
$chunk = explode( "/", $part );
|
||||
$software[ strtolower( $chunk[0] ) ] = $chunk[1];
|
||||
}
|
||||
}
|
||||
$software['full'] = $_SERVER['SERVER_SOFTWARE'];
|
||||
$data['environment'] = $software;
|
||||
$data['environment']['mysql'] = $wpdb->db_version();
|
||||
// if ( function_exists( 'mysqli_get_server_info' ) ) {
|
||||
// $link = mysqli_connect() or die( "Error " . mysqli_error( $link ) );
|
||||
// $data['environment']['mysql'] = mysqli_get_server_info( $link );
|
||||
// } else if ( class_exists( 'PDO' ) && method_exists( 'PDO', 'getAttribute' ) ) {
|
||||
// $data['environment']['mysql'] = PDO::getAttribute( PDO::ATTR_SERVER_VERSION );
|
||||
// } else {
|
||||
// $data['environment']['mysql'] = mysql_get_server_info();
|
||||
// }
|
||||
|
||||
if ( empty( $data['developer'] ) ) {
|
||||
unset( $data['developer'] );
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function trackingObject() {
|
||||
|
||||
$data = wp_remote_post(
|
||||
'http://verify.redux.io',
|
||||
array(
|
||||
'body' => array(
|
||||
'hash' => $_GET['action'],
|
||||
'site' => esc_url( home_url( '/' ) ),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$data['body'] = urldecode( $data['body'] );
|
||||
|
||||
if ( ! isset( $_GET['code'] ) || $data['body'] != $_GET['code'] ) {
|
||||
die();
|
||||
}
|
||||
|
||||
return Redux_Helpers::getTrackingObject();
|
||||
}
|
||||
|
||||
public static function isParentTheme( $file ) {
|
||||
$file = self::cleanFilePath( $file );
|
||||
$dir = self::cleanFilePath( get_template_directory() );
|
||||
|
||||
$file = str_replace( '//', '/', $file );
|
||||
$dir = str_replace( '//', '/', $dir );
|
||||
|
||||
if ( strpos( $file, $dir ) !== false ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function isChildTheme( $file ) {
|
||||
$file = self::cleanFilePath( $file );
|
||||
$dir = self::cleanFilePath( get_stylesheet_directory() );
|
||||
|
||||
$file = str_replace( '//', '/', $file );
|
||||
$dir = str_replace( '//', '/', $dir );
|
||||
|
||||
if ( strpos( $file, $dir ) !== false ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static function reduxAsPlugin() {
|
||||
return ReduxFramework::$_as_plugin;
|
||||
}
|
||||
|
||||
public static function isTheme( $file ) {
|
||||
|
||||
if ( true == self::isChildTheme( $file ) || true == self::isParentTheme( $file ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function array_in_array( $needle, $haystack ) {
|
||||
//Make sure $needle is an array for foreach
|
||||
if ( ! is_array( $needle ) ) {
|
||||
$needle = array( $needle );
|
||||
}
|
||||
//For each value in $needle, return TRUE if in $haystack
|
||||
foreach ( $needle as $pin ) //echo 'needle' . $pin;
|
||||
{
|
||||
if ( in_array( $pin, $haystack ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//Return FALSE if none of the values from $needle are found in $haystack
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function recursive_array_search( $needle, $haystack ) {
|
||||
foreach ( $haystack as $key => $value ) {
|
||||
if ( $needle === $value || ( is_array( $value ) && self::recursive_array_search( $needle, $value ) !== false ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Take a path and return it clean
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @since 3.1.7
|
||||
*/
|
||||
public static function cleanFilePath( $path ) {
|
||||
$path = str_replace( '', '', str_replace( array( "\\", "\\\\" ), '/', $path ) );
|
||||
|
||||
if ( $path[ strlen( $path ) - 1 ] === '/' ) {
|
||||
$path = rtrim( $path, '/' );
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Take a path and delete it
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @since 3.3.3
|
||||
*/
|
||||
public static function rmdir( $dir ) {
|
||||
if ( is_dir( $dir ) ) {
|
||||
$objects = scandir( $dir );
|
||||
foreach ( $objects as $object ) {
|
||||
if ( $object != "." && $object != ".." ) {
|
||||
if ( filetype( $dir . "/" . $object ) == "dir" ) {
|
||||
rrmdir( $dir . "/" . $object );
|
||||
} else {
|
||||
unlink( $dir . "/" . $object );
|
||||
}
|
||||
}
|
||||
}
|
||||
reset( $objects );
|
||||
rmdir( $dir );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
* Takes the color hex value and converts to a rgba.
|
||||
*
|
||||
* @since ReduxFramework 3.0.4
|
||||
*/
|
||||
public static function hex2rgba( $hex, $alpha = '' ) {
|
||||
$hex = str_replace( "#", "", $hex );
|
||||
if ( strlen( $hex ) == 3 ) {
|
||||
$r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
|
||||
$g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
|
||||
$b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
|
||||
} else {
|
||||
$r = hexdec( substr( $hex, 0, 2 ) );
|
||||
$g = hexdec( substr( $hex, 2, 2 ) );
|
||||
$b = hexdec( substr( $hex, 4, 2 ) );
|
||||
}
|
||||
$rgb = $r . ',' . $g . ',' . $b;
|
||||
|
||||
if ( '' == $alpha ) {
|
||||
return $rgb;
|
||||
} else {
|
||||
$alpha = floatval( $alpha );
|
||||
|
||||
return 'rgba(' . $rgb . ',' . $alpha . ')';
|
||||
}
|
||||
}
|
||||
|
||||
public static function makeBoolStr( $var ) {
|
||||
if ( $var === false || $var === 'false' || $var === 0 || $var === '0' || $var === '' || empty( $var ) ) {
|
||||
return 'false';
|
||||
} elseif ($var === true || $var === 'true' || $var === 1 || $var === '1') {
|
||||
return 'true';
|
||||
} else {
|
||||
return $var;
|
||||
}
|
||||
}
|
||||
|
||||
public static function localize( $localize ) {
|
||||
$redux = ReduxFrameworkInstances::get_instance( $localize['args']['opt_name'] );
|
||||
$nonce = wp_create_nonce( 'redux-ads-nonce' );
|
||||
$base = admin_url( 'admin-ajax.php' ) . '?action=redux_p&nonce=' . $nonce . '&url=';
|
||||
$localize['rAds'] = Redux_Helpers::rURL_fix( $base, $redux->args['opt_name'] );
|
||||
|
||||
return $localize;
|
||||
}
|
||||
|
||||
public static function compileSystemStatus( $json_output = false, $remote_checks = false ) {
|
||||
global $wpdb;
|
||||
|
||||
$sysinfo = array();
|
||||
|
||||
$sysinfo['home_url'] = home_url();
|
||||
$sysinfo['site_url'] = site_url();
|
||||
$sysinfo['redux_ver'] = esc_html( ReduxFramework::$_version );
|
||||
$sysinfo['redux_data_dir'] = ReduxFramework::$_upload_dir;
|
||||
$f = 'fo' . 'pen';
|
||||
|
||||
$res = true;
|
||||
if ($f( ReduxFramework::$_upload_dir . 'test-log.log', 'a' ) === false) {
|
||||
$res = false;
|
||||
}
|
||||
|
||||
// Only is a file-write check
|
||||
$sysinfo['redux_data_writeable'] = $res;
|
||||
$sysinfo['wp_content_url'] = WP_CONTENT_URL;
|
||||
$sysinfo['wp_ver'] = get_bloginfo( 'version' );
|
||||
$sysinfo['wp_multisite'] = is_multisite();
|
||||
$sysinfo['permalink_structure'] = get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default';
|
||||
$sysinfo['front_page_display'] = get_option( 'show_on_front' );
|
||||
if ( $sysinfo['front_page_display'] == 'page' ) {
|
||||
$front_page_id = get_option( 'page_on_front' );
|
||||
$blog_page_id = get_option( 'page_for_posts' );
|
||||
|
||||
$sysinfo['front_page'] = $front_page_id != 0 ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset';
|
||||
$sysinfo['posts_page'] = $blog_page_id != 0 ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset';
|
||||
}
|
||||
|
||||
$sysinfo['wp_mem_limit']['raw'] = self::let_to_num( WP_MEMORY_LIMIT );
|
||||
$sysinfo['wp_mem_limit']['size'] = size_format( $sysinfo['wp_mem_limit']['raw'] );
|
||||
|
||||
$sysinfo['db_table_prefix'] = 'Length: ' . strlen( $wpdb->prefix ) . ' - Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' );
|
||||
|
||||
$sysinfo['wp_debug'] = 'false';
|
||||
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
|
||||
$sysinfo['wp_debug'] = 'true';
|
||||
}
|
||||
|
||||
$sysinfo['wp_lang'] = get_locale();
|
||||
|
||||
if ( ! class_exists( 'Browser' ) ) {
|
||||
require_once ReduxFramework::$_dir . 'inc/browser.php';
|
||||
}
|
||||
|
||||
$browser = new Browser();
|
||||
|
||||
$sysinfo['browser'] = array(
|
||||
'agent' => $browser->getUserAgent(),
|
||||
'browser' => $browser->getBrowser(),
|
||||
'version' => $browser->getVersion(),
|
||||
'platform' => $browser->getPlatform(),
|
||||
//'mobile' => $browser->isMobile() ? 'true' : 'false',
|
||||
);
|
||||
|
||||
$sysinfo['server_info'] = esc_html( $_SERVER['SERVER_SOFTWARE'] );
|
||||
$sysinfo['localhost'] = self::makeBoolStr( self::isLocalHost() );
|
||||
$sysinfo['php_ver'] = function_exists( 'phpversion' ) ? esc_html( phpversion() ) : 'phpversion() function does not exist.';
|
||||
$sysinfo['abspath'] = ABSPATH;
|
||||
|
||||
if ( function_exists( 'ini_get' ) ) {
|
||||
$sysinfo['php_mem_limit'] = size_format( self::let_to_num( ini_get( 'memory_limit' ) ) );
|
||||
$sysinfo['php_post_max_size'] = size_format( self::let_to_num( ini_get( 'post_max_size' ) ) );
|
||||
$sysinfo['php_time_limit'] = ini_get( 'max_execution_time' );
|
||||
$sysinfo['php_max_input_var'] = ini_get( 'max_input_vars' );
|
||||
$sysinfo['php_display_errors'] = self::makeBoolStr( ini_get( 'display_errors' ) );
|
||||
}
|
||||
|
||||
$sysinfo['suhosin_installed'] = extension_loaded( 'suhosin' );
|
||||
$sysinfo['mysql_ver'] = $wpdb->db_version();
|
||||
$sysinfo['max_upload_size'] = size_format( wp_max_upload_size() );
|
||||
|
||||
$sysinfo['def_tz_is_utc'] = 'true';
|
||||
if ( date_default_timezone_get() !== 'UTC' ) {
|
||||
$sysinfo['def_tz_is_utc'] = 'false';
|
||||
}
|
||||
|
||||
$sysinfo['fsockopen_curl'] = 'false';
|
||||
if ( function_exists( 'fsockopen' ) || function_exists( 'curl_init' ) ) {
|
||||
$sysinfo['fsockopen_curl'] = 'true';
|
||||
}
|
||||
|
||||
//$sysinfo['soap_client'] = 'false';
|
||||
//if ( class_exists( 'SoapClient' ) ) {
|
||||
// $sysinfo['soap_client'] = 'true';
|
||||
//}
|
||||
//
|
||||
//$sysinfo['dom_document'] = 'false';
|
||||
//if ( class_exists( 'DOMDocument' ) ) {
|
||||
// $sysinfo['dom_document'] = 'true';
|
||||
//}
|
||||
|
||||
//$sysinfo['gzip'] = 'false';
|
||||
//if ( is_callable( 'gzopen' ) ) {
|
||||
// $sysinfo['gzip'] = 'true';
|
||||
//}
|
||||
|
||||
if ( $remote_checks == true ) {
|
||||
$response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', array(
|
||||
'sslverify' => false,
|
||||
'timeout' => 60,
|
||||
'user-agent' => 'ReduxFramework/' . ReduxFramework::$_version,
|
||||
'body' => array(
|
||||
'cmd' => '_notify-validate'
|
||||
)
|
||||
) );
|
||||
|
||||
if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
|
||||
$sysinfo['wp_remote_post'] = 'true';
|
||||
$sysinfo['wp_remote_post_error'] = '';
|
||||
} else {
|
||||
$sysinfo['wp_remote_post'] = 'false';
|
||||
$sysinfo['wp_remote_post_error'] = $response->get_error_message();
|
||||
}
|
||||
|
||||
$response = @wp_remote_get( 'http://reduxframework.com/wp-admin/admin-ajax.php?action=get_redux_extensions' );
|
||||
|
||||
if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
|
||||
$sysinfo['wp_remote_get'] = 'true';
|
||||
$sysinfo['wp_remote_get_error'] = '';
|
||||
} elseif( is_wp_error( $response ) ) {
|
||||
$sysinfo['wp_remote_get'] = 'false';
|
||||
$sysinfo['wp_remote_get_error'] = $response->get_error_message();
|
||||
} else {
|
||||
$sysinfo['wp_remote_get'] = 'false';
|
||||
$sysinfo['wp_remote_get_error'] = $response['response']['code'] . (isset($response['response']['message']) ? $response['response']['message'] : '');
|
||||
}
|
||||
}
|
||||
|
||||
$active_plugins = (array) get_option( 'active_plugins', array() );
|
||||
|
||||
if ( is_multisite() ) {
|
||||
$active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
|
||||
}
|
||||
|
||||
$sysinfo['plugins'] = array();
|
||||
|
||||
foreach ( $active_plugins as $plugin ) {
|
||||
if (file_exists(WP_PLUGIN_DIR . '/' . $plugin)) {
|
||||
$plugin_data = @get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
|
||||
$plugin_name = esc_html( $plugin_data['Name'] );
|
||||
|
||||
$sysinfo['plugins'][ $plugin_name ] = $plugin_data;
|
||||
}
|
||||
}
|
||||
|
||||
$redux = ReduxFrameworkInstances::get_all_instances();
|
||||
|
||||
$sysinfo['redux_instances'] = array();
|
||||
|
||||
if ( ! empty( $redux ) && is_array( $redux ) ) {
|
||||
foreach ( $redux as $inst => $data ) {
|
||||
Redux::init( $inst );
|
||||
|
||||
$sysinfo['redux_instances'][ $inst ]['args'] = $data->args;
|
||||
$sysinfo['redux_instances'][ $inst ]['sections'] = $data->sections;
|
||||
foreach ( $sysinfo['redux_instances'][ $inst ]['sections'] as $sKey => $section ) {
|
||||
if ( isset( $section['fields'] ) && is_array( $section['fields'] ) ) {
|
||||
foreach ( $section['fields'] as $fKey => $field ) {
|
||||
if ( isset( $field['validate_callback'] ) ) {
|
||||
unset( $sysinfo['redux_instances'][ $inst ]['sections'][ $sKey ]['fields'][ $fKey ]['validate_callback'] );
|
||||
}
|
||||
if ( $field['type'] == "js_button" ) {
|
||||
if ( isset( $field['script'] ) && isset( $field['script']['ver'] ) ) {
|
||||
unset( $sysinfo['redux_instances'][ $inst ]['sections'][ $sKey ]['fields'][ $fKey ]['script']['ver'] );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sysinfo['redux_instances'][ $inst ]['extensions'] = Redux::getExtensions( $inst );
|
||||
|
||||
if ( isset( $data->extensions['metaboxes'] ) ) {
|
||||
$data->extensions['metaboxes']->init();
|
||||
$sysinfo['redux_instances'][ $inst ]['metaboxes'] = $data->extensions['metaboxes']->boxes;
|
||||
}
|
||||
|
||||
if ( isset( $data->args['templates_path'] ) && $data->args['templates_path'] != '' ) {
|
||||
$sysinfo['redux_instances'][ $inst ]['templates'] = self::getReduxTemplates( $data->args['templates_path'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$active_theme = wp_get_theme();
|
||||
|
||||
$sysinfo['theme']['name'] = $active_theme->Name;
|
||||
$sysinfo['theme']['version'] = $active_theme->Version;
|
||||
$sysinfo['theme']['author_uri'] = $active_theme->{'Author URI'};
|
||||
$sysinfo['theme']['is_child'] = self::makeBoolStr( is_child_theme() );
|
||||
|
||||
if ( is_child_theme() ) {
|
||||
$parent_theme = wp_get_theme( $active_theme->Template );
|
||||
|
||||
$sysinfo['theme']['parent_name'] = $parent_theme->Name;
|
||||
$sysinfo['theme']['parent_version'] = $parent_theme->Version;
|
||||
$sysinfo['theme']['parent_author_uri'] = $parent_theme->{'Author URI'};
|
||||
}
|
||||
|
||||
//if ( $json_output ) {
|
||||
// $sysinfo = json_encode( $sysinfo );
|
||||
//}
|
||||
|
||||
//print_r($sysinfo);
|
||||
//exit();
|
||||
|
||||
return $sysinfo;
|
||||
}
|
||||
|
||||
private static function getReduxTemplates( $custom_template_path ) {
|
||||
$template_paths = array( 'ReduxFramework' => ReduxFramework::$_dir . 'templates/panel' );
|
||||
$scanned_files = array();
|
||||
$found_files = array();
|
||||
$outdated_templates = false;
|
||||
|
||||
foreach ( $template_paths as $plugin_name => $template_path ) {
|
||||
$scanned_files[ $plugin_name ] = self::scan_template_files( $template_path );
|
||||
}
|
||||
|
||||
foreach ( $scanned_files as $plugin_name => $files ) {
|
||||
foreach ( $files as $file ) {
|
||||
if ( file_exists( $custom_template_path . '/' . $file ) ) {
|
||||
$theme_file = $custom_template_path . '/' . $file;
|
||||
} else {
|
||||
$theme_file = false;
|
||||
}
|
||||
|
||||
if ( $theme_file ) {
|
||||
$core_version = self::get_template_version( ReduxFramework::$_dir . 'templates/panel/' . $file );
|
||||
$theme_version = self::get_template_version( $theme_file );
|
||||
|
||||
if ( $core_version && ( empty( $theme_version ) || version_compare( $theme_version, $core_version, '<' ) ) ) {
|
||||
if ( ! $outdated_templates ) {
|
||||
$outdated_templates = true;
|
||||
}
|
||||
|
||||
$found_files[ $plugin_name ][] = sprintf( __( '<code>%s</code> version <strong style="color:red">%s</strong> is out of date. The core version is %s', 'redux-framework' ), str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file ), $theme_version ? $theme_version : '-', $core_version );
|
||||
} else {
|
||||
$found_files[ $plugin_name ][] = sprintf( '<code>%s</code>', str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $found_files;
|
||||
}
|
||||
|
||||
public static function rURL_fix( $base, $opt_name ) {
|
||||
$url = $base . urlencode( 'http://look.redux.io/api/index.php?js&g&1&v=2' ) . '&proxy=' . urlencode( $base ) . '';
|
||||
|
||||
return Redux_Functions::tru( $url, $opt_name );
|
||||
}
|
||||
|
||||
private static function scan_template_files( $template_path ) {
|
||||
$files = scandir( $template_path );
|
||||
$result = array();
|
||||
|
||||
if ( $files ) {
|
||||
foreach ( $files as $key => $value ) {
|
||||
if ( ! in_array( $value, array( ".", ".." ) ) ) {
|
||||
if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) {
|
||||
$sub_files = redux_scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value );
|
||||
foreach ( $sub_files as $sub_file ) {
|
||||
$result[] = $value . DIRECTORY_SEPARATOR . $sub_file;
|
||||
}
|
||||
} else {
|
||||
$result[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function get_template_version( $file ) {
|
||||
$filesystem = Redux_Filesystem::get_instance();
|
||||
|
||||
// Avoid notices if file does not exist
|
||||
if ( ! file_exists( $file ) ) {
|
||||
return '';
|
||||
}
|
||||
//
|
||||
//// We don't need to write to the file, so just open for reading.
|
||||
//$fp = fopen( $file, 'r' );
|
||||
//
|
||||
//// Pull only the first 8kiB of the file in.
|
||||
//$file_data = fread( $fp, 8192 );
|
||||
//
|
||||
//// PHP will close file handle, but we are good citizens.
|
||||
//fclose( $fp );
|
||||
//
|
||||
// Make sure we catch CR-only line endings.
|
||||
|
||||
$data = get_file_data( $file, array( 'version' ), 'plugin' );
|
||||
if ( ! empty( $data[0] ) ) {
|
||||
return $data[0];
|
||||
} else {
|
||||
$file_data = $filesystem->execute( 'get_contents', $file );
|
||||
|
||||
$file_data = str_replace( "\r", "\n", $file_data );
|
||||
$version = '';
|
||||
|
||||
if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( '@version', '/' ) . '(.*)$/mi', $file_data, $match ) && $match[1] ) {
|
||||
$version = _cleanup_header_comment( $match[1] );
|
||||
}
|
||||
|
||||
return $version;
|
||||
}
|
||||
}
|
||||
|
||||
private static function let_to_num( $size ) {
|
||||
$l = substr( $size, - 1 );
|
||||
$ret = substr( $size, 0, - 1 );
|
||||
|
||||
switch ( strtoupper( $l ) ) {
|
||||
case 'P':
|
||||
$ret *= 1024;
|
||||
case 'T':
|
||||
$ret *= 1024;
|
||||
case 'G':
|
||||
$ret *= 1024;
|
||||
case 'M':
|
||||
$ret *= 1024;
|
||||
case 'K':
|
||||
$ret *= 1024;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function get_extension_dir( $dir ) {
|
||||
return trailingslashit( wp_normalize_path( dirname( $dir ) ) );
|
||||
}
|
||||
|
||||
public static function get_extension_url( $dir ) {
|
||||
$ext_dir = Redux_Helpers::get_extension_dir( $dir );
|
||||
$ext_url = str_replace( wp_normalize_path( WP_CONTENT_DIR ), WP_CONTENT_URL, $ext_dir );
|
||||
|
||||
return $ext_url;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Redux Framework Instance Container Class
|
||||
* Automatically captures and stores all instances
|
||||
* of ReduxFramework at instantiation.
|
||||
*
|
||||
* @package Redux_Framework
|
||||
* @subpackage Core
|
||||
*/
|
||||
class ReduxFrameworkInstances {
|
||||
|
||||
/**
|
||||
* ReduxFrameworkInstances
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* ReduxFramework instances
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $instances;
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $options = array();
|
||||
|
||||
/**
|
||||
* Get Instance
|
||||
* Get ReduxFrameworkInstances instance
|
||||
* OR an instance of ReduxFramework by [opt_name]
|
||||
*
|
||||
* @param string $opt_name the defined opt_name
|
||||
*
|
||||
* @return object class instance
|
||||
*/
|
||||
public static function get_instance( $opt_name = false ) {
|
||||
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
if ( $opt_name && ! empty( self::$instances[ $opt_name ] ) ) {
|
||||
return self::$instances[ $opt_name ];
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all instantiated ReduxFramework instances (so far)
|
||||
*
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public static function get_all_instances() {
|
||||
return self::$instances;
|
||||
}
|
||||
|
||||
private function __construct() {
|
||||
|
||||
add_action( 'redux/construct', array( $this, 'capture' ), 5, 1 );
|
||||
|
||||
$hash = md5( trailingslashit( network_site_url() ) . '-redux' );
|
||||
add_action( 'wp_ajax_nopriv_' . $hash, array( $this, 'tracking_arg' ) );
|
||||
add_action( 'wp_ajax_' . $hash, array( $this, 'tracking_arg' ) );
|
||||
|
||||
if (!class_exists('Redux_Tracking') || !method_exists('Redux_Tracking', 'trackingObject')) {
|
||||
$hash = md5( md5( AUTH_KEY . SECURE_AUTH_KEY . '-redux' ) . '-support' );
|
||||
add_action( 'wp_ajax_nopriv_' . $hash, array( $this, 'support_args' ) );
|
||||
add_action( 'wp_ajax_' . $hash, array( $this, 'support_args' ) );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function tracking_arg() {
|
||||
echo md5( AUTH_KEY . SECURE_AUTH_KEY . '-redux' );
|
||||
die();
|
||||
}
|
||||
|
||||
function support_args() {
|
||||
|
||||
$this->options = get_option( 'redux-framework-tracking' );
|
||||
$this->options['dev_mode'] = false;
|
||||
|
||||
if ( ! isset( $this->options['hash'] ) || ! $this->options['hash'] || empty( $this->options['hash'] ) ) {
|
||||
$this->options['hash'] = md5( network_site_url() . '-' . $_SERVER['REMOTE_ADDR'] );
|
||||
update_option( 'redux-framework-tracking', $this->options );
|
||||
}
|
||||
|
||||
if ( isset( $_GET['redux_framework_disable_tracking'] ) && ! empty( $_GET['redux_framework_disable_tracking'] ) ) {
|
||||
$this->options['allow_tracking'] = false;
|
||||
update_option( 'redux-framework-tracking', $this->options );
|
||||
}
|
||||
|
||||
if ( isset( $_GET['redux_framework_enable_tracking'] ) && ! empty( $_GET['redux_framework_enable_tracking'] ) ) {
|
||||
$this->options['allow_tracking'] = true;
|
||||
update_option( 'redux-framework-tracking', $this->options );
|
||||
}
|
||||
|
||||
header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
|
||||
header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" );
|
||||
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
|
||||
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
|
||||
header( 'Cache-Control: post-check=0, pre-check=0', false );
|
||||
header( 'Pragma: no-cache' );
|
||||
$instances = ReduxFrameworkInstances::get_all_instances();
|
||||
|
||||
$array = array();
|
||||
|
||||
if ( isset( $_REQUEST['i'] ) && ! empty( $_REQUEST['i'] ) ) {
|
||||
if ( is_array( $instances ) && ! empty( $instances ) ) {
|
||||
foreach ( $instances as $opt_name => $data ) {
|
||||
if ( md5( $opt_name . '-debug' ) == $_REQUEST['i'] ) {
|
||||
$array = $instances[ $opt_name ];
|
||||
}
|
||||
if ($data->args['dev_mode']) {
|
||||
$this->options['dev_mode'] = $data->args['dev_mode'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( isset( $array ) ) {
|
||||
if ( isset( $array->extensions ) && is_array( $array->extensions ) && ! empty( $array->extensions ) ) {
|
||||
foreach ( $array->extensions as $key => $extension ) {
|
||||
if ( isset( $extension->version ) ) {
|
||||
$array->extensions[ $key ] = $extension->version;
|
||||
} else {
|
||||
$array->extensions[ $key ] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $array->import_export ) ) {
|
||||
unset( $array->import_export );
|
||||
}
|
||||
|
||||
if ( isset( $array->debug ) ) {
|
||||
unset( $array->debug );
|
||||
}
|
||||
} else {
|
||||
die();
|
||||
}
|
||||
|
||||
} else {
|
||||
$array = Redux_Helpers::trackingObject();
|
||||
if ( is_array( $instances ) && ! empty( $instances ) ) {
|
||||
$array['instances'] = array();
|
||||
foreach ( $instances as $opt_name => $data ) {
|
||||
$array['instances'][] = $opt_name;
|
||||
}
|
||||
}
|
||||
$array['key'] = md5( AUTH_KEY . SECURE_AUTH_KEY );
|
||||
}
|
||||
|
||||
echo @json_encode( $array, true );
|
||||
die();
|
||||
}
|
||||
|
||||
function capture( $ReduxFramework ) {
|
||||
$this->store( $ReduxFramework );
|
||||
}
|
||||
|
||||
private function store( $ReduxFramework ) {
|
||||
if ( $ReduxFramework instanceof ReduxFramework ) {
|
||||
$key = $ReduxFramework->args['opt_name'];
|
||||
self::$instances[ $key ] = $ReduxFramework;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Fix for the GT3 page builder: http://www.gt3themes.com/wordpress-gt3-page-builder-plugin/
|
||||
/** @global string $pagenow */
|
||||
if ( has_action( 'ecpt_field_options_' ) ) {
|
||||
global $pagenow;
|
||||
if ( $pagenow === 'admin.php' ) {
|
||||
|
||||
remove_action( 'admin_init', 'pb_admin_init' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
This directory is a placeholder for Redux Framework extensions.
|
||||
@@ -0,0 +1 @@
|
||||
.redux-section p.customize-section-description{margin-top:22px;word-break:break-word}.redux-section p.customize-section-description.legacy{margin-top:7px}.control-section-themes .accordion-section-title{margin:0}#customize-controls .customize-info{margin-bottom:0}#customize-controls .redux-section .accordion-section-content{background:#FCFCFC}.redux-section .accordion-section-title i,.redux-field .accordion-field-title i,.redux-panel .accordion-section-title i{margin-right:5px}.accordion-section.redux-main{background:inherit;margin-left:inherit;border-left:inherit;-moz-box-shadow:inherit;-webkit-box-shadow:inherit;padding:inherit;box-shadow:inherit}.redux_field_th{padding:13px 0px 0px 0px}.redux-main .redux-field-container{padding:10px 0}.redux-main .select_wrapper{float:none;width:100%;display:inline-block}.redux-main .select2-container{margin-right:0 !important;margin-bottom:5px !important;width:100% !important}.redux-main .select_wrapper:nth-child(odd){margin-right:0}.redux-main .redux-option-image{max-width:42% !important;margin-right:3%}.redux-main .customize-control{border-bottom:1px solid #ddd;padding-bottom:4px}.redux-main .customize-control:last-child{border-bottom:0;padding-bottom:0}.redux-main .upload{width:100% !important}.redux-main h3{margin-top:inherit}.redux-main .redux-container-raw{margin-top:22px;word-break:break-word;padding:0 !important}.redux-main .redux-container-password input{width:100%}.select2-drop{z-index:999999}.rAdsContainer{line-height:0;border:0}.customize-control-redux-raw{list-style:none}.rAds{position:inherit !important;right:0 !important;top:0 !important;bottom:0 !important;left:0 !important;text-align:center;margin-bottom:0;line-height:0;-webkit-transition:left ease-in-out .18s;transition:left ease-in-out .18s}.rAds img{-webkit-transition:left ease-in-out .18s;transition:left ease-in-out .18s}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"mappings": "AACI,8CAAgC;EAC5B,UAAU,EAAE,IAAI;EAChB,UAAU,EAAE,UAAU;EACtB,qDAAS;IACL,UAAU,EAAE,GAAG;;AAK3B,gDAAiD;EAC7C,MAAM,EAAE,CAAC;;AAIT,mCAAgB;EACZ,aAAa,EAAE,CAAC;AAEpB,6DAA0C;EACtC,UAAU,EAAE,OAAO;;AAI3B;;uCAEwC;EACpC,YAAY,EAAE,GAAG;;AAGrB,6BAA8B;EAC1B,UAAU,EAAE,OAAO;EACnB,WAAW,EAAE,OAAO;EACpB,WAAW,EAAE,OAAO;EACpB,eAAe,EAAE,OAAO;EACxB,kBAAkB,EAAE,OAAO;EAC3B,OAAO,EAAE,OAAO;EAChB,UAAU,EAAE,OAAO;;AAGvB,eAAgB;EACZ,OAAO,EAAE,gBAAgB;;AAIzB,kCAAuB;EACnB,OAAO,EAAE,MAAM;AAEnB,2BAAgB;EACZ,KAAK,EAAE,IAAI;EACX,KAAK,EAAE,IAAI;EACX,OAAO,EAAE,YAAY;AAEzB,8BAAmB;EACf,YAAY,EAAE,YAAY;EAC1B,aAAa,EAAE,cAAc;EAC7B,KAAK,EAAE,eAAe;AAE1B,0CAA+B;EAC3B,YAAY,EAAE,CAAC;AAEnB,+BAAoB;EAChB,SAAS,EAAE,cAAc;EACzB,YAAY,EAAE,EAAE;AAEpB,8BAAmB;EACf,aAAa,EAAE,cAAc;EAC7B,cAAc,EAAE,GAAG;AAEvB,yCAA8B;EAC1B,aAAa,EAAE,CAAC;EAChB,cAAc,EAAE,CAAC;AAErB,mBAAQ;EACJ,KAAK,EAAE,eAAe;AAE1B,cAAG;EACC,UAAU,EAAE,OAAO;AAEvB,gCAAqB;EACjB,UAAU,EAAE,IAAI;EAChB,UAAU,EAAE,UAAU;EACtB,OAAO,EAAE,YAAY;AAEzB,2CAAgC;EAC5B,KAAK,EAAE,IAAI;;AAInB,aAAc;EACV,OAAO,EAAE,MAAM;;AAGnB,cAAe;EACX,WAAW,EAAE,CAAC;EACd,MAAM,EAAE,CAAC;EACT,sBAAsB;EACtB,yBAAyB;;AAG7B,4BAA6B;EACzB,UAAU,EAAE,IAAI;;AAGpB,KAAM;EACF,QAAQ,EAAE,kBAAkB;EAC5B,KAAK,EAAE,YAAY;EACnB,GAAG,EAAE,YAAY;EACjB,MAAM,EAAE,YAAY;EACpB,IAAI,EAAE,YAAY;EAClB,UAAU,EAAE,MAAM;EAClB,aAAa,EAAE,CAAC;EAChB,WAAW,EAAE,CAAC;EACd,kBAAkB,EAAE,qBAAqB;EACzC,UAAU,EAAE,qBAAqB;EACjC,SAAI;IACA,kBAAkB,EAAE,qBAAqB;IACzC,UAAU,EAAE,qBAAqB",
|
||||
"sources": ["extension_customizer.scss"],
|
||||
"names": [],
|
||||
"file": "extension_customizer.css"
|
||||
}
|
||||
@@ -0,0 +1,396 @@
|
||||
/* global jQuery, document, redux, redux_change, setting */
|
||||
|
||||
/*!
|
||||
SerializeJSON jQuery plugin.
|
||||
https://github.com/marioizquierdo/jquery.serializeJSON
|
||||
version 2.6.0 (Apr, 2015)
|
||||
|
||||
Copyright (c) 2012, 2015 Mario Izquierdo
|
||||
Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
|
||||
and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
|
||||
*/
|
||||
(function( $ ) {
|
||||
"use strict";
|
||||
|
||||
// jQuery('form').serializeJSON()
|
||||
$.fn.serializeJSON = function( options ) {
|
||||
var serializedObject, formAsArray, keys, type, value, _ref, f, opts;
|
||||
f = $.serializeJSON;
|
||||
opts = f.setupOpts( options ); // calculate values for options {parseNumbers, parseBoolens, parseNulls}
|
||||
formAsArray = this.serializeArray(); // array of objects {name, value}
|
||||
f.readCheckboxUncheckedValues( formAsArray, this, opts ); // add {name, value} of unchecked checkboxes if needed
|
||||
|
||||
serializedObject = {};
|
||||
$.each(
|
||||
formAsArray, function( i, input ) {
|
||||
keys = f.splitInputNameIntoKeysArray( input.name, opts );
|
||||
type = keys.pop(); // the last element is always the type ("string" by default)
|
||||
if ( type !== 'skip' ) { // easy way to skip a value
|
||||
value = f.parseValue( input.value, type, opts ); // string, number, boolean or null
|
||||
if ( opts.parseWithFunction && type === '_' ) value = opts.parseWithFunction( value, input.name ); // allow for custom parsing
|
||||
f.deepSet( serializedObject, keys, value, opts );
|
||||
}
|
||||
}
|
||||
);
|
||||
return serializedObject;
|
||||
};
|
||||
|
||||
// Use $.serializeJSON as namespace for the auxiliar functions
|
||||
// and to define defaults
|
||||
$.serializeJSON = {
|
||||
|
||||
defaultOptions: {
|
||||
checkboxUncheckedValue: undefined, // to include that value for unchecked checkboxes (instead of ignoring them)
|
||||
|
||||
parseNumbers: false, // convert values like "1", "-2.33" to 1, -2.33
|
||||
parseBooleans: false, // convert "true", "false" to true, false
|
||||
parseNulls: false, // convert "null" to null
|
||||
parseAll: false, // all of the above
|
||||
parseWithFunction: null, // to use custom parser, a function like: function(val){ return parsed_val; }
|
||||
|
||||
customTypes: {}, // override defaultTypes
|
||||
defaultTypes: {
|
||||
string: function( str ) {
|
||||
return String( str );
|
||||
},
|
||||
number: function( str ) {
|
||||
return Number( str );
|
||||
},
|
||||
boolean: function( str ) {
|
||||
return (["false", "null", "undefined", "", "0"].indexOf( str ) === -1);
|
||||
},
|
||||
null: function( str ) {
|
||||
return (["false", "null", "undefined", "", "0"].indexOf( str ) !== -1) ? null : str;
|
||||
},
|
||||
array: function( str ) {
|
||||
return JSON.parse( str );
|
||||
},
|
||||
object: function( str ) {
|
||||
return JSON.parse( str );
|
||||
},
|
||||
auto: function( str ) {
|
||||
return $.serializeJSON.parseValue(
|
||||
str, null, {parseNumbers: true, parseBooleans: true, parseNulls: true}
|
||||
);
|
||||
} // try again with something like "parseAll"
|
||||
},
|
||||
|
||||
useIntKeysAsArrayIndex: false, // name="foo[2]" value="v" => {foo: [null, null, "v"]}, instead of {foo: ["2": "v"]}
|
||||
},
|
||||
|
||||
// Merge option defaults into the options
|
||||
setupOpts: function( options ) {
|
||||
var opt, validOpts, defaultOptions, optWithDefault, parseAll, f;
|
||||
f = $.serializeJSON;
|
||||
|
||||
if ( options === null || options === undefined ) options = {}; // options ||= {}
|
||||
defaultOptions = f.defaultOptions || {}; // defaultOptions
|
||||
|
||||
// Make sure that the user didn't misspell an option
|
||||
validOpts = ['checkboxUncheckedValue', 'parseNumbers', 'parseBooleans', 'parseNulls', 'parseAll', 'parseWithFunction', 'customTypes', 'defaultTypes', 'useIntKeysAsArrayIndex']; // re-define because the user may override the defaultOptions
|
||||
for ( opt in options ) {
|
||||
if ( validOpts.indexOf( opt ) === -1 ) {
|
||||
throw new Error(
|
||||
"serializeJSON ERROR: invalid option '" + opt + "'. Please use one of " + validOpts.join(
|
||||
', '
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Helper to get the default value for this option if none is specified by the user
|
||||
optWithDefault = function( key ) {
|
||||
return (options[key] !== false) && (options[key] !== '') && (options[key] || defaultOptions[key]);
|
||||
};
|
||||
|
||||
// Return computed options (opts to be used in the rest of the script)
|
||||
parseAll = optWithDefault( 'parseAll' );
|
||||
return {
|
||||
checkboxUncheckedValue: optWithDefault( 'checkboxUncheckedValue' ),
|
||||
parseNumbers: parseAll || optWithDefault( 'parseNumbers' ),
|
||||
parseBooleans: parseAll || optWithDefault( 'parseBooleans' ),
|
||||
parseNulls: parseAll || optWithDefault( 'parseNulls' ),
|
||||
parseWithFunction: optWithDefault( 'parseWithFunction' ),
|
||||
typeFunctions: $.extend( {}, optWithDefault( 'defaultTypes' ), optWithDefault( 'customTypes' ) ),
|
||||
useIntKeysAsArrayIndex: optWithDefault( 'useIntKeysAsArrayIndex' ),
|
||||
};
|
||||
},
|
||||
|
||||
// Given a string, apply the type or the relevant "parse" options, to return the parsed value
|
||||
parseValue: function( str, type, opts ) {
|
||||
var typeFunction, f;
|
||||
f = $.serializeJSON;
|
||||
|
||||
// Parse with a type if available
|
||||
typeFunction = opts.typeFunctions && opts.typeFunctions[type];
|
||||
if ( typeFunction ) return typeFunction( str ); // use specific type
|
||||
|
||||
// Otherwise, check if there is any auto-parse option enabled and use it.
|
||||
if ( opts.parseNumbers && f.isNumeric( str ) ) return Number( str ); // auto: number
|
||||
if ( opts.parseBooleans && (str === "true" || str === "false") ) return str === "true"; // auto: boolean
|
||||
if ( opts.parseNulls && str == "null" ) return null; // auto: null
|
||||
|
||||
// If none applies, just return the str
|
||||
return str;
|
||||
},
|
||||
|
||||
isObject: function( obj ) {
|
||||
return obj === Object( obj );
|
||||
}, // is this variable an object?
|
||||
isUndefined: function( obj ) {
|
||||
return obj === void 0;
|
||||
}, // safe check for undefined values
|
||||
isValidArrayIndex: function( val ) {
|
||||
return /^[0-9]+$/.test( String( val ) );
|
||||
}, // 1,2,3,4 ... are valid array indexes
|
||||
isNumeric: function( obj ) {
|
||||
return obj - parseFloat( obj ) >= 0;
|
||||
}, // taken from jQuery.isNumeric implementation. Not using jQuery.isNumeric to support old jQuery and Zepto versions
|
||||
|
||||
optionKeys: function( obj ) {
|
||||
if ( Object.keys ) {
|
||||
return Object.keys( obj );
|
||||
} else {
|
||||
var keys = [];
|
||||
for ( var key in obj ) {
|
||||
keys.push( key );
|
||||
}
|
||||
|
||||
return keys;
|
||||
}
|
||||
}, // polyfill Object.keys to get option keys in IE<9
|
||||
|
||||
// Split the input name in programatically readable keys.
|
||||
// The last element is always the type (default "_").
|
||||
// Examples:
|
||||
// "foo" => ['foo', '_']
|
||||
// "foo:string" => ['foo', 'string']
|
||||
// "foo:boolean" => ['foo', 'boolean']
|
||||
// "[foo]" => ['foo', '_']
|
||||
// "foo[inn][bar]" => ['foo', 'inn', 'bar', '_']
|
||||
// "foo[inn[bar]]" => ['foo', 'inn', 'bar', '_']
|
||||
// "foo[inn][arr][0]" => ['foo', 'inn', 'arr', '0', '_']
|
||||
// "arr[][val]" => ['arr', '', 'val', '_']
|
||||
// "arr[][val]:null" => ['arr', '', 'val', 'null']
|
||||
splitInputNameIntoKeysArray: function( name, opts ) {
|
||||
var keys, nameWithoutType, type, _ref, f;
|
||||
f = $.serializeJSON;
|
||||
_ref = f.extractTypeFromInputName( name, opts ), nameWithoutType = _ref[0], type = _ref[1];
|
||||
keys = nameWithoutType.split( '[' ); // split string into array
|
||||
keys = $.map(
|
||||
keys, function( key ) {
|
||||
return key.replace( /]/g, '' );
|
||||
}
|
||||
); // remove closing brackets
|
||||
if ( keys[0] === '' ) {
|
||||
keys.shift();
|
||||
} // ensure no opening bracket ("[foo][inn]" should be same as "foo[inn]")
|
||||
keys.push( type ); // add type at the end
|
||||
return keys;
|
||||
},
|
||||
|
||||
// Returns [name-without-type, type] from name.
|
||||
// "foo" => ["foo", '_']
|
||||
// "foo:boolean" => ["foo", 'boolean']
|
||||
// "foo[bar]:null" => ["foo[bar]", 'null']
|
||||
extractTypeFromInputName: function( name, opts ) {
|
||||
var match, validTypes, f;
|
||||
if ( match = name.match( /(.*):([^:]+)$/ ) ) {
|
||||
f = $.serializeJSON;
|
||||
|
||||
validTypes = f.optionKeys( opts ? opts.typeFunctions : f.defaultOptions.defaultTypes );
|
||||
validTypes.push( 'skip' ); // skip is a special type that makes it easy to remove
|
||||
if ( validTypes.indexOf( match[2] ) !== -1 ) {
|
||||
return [match[1], match[2]];
|
||||
} else {
|
||||
throw new Error(
|
||||
"serializeJSON ERROR: Invalid type " + match[2] + " found in input name '" + name + "', please use one of " + validTypes.join(
|
||||
', '
|
||||
)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
return [name, '_']; // no defined type, then use parse options
|
||||
}
|
||||
},
|
||||
|
||||
// Set a value in an object or array, using multiple keys to set in a nested object or array:
|
||||
//
|
||||
// deepSet(obj, ['foo'], v) // obj['foo'] = v
|
||||
// deepSet(obj, ['foo', 'inn'], v) // obj['foo']['inn'] = v // Create the inner obj['foo'] object, if needed
|
||||
// deepSet(obj, ['foo', 'inn', '123'], v) // obj['foo']['arr']['123'] = v //
|
||||
//
|
||||
// deepSet(obj, ['0'], v) // obj['0'] = v
|
||||
// deepSet(arr, ['0'], v, {useIntKeysAsArrayIndex: true}) // arr[0] = v
|
||||
// deepSet(arr, [''], v) // arr.push(v)
|
||||
// deepSet(obj, ['arr', ''], v) // obj['arr'].push(v)
|
||||
//
|
||||
// arr = [];
|
||||
// deepSet(arr, ['', v] // arr => [v]
|
||||
// deepSet(arr, ['', 'foo'], v) // arr => [v, {foo: v}]
|
||||
// deepSet(arr, ['', 'bar'], v) // arr => [v, {foo: v, bar: v}]
|
||||
// deepSet(arr, ['', 'bar'], v) // arr => [v, {foo: v, bar: v}, {bar: v}]
|
||||
//
|
||||
deepSet: function( o, keys, value, opts ) {
|
||||
var key, nextKey, tail, lastIdx, lastVal, f;
|
||||
if ( opts == null ) opts = {};
|
||||
f = $.serializeJSON;
|
||||
if ( f.isUndefined( o ) ) {
|
||||
throw new Error( "ArgumentError: param 'o' expected to be an object or array, found undefined" );
|
||||
}
|
||||
if ( !keys || keys.length === 0 ) {
|
||||
throw new Error( "ArgumentError: param 'keys' expected to be an array with least one element" );
|
||||
}
|
||||
|
||||
key = keys[0];
|
||||
|
||||
// Only one key, then it's not a deepSet, just assign the value.
|
||||
if ( keys.length === 1 ) {
|
||||
if ( key === '' ) {
|
||||
o.push( value ); // '' is used to push values into the array (assume o is an array)
|
||||
} else {
|
||||
o[key] = value; // other keys can be used as object keys or array indexes
|
||||
}
|
||||
|
||||
// With more keys is a deepSet. Apply recursively.
|
||||
} else {
|
||||
nextKey = keys[1];
|
||||
|
||||
// '' is used to push values into the array,
|
||||
// with nextKey, set the value into the same object, in object[nextKey].
|
||||
// Covers the case of ['', 'foo'] and ['', 'var'] to push the object {foo, var}, and the case of nested arrays.
|
||||
if ( key === '' ) {
|
||||
lastIdx = o.length - 1; // asume o is array
|
||||
lastVal = o[lastIdx];
|
||||
if ( f.isObject( lastVal ) && (f.isUndefined( lastVal[nextKey] ) || keys.length > 2) ) { // if nextKey is not present in the last object element, or there are more keys to deep set
|
||||
key = lastIdx; // then set the new value in the same object element
|
||||
} else {
|
||||
key = lastIdx + 1; // otherwise, point to set the next index in the array
|
||||
}
|
||||
}
|
||||
|
||||
// '' is used to push values into the array "array[]"
|
||||
if ( nextKey === '' ) {
|
||||
if ( f.isUndefined( o[key] ) || !$.isArray( o[key] ) ) {
|
||||
o[key] = []; // define (or override) as array to push values
|
||||
}
|
||||
} else {
|
||||
if ( opts.useIntKeysAsArrayIndex && f.isValidArrayIndex( nextKey ) ) { // if 1, 2, 3 ... then use an array, where nextKey is the index
|
||||
if ( f.isUndefined( o[key] ) || !$.isArray( o[key] ) ) {
|
||||
o[key] = []; // define (or override) as array, to insert values using int keys as array indexes
|
||||
}
|
||||
} else { // for anything else, use an object, where nextKey is going to be the attribute name
|
||||
if ( f.isUndefined( o[key] ) || !f.isObject( o[key] ) ) {
|
||||
o[key] = {}; // define (or override) as object, to set nested properties
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Recursively set the inner object
|
||||
tail = keys.slice( 1 );
|
||||
f.deepSet( o[key], tail, value, opts );
|
||||
}
|
||||
},
|
||||
|
||||
// Fill the formAsArray object with values for the unchecked checkbox inputs,
|
||||
// using the same format as the jquery.serializeArray function.
|
||||
// The value of the unchecked values is determined from the opts.checkboxUncheckedValue
|
||||
// and/or the data-unchecked-value attribute of the inputs.
|
||||
readCheckboxUncheckedValues: function( formAsArray, $form, opts ) {
|
||||
var selector, $uncheckedCheckboxes, $el, dataUncheckedValue, f;
|
||||
if ( opts == null ) opts = {};
|
||||
f = $.serializeJSON;
|
||||
|
||||
selector = 'input[type=checkbox][name]:not(:checked):not([disabled])';
|
||||
$uncheckedCheckboxes = $form.find( selector ).add( $form.filter( selector ) );
|
||||
$uncheckedCheckboxes.each(
|
||||
function( i, el ) {
|
||||
$el = $( el );
|
||||
dataUncheckedValue = $el.attr( 'data-unchecked-value' );
|
||||
if ( dataUncheckedValue ) { // data-unchecked-value has precedence over option opts.checkboxUncheckedValue
|
||||
formAsArray.push( {name: el.name, value: dataUncheckedValue} );
|
||||
} else {
|
||||
if ( !f.isUndefined( opts.checkboxUncheckedValue ) ) {
|
||||
formAsArray.push( {name: el.name, value: opts.checkboxUncheckedValue} );
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}( window.jQuery || window.$ ));
|
||||
|
||||
(function( $ ) { //This functions first parameter is named $
|
||||
'use strict';
|
||||
|
||||
redux.customizer = redux.customizer || {};
|
||||
|
||||
$( document ).ready(
|
||||
function() {
|
||||
redux.customizer.init();
|
||||
}
|
||||
);
|
||||
redux.customizer.init = function() {
|
||||
$( 'body' ).addClass( redux_customizer.body_class );
|
||||
$( '.accordion-section.redux-section, .accordion-section.redux-panel, .accordion-section-title' ).click(
|
||||
function() {
|
||||
$.redux.initFields();
|
||||
}
|
||||
);
|
||||
|
||||
redux.args.disable_save_warn = true;
|
||||
var reduxChange = redux_change;
|
||||
redux_change = function( variable ) {
|
||||
variable = $( variable );
|
||||
reduxChange.apply( this, arguments );
|
||||
redux.customizer.save( variable )
|
||||
};
|
||||
|
||||
var redux_initFields = $.redux.initFields;
|
||||
$.redux.initFiles = function() {
|
||||
redux_initFields();
|
||||
}
|
||||
};
|
||||
|
||||
redux.customizer.save = function( $obj ) {
|
||||
var $parent = $obj.hasClass( 'redux-field' ) ? $obj : $obj.parents( '.redux-field-container:first' );
|
||||
redux.customizer.inputSave( $parent );
|
||||
};
|
||||
redux.customizer.inputSave = function( $parent ) {
|
||||
|
||||
if ( !$parent.hasClass( 'redux-field-container' ) ) {
|
||||
$parent = $parent.parents( '[class^="redux-field-container"]' );
|
||||
}
|
||||
|
||||
var $id = $parent.parent().find( '.redux-customizer-input' ).data( 'id' );
|
||||
|
||||
if ( !$id ) {
|
||||
$parent = $parent.parents( '.redux-container-repeater:first' );
|
||||
var $id = $parent.parent().find( '.redux-customizer-input' ).data( 'id' );
|
||||
}
|
||||
|
||||
//var $nData = $parent.serializeJSON();
|
||||
var $nData = $parent.find( ':input' ).serializeJSON();
|
||||
|
||||
$.each(
|
||||
$nData, function( $k, $v ) {
|
||||
$nData = $v;
|
||||
}
|
||||
);
|
||||
|
||||
var $key = $parent.parent().find( '.redux-customizer-input' ).data( 'key' );
|
||||
if ( $nData[$key] ) {
|
||||
$nData = $nData[$key];
|
||||
}
|
||||
|
||||
var $control = wp.customize.control( $id );
|
||||
|
||||
// Customizer hack since they didn't code it to save order...
|
||||
if ( JSON.stringify( $control.setting._value ) !== JSON.stringify( $nData ) ) {
|
||||
$control.setting._value = null;
|
||||
}
|
||||
$control.setting.set( $nData );
|
||||
}
|
||||
})( jQuery );
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,811 @@
|
||||
<?php
|
||||
// <input type="radio" value="1" name="_customize-radio-redux_demo[opt-radio]" data-customize-setting-link="redux_demo[opt-color-title]">
|
||||
//return;
|
||||
/**
|
||||
* Redux Framework is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* any later version.
|
||||
* Redux Framework is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package ReduxFramework
|
||||
* @author Dovy Paukstys (dovy)
|
||||
* @version 0.1.0
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Don't duplicate me!
|
||||
if ( ! class_exists( 'ReduxFramework_extension_customizer' ) ) {
|
||||
|
||||
/**
|
||||
* Main ReduxFramework customizer extension class
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ReduxFramework_extension_customizer {
|
||||
|
||||
// Protected vars
|
||||
protected $redux;
|
||||
private $_extension_url;
|
||||
private $_extension_dir;
|
||||
private $parent;
|
||||
private $orig_options = array();
|
||||
private static $post_values = array();
|
||||
public static $version = "2.0.0";
|
||||
private $options = array();
|
||||
|
||||
/**
|
||||
* Class Constructor. Defines the args for the extions class
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*
|
||||
* @param array $sections Panel sections.
|
||||
* @param array $args Class constructor arguments.
|
||||
* @param array $extra_tabs Extra panel tabs.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $parent ) {
|
||||
|
||||
$this->parent = $parent;
|
||||
|
||||
$this->upload_dir = ReduxFramework::$_upload_dir . 'advanced-customizer/';
|
||||
|
||||
//add_action('wp_head', array( $this, '_enqueue_new' ));
|
||||
if ( $parent->args['customizer'] == false ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Override the ReduxCore class
|
||||
add_filter( "redux/extension/{$this->parent->args['opt_name']}/customizer", array(
|
||||
$this,
|
||||
'remove_core_customizer_class'
|
||||
) );
|
||||
|
||||
global $pagenow, $wp_customize;
|
||||
if ( ! isset( $wp_customize ) && $pagenow !== "customize.php" && $pagenow !== "admin-ajax.php" ) {
|
||||
return;
|
||||
}
|
||||
if ( ( $pagenow !== "customize.php" && $pagenow !== "admin-ajax.php" && ! isset( $GLOBALS['wp_customize'] ) ) ) {
|
||||
//return;
|
||||
}
|
||||
|
||||
if ( empty( $this->_extension_dir ) ) {
|
||||
$this->_extension_dir = apply_filters( "redux/extension/customizer/dir", trailingslashit( str_replace( '\\', '/', dirname( __FILE__ ) ) ) );
|
||||
$this->_extension_url = apply_filters( "redux/extension/customizer/url", site_url( str_replace( trailingslashit( str_replace( '\\', '/', ABSPATH ) ), '', $this->_extension_dir ) ) );
|
||||
}
|
||||
|
||||
self::get_post_values();
|
||||
|
||||
// Create defaults array
|
||||
$defaults = array();
|
||||
/*
|
||||
customize_controls_init
|
||||
customize_controls_enqueue_scripts
|
||||
customize_controls_print_styles
|
||||
customize_controls_print_scripts
|
||||
customize_controls_print_footer_scripts
|
||||
*/
|
||||
|
||||
//add_action('customize_save', );
|
||||
|
||||
if ( isset( $_POST['wp_customize'] ) && $_POST['wp_customize'] == "on" ) {
|
||||
$this->parent->args['customizer_only'] = true;
|
||||
}
|
||||
|
||||
if ( isset( $_POST['wp_customize'] ) && $_POST['wp_customize'] == "on" && isset( $_POST['customized'] ) && ! empty( $_POST['customized'] ) && ! isset( $_POST['action'] ) ) {
|
||||
add_action( "redux/options/{$this->parent->args['opt_name']}/options", array(
|
||||
$this,
|
||||
'_override_values'
|
||||
), 100 );
|
||||
}
|
||||
|
||||
add_action( 'customize_register', array(
|
||||
$this,
|
||||
'_register_customizer_controls'
|
||||
) ); // Create controls
|
||||
|
||||
add_action( 'wp_head', array( $this, 'customize_preview_init' ) );
|
||||
|
||||
|
||||
//add_action( 'customize_save', array( $this, 'customizer_save_before' ) ); // Before save
|
||||
add_action( 'customize_save_after', array( &$this, 'customizer_save_after' ) ); // After save
|
||||
|
||||
// Add global controls CSS file
|
||||
add_action( 'customize_controls_print_scripts', array( $this, 'enqueue_controls_css' ) );
|
||||
|
||||
add_action( 'customize_controls_init', array( $this, 'enqueue_panel_css' ) );
|
||||
|
||||
|
||||
//add_action( 'wp_enqueue_scripts', array( &$this, '_enqueue_previewer_css' ) ); // Enqueue previewer css
|
||||
//add_action( 'wp_enqueue_scripts', array( &$this, '_enqueue_previewer_js' ) ); // Enqueue previewer javascript
|
||||
//add_action( "wp_footer", array( $this, '_enqueue_new' ), 100 );
|
||||
//$this->_enqueue_new();
|
||||
|
||||
|
||||
}
|
||||
|
||||
function enqueue_controls_css() {
|
||||
|
||||
require_once ReduxFramework::$_dir . 'core/enqueue.php';
|
||||
$enqueue = new reduxCoreEnqueue ( $this->parent );
|
||||
$enqueue->get_warnings_and_errors_array();
|
||||
$enqueue->init();
|
||||
wp_enqueue_style( 'redux-extension-advanced-customizer', $this->_extension_url . 'extension_customizer.css', '', time() );
|
||||
|
||||
wp_enqueue_script(
|
||||
'redux-extension-customizer',
|
||||
$this->_extension_url . 'extension_customizer' . Redux_Functions::isMin() . '.js',
|
||||
array( 'jquery', 'redux-js' ),
|
||||
ReduxFramework_extension_customizer::$version,
|
||||
true
|
||||
);
|
||||
wp_localize_script( 'redux-extension-customizer', 'redux_customizer', array( 'body_class' => sanitize_html_class( 'admin-color-' . get_user_option( 'admin_color' ), 'fresh' ) ) );
|
||||
}
|
||||
|
||||
function enqueue_panel_css() {
|
||||
|
||||
}
|
||||
|
||||
function remove_core_customizer_class( $path ) {
|
||||
return "";
|
||||
}
|
||||
|
||||
function customize_preview_init() {
|
||||
do_action( 'redux/customizer/live_preview' );
|
||||
}
|
||||
|
||||
protected static function get_post_values() {
|
||||
if ( empty( self::$post_values ) && isset( $_POST['customized'] ) && ! empty( $_POST['customized'] ) ) {
|
||||
self::$post_values = json_decode( stripslashes_deep( $_POST['customized'] ), true );
|
||||
}
|
||||
}
|
||||
|
||||
public function _override_values( $data ) {
|
||||
|
||||
self::get_post_values();
|
||||
|
||||
|
||||
if ( isset( $_POST['customized'] ) && ! empty( self::$post_values ) ) {
|
||||
|
||||
if ( is_array( self::$post_values ) ) {
|
||||
foreach ( self::$post_values as $key => $value ) {
|
||||
if ( strpos( $key, $this->parent->args['opt_name'] ) !== false ) {
|
||||
|
||||
//if (is_array($value)) {
|
||||
// $value = @stripslashes( $value );
|
||||
// if ( function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() ) {
|
||||
// $value = @array_map( 'stripslashes_deep', $value );
|
||||
// $value = @array_map( 'urldecode', $value );
|
||||
// }
|
||||
//} else {
|
||||
// $value = @urldecode($value);
|
||||
//}
|
||||
$key = str_replace( $this->parent->args['opt_name'] . '[', '', rtrim( $key, "]" ) );
|
||||
$data[ $key ] = $value;
|
||||
$GLOBALS[ $this->parent->args['global_variable'] ][ $key ] = $value;
|
||||
$this->parent->options[ $key ] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function _enqueue_new() {
|
||||
//echo "<script type='text/javascript' src='".$this->_extension_url . 'new/codemirror.min.js'."'></script>";
|
||||
//echo "<script type='text/javascript' src='".$this->_extension_url . 'new/colors-control.js'."'></script>";
|
||||
//echo "<script type='text/javascript' src='".$this->_extension_url . 'new/customizer-control.js'."'></script>";
|
||||
//echo "<script type='text/javascript' src='".$this->_extension_url . 'new/fonts-customizer-admin.js'."'></script>";
|
||||
//echo "<script type='text/javascript' src='".$this->_extension_url . 'new/header-control.js'."'></script>";
|
||||
//echo "<script type='text/javascript' src='".$this->_extension_url . 'new/header-models.js'."'></script>";
|
||||
//echo "<script type='text/javascript' src='".$this->_extension_url . 'new/jquery.slimscroll.js'."'></script>";
|
||||
//echo "<script type='text/javascript' src='".$this->_extension_url . 'new/jquery.ui.droppable.min.js'."'></script>";
|
||||
//echo "<script type='text/javascript' src='".$this->_extension_url . 'new/media-editor.min.js'."'></script>";
|
||||
//echo "<script type='text/javascript' src='".$this->_extension_url . 'new/new-customizer.js'."'></script>";
|
||||
//echo "<script type='text/javascript' src='".$this->_extension_url . 'new/previewing.js'."'></script>";
|
||||
//echo "<script type='text/javascript' src='".$this->_extension_url . 'new/theme-customizer.js'."'></script>";
|
||||
|
||||
/*
|
||||
wp_enqueue_script('redux-extension-customizer-codemirror-js', $this->_extension_url . 'new/codemirror.min.js');
|
||||
wp_enqueue_script('redux-extension-customizer-color-js', $this->_extension_url . 'new/colors-control.js');
|
||||
wp_enqueue_script('redux-extension-customizer-controls-js', $this->_extension_url . 'new/customizer-control.js');
|
||||
wp_enqueue_script('redux-extension-customizer-fonts-js', $this->_extension_url . 'new/fonts-customizer-admin.js');
|
||||
wp_enqueue_script('redux-extension-customizer-header-js', $this->_extension_url . 'new/header-control.js');
|
||||
wp_enqueue_script('redux-extension-customizer-models-js', $this->_extension_url . 'new/header-models.js');
|
||||
wp_enqueue_script('redux-extension-customizer-slimscroll-js', $this->_extension_url . 'new/jquery.slimscroll.js');
|
||||
wp_enqueue_script('redux-extension-customizer-droppable-js', $this->_extension_url . 'new/jquery.ui.droppable.min.js');
|
||||
wp_enqueue_script('redux-extension-customizer-editor-js', $this->_extension_url . 'new/media-editor.min.js');
|
||||
wp_enqueue_script('redux-extension-customizer-new-js', $this->_extension_url . 'new/new-customizer.js');
|
||||
wp_enqueue_script('redux-extension-customizer-previewing-js', $this->_extension_url . 'new/previewing.js');
|
||||
wp_enqueue_script('redux-extension-customizer-theme-js', $this->_extension_url . 'new/theme-customizer.js');
|
||||
*/
|
||||
}
|
||||
|
||||
public function render( $control ) {
|
||||
$fieldID = str_replace( $this->parent->args['opt_name'] . '-', '', $control->redux_id );
|
||||
$field = $this->options[ $fieldID ];
|
||||
|
||||
if ( isset( $field['compiler'] ) && ! empty( $field['compiler'] ) ) {
|
||||
echo '<tr class="compiler">';
|
||||
} else {
|
||||
echo '<tr>';
|
||||
}
|
||||
echo '<th scope="row">' . $this->parent->field_head[ $field['id'] ] . '</th>';
|
||||
echo '<td>';
|
||||
//$field['data-customize-setting-link'] = array(
|
||||
// 'name' => $field['name'],
|
||||
// 'suffix' => isset($field['name_suffix']) ? $field['name_suffix'] : ''
|
||||
//);
|
||||
//
|
||||
$field['name'] = $field['id'];
|
||||
$this->parent->_field_input( $field );
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
// All sections, settings, and controls will be added here
|
||||
public function _register_customizer_controls( $wp_customize ) {
|
||||
|
||||
if ( ! class_exists( 'Redux_Customizer_Section' ) ) {
|
||||
require_once dirname( __FILE__ ) . '/inc/customizer_section.php';
|
||||
if ( method_exists( $wp_customize, 'register_section_type' ) ) {
|
||||
$wp_customize->register_section_type( 'Redux_Customizer_Section' );
|
||||
}
|
||||
}
|
||||
if ( ! class_exists( 'Redux_Customizer_Panel' ) ) {
|
||||
require_once dirname( __FILE__ ) . '/inc/customizer_panel.php';
|
||||
if ( method_exists( $wp_customize, 'register_panel_type' ) ) {
|
||||
$wp_customize->register_panel_type( 'Redux_Customizer_Panel' );
|
||||
}
|
||||
}
|
||||
if ( ! class_exists( 'Redux_Customizer_Control' ) ) {
|
||||
require_once dirname( __FILE__ ) . '/inc/customizer_control.php';
|
||||
}
|
||||
|
||||
require_once dirname( __FILE__ ) . '/inc/customizer_fields.php';
|
||||
require_once dirname( __FILE__ ) . '/inc/customizer_devs.php';
|
||||
|
||||
do_action( "redux/extension/customizer/control/includes" );
|
||||
|
||||
//if ($this->parent->args['dev_mode']) {
|
||||
// $section = new Redux_Customizer_rAds( $wp_customize, 'redux_rAds', array(
|
||||
// 'priority' => 0,
|
||||
// ) );
|
||||
// $wp_customize->add_section( $section, array(
|
||||
// 'priority' => 0,
|
||||
// ) );
|
||||
//
|
||||
// //$wp_customize->add_control( new Redux_Customizer_Control_rAds( $wp_customize, 'reduxAdsDisplay', array(
|
||||
// // 'section' => 'redux_rAds',
|
||||
// // 'settings' => 'redux_rAds_field',
|
||||
// // 'type' => 'redux-rAds',
|
||||
// //) ) );
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//}
|
||||
if ( $this->parent->args['dev_mode'] ) {
|
||||
//$args = array(
|
||||
// 'priority' => 0,
|
||||
//);
|
||||
////$section = new Redux_Customizer_Section( $wp_customize, 'redux_rAds', $args );
|
||||
////$wp_customize->add_section( $section, $args );
|
||||
//$this->add_section( 'redux_rAds', array(
|
||||
// 'title' => '',
|
||||
// 'priority' => 1,
|
||||
// 'description' => '',
|
||||
// 'capability' => 'edit_theme_options',
|
||||
//), $wp_customize );
|
||||
//
|
||||
//$wp_customize->add_control( new WP_Customize_Color_Control(
|
||||
// $wp_customize,
|
||||
// 'redux_rAds_display',
|
||||
// array(
|
||||
// 'section' => 'redux_rAds',
|
||||
// 'settings' => 'redux_rAds_display',
|
||||
// )
|
||||
//));
|
||||
////$wp_customize->add_control( new Redux_Customizer_Control_rAds( $wp_customize, 'reduxAdsDisplay', array(
|
||||
//// 'section' => 'redux_rAds',
|
||||
//// 'settings' => 'redux_rAds_field',
|
||||
//// 'type' => 'redux-rAds',
|
||||
////) ) );
|
||||
//start copyright settings
|
||||
|
||||
//$section = new Redux_Customizer_section_rAds( $wp_customize, 'redux_rAds', array(
|
||||
// 'priority' => -999,
|
||||
//) );
|
||||
//$wp_customize->add_section( $section, array(
|
||||
// 'priority' => -999,
|
||||
//) );
|
||||
//$wp_customize->add_setting(
|
||||
// 'redux_rAds_empty'
|
||||
//);
|
||||
//$wp_customize->add_control(
|
||||
// new Redux_Customizer_Control_rAds(
|
||||
// $wp_customize,
|
||||
// 'redux_rAds_empty',
|
||||
// array(
|
||||
// 'section' => 'redux_rAds',
|
||||
// 'settings' => 'redux_rAds_empty'
|
||||
// )
|
||||
// )
|
||||
//);
|
||||
}
|
||||
|
||||
|
||||
$order = array(
|
||||
'heading' => - 500,
|
||||
'option' => - 500,
|
||||
);
|
||||
$defaults = array(
|
||||
'default-color' => '',
|
||||
'default-image' => '',
|
||||
'wp-head-callback' => '',
|
||||
'admin-head-callback' => '',
|
||||
'admin-preview-callback' => ''
|
||||
);
|
||||
$panel = "";
|
||||
|
||||
$this->parent->args['options_api'] = false;
|
||||
$this->parent->_register_settings();
|
||||
|
||||
foreach ( $this->parent->sections as $key => $section ) {
|
||||
|
||||
// Not a type that should go on the customizer
|
||||
if ( isset( $section['type'] ) && ( $section['type'] == "divide" ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( isset( $section['id'] ) && $section['id'] == "import/export" ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If section customizer is set to false
|
||||
if ( isset( $section['customizer'] ) && $section['customizer'] === false ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$section['permissions'] = isset( $section['permissions'] ) ? $section['permissions'] : 'edit_theme_options';
|
||||
|
||||
// No errors please
|
||||
if ( ! isset( $section['desc'] ) ) {
|
||||
$section['desc'] = "";
|
||||
}
|
||||
|
||||
// Fill the description if there is a subtitle
|
||||
if ( empty( $section['desc'] ) && ! empty( $section['subtitle'] ) ) {
|
||||
$section['desc'] = $section['subtitle'];
|
||||
}
|
||||
|
||||
// Let's make a section ID from the title
|
||||
if ( empty( $section['id'] ) ) {
|
||||
$section['id'] = strtolower( str_replace( " ", "", $section['title'] ) );
|
||||
}
|
||||
|
||||
// No title is present, let's show what section is missing a title
|
||||
if ( ! isset( $section['title'] ) ) {
|
||||
$section['title'] = "";
|
||||
}
|
||||
|
||||
// Let's set a default priority
|
||||
if ( empty( $section['priority'] ) ) {
|
||||
$section['priority'] = $order['heading'];
|
||||
$order['heading'] ++;
|
||||
}
|
||||
|
||||
//print_r($section);
|
||||
//print_r($this->parent->sections[$key+1]);
|
||||
//echo $key;
|
||||
//exit();
|
||||
|
||||
|
||||
if ( method_exists( $wp_customize, 'add_panel' ) && ( ! isset( $section['subsection'] ) || ( isset( $section['subsection'] ) && $section['subsection'] != true ) ) && isset( $this->parent->sections[ ( $key + 1 ) ]['subsection'] ) && $this->parent->sections[ ( $key + 1 ) ]['subsection'] ) {
|
||||
|
||||
$this->add_panel( $section['id'], array(
|
||||
'priority' => $section['priority'],
|
||||
'capability' => $section['permissions'],
|
||||
//'theme_supports' => '',
|
||||
'title' => $section['title'],
|
||||
'section' => $section,
|
||||
'opt_name' => $this->parent->args['opt_name'],
|
||||
'description' => '',
|
||||
), $wp_customize );
|
||||
$panel = $section['id'];
|
||||
|
||||
$this->add_section( $section['id'], array(
|
||||
'title' => $section['title'],
|
||||
'priority' => $section['priority'],
|
||||
'description' => $section['desc'],
|
||||
'section' => $section,
|
||||
'opt_name' => $this->parent->args['opt_name'],
|
||||
'capability' => $section['permissions'],
|
||||
'panel' => $panel
|
||||
), $wp_customize );
|
||||
|
||||
|
||||
} else {
|
||||
if ( ! isset( $section['subsection'] ) || ( isset( $section['subsection'] ) && $section['subsection'] != true ) ) {
|
||||
$panel = "";
|
||||
}
|
||||
$this->add_section( $section['id'], array(
|
||||
'title' => $section['title'],
|
||||
'priority' => $section['priority'],
|
||||
'description' => $section['desc'],
|
||||
'opt_name' => $this->parent->args['opt_name'],
|
||||
'section' => $section,
|
||||
'capability' => $section['permissions'],
|
||||
'panel' => $panel
|
||||
), $wp_customize );
|
||||
}
|
||||
|
||||
if ( ! isset( $section['fields'] ) || ( isset( $section['fields'] ) && empty( $section['fields'] ) ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ( $section['fields'] as $skey => $option ) {
|
||||
|
||||
if ( isset( $option['customizer'] ) && $option['customizer'] === false ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $this->parent->args['customizer'] === false && ( ! isset( $option['customizer'] ) || $option['customizer'] !== true ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->options[ $option['id'] ] = $option;
|
||||
add_action( 'redux/advanced_customizer/control/render/' . $this->parent->args['opt_name'] . '-' . $option['id'], array(
|
||||
$this,
|
||||
'render'
|
||||
) );
|
||||
|
||||
$option['permissions'] = isset( $option['permissions'] ) ? $option['permissions'] : 'edit_theme_options';
|
||||
|
||||
//
|
||||
//if ( isset( $option['validate_callback'] ) && ! empty( $option['validate_callback'] ) ) {
|
||||
// continue;
|
||||
//}
|
||||
|
||||
|
||||
//Change the item priority if not set
|
||||
if ( $option['type'] != 'heading' && ! isset( $option['priority'] ) ) {
|
||||
$option['priority'] = $order['option'];
|
||||
$order['option'] ++;
|
||||
}
|
||||
|
||||
if ( ! empty( $this->options_defaults[ $option['id'] ] ) ) {
|
||||
$option['default'] = $this->options_defaults['option']['id'];
|
||||
}
|
||||
|
||||
//$option['id'] = $this->parent->args['opt_name'].'['.$option['id'].']';
|
||||
//echo $option['id'];
|
||||
|
||||
if ( ! isset( $option['default'] ) ) {
|
||||
$option['default'] = "";
|
||||
}
|
||||
if ( ! isset( $option['title'] ) ) {
|
||||
$option['title'] = "";
|
||||
}
|
||||
|
||||
|
||||
$option['id'] = $this->parent->args['opt_name'] . '[' . $option['id'] . ']';
|
||||
|
||||
if ( $option['type'] != "heading" && $option['type'] != "import_export" && ! empty( $option['type'] ) ) {
|
||||
|
||||
$wp_customize->add_setting( $option['id'],
|
||||
array(
|
||||
'default' => $option['default'],
|
||||
//'type' => 'option',
|
||||
//'capabilities' => $option['permissions'],
|
||||
//'capabilities' => 'edit_theme_options',
|
||||
//'capabilities' => $this->parent->args['page_permissions'],
|
||||
'transport' => 'refresh',
|
||||
'opt_name' => $this->parent->args['opt_name'],
|
||||
//'theme_supports' => '',
|
||||
//'sanitize_callback' => '__return_false',
|
||||
'sanitize_callback' => array( $this, '_field_validation' ),
|
||||
//'sanitize_js_callback' =>array( &$parent, '_field_input' ),
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
if ( ! empty( $option['data'] ) && empty( $option['options'] ) ) {
|
||||
if ( empty( $option['args'] ) ) {
|
||||
$option['args'] = array();
|
||||
}
|
||||
|
||||
if ( $option['data'] == "elusive-icons" || $option['data'] == "elusive-icon" || $option['data'] == "elusive" ) {
|
||||
$icons_file = ReduxFramework::$_dir . 'inc/fields/select/elusive-icons.php';
|
||||
$icons_file = apply_filters( 'redux-font-icons-file', $icons_file );
|
||||
|
||||
if ( file_exists( $icons_file ) ) {
|
||||
require_once $icons_file;
|
||||
}
|
||||
}
|
||||
$option['options'] = $this->parent->get_wordpress_data( $option['data'], $option['args'] );
|
||||
}
|
||||
|
||||
$class_name = 'Redux_Customizer_Control_' . $option['type'];
|
||||
|
||||
do_action( 'redux/extension/customizer/control_init', $option );
|
||||
|
||||
if ( ! class_exists( $class_name ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$wp_customize->add_control( new $class_name( $wp_customize, $option['id'], array(
|
||||
'label' => $option['title'],
|
||||
'section' => $section['id'],
|
||||
'settings' => $option['id'],
|
||||
'type' => 'redux-' . $option['type'],
|
||||
'field' => $option,
|
||||
'ReduxFramework' => $this->parent,
|
||||
'active_callback' => ( isset( $option['required'] ) && class_exists( 'Redux_Customizer_Active_Callback' ) ) ? array(
|
||||
'Redux_Customizer_Active_Callback',
|
||||
'evaluate'
|
||||
) : '__return_true',
|
||||
'priority' => $option['priority'],
|
||||
) ) );
|
||||
|
||||
$section['fields'][ $skey ]['name'] = $option['id'];
|
||||
if ( ! isset ( $section['fields'][ $skey ]['class'] ) ) { // No errors please
|
||||
$section['fields'][ $skey ]['class'] = "";
|
||||
}
|
||||
|
||||
$this->controls[ $section['fields'][ $skey ]['id'] ] = $section['fields'][ $skey ];
|
||||
|
||||
add_action( 'redux/advanced_customizer/render/' . $option['id'], array(
|
||||
$this,
|
||||
'field_render'
|
||||
), $option['priority'] );
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function add_section( $id, $args = array(), $wp_customize ) {
|
||||
|
||||
if ( is_a( $id, 'WP_Customize_Section' ) ) {
|
||||
$section = $id;
|
||||
} else {
|
||||
|
||||
$section_class = apply_filters( 'redux/customizer/section/class_name', "Redux_Customizer_Section" );
|
||||
$section = new $section_class( $wp_customize, $id, $args );
|
||||
}
|
||||
|
||||
$wp_customize->add_section( $section, $args );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a customize panel.
|
||||
*
|
||||
* @since 4.0.0
|
||||
* @access public
|
||||
*
|
||||
* @param WP_Customize_Panel|string $id Customize Panel object, or Panel ID.
|
||||
* @param array $args Optional. Panel arguments. Default empty array.
|
||||
*/
|
||||
public function add_panel( $id, $args = array(), $wp_customize ) {
|
||||
if ( is_a( $id, 'WP_Customize_Panel' ) ) {
|
||||
$panel = $id;
|
||||
} else {
|
||||
$panel_class = apply_filters( 'redux/customizer/panel/class_name', "Redux_Customizer_Panel" );
|
||||
$panel = new $panel_class( $wp_customize, $id, $args );
|
||||
}
|
||||
|
||||
$wp_customize->add_panel( $panel, $args );
|
||||
}
|
||||
|
||||
public function field_render( $option ) {
|
||||
echo '1';
|
||||
preg_match_all( "/\[([^\]]*)\]/", $option->id, $matches );
|
||||
$id = $matches[1][0];
|
||||
echo $option->link();
|
||||
//$link = $option->link();
|
||||
//echo $link;
|
||||
|
||||
$this->parent->_field_input( $this->controls[ $id ] );
|
||||
echo '2';
|
||||
}
|
||||
|
||||
public function customizer_save_before( $plugin_options ) {
|
||||
$this->before_save = $this->parent->options;
|
||||
//$parent->_field_input( $plugin_options );
|
||||
}
|
||||
|
||||
public function customizer_save_after( $wp_customize ) {
|
||||
|
||||
if ( empty( $this->parent->options ) ) {
|
||||
$this->parent->get_options();
|
||||
}
|
||||
if ( empty( $this->orig_options ) && ! empty( $this->parent->options ) ) {
|
||||
$this->orig_options = $this->parent->options;
|
||||
}
|
||||
|
||||
$options = json_decode( stripslashes_deep( $_POST['customized'] ), true );
|
||||
$compiler = false;
|
||||
$changed = false;
|
||||
|
||||
foreach ( $options as $key => $value ) {
|
||||
if ( strpos( $key, $this->parent->args['opt_name'] ) !== false ) {
|
||||
$key = str_replace( $this->parent->args['opt_name'] . '[', '', rtrim( $key, "]" ) );
|
||||
|
||||
if ( ! isset( $this->orig_options[ $key ] ) || $this->orig_options[ $key ] != $value || ( isset( $this->orig_options[ $key ] ) && ! empty( $this->orig_options[ $key ] ) && empty( $value ) ) ) {
|
||||
$this->parent->options[ $key ] = $value;
|
||||
$changed = true;
|
||||
if ( isset( $this->parent->compiler_fields[ $key ] ) ) {
|
||||
$compiler = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $changed ) {
|
||||
$this->parent->set_options( $this->parent->options );
|
||||
if ( $compiler ) {
|
||||
// Have to set this to stop the output of the CSS and typography stuff.
|
||||
$this->parent->no_output = true;
|
||||
$this->parent->_enqueue_output();
|
||||
do_action( "redux/options/{$this->parent->args['opt_name']}/compiler", $this->parent->options, $this->parent->compilerCSS );
|
||||
do_action( "redux/options/{$this->args['opt_name']}/compiler/advanced", $this->parent );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue CSS/JS for preview pane
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @global $wp_styles
|
||||
* @return void
|
||||
*/
|
||||
public function _enqueue_previewer() {
|
||||
wp_enqueue_script(
|
||||
'redux-extension-previewer-js',
|
||||
$this->_extension_url . 'assets/js/preview.js'
|
||||
);
|
||||
|
||||
$localize = array(
|
||||
'save_pending' => __( 'You have changes that are not saved. Would you like to save them now?', 'redux-framework' ),
|
||||
'reset_confirm' => __( 'Are you sure? Resetting will lose all custom values.', 'redux-framework' ),
|
||||
'preset_confirm' => __( 'Your current options will be replaced with the values of this preset. Would you like to proceed?', 'redux-framework' ),
|
||||
'opt_name' => $this->args['opt_name'],
|
||||
//'folds' => $this->folds,
|
||||
'options' => $this->parent->options,
|
||||
'defaults' => $this->parent->options_defaults,
|
||||
);
|
||||
|
||||
wp_localize_script(
|
||||
'redux-extension-previewer-js',
|
||||
'reduxPost',
|
||||
$localize
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue CSS/JS for the customizer controls
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @global $wp_styles
|
||||
* @return void
|
||||
*/
|
||||
public function _enqueue() {
|
||||
global $wp_styles;
|
||||
|
||||
//wp_enqueue_style( 'wp-pointer' );
|
||||
//wp_enqueue_script( 'wp-pointer' );
|
||||
// Remove when code is in place!
|
||||
//wp_enqueue_script('redux-extension-customizer-js', $this->_extension_url . 'assets/js/customizer.js');
|
||||
// Get styles
|
||||
//wp_enqueue_style('redux-extension-customizer-css', $this->_extension_url . 'assets/css/customizer.css');
|
||||
|
||||
$localize = array(
|
||||
'save_pending' => __( 'You have changes that are not saved. Would you like to save them now?', 'redux-framework' ),
|
||||
'reset_confirm' => __( 'Are you sure? Resetting will lose all custom values.', 'redux-framework' ),
|
||||
'preset_confirm' => __( 'Your current options will be replaced with the values of this preset. Would you like to proceed?', 'redux-framework' ),
|
||||
'opt_name' => $this->args['opt_name'],
|
||||
//'folds' => $this->folds,
|
||||
'field' => $this->parent->options,
|
||||
'defaults' => $this->parent->options_defaults,
|
||||
);
|
||||
|
||||
// Values used by the javascript
|
||||
wp_localize_script(
|
||||
'redux-js',
|
||||
'redux_opts',
|
||||
$localize
|
||||
);
|
||||
|
||||
do_action( 'redux-enqueue-' . $this->args['opt_name'] );
|
||||
|
||||
|
||||
foreach ( $this->sections as $section ) {
|
||||
if ( isset( $section['fields'] ) ) {
|
||||
foreach ( $section['fields'] as $field ) {
|
||||
if ( isset( $field['type'] ) ) {
|
||||
$field_class = 'ReduxFramework_' . $field['type'];
|
||||
|
||||
if ( ! class_exists( $field_class ) ) {
|
||||
$class_file = apply_filters( 'redux-typeclass-load', $this->path . 'inc/fields/' . $field['type'] . '/field_' . $field['type'] . '.php', $field_class );
|
||||
if ( $class_file ) {
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
require_once( $class_file );
|
||||
}
|
||||
}
|
||||
|
||||
if ( class_exists( $field_class ) && method_exists( $field_class, 'enqueue' ) ) {
|
||||
$enqueue = new $field_class( '', '', $this );
|
||||
$enqueue->enqueue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Option for use
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function _register_setting() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the options before insertion
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @access public
|
||||
*
|
||||
* @param array $plugin_options The options array
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public function _field_validation( $value ) {
|
||||
//print_r( $value );
|
||||
//print_r( $_POST );
|
||||
|
||||
return $value;
|
||||
|
||||
//return $this->parent->_validate_options( $plugin_options );
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML OUTPUT.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function _customizer_html_output() {
|
||||
|
||||
}
|
||||
} // class
|
||||
function redux_customizer_custom_validation( $field ) {
|
||||
return $field;
|
||||
}
|
||||
} // if
|
||||
@@ -0,0 +1,119 @@
|
||||
.redux-section {
|
||||
p.customize-section-description {
|
||||
margin-top: 22px;
|
||||
word-break: break-word;
|
||||
&.legacy {
|
||||
margin-top: 7px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.control-section-themes .accordion-section-title {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#customize-controls {
|
||||
.customize-info {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.redux-section .accordion-section-content {
|
||||
background: #FCFCFC;
|
||||
}
|
||||
}
|
||||
|
||||
.redux-section .accordion-section-title i,
|
||||
.redux-field .accordion-field-title i,
|
||||
.redux-panel .accordion-section-title i {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.accordion-section.redux-main {
|
||||
background: inherit;
|
||||
margin-left: inherit;
|
||||
border-left: inherit;
|
||||
-moz-box-shadow: inherit;
|
||||
-webkit-box-shadow: inherit;
|
||||
padding: inherit;
|
||||
box-shadow: inherit;
|
||||
}
|
||||
|
||||
.redux_field_th {
|
||||
padding: 13px 0px 0px 0px;
|
||||
}
|
||||
|
||||
.redux-main {
|
||||
.redux-field-container {
|
||||
padding: 10px 0;
|
||||
}
|
||||
.select_wrapper {
|
||||
float: none;
|
||||
width: 100%;
|
||||
display: inline-block;
|
||||
}
|
||||
.select2-container {
|
||||
margin-right: 0 !important;
|
||||
margin-bottom: 5px !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
.select_wrapper:nth-child(odd) {
|
||||
margin-right: 0;
|
||||
}
|
||||
.redux-option-image {
|
||||
max-width: 42% !important;
|
||||
margin-right: 3%;
|
||||
}
|
||||
.customize-control {
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding-bottom: 4px;
|
||||
}
|
||||
.customize-control:last-child {
|
||||
border-bottom: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
.upload {
|
||||
width: 100% !important;
|
||||
}
|
||||
h3 {
|
||||
margin-top: inherit;
|
||||
}
|
||||
.redux-container-raw {
|
||||
margin-top: 22px;
|
||||
word-break: break-word;
|
||||
padding: 0 !important;
|
||||
}
|
||||
.redux-container-password input {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.select2-drop {
|
||||
z-index: 999999;
|
||||
}
|
||||
|
||||
.rAdsContainer {
|
||||
line-height: 0;
|
||||
border: 0;
|
||||
/*margin-top: -15px;*/
|
||||
/*margin-bottom: -15px;*/
|
||||
}
|
||||
|
||||
.customize-control-redux-raw {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.rAds {
|
||||
position: inherit !important;
|
||||
right: 0 !important;
|
||||
top: 0 !important;
|
||||
bottom: 0 !important;
|
||||
left: 0 !important;
|
||||
text-align: center;
|
||||
margin-bottom: 0;
|
||||
line-height: 0;
|
||||
-webkit-transition: left ease-in-out .18s;
|
||||
transition: left ease-in-out .18s;
|
||||
img {
|
||||
-webkit-transition: left ease-in-out .18s;
|
||||
transition: left ease-in-out .18s;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
if ( ! class_exists( 'Redux_Customizer_Control' ) ) {
|
||||
class Redux_Customizer_Control extends WP_Customize_Control {
|
||||
|
||||
public function render() {
|
||||
$this->redux_id = str_replace( 'customize-control-', '', 'customize-control-' . str_replace( '[', '-', str_replace( ']', '', $this->id ) ) );
|
||||
$class = 'customize-control redux-group-tab redux-field customize-control-' . $this->type;
|
||||
$opt_name = explode( '[', $this->id );
|
||||
$opt_name = $opt_name[0];
|
||||
?>
|
||||
<li id="<?php echo esc_attr( $this->redux_id ); ?>" class="<?php echo esc_attr( $class ); ?>">
|
||||
<?php if ( $this->type != "repeater" ): ?>
|
||||
<input type="hidden"
|
||||
data-id="<?php echo esc_attr( $this->id ); ?>"
|
||||
data-key="<?php echo str_replace( $opt_name . '-', '', $this->redux_id ); ?>"
|
||||
class="redux-customizer-input"
|
||||
id="customizer_control_id_<?php echo esc_attr( $this->redux_id ); ?>" <?php echo esc_url( $this->link() ) ?>
|
||||
value=""/>
|
||||
<?php endif; ?>
|
||||
<?php $this->render_content(); ?>
|
||||
</li>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
public function render_content() {
|
||||
do_action( 'redux/advanced_customizer/control/render/' . $this->redux_id, $this );
|
||||
}
|
||||
|
||||
public function label() {
|
||||
// The label has already been sanitized in the Fields class, no need to re-sanitize it.
|
||||
echo $this->label;
|
||||
}
|
||||
|
||||
public function description() {
|
||||
if ( ! empty( $this->description ) ) {
|
||||
// The description has already been sanitized in the Fields class, no need to re-sanitize it.
|
||||
echo '<span class="description customize-control-description">' . $this->description . '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
public function title() {
|
||||
echo '<span class="customize-control-title">';
|
||||
$this->label();
|
||||
$this->description();
|
||||
echo '</span>';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
if ( ! class_exists( 'Redux_Customizer_Control_rAds' ) && ! class_exists( 'Redux_Customizer_section_rAds' ) ) {
|
||||
/**
|
||||
* Customizer section representing widget area (sidebar).
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Customize
|
||||
* @since 4.1.0
|
||||
* @see WP_Customize_Section
|
||||
*/
|
||||
class Redux_Customizer_section_rAds extends WP_Customize_Section {
|
||||
|
||||
/**
|
||||
* Type of this section.
|
||||
*
|
||||
* @since 4.1.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'redux-rAds';
|
||||
|
||||
protected function render() {
|
||||
?>
|
||||
<li id="accordion-section-<?php echo esc_attr( $this->id ); ?>" class="accordion-section rAdsContainer"></li>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
class Redux_Customizer_Control_rAds extends WP_Customize_Control {
|
||||
public function render() {
|
||||
}
|
||||
|
||||
public function label() {
|
||||
}
|
||||
|
||||
public function description() {
|
||||
}
|
||||
|
||||
public function title() {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
class Redux_Customizer_Control_checkbox extends Redux_Customizer_Control {
|
||||
public $type = "redux-checkbox";
|
||||
}
|
||||
class Redux_Customizer_Control_color_rgba extends Redux_Customizer_Control {
|
||||
public $type = "redux-color_rgba";
|
||||
}
|
||||
class Redux_Customizer_Control_color extends Redux_Customizer_Control {
|
||||
public $type = "redux-color";
|
||||
}
|
||||
//class Redux_Customizer_Control_raw extends Redux_Customizer_Control {
|
||||
// public $type = "redux-raw";
|
||||
//}
|
||||
class Redux_Customizer_Control_media extends Redux_Customizer_Control {
|
||||
public $type = "redux-media";
|
||||
}
|
||||
class Redux_Customizer_Control_spinner extends Redux_Customizer_Control {
|
||||
public $type = "redux-spinner";
|
||||
}
|
||||
class Redux_Customizer_Control_palette extends Redux_Customizer_Control {
|
||||
public $type = "redux-palette";
|
||||
}
|
||||
class Redux_Customizer_Control_button_set extends Redux_Customizer_Control {
|
||||
public $type = "redux-button_set";
|
||||
}
|
||||
class Redux_Customizer_Control_image_select extends Redux_Customizer_Control {
|
||||
public $type = "redux-image_select";
|
||||
}
|
||||
class Redux_Customizer_Control_radio extends Redux_Customizer_Control {
|
||||
public $type = "redux-radio";
|
||||
}
|
||||
class Redux_Customizer_Control_select extends Redux_Customizer_Control {
|
||||
public $type = "redux-select";
|
||||
}
|
||||
class Redux_Customizer_Control_gallery extends Redux_Customizer_Control {
|
||||
public $type = "redux-gallery";
|
||||
}
|
||||
class Redux_Customizer_Control_slider extends Redux_Customizer_Control {
|
||||
public $type = "redux-slider";
|
||||
}
|
||||
class Redux_Customizer_Control_sortable extends Redux_Customizer_Control {
|
||||
public $type = "redux-sortable";
|
||||
}
|
||||
class Redux_Customizer_Control_switch extends Redux_Customizer_Control {
|
||||
public $type = "redux-switch";
|
||||
}
|
||||
class Redux_Customizer_Control_text extends Redux_Customizer_Control {
|
||||
public $type = "redux-text";
|
||||
}
|
||||
class Redux_Customizer_Control_textarea extends Redux_Customizer_Control {
|
||||
public $type = "redux-textarea";
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Customizer section representing widget area (sidebar).
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Customize
|
||||
* @since 4.1.0
|
||||
* @see WP_Customize_Section
|
||||
*/
|
||||
class Redux_Customizer_Panel extends WP_Customize_Panel {
|
||||
|
||||
/**
|
||||
* Type of this panel.
|
||||
*
|
||||
* @since 4.1.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'redux';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Any supplied $args override class property defaults.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param WP_Customize_Manager $manager Customizer bootstrap instance.
|
||||
* @param string $id An specific ID for the panel.
|
||||
* @param array $args Panel arguments.
|
||||
*/
|
||||
public function __construct( $manager, $id, $args = array() ) {
|
||||
$keys = array_keys( get_object_vars( $this ) );
|
||||
foreach ( $keys as $key ) {
|
||||
if ( isset( $args[ $key ] ) ) {
|
||||
$this->$key = $args[ $key ];
|
||||
}
|
||||
}
|
||||
$this->manager = $manager;
|
||||
$this->id = $id;
|
||||
if ( empty( $this->active_callback ) ) {
|
||||
$this->active_callback = array( $this, 'active_callback' );
|
||||
}
|
||||
self::$instance_count += 1;
|
||||
$this->instance_number = self::$instance_count;
|
||||
|
||||
$this->sections = array(); // Users cannot customize the $sections array.
|
||||
|
||||
// TODO Redux addition
|
||||
if ( isset( $args['section'] ) ) {
|
||||
$this->section = $args['section'];
|
||||
$this->description = isset( $this->section['desc'] ) ? $this->section['desc'] : '';
|
||||
$this->opt_name = isset( $args['opt_name'] ) ? $args['opt_name'] : '';
|
||||
}
|
||||
// TODO END Redux Addition
|
||||
}
|
||||
|
||||
/**
|
||||
* WP < 4.3 Render
|
||||
*
|
||||
* @since
|
||||
* @access protected
|
||||
*/
|
||||
protected function render() {
|
||||
global $wp_version;
|
||||
$version = explode( '-', $wp_version );
|
||||
if ( version_compare( $version[0], '4.3', '<' ) ) {
|
||||
$this->render_fallback();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function render_fallback() {
|
||||
$classes = 'accordion-section redux-main redux-panel control-section control-panel control-panel-' . esc_attr($this->type);
|
||||
?>
|
||||
<li id="accordion-panel-<?php echo esc_attr( $this->id ); ?>" class="<?php echo esc_attr( $classes ); ?>">
|
||||
<h3 class="accordion-section-title" tabindex="0">
|
||||
<?php
|
||||
echo wp_kses( $this->title, array(
|
||||
'em' => array(),
|
||||
'i' => array(),
|
||||
'strong' => array(),
|
||||
'span' => array(
|
||||
'class' => array(),
|
||||
'style' => array(),
|
||||
),
|
||||
) );
|
||||
?>
|
||||
<span class="screen-reader-text"><?php esc_html_e( 'Press return or enter to open this panel', 'redux-framework' ); ?></span>
|
||||
</h3>
|
||||
<ul class="accordion-sub-container control-panel-content">
|
||||
<table class="form-table">
|
||||
<tbody><?php $this->render_content(); ?></tbody>
|
||||
</table>
|
||||
</ul>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the sections that have been added to the panel.
|
||||
*
|
||||
* @since 4.1.0
|
||||
* @access protected
|
||||
*/
|
||||
protected function render_content() {
|
||||
?>
|
||||
<li class="panel-meta accordion-section redux-panel redux-panel-meta control-section<?php if ( empty( $this->description ) ) {
|
||||
echo ' cannot-expand';
|
||||
} ?>">
|
||||
<div class="accordion-section-title" tabindex="0">
|
||||
<span class="preview-notice"><?php
|
||||
/* translators: %s is the site/panel title in the Customizer */
|
||||
echo sprintf( __( 'You are customizing %s', 'redux-framework' ), '<strong class="panel-title">' . esc_html( $this->title ) . '</strong>' );
|
||||
?></span>
|
||||
</div>
|
||||
<?php if ( ! empty( $this->description ) ) : ?>
|
||||
<div class="accordion-section-content description legacy">
|
||||
<?php echo $this->description; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* An Underscore (JS) template for this panel's content (but not its container).
|
||||
* Class variables for this panel class are available in the `data` JS object;
|
||||
* export custom variables by overriding {@see WP_Customize_Panel::json()}.
|
||||
*
|
||||
* @see WP_Customize_Panel::print_template()
|
||||
* @since 4.3.0
|
||||
*/
|
||||
protected function content_template() {
|
||||
?>
|
||||
<li class="panel-meta customize-info redux-panel accordion-section <# if ( ! data.description ) { #> cannot-expand<# } #>">
|
||||
<button class="customize-panel-back" tabindex="-1">
|
||||
<span class="screen-reader-text"><?php esc_attr_e( 'Back', 'redux-framework' ); ?></span></button>
|
||||
<div class="accordion-section-title">
|
||||
<span class="preview-notice"><?php
|
||||
/* translators: %s is the site/panel title in the Customizer */
|
||||
echo sprintf( __( 'You are customizing %s', 'redux-framework' ), '<strong class="panel-title">{{ data.title }}</strong>' );
|
||||
?></span>
|
||||
<# if ( data.description ) { #>
|
||||
<button class="customize-help-toggle dashicons dashicons-editor-help" tabindex="0" aria-expanded="false">
|
||||
<span class="screen-reader-text"><?php esc_attr_e( 'Help', 'redux-framework' ); ?></span></button>
|
||||
<# } #>
|
||||
</div>
|
||||
<# if ( data.description ) { #>
|
||||
<div class="description customize-panel-description">
|
||||
{{{ data.description }}}
|
||||
</div>
|
||||
<# } #>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Customizer section representing widget area (sidebar).
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Customize
|
||||
* @since 4.1.0
|
||||
* @see WP_Customize_Section
|
||||
*/
|
||||
class Redux_Customizer_Section extends WP_Customize_Section {
|
||||
|
||||
/**
|
||||
* Type of this section.
|
||||
*
|
||||
* @since 4.1.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'redux';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Any supplied $args override class property defaults.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param WP_Customize_Manager $manager Customizer bootstrap instance.
|
||||
* @param string $id An specific ID of the section.
|
||||
* @param array $args Section arguments.
|
||||
*/
|
||||
public function __construct( $manager, $id, $args = array() ) {
|
||||
$keys = array_keys( get_object_vars( $this ) );
|
||||
foreach ( $keys as $key ) {
|
||||
if ( isset( $args[ $key ] ) ) {
|
||||
$this->$key = $args[ $key ];
|
||||
}
|
||||
}
|
||||
|
||||
$this->manager = $manager;
|
||||
$this->id = $id;
|
||||
if ( empty( $this->active_callback ) ) {
|
||||
$this->active_callback = array( $this, 'active_callback' );
|
||||
}
|
||||
self::$instance_count += 1;
|
||||
$this->instance_number = self::$instance_count;
|
||||
|
||||
$this->controls = array(); // Users cannot customize the $controls array.
|
||||
|
||||
// TODO Redux addition
|
||||
if ( isset( $args['section'] ) ) {
|
||||
$this->section = $args['section'];
|
||||
$this->description = isset( $this->section['desc'] ) ? $this->section['desc'] : '';
|
||||
$this->opt_name = isset( $args['opt_name'] ) ? $args['opt_name'] : '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An Underscore (JS) template for rendering this section.
|
||||
* Class variables for this section class are available in the `data` JS object;
|
||||
* export custom variables by overriding {@see WP_Customize_Section::json()}.
|
||||
*
|
||||
* @see WP_Customize_Section::print_template()
|
||||
* @since 4.3.0
|
||||
*/
|
||||
protected function render_template() {
|
||||
?>
|
||||
<li id="accordion-section-{{ data.id }}" class="redux-section accordion-section control-section control-section-{{ data.type }}">
|
||||
<h3 class="accordion-section-title" tabindex="0">
|
||||
{{ data.title }}
|
||||
<span class="screen-reader-text"><?php _e( 'Press return or enter to open', 'redux-framework' ); ?></span>
|
||||
</h3>
|
||||
<ul class="accordion-section-content redux-main">
|
||||
|
||||
<li class="customize-section-description-container">
|
||||
<div class="customize-section-title">
|
||||
<button class="customize-section-back" tabindex="-1">
|
||||
<span class="screen-reader-text"><?php _e( 'Back', 'redux-framework' ); ?></span>
|
||||
</button>
|
||||
<h3>
|
||||
<span class="customize-action">
|
||||
{{{ data.customizeAction }}}
|
||||
</span> {{ data.title }}
|
||||
</h3>
|
||||
</div>
|
||||
<# if ( data.description ) { #>
|
||||
<p class="description customize-section-description">{{{ data.description }}}</p>
|
||||
<# } #>
|
||||
<?php
|
||||
if ( isset( $this->opt_name ) && isset( $this->section ) ) {
|
||||
do_action( "redux/page/{$this->opt_name}/section/before", $this->section );
|
||||
}
|
||||
?>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the section, and the controls that have been added to it.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*/
|
||||
protected function render_fallback() {
|
||||
$classes = 'accordion-section redux-section control-section control-section-' . $this->type;
|
||||
?>
|
||||
<li id="accordion-section-<?php echo esc_attr( $this->id ); ?>" class="<?php echo esc_attr( $classes ); ?>">
|
||||
<h3 class="accordion-section-title" tabindex="0">
|
||||
<?php
|
||||
echo wp_kses( $this->title, array(
|
||||
'em' => array(),
|
||||
'i' => array(),
|
||||
'strong' => array(),
|
||||
'span' => array(
|
||||
'class' => array(),
|
||||
'style' => array(),
|
||||
),
|
||||
) );
|
||||
?>
|
||||
<span class="screen-reader-text"><?php esc_attr_e( 'Press return or enter to expand', 'redux-framework' ); ?></span>
|
||||
</h3>
|
||||
<ul class="accordion-section-content redux-main">
|
||||
<?php
|
||||
if ( isset( $this->opt_name ) && isset( $this->section ) ) {
|
||||
do_action( "redux/page/{$this->opt_name}/section/before", $this->section );
|
||||
}
|
||||
?>
|
||||
<?php if ( ! empty( $this->description ) ) : ?>
|
||||
<li class="customize-section-description-container">
|
||||
<p class="description customize-section-description legacy"><?php echo $this->description; ?></p>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
protected function render() {
|
||||
global $wp_version;
|
||||
$version = explode( '-', $wp_version );
|
||||
if ( version_compare( $version[0], '4.3', '<' ) ) {
|
||||
$this->render_fallback();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Redux Framework is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* any later version.
|
||||
* Redux Framework is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package ReduxFramework
|
||||
* @author Dovy Paukstys (dovy)
|
||||
* @version 4.0.0
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Don't duplicate me!
|
||||
if ( ! class_exists( 'ReduxFramework_extension_import_export' ) ) {
|
||||
|
||||
|
||||
/**
|
||||
* Main ReduxFramework import_export extension class
|
||||
*
|
||||
* @since 3.1.6
|
||||
*/
|
||||
class ReduxFramework_extension_import_export {
|
||||
|
||||
// Protected vars
|
||||
protected $parent;
|
||||
public $extension_url;
|
||||
public $extension_dir;
|
||||
public static $theInstance;
|
||||
public static $version = "4.0";
|
||||
public $is_field = false;
|
||||
|
||||
/**
|
||||
* Class Constructor. Defines the args for the extions class
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*
|
||||
* @param array $sections Panel sections.
|
||||
* @param array $args Class constructor arguments.
|
||||
* @param array $extra_tabs Extra panel tabs.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $parent ) {
|
||||
|
||||
$this->parent = $parent;
|
||||
if ( empty( $this->extension_dir ) ) {
|
||||
//$this->extension_dir = trailingslashit( str_replace( '\\', '/', dirname( __FILE__ ) ) );
|
||||
}
|
||||
$this->field_name = 'import_export';
|
||||
|
||||
self::$theInstance = $this;
|
||||
|
||||
add_action( "wp_ajax_redux_link_options-" . $this->parent->args['opt_name'], array(
|
||||
$this,
|
||||
"link_options"
|
||||
) );
|
||||
add_action( "wp_ajax_nopriv_redux_link_options-" . $this->parent->args['opt_name'], array(
|
||||
$this,
|
||||
"link_options"
|
||||
) );
|
||||
|
||||
add_action( "wp_ajax_redux_download_options-" . $this->parent->args['opt_name'], array(
|
||||
$this,
|
||||
"download_options"
|
||||
) );
|
||||
add_action( "wp_ajax_nopriv_redux_download_options-" . $this->parent->args['opt_name'], array(
|
||||
$this,
|
||||
"download_options"
|
||||
) );
|
||||
|
||||
do_action( "redux/options/{$this->parent->args['opt_name']}/import", array( $this, 'remove_cookie' ) );
|
||||
|
||||
$this->is_field = Redux_Helpers::isFieldInUse( $parent, 'import_export' );
|
||||
|
||||
if ( ! $this->is_field && $this->parent->args['show_import_export'] ) {
|
||||
$this->add_section();
|
||||
}
|
||||
|
||||
add_filter( 'redux/' . $this->parent->args['opt_name'] . '/field/class/' . $this->field_name, array(
|
||||
&$this,
|
||||
'overload_field_path'
|
||||
) ); // Adds the local field
|
||||
|
||||
add_filter( 'upload_mimes', array(
|
||||
$this,
|
||||
'custom_upload_mimes'
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the appropriate mime types to WordPress
|
||||
*
|
||||
* @param array $existing_mimes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function custom_upload_mimes( $existing_mimes = array() ) {
|
||||
$existing_mimes['redux'] = 'application/redux';
|
||||
|
||||
return $existing_mimes;
|
||||
}
|
||||
|
||||
public function add_section() {
|
||||
$this->parent->sections[] = array(
|
||||
'id' => 'import/export',
|
||||
'title' => __( 'Import / Export', 'redux-framework' ),
|
||||
'heading' => '',
|
||||
'icon' => 'el el-refresh',
|
||||
'customizer' => false,
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => 'redux_import_export',
|
||||
'type' => 'import_export',
|
||||
//'class' => 'redux-field-init redux_remove_th',
|
||||
//'title' => '',
|
||||
'full_width' => true,
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function link_options() {
|
||||
if ( ! isset( $_GET['secret'] ) || $_GET['secret'] != md5( md5( AUTH_KEY . SECURE_AUTH_KEY ) . '-' . $this->parent->args['opt_name'] ) ) {
|
||||
wp_die( 'Invalid Secret for options use' );
|
||||
exit;
|
||||
}
|
||||
|
||||
$var = $this->parent->options;
|
||||
$var['redux-backup'] = '1';
|
||||
if ( isset( $var['REDUX_imported'] ) ) {
|
||||
unset( $var['REDUX_imported'] );
|
||||
}
|
||||
|
||||
echo json_encode( $var );
|
||||
|
||||
die();
|
||||
}
|
||||
|
||||
public function download_options() {
|
||||
if ( ! isset( $_GET['secret'] ) || $_GET['secret'] != md5( md5( AUTH_KEY . SECURE_AUTH_KEY ) . '-' . $this->parent->args['opt_name'] ) ) {
|
||||
wp_die( 'Invalid Secret for options use' );
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->parent->get_options();
|
||||
$backup_options = $this->parent->options;
|
||||
$backup_options['redux-backup'] = '1';
|
||||
if ( isset( $backup_options['REDUX_imported'] ) ) {
|
||||
unset( $backup_options['REDUX_imported'] );
|
||||
}
|
||||
|
||||
// No need to escape this, as it's been properly escaped previously and through json_encode
|
||||
$content = json_encode( $backup_options );
|
||||
|
||||
if ( isset( $_GET['action'] ) && $_GET['action'] == 'redux_download_options-' . $this->parent->args['opt_name'] ) {
|
||||
header( 'Content-Description: File Transfer' );
|
||||
header( 'Content-type: application/txt' );
|
||||
header( 'Content-Disposition: attachment; filename="redux_options_' . $this->parent->args['opt_name'] . '_backup_' . date( 'd-m-Y' ) . '.json"' );
|
||||
header( 'Content-Transfer-Encoding: binary' );
|
||||
header( 'Expires: 0' );
|
||||
header( 'Cache-Control: must-revalidate' );
|
||||
header( 'Pragma: public' );
|
||||
|
||||
echo $content;
|
||||
exit;
|
||||
} else {
|
||||
header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
|
||||
header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" );
|
||||
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
|
||||
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
|
||||
header( 'Cache-Control: post-check=0, pre-check=0', false );
|
||||
header( 'Pragma: no-cache' );
|
||||
|
||||
// Can't include the type. Thanks old Firefox and IE. BAH.
|
||||
//header("Content-type: application/json");
|
||||
echo $content;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Forces the use of the embeded field path vs what the core typically would use
|
||||
public function overload_field_path( $field ) {
|
||||
return dirname( __FILE__ ) . '/' . $this->field_name . '/field_' . $this->field_name . '.php';
|
||||
}
|
||||
|
||||
public function remove_cookie() {
|
||||
// Remove the import/export tab cookie.
|
||||
if ( $_COOKIE['redux_current_tab'] == 'import_export_default' ) {
|
||||
setcookie( 'redux_current_tab', '', 1, '/' );
|
||||
$_COOKIE['redux_current_tab'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
#redux-import-link-wrapper,#redux-import-code-wrapper{display:none}#redux-export-code,#redux-export-link-value{display:none}#redux-import-action span{color:#B94A48}
|
||||
@@ -0,0 +1,198 @@
|
||||
/*global jQuery, document, redux*/
|
||||
|
||||
(function( $ ) {
|
||||
"use strict";
|
||||
|
||||
redux.field_objects = redux.field_objects || {};
|
||||
redux.field_objects.import_export = redux.field_objects.import_export || {};
|
||||
|
||||
redux.field_objects.import_export.init = function( selector ) {
|
||||
if ( !selector ) {
|
||||
selector = $( document ).find( ".redux-group-tab:visible" ).find( '.redux-container-import_export:visible' );
|
||||
}
|
||||
|
||||
$( selector ).each(
|
||||
function() {
|
||||
var el = $( this );
|
||||
var parent = el;
|
||||
if ( !el.hasClass( 'redux-field-container' ) ) {
|
||||
parent = el.parents( '.redux-field-container:first' );
|
||||
}
|
||||
if ( parent.is( ":hidden" ) ) { // Skip hidden fields
|
||||
return;
|
||||
}
|
||||
if ( parent.hasClass( 'redux-field-init' ) ) {
|
||||
parent.removeClass( 'redux-field-init' );
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
el.each(
|
||||
function() {
|
||||
$( '#redux-import' ).click(
|
||||
function( e ) {
|
||||
if ( $( '#import-code-value' ).val() === "" && $( '#import-link-value' ).val() === "" ) {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
$( this ).find( '#redux-import-code-button' ).click(
|
||||
function() {
|
||||
var $el = $( '#redux-import-code-wrapper' );
|
||||
if ( $( '#redux-import-link-wrapper' ).is( ':visible' ) ) {
|
||||
$( '#import-link-value' ).text( '' );
|
||||
$( '#redux-import-link-wrapper' ).slideUp(
|
||||
'fast', function() {
|
||||
$el.slideDown(
|
||||
'fast', function() {
|
||||
$( '#import-code-value' ).focus();
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
if ( $el.is( ':visible' ) ) {
|
||||
$el.slideUp();
|
||||
} else {
|
||||
$el.slideDown(
|
||||
'medium', function() {
|
||||
$( '#import-code-value' ).focus();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
$( this ).find( '#redux-import-link-button' ).click(
|
||||
function() {
|
||||
var $el = $( '#redux-import-link-wrapper' );
|
||||
if ( $( '#redux-import-code-wrapper' ).is( ':visible' ) ) {
|
||||
$( '#import-code-value' ).text( '' );
|
||||
$( '#redux-import-code-wrapper' ).slideUp(
|
||||
'fast', function() {
|
||||
$el.slideDown(
|
||||
'fast', function() {
|
||||
$( '#import-link-value' ).focus();
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
if ( $el.is( ':visible' ) ) {
|
||||
$el.slideUp();
|
||||
} else {
|
||||
$el.slideDown(
|
||||
'medium', function() {
|
||||
$( '#import-link-value' ).focus();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
$( this ).find( '#redux-export-code-copy' ).click(
|
||||
function() {
|
||||
var $el = $( '#redux-export-code' );
|
||||
if ( $( '#redux-export-link-value' ).is( ':visible' ) ) {
|
||||
$( '#redux-export-link-value' ).slideUp(
|
||||
'fast', function() {
|
||||
$el.slideDown(
|
||||
'medium', function() {
|
||||
var options = redux.options;
|
||||
options['redux-backup'] = 1;
|
||||
$( this ).text( JSON.stringify( options ) ).focus().select();
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
if ( $el.is( ':visible' ) ) {
|
||||
$el.slideUp().text( '' );
|
||||
} else {
|
||||
$el.slideDown(
|
||||
'medium', function() {
|
||||
var options = redux.options;
|
||||
options['redux-backup'] = 1;
|
||||
$( this ).text( JSON.stringify( options ) ).focus().select();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
$( this ).find( 'textarea' ).focusout(
|
||||
function() {
|
||||
var $id = $( this ).attr( 'id' );
|
||||
var $el = $( this );
|
||||
var $container = $el;
|
||||
if ( $id == "import-link-value" || $id == "import-code-value" ) {
|
||||
$container = $( this ).parent();
|
||||
}
|
||||
$container.slideUp(
|
||||
'medium', function() {
|
||||
if ( $id != "redux-export-link-value" ) {
|
||||
$el.text( '' );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
$( this ).find( '#redux-export-link' ).click(
|
||||
function() {
|
||||
var $el = $( '#redux-export-link-value' );
|
||||
if ( $( '#redux-export-code' ).is( ':visible' ) ) {
|
||||
$( '#redux-export-code' ).slideUp(
|
||||
'fast', function() {
|
||||
$el.slideDown().focus().select();
|
||||
}
|
||||
);
|
||||
} else {
|
||||
if ( $el.is( ':visible' ) ) {
|
||||
$el.slideUp();
|
||||
} else {
|
||||
$el.slideDown(
|
||||
'medium', function() {
|
||||
$( this ).focus().select();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
var textBox1 = document.getElementById( "redux-export-code" );
|
||||
textBox1.onfocus = function() {
|
||||
textBox1.select();
|
||||
// Work around Chrome's little problem
|
||||
textBox1.onmouseup = function() {
|
||||
// Prevent further mouseup intervention
|
||||
textBox1.onmouseup = null;
|
||||
return false;
|
||||
};
|
||||
};
|
||||
var textBox2 = document.getElementById( "import-code-value" );
|
||||
textBox2.onfocus = function() {
|
||||
textBox2.select();
|
||||
// Work around Chrome's little problem
|
||||
textBox2.onmouseup = function() {
|
||||
// Prevent further mouseup intervention
|
||||
textBox2.onmouseup = null;
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
})( jQuery );
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
!function(o){"use strict";redux.field_objects=redux.field_objects||{},redux.field_objects.import_export=redux.field_objects.import_export||{},redux.field_objects.import_export.init=function(e){e||(e=o(document).find(".redux-group-tab:visible").find(".redux-container-import_export:visible")),o(e).each(function(){var e=o(this),i=e;e.hasClass("redux-field-container")||(i=e.parents(".redux-field-container:first")),i.is(":hidden")||i.hasClass("redux-field-init")&&(i.removeClass("redux-field-init"),e.each(function(){o("#redux-import").click(function(e){if(""===o("#import-code-value").val()&&""===o("#import-link-value").val())return e.preventDefault(),!1}),o(this).find("#redux-import-code-button").click(function(){var e=o("#redux-import-code-wrapper");o("#redux-import-link-wrapper").is(":visible")?(o("#import-link-value").text(""),o("#redux-import-link-wrapper").slideUp("fast",function(){e.slideDown("fast",function(){o("#import-code-value").focus()})})):e.is(":visible")?e.slideUp():e.slideDown("medium",function(){o("#import-code-value").focus()})}),o(this).find("#redux-import-link-button").click(function(){var e=o("#redux-import-link-wrapper");o("#redux-import-code-wrapper").is(":visible")?(o("#import-code-value").text(""),o("#redux-import-code-wrapper").slideUp("fast",function(){e.slideDown("fast",function(){o("#import-link-value").focus()})})):e.is(":visible")?e.slideUp():e.slideDown("medium",function(){o("#import-link-value").focus()})}),o(this).find("#redux-export-code-copy").click(function(){var e=o("#redux-export-code");o("#redux-export-link-value").is(":visible")?o("#redux-export-link-value").slideUp("fast",function(){e.slideDown("medium",function(){var e=redux.options;e["redux-backup"]=1,o(this).text(JSON.stringify(e)).focus().select()})}):e.is(":visible")?e.slideUp().text(""):e.slideDown("medium",function(){var e=redux.options;e["redux-backup"]=1,o(this).text(JSON.stringify(e)).focus().select()})}),o(this).find("textarea").focusout(function(){var e=o(this).attr("id"),i=o(this),t=i;"import-link-value"!=e&&"import-code-value"!=e||(t=o(this).parent()),t.slideUp("medium",function(){"redux-export-link-value"!=e&&i.text("")})}),o(this).find("#redux-export-link").click(function(){var e=o("#redux-export-link-value");o("#redux-export-code").is(":visible")?o("#redux-export-code").slideUp("fast",function(){e.slideDown().focus().select()}):e.is(":visible")?e.slideUp():e.slideDown("medium",function(){o(this).focus().select()})});var e=document.getElementById("redux-export-code");e.onfocus=function(){e.select(),e.onmouseup=function(){return e.onmouseup=null,!1}};var i=document.getElementById("import-code-value");i.onfocus=function(){i.select(),i.onmouseup=function(){return i.onmouseup=null,!1}}}))})}}(jQuery);
|
||||
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
/**
|
||||
* Redux Framework is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* any later version.
|
||||
* Redux Framework is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package ReduxFramework
|
||||
* @author Dovy Paukstys
|
||||
* @version 3.1.5
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Don't duplicate me!
|
||||
if ( ! class_exists( 'ReduxFramework_import_export' ) ) {
|
||||
|
||||
/**
|
||||
* Main ReduxFramework_import_export class
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ReduxFramework_import_export extends ReduxFramework {
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function __construct( $field = array(), $value = '', $parent ) {
|
||||
|
||||
$this->parent = $parent;
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
$this->is_field = $this->parent->extensions['import_export']->is_field;
|
||||
|
||||
$this->extension_dir = ReduxFramework::$_dir . 'inc/extensions/import_export/';
|
||||
$this->extension_url = ReduxFramework::$_url . 'inc/extensions/import_export/';
|
||||
|
||||
// Set default args for this field to avoid bad indexes. Change this to anything you use.
|
||||
$defaults = array(
|
||||
'options' => array(),
|
||||
'stylesheet' => '',
|
||||
'output' => true,
|
||||
'enqueue' => true,
|
||||
'enqueue_frontend' => true
|
||||
);
|
||||
$this->field = wp_parse_args( $this->field, $defaults );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function render() {
|
||||
|
||||
$secret = md5( md5( AUTH_KEY . SECURE_AUTH_KEY ) . '-' . $this->parent->args['opt_name'] );
|
||||
|
||||
// No errors please
|
||||
$defaults = array(
|
||||
'full_width' => true,
|
||||
'overflow' => 'inherit',
|
||||
);
|
||||
|
||||
$this->field = wp_parse_args( $this->field, $defaults );
|
||||
|
||||
$bDoClose = false;
|
||||
|
||||
// $this->parent->args['opt_name'] & $this->field['id'] are sanitized in the ReduxFramework class, no need to re-sanitize it.
|
||||
$id = $this->parent->args['opt_name'] . '-' . $this->field['id'];
|
||||
|
||||
// $this->field['type'] && $this->field['id'] is sanitized in the ReduxFramework class, no need to re-sanitize it.
|
||||
?>
|
||||
<h4><?php esc_html_e( 'Import Options', 'redux-framework' ); ?></h4>
|
||||
|
||||
<p>
|
||||
<a href="javascript:void(0);" id="redux-import-code-button" class="button-secondary">
|
||||
<?php esc_html_e( 'Import from File', 'redux-framework' ); ?>
|
||||
</a>
|
||||
<a href="javascript:void(0);" id="redux-import-link-button" class="button-secondary">
|
||||
<?php esc_html_e( 'Import from URL', 'redux-framework' ) ?>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<div id="redux-import-code-wrapper">
|
||||
<p class="description" id="import-code-description">
|
||||
<?php echo esc_html( apply_filters( 'redux-import-file-description', __( 'Input your backup file below and hit Import to restore your sites options from a backup.', 'redux-framework' ) ) ); ?>
|
||||
</p>
|
||||
<?php // $this->parent->args['opt_name'] is sanitized in the ReduxFramework class, no need to re-sanitize it. ?>
|
||||
<textarea id="import-code-value" name="<?php echo $this->parent->args['opt_name']; ?>[import_code]" class="large-text noUpdate" rows="2"></textarea>
|
||||
</div>
|
||||
|
||||
<div id="redux-import-link-wrapper">
|
||||
<p class="description" id="import-link-description"><?php echo esc_html( apply_filters( 'redux-import-link-description', __( 'Input the URL to another sites options set and hit Import to load the options from that site.', 'redux-framework' ) ) ); ?></p>
|
||||
<?php // $this->parent->args['opt_name'] is sanitized in the ReduxFramework class, no need to re-sanitize it. ?>
|
||||
<textarea class="large-text noUpdate" id="import-link-value" name="<?php echo $this->parent->args['opt_name'] ?>[import_link]" rows="2"></textarea>
|
||||
</div>
|
||||
|
||||
<p id="redux-import-action"><input type="submit" id="redux-import" name="import" class="button-primary" value="<?php esc_html_e( 'Import', 'redux-framework' ) ?>"> <span><?php echo esc_html( apply_filters( 'redux-import-warning', __( 'WARNING! This will overwrite all existing option values, please proceed with caution!', 'redux-framework' ) ) ) ?></span></p>
|
||||
|
||||
<div class="hr"/>
|
||||
<div class="inner"><span> </span></div></div>
|
||||
<h4><?php esc_html_e( 'Export Options', 'redux-framework' ) ?></h4>
|
||||
|
||||
<div class="redux-section-desc">
|
||||
<p class="description">
|
||||
<?php echo esc_html( apply_filters( 'redux-backup-description', __( 'Here you can copy/download your current option settings. Keep this safe as you can use it as a backup should anything go wrong, or you can use it to restore your settings on this site (or any other site).', 'redux-framework' ) ) ) ?>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
// $this->parent->args['opt_name'] is sanitized in the ReduxFramework class, no need to re-sanitize it.
|
||||
$link = esc_url( admin_url( 'admin-ajax.php?action=redux_download_options-' . $this->parent->args['opt_name'] . '&secret=' . $secret ) );
|
||||
?>
|
||||
<p>
|
||||
<a href="javascript:void(0);" id="redux-export-code-copy" class="button-secondary"><?php esc_html_e( 'Copy Data', 'redux-framework' ) ?></a>
|
||||
<a href="<?php echo $link; ?>" id="redux-export-code-dl" class="button-primary"><?php esc_html_e( 'Download Data File', 'redux-framework' ) ?></a>
|
||||
<a href="javascript:void(0);" id="redux-export-link" class="button-secondary"><?php esc_html_e( 'Copy Export URL', 'redux-framework' ) ?></a>
|
||||
</p>
|
||||
|
||||
<p></p>
|
||||
<textarea class="large-text noUpdate" id="redux-export-code" rows="2"></textarea>
|
||||
<textarea class="large-text noUpdate" id="redux-export-link-value" data-url="<?php echo $link; ?>" rows="2"><?php echo $link; ?></textarea>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {
|
||||
|
||||
wp_enqueue_script(
|
||||
'redux-import-export',
|
||||
$this->extension_url . 'import_export/field_import_export' . Redux_Functions::isMin() . '.js',
|
||||
array( 'jquery' ),
|
||||
ReduxFramework_extension_import_export::$version,
|
||||
true
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'redux-import-export',
|
||||
$this->extension_url . 'import_export/field_import_export.css',
|
||||
time(),
|
||||
true
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Output Function.
|
||||
* Used to enqueue to the front-end
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
|
||||
if ( $this->field['enqueue_frontend'] ) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#redux-import-link-wrapper,
|
||||
#redux-import-code-wrapper {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#redux-export-code,
|
||||
#redux-export-link-value {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#redux-import-action span {
|
||||
color: #B94A48;
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Redux Framework is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* any later version.
|
||||
* Redux Framework is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package ReduxFramework
|
||||
* @author Kevin Provance (kprovance)
|
||||
* @version 4.0.0
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Don't duplicate me!
|
||||
if ( ! class_exists( 'ReduxFramework_Extension_options_object' ) ) {
|
||||
|
||||
|
||||
/**
|
||||
* Main ReduxFramework options_object extension class
|
||||
*
|
||||
* @since 3.1.6
|
||||
*/
|
||||
class ReduxFramework_Extension_options_object {
|
||||
|
||||
// Protected vars
|
||||
protected $parent;
|
||||
public $extension_url;
|
||||
public $extension_dir;
|
||||
public static $theInstance;
|
||||
public static $version = "4.0";
|
||||
public $is_field = false;
|
||||
|
||||
/**
|
||||
* Class Constructor. Defines the args for the extions class
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*
|
||||
* @param array $sections Panel sections.
|
||||
* @param array $args Class constructor arguments.
|
||||
* @param array $extra_tabs Extra panel tabs.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $parent ) {
|
||||
|
||||
$this->parent = $parent;
|
||||
if ( empty( $this->extension_dir ) ) {
|
||||
//$this->extension_dir = trailingslashit( str_replace( '\\', '/', dirname( __FILE__ ) ) );
|
||||
}
|
||||
$this->field_name = 'options_object';
|
||||
|
||||
|
||||
self::$theInstance = $this;
|
||||
|
||||
$this->is_field = Redux_Helpers::isFieldInUse($parent, 'options_object');
|
||||
|
||||
if ( !$this->is_field && $this->parent->args['dev_mode'] && $this->parent->args['show_options_object'] ) {
|
||||
$this->add_section();
|
||||
}
|
||||
|
||||
add_filter( 'redux/' . $this->parent->args['opt_name'] . '/field/class/' . $this->field_name, array(
|
||||
&$this,
|
||||
'overload_field_path'
|
||||
) ); // Adds the local field
|
||||
}
|
||||
|
||||
public function add_section() {
|
||||
$this->parent->sections[] = array(
|
||||
'id' => 'options-object',
|
||||
'title' => __( 'Options Object', 'redux-framework' ),
|
||||
'heading' => '',
|
||||
'icon' => 'el el-info-circle',
|
||||
'customizer' => false,
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => 'redux_options_object',
|
||||
'type'=> 'options_object',
|
||||
'title' => '',
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Forces the use of the embeded field path vs what the core typically would use
|
||||
public function overload_field_path( $field ) {
|
||||
return dirname( __FILE__ ) . '/' . $this->field_name . '/field_' . $this->field_name . '.php';
|
||||
}
|
||||
} // class
|
||||
} // if
|
||||
@@ -0,0 +1 @@
|
||||
#redux-object-browser{overflow:auto;word-wrap:break-word;max-height:600px;max-width:100%}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*global redux_change, redux*/
|
||||
|
||||
(function( $ ) {
|
||||
"use strict";
|
||||
|
||||
redux.field_objects = redux.field_objects || {};
|
||||
redux.field_objects.options_object = redux.field_objects.options_object || {};
|
||||
|
||||
// $( document ).ready(
|
||||
// function() {
|
||||
// redux.field_objects.import_export.init();
|
||||
// }
|
||||
// );
|
||||
|
||||
redux.field_objects.options_object.init = function( selector ) {
|
||||
|
||||
if ( !selector ) {
|
||||
selector = $( document ).find( '.redux-container-options_object' );
|
||||
}
|
||||
|
||||
var parent = selector;
|
||||
|
||||
if ( !selector.hasClass( 'redux-field-container' ) ) {
|
||||
parent = selector.parents( '.redux-field-container:first' );
|
||||
}
|
||||
|
||||
if ( parent.hasClass( 'redux-field-init' ) ) {
|
||||
parent.removeClass( 'redux-field-init' );
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
$( '#consolePrintObject' ).on(
|
||||
'click', function( e ) {
|
||||
e.preventDefault();
|
||||
console.log( $.parseJSON( $( "#redux-object-json" ).html() ) );
|
||||
}
|
||||
);
|
||||
|
||||
if ( typeof jsonView === 'function' ) {
|
||||
jsonView( '#redux-object-json', '#redux-object-browser' );
|
||||
}
|
||||
};
|
||||
})( jQuery );
|
||||
@@ -0,0 +1 @@
|
||||
!function(t){"use strict";redux.field_objects=redux.field_objects||{},redux.field_objects.options_object=redux.field_objects.options_object||{},redux.field_objects.options_object.init=function(e){e||(e=t(document).find(".redux-container-options_object"));var o=e;e.hasClass("redux-field-container")||(o=e.parents(".redux-field-container:first")),o.hasClass("redux-field-init")&&(o.removeClass("redux-field-init"),t("#consolePrintObject").on("click",function(e){e.preventDefault(),console.log(t.parseJSON(t("#redux-object-json").html()))}),"function"==typeof jsonView&&jsonView("#redux-object-json","#redux-object-browser"))}}(jQuery);
|
||||
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
/**
|
||||
* Redux Framework is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* any later version.
|
||||
* Redux Framework is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package ReduxFramework
|
||||
* @author Kevin Provance (kprovance)
|
||||
* @version 3.5.4
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Don't duplicate me!
|
||||
if ( ! class_exists( 'ReduxFramework_options_object' ) ) {
|
||||
|
||||
/**
|
||||
* Main ReduxFramework_options_object class
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ReduxFramework_options_object {
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function __construct( $field = array(), $value = '', $parent ) {
|
||||
|
||||
$this->parent = $parent;
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
$this->is_field = $this->parent->extensions['options_object']->is_field;
|
||||
|
||||
$this->extension_dir = ReduxFramework::$_dir . 'inc/extensions/options_object/';
|
||||
$this->extension_url = ReduxFramework::$_url . 'inc/extensions/options_object/';
|
||||
|
||||
// Set default args for this field to avoid bad indexes. Change this to anything you use.
|
||||
$defaults = array(
|
||||
'options' => array(),
|
||||
'stylesheet' => '',
|
||||
'output' => true,
|
||||
'enqueue' => true,
|
||||
'enqueue_frontend' => true
|
||||
);
|
||||
$this->field = wp_parse_args( $this->field, $defaults );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function render() {
|
||||
if ( version_compare( phpversion(), "5.3.0", ">=" ) ) {
|
||||
$json = json_encode( $this->parent->options, true );
|
||||
} else {
|
||||
$json = json_encode( $this->parent->options );
|
||||
}
|
||||
|
||||
$defaults = array(
|
||||
'full_width' => true,
|
||||
'overflow' => 'inherit',
|
||||
);
|
||||
|
||||
$this->field = wp_parse_args( $this->field, $defaults );
|
||||
|
||||
if ( $this->is_field ) {
|
||||
$fullWidth = $this->field['full_width'];
|
||||
}
|
||||
|
||||
$bDoClose = false;
|
||||
|
||||
$id = $this->parent->args['opt_name'] . '-' . $this->field['id'];
|
||||
|
||||
if ( ! $this->is_field || ( $this->is_field && false == $fullWidth ) ) { ?>
|
||||
<style>#<?php echo esc_html($id); ?> {padding: 0;}</style>
|
||||
</td></tr></table>
|
||||
<table id="<?php echo esc_attr($id); ?>-table" class="form-table no-border redux-group-table redux-raw-table" style=" overflow: <?php esc_attr($this->field['overflow']); ?>;">
|
||||
<tbody><tr><td>
|
||||
<?php
|
||||
$bDoClose = true;
|
||||
}
|
||||
?>
|
||||
<fieldset id="<?php echo esc_attr($id); ?>-fieldset" class="redux-field redux-container-<?php echo esc_attr($this->field['type']) . ' ' . esc_attr($this->field['class']); ?>" data-id="<?php echo esc_attr($this->field['id']); ?>">
|
||||
<h3><?php esc_html_e( 'Options Object', 'redux-framework' ); ?></h3>
|
||||
<div id="redux-object-browser"></div>
|
||||
<div id="redux-object-json" class="hide"><?php echo $json; ?></div>
|
||||
<a href="#" id="consolePrintObject" class="button"><?php esc_html_e( 'Show Object in Javascript Console Object', 'redux-framework' ); ?></a>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php
|
||||
if ( true == $bDoClose ) { ?>
|
||||
</td></tr></table>
|
||||
<table class="form-table no-border" style="margin-top: 0;">
|
||||
<tbody>
|
||||
<tr style="border-bottom: 0;">
|
||||
<th></th>
|
||||
<td>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {
|
||||
|
||||
wp_enqueue_script(
|
||||
'redux-options-object',
|
||||
$this->extension_url . 'options_object/field_options_object' . Redux_Functions::isMin() . '.js',
|
||||
array( 'jquery' ),
|
||||
ReduxFramework_extension_options_object::$version,
|
||||
true
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'redux-options-object',
|
||||
$this->extension_url . 'options_object/field_options_object.css',
|
||||
array(),
|
||||
time(),
|
||||
'all'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Output Function.
|
||||
* Used to enqueue to the front-end
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
|
||||
if ( $this->field['enqueue_frontend'] ) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#redux-object-browser {
|
||||
overflow: auto;
|
||||
word-wrap: break-word;
|
||||
max-height: 600px;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
.redux-container-ace_editor .ace-wrapper{position:static}.redux-container-ace_editor .ace_editor{height:200px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.redux-container-ace_editor .ace_gutter{z-index:1 !important}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"mappings": "AACI,wCAAa;EACT,QAAQ,EAAE,MAAM;AAGpB,uCAAY;EACR,MAAM,EAAE,KAAK;EACb,qBAAqB,EAAE,GAAG;EAC1B,kBAAkB,EAAE,GAAG;EACvB,aAAa,EAAE,GAAG;AAGtB,uCAAY;EACR,OAAO,EAAE,YAAY",
|
||||
"sources": ["field_ace_editor.scss"],
|
||||
"names": [],
|
||||
"file": "field_ace_editor.css"
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*global jQuery, document, redux*/
|
||||
|
||||
(function( $ ) {
|
||||
"use strict";
|
||||
|
||||
redux.field_objects = redux.field_objects || {};
|
||||
redux.field_objects.ace_editor = redux.field_objects.ace_editor || {};
|
||||
|
||||
redux.field_objects.ace_editor.init = function( selector ) {
|
||||
if ( !selector ) {
|
||||
selector = $( document ).find( ".redux-group-tab:visible" ).find( '.redux-container-ace_editor:visible' );
|
||||
}
|
||||
|
||||
$( selector ).each(
|
||||
function() {
|
||||
var el = $( this );
|
||||
var parent = el;
|
||||
if ( !el.hasClass( 'redux-field-container' ) ) {
|
||||
parent = el.parents( '.redux-field-container:first' );
|
||||
}
|
||||
if ( parent.is( ":hidden" ) ) { // Skip hidden fields
|
||||
return;
|
||||
}
|
||||
if ( parent.hasClass( 'redux-field-init' ) ) {
|
||||
parent.removeClass( 'redux-field-init' );
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
el.find( '.ace-editor' ).each(
|
||||
function( index, element ) {
|
||||
var area = element;
|
||||
var params = JSON.parse( $( this ).parent().find( '.localize_data' ).val() );
|
||||
var editor = $( element ).attr( 'data-editor' );
|
||||
|
||||
var aceeditor = ace.edit( editor );
|
||||
aceeditor.setTheme( "ace/theme/" + jQuery( element ).attr( 'data-theme' ) );
|
||||
aceeditor.getSession().setMode( "ace/mode/" + $( element ).attr( 'data-mode' ) );
|
||||
var parent = '';
|
||||
if ( el.hasClass( 'redux-field-container' ) ) {
|
||||
parent = el.attr( 'data-id' );
|
||||
} else {
|
||||
parent = el.parents( '.redux-field-container:first' ).attr( 'data-id' );
|
||||
}
|
||||
|
||||
aceeditor.setOptions( params );
|
||||
aceeditor.on(
|
||||
'change', function( e ) {
|
||||
$( '#' + area.id ).val( aceeditor.getSession().getValue() );
|
||||
redux_change( $( element ) );
|
||||
aceeditor.resize();
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
})( jQuery );
|
||||
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/ace_editor/field_ace_editor.min.js
vendored
Normal file
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/ace_editor/field_ace_editor.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(s){"use strict";redux.field_objects=redux.field_objects||{},redux.field_objects.ace_editor=redux.field_objects.ace_editor||{},redux.field_objects.ace_editor.init=function(e){e||(e=s(document).find(".redux-group-tab:visible").find(".redux-container-ace_editor:visible")),s(e).each(function(){var n=s(this),e=n;n.hasClass("redux-field-container")||(e=n.parents(".redux-field-container:first")),e.is(":hidden")||e.hasClass("redux-field-init")&&(e.removeClass("redux-field-init"),n.find(".ace-editor").each(function(e,t){var i=t,a=JSON.parse(s(this).parent().find(".localize_data").val()),d=s(t).attr("data-editor"),r=ace.edit(d);r.setTheme("ace/theme/"+jQuery(t).attr("data-theme")),r.getSession().setMode("ace/mode/"+s(t).attr("data-mode"));n.hasClass("redux-field-container")?n.attr("data-id"):n.parents(".redux-field-container:first").attr("data-id"),r.setOptions(a),r.on("change",function(e){s("#"+i.id).val(r.getSession().getValue()),redux_change(s(t)),r.resize()})}))})}}(jQuery);
|
||||
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Redux Framework is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* any later version.
|
||||
* Redux Framework is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package Redux_Field
|
||||
* @subpackage ACE_Editor
|
||||
* @version 3.0.0
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Don't duplicate me!
|
||||
if ( ! class_exists( 'ReduxFramework_ace_editor' ) ) {
|
||||
class ReduxFramework_ace_editor {
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since ReduxFramework 1.0.0
|
||||
*/
|
||||
function __construct( $field = array(), $value = '', $parent ) {
|
||||
$this->parent = $parent;
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
|
||||
if ( is_array( $this->value ) ) {
|
||||
$this->value = '';
|
||||
} else {
|
||||
$this->value = trim( $this->value );
|
||||
}
|
||||
|
||||
if ( ! empty( $this->field['options'] ) ) {
|
||||
$this->field['args'] = $this->field['options'];
|
||||
unset( $this->field['options'] );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since ReduxFramework 1.0.0
|
||||
*/
|
||||
function render() {
|
||||
|
||||
if ( ! isset( $this->field['mode'] ) ) {
|
||||
$this->field['mode'] = 'javascript';
|
||||
}
|
||||
if ( ! isset( $this->field['theme'] ) ) {
|
||||
$this->field['theme'] = 'monokai';
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'minLines' => 10,
|
||||
'maxLines' => 30,
|
||||
);
|
||||
|
||||
if ( isset( $this->field['args'] ) && ! empty( $this->field['args'] ) && is_array( $this->field['args'] ) ) {
|
||||
$params = wp_parse_args( $this->field['args'], $params );
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="ace-wrapper">
|
||||
<input type="hidden"
|
||||
class="localize_data"
|
||||
value="<?php echo htmlspecialchars( json_encode( $params ) ); ?>"
|
||||
/>
|
||||
<textarea name="<?php echo esc_attr($this->field['name'] . $this->field['name_suffix']); ?>" id="<?php echo esc_attr($this->field['id']); ?>-textarea" class="ace-editor hide <?php echo esc_attr($this->field['class']); ?>" data-editor="<?php echo esc_attr($this->field['id']); ?>-editor" data-mode="<?php echo esc_attr($this->field['mode']); ?>" data-theme="<?php echo esc_attr($this->field['theme']); ?>"><?php echo esc_textarea($this->value); ?></textarea>
|
||||
<pre id="<?php echo esc_attr($this->field['id']); ?>-editor" class="ace-editor-area"><?php echo htmlspecialchars( $this->value ); ?></pre>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {
|
||||
if ( $this->parent->args['dev_mode'] ) {
|
||||
if ( ! wp_style_is( 'redux-field-ace-editor-css' ) ) {
|
||||
wp_enqueue_style(
|
||||
'redux-field-ace-editor-css',
|
||||
ReduxFramework::$_url . 'inc/fields/ace_editor/field_ace_editor.css',
|
||||
array(),
|
||||
time(),
|
||||
'all'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! wp_script_is( 'ace-editor-js' ) ) {
|
||||
Redux_CDN::enqueue_script(
|
||||
'ace-editor-js',
|
||||
'//cdn.jsdelivr.net/ace/1.1.9/min/ace.js',
|
||||
array( 'jquery' ),
|
||||
'1.1.9',
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! wp_script_is( 'redux-field-ace-editor-js' ) ) {
|
||||
wp_enqueue_script(
|
||||
'redux-field-ace-editor-js',
|
||||
ReduxFramework::$_url . 'inc/fields/ace_editor/field_ace_editor' . Redux_Functions::isMin() . '.js',
|
||||
array( 'jquery', 'ace-editor-js', 'redux-js' ),
|
||||
time(),
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
.redux-container-ace_editor {
|
||||
.ace-wrapper {
|
||||
position: static;
|
||||
}
|
||||
|
||||
.ace_editor {
|
||||
height: 200px;
|
||||
-webkit-border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.ace_gutter {
|
||||
z-index: 1 !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
.redux-main .redux-container-background .redux-background-position,.redux-main .redux-container-background .redux-background-position select,.redux-main .redux-container-background .redux-background-attachment,.redux-main .redux-container-background .redux-background-attachment select,.redux-main .redux-container-background .redux-background-clip,.redux-main .redux-container-background .redux-background-clip select,.redux-main .redux-container-background .redux-background-origin,.redux-main .redux-container-background .redux-background-origin select,.redux-main .redux-container-background .redux-background-size,.redux-main .redux-container-background .redux-background-size select,.redux-main .redux-container-background .redux-background-repeat,.redux-main .redux-container-background .redux-background-repeat select{width:200px !important;margin-right:10px;margin-bottom:7px}.redux-main .redux-container-background .background-preview{display:block;width:100%;margin:5px 0 10px;border:1px dotted lightgray}.redux-main .redux-container-background .select2-container{margin-right:10px;margin-bottom:10px}.redux-main .redux-container-background .wp-picker-container{margin-bottom:10px}.redux-main .redux-container-background .upload{width:100%;margin-bottom:8px}.redux-main .redux-container-select li.ui-state-highlight{height:20px;margin-top:2px;margin-left:5px;width:64px;margin-bottom:0}.wp-customizer .redux-container-background .redux-background-position,.wp-customizer .redux-container-background .redux-background-position select,.wp-customizer .redux-container-background .redux-background-attachment,.wp-customizer .redux-container-background .redux-background-attachment select,.wp-customizer .redux-container-background .redux-background-clip,.wp-customizer .redux-container-background .redux-background-clip select,.wp-customizer .redux-container-background .redux-background-origin,.wp-customizer .redux-container-background .redux-background-origin select,.wp-customizer .redux-container-background .redux-background-size,.wp-customizer .redux-container-background .redux-background-size select,.wp-customizer .redux-container-background .redux-background-repeat,.wp-customizer .redux-container-background .redux-background-repeat select{width:100% !important}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"mappings": "AAEQ;;;;;;;;;;;uEAWgC;EAC5B,KAAK,EAAC,gBAAgB;EACtB,YAAY,EAAE,IAAI;EAClB,aAAa,EAAE,GAAG;AAItB,2DAAoB;EAChB,OAAO,EAAC,KAAK;EACb,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,UAAU;EAClB,MAAM,EAAC,oBAAoB;AAG/B,0DAAmB;EACf,YAAY,EAAE,IAAI;EAClB,aAAa,EAAE,IAAI;AAGvB,4DAAqB;EACjB,aAAa,EAAE,IAAI;AAGvB,+CAAQ;EACJ,KAAK,EAAE,IAAI;EACX,aAAa,EAAE,GAAG;AAKtB,yDAAsB;EAClB,MAAM,EAAE,IAAI;EACZ,UAAU,EAAC,GAAG;EACd,WAAW,EAAE,GAAG;EAChB,KAAK,EAAE,IAAI;EACX,aAAa,EAAE,CAAC;;AAOpB,w2BAAqW;EACjW,KAAK,EAAE,eAAe",
|
||||
"sources": ["field_background.scss"],
|
||||
"names": [],
|
||||
"file": "field_background.css"
|
||||
}
|
||||
@@ -0,0 +1,324 @@
|
||||
/**
|
||||
* Redux Background
|
||||
* Dependencies : jquery, wp media uploader
|
||||
* Feature added by : Dovy Paukstys
|
||||
* Date : 07 Jan 2014
|
||||
*/
|
||||
|
||||
/*global redux_change, wp, redux*/
|
||||
|
||||
(function( $ ) {
|
||||
"use strict";
|
||||
|
||||
redux.field_objects = redux.field_objects || {};
|
||||
redux.field_objects.background = redux.field_objects.background || {};
|
||||
|
||||
redux.field_objects.background.init = function( selector ) {
|
||||
if ( !selector ) {
|
||||
selector = $( document ).find( ".redux-group-tab:visible" ).find( '.redux-container-background:visible' );
|
||||
}
|
||||
|
||||
$( selector ).each(
|
||||
function() {
|
||||
var el = $( this );
|
||||
var parent = el;
|
||||
if ( !el.hasClass( 'redux-field-container' ) ) {
|
||||
parent = el.parents( '.redux-field-container:first' );
|
||||
}
|
||||
|
||||
if ( parent.is( ":hidden" ) ) { // Skip hidden fields
|
||||
return;
|
||||
}
|
||||
|
||||
if ( parent.hasClass( 'redux-field-init' ) ) {
|
||||
parent.removeClass( 'redux-field-init' );
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
// Remove the image button
|
||||
el.find( '.redux-remove-background' ).unbind( 'click' ).on(
|
||||
'click', function( e ) {
|
||||
e.preventDefault();
|
||||
redux.field_objects.background.removeImage( $( this ).parents( '.redux-container-background:first' ) );
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
// Upload media button
|
||||
el.find( '.redux-background-upload' ).unbind().on(
|
||||
'click', function( event ) {
|
||||
redux.field_objects.background.addImage(
|
||||
event, $( this ).parents( '.redux-container-background:first' )
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
el.find( '.redux-background-input' ).on(
|
||||
'change', function() {
|
||||
redux.field_objects.background.preview( $( this ) );
|
||||
}
|
||||
);
|
||||
|
||||
el.find( '.redux-color' ).wpColorPicker(
|
||||
{
|
||||
change: function( e, ui ) {
|
||||
$( this ).val( ui.color.toString() );
|
||||
redux_change( $( this ) );
|
||||
$( '#' + e.target.id + '-transparency' ).removeAttr( 'checked' );
|
||||
redux.field_objects.background.preview( $( this ) );
|
||||
},
|
||||
|
||||
clear: function( e, ui ) {
|
||||
$( this ).val( ui.color.toString() );
|
||||
redux_change( $( this ).parent().find( '.redux-color-init' ) );
|
||||
redux.field_objects.background.preview( $( this ) );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Replace and validate field on blur
|
||||
el.find( '.redux-color' ).on(
|
||||
'blur', function() {
|
||||
var value = $( this ).val();
|
||||
var id = '#' + $( this ).attr( 'id' );
|
||||
|
||||
if ( value === "transparent" ) {
|
||||
$( this ).parent().parent().find( '.wp-color-result' ).css(
|
||||
'background-color', 'transparent'
|
||||
);
|
||||
|
||||
el.find( id + '-transparency' ).attr( 'checked', 'checked' );
|
||||
} else {
|
||||
if ( colorValidate( this ) === value ) {
|
||||
if ( value.indexOf( "#" ) !== 0 ) {
|
||||
$( this ).val( $( this ).data( 'oldcolor' ) );
|
||||
}
|
||||
}
|
||||
|
||||
el.find( id + '-transparency' ).removeAttr( 'checked' );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
el.find( '.redux-color' ).on(
|
||||
'focus', function() {
|
||||
$( this ).data( 'oldcolor', $( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
el.find( '.redux-color' ).on(
|
||||
'keyup', function() {
|
||||
var value = $( this ).val();
|
||||
var color = colorValidate( this );
|
||||
var id = '#' + $( this ).attr( 'id' );
|
||||
|
||||
if ( value === "transparent" ) {
|
||||
$( this ).parent().parent().find( '.wp-color-result' ).css(
|
||||
'background-color', 'transparent'
|
||||
);
|
||||
el.find( id + '-transparency' ).attr( 'checked', 'checked' );
|
||||
} else {
|
||||
el.find( id + '-transparency' ).removeAttr( 'checked' );
|
||||
|
||||
if ( color && color !== $( this ).val() ) {
|
||||
$( this ).val( color );
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// When transparency checkbox is clicked
|
||||
el.find( '.color-transparency' ).on(
|
||||
'click', function() {
|
||||
if ( $( this ).is( ":checked" ) ) {
|
||||
el.find( '.redux-saved-color' ).val( $( '#' + $( this ).data( 'id' ) ).val() );
|
||||
el.find( '#' + $( this ).data( 'id' ) ).val( 'transparent' );
|
||||
el.find( '#' + $( this ).data( 'id' ) ).parent().parent().find( '.wp-color-result' ).css(
|
||||
'background-color', 'transparent'
|
||||
);
|
||||
} else {
|
||||
if ( el.find( '#' + $( this ).data( 'id' ) ).val() === 'transparent' ) {
|
||||
var prevColor = $( '.redux-saved-color' ).val();
|
||||
|
||||
if ( prevColor === '' ) {
|
||||
prevColor = $( '#' + $( this ).data( 'id' ) ).data( 'default-color' );
|
||||
}
|
||||
|
||||
el.find( '#' + $( this ).data( 'id' ) ).parent().parent().find( '.wp-color-result' ).css(
|
||||
'background-color', prevColor
|
||||
);
|
||||
el.find( '#' + $( this ).data( 'id' ) ).val( prevColor );
|
||||
}
|
||||
}
|
||||
redux.field_objects.background.preview( $( this ) );
|
||||
redux_change( $( this ) );
|
||||
}
|
||||
);
|
||||
|
||||
var default_params = {
|
||||
width: 'resolve',
|
||||
triggerChange: true,
|
||||
allowClear: true
|
||||
};
|
||||
|
||||
var select2_handle = el.find( '.select2_params' );
|
||||
if ( select2_handle.size() > 0 ) {
|
||||
var select2_params = select2_handle.val();
|
||||
|
||||
select2_params = JSON.parse( select2_params );
|
||||
default_params = $.extend( {}, default_params, select2_params );
|
||||
}
|
||||
|
||||
el.find( " .redux-background-repeat, .redux-background-clip, .redux-background-origin, .redux-background-size, .redux-background-attachment, .redux-background-position" ).select2( default_params );
|
||||
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
// Update the background preview
|
||||
redux.field_objects.background.preview = function( selector ) {
|
||||
var parent = $( selector ).parents( '.redux-container-background:first' );
|
||||
var preview = $( parent ).find( '.background-preview' );
|
||||
|
||||
if ( !preview ) { // No preview present
|
||||
return;
|
||||
}
|
||||
var hide = true;
|
||||
|
||||
var css = 'height:' + preview.height() + 'px;';
|
||||
$( parent ).find( '.redux-background-input' ).each(
|
||||
function() {
|
||||
var data = $( this ).serializeArray();
|
||||
data = data[0];
|
||||
if ( data && data.name.indexOf( '[background-' ) != -1 ) {
|
||||
if ( data.value !== "" ) {
|
||||
hide = false;
|
||||
data.name = data.name.split( '[background-' );
|
||||
data.name = 'background-' + data.name[1].replace( ']', '' );
|
||||
if ( data.name == "background-image" ) {
|
||||
css += data.name + ':url("' + data.value + '");';
|
||||
} else {
|
||||
css += data.name + ':' + data.value + ';';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
if ( !hide ) {
|
||||
preview.attr( 'style', css ).fadeIn();
|
||||
} else {
|
||||
preview.slideUp();
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
// Add a file via the wp.media function
|
||||
redux.field_objects.background.addImage = function( event, selector ) {
|
||||
event.preventDefault();
|
||||
|
||||
var frame;
|
||||
var jQueryel = $( this );
|
||||
|
||||
// If the media frame already exists, reopen it.
|
||||
if ( frame ) {
|
||||
frame.open();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the media frame.
|
||||
frame = wp.media(
|
||||
{
|
||||
multiple: false,
|
||||
library: {
|
||||
//type: 'image' //Only allow images
|
||||
},
|
||||
// Set the title of the modal.
|
||||
title: jQueryel.data( 'choose' ),
|
||||
// Customize the submit button.
|
||||
button: {
|
||||
// Set the text of the button.
|
||||
text: jQueryel.data( 'update' )
|
||||
// Tell the button not to close the modal, since we're
|
||||
// going to refresh the page when the image is selected.
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// When an image is selected, run a callback.
|
||||
frame.on(
|
||||
'select', function() {
|
||||
// Grab the selected attachment.
|
||||
var attachment = frame.state().get( 'selection' ).first();
|
||||
frame.close();
|
||||
|
||||
//console.log(attachment.attributes.type);
|
||||
|
||||
if ( attachment.attributes.type !== "image" ) {
|
||||
return;
|
||||
}
|
||||
|
||||
selector.find( '.upload' ).val( attachment.attributes.url );
|
||||
selector.find( '.upload-id' ).val( attachment.attributes.id );
|
||||
selector.find( '.upload-height' ).val( attachment.attributes.height );
|
||||
selector.find( '.upload-width' ).val( attachment.attributes.width );
|
||||
redux_change( $( selector ).find( '.upload-id' ) );
|
||||
var thumbSrc = attachment.attributes.url;
|
||||
if ( typeof attachment.attributes.sizes !== 'undefined' && typeof attachment.attributes.sizes.thumbnail !== 'undefined' ) {
|
||||
thumbSrc = attachment.attributes.sizes.thumbnail.url;
|
||||
} else if ( typeof attachment.attributes.sizes !== 'undefined' ) {
|
||||
var height = attachment.attributes.height;
|
||||
for ( var key in attachment.attributes.sizes ) {
|
||||
var object = attachment.attributes.sizes[key];
|
||||
if ( object.height < height ) {
|
||||
height = object.height;
|
||||
thumbSrc = object.url;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
thumbSrc = attachment.attributes.icon;
|
||||
}
|
||||
selector.find( '.upload-thumbnail' ).val( thumbSrc );
|
||||
if ( !selector.find( '.upload' ).hasClass( 'noPreview' ) ) {
|
||||
selector.find( '.screenshot' ).empty().hide().append( '<img class="redux-option-image" src="' + thumbSrc + '">' ).slideDown( 'fast' );
|
||||
}
|
||||
|
||||
selector.find( '.redux-remove-background' ).removeClass( 'hide' );//show "Remove" button
|
||||
selector.find( '.redux-background-input-properties' ).slideDown();
|
||||
redux.field_objects.background.preview( selector.find( '.upload' ) );
|
||||
}
|
||||
);
|
||||
|
||||
// Finally, open the modal.
|
||||
frame.open();
|
||||
};
|
||||
|
||||
// Update the background preview
|
||||
redux.field_objects.background.removeImage = function( selector ) {
|
||||
|
||||
// This shouldn't have been run...
|
||||
if ( !selector.find( '.redux-remove-background' ).addClass( 'hide' ) ) {
|
||||
return;
|
||||
}
|
||||
selector.find( '.redux-remove-background' ).addClass( 'hide' ); //hide "Remove" button
|
||||
|
||||
selector.find( '.upload' ).val( '' );
|
||||
selector.find( '.upload-id' ).val( '' );
|
||||
selector.find( '.upload-height' ).val( '' );
|
||||
selector.find( '.upload-width' ).val( '' );
|
||||
redux_change( $( selector ).find( '.upload-id' ) );
|
||||
selector.find( '.redux-background-input-properties' ).hide();
|
||||
var screenshot = selector.find( '.screenshot' );
|
||||
|
||||
// Hide the screenshot
|
||||
screenshot.slideUp();
|
||||
|
||||
selector.find( '.remove-file' ).unbind();
|
||||
// We don't display the upload button if .upload-notice is present
|
||||
// This means the user doesn't have the WordPress 3.5 Media Library Support
|
||||
if ( $( '.section-upload .upload-notice' ).length > 0 ) {
|
||||
$( '.redux-background-upload' ).remove();
|
||||
}
|
||||
};
|
||||
})( jQuery );
|
||||
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/background/field_background.min.js
vendored
Normal file
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/background/field_background.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,430 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Redux Framework is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* any later version.
|
||||
* Redux Framework is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package ReduxFramework
|
||||
* @subpackage Field_Background
|
||||
* @author Dovy Paukstys
|
||||
* @version 3.1.5
|
||||
*/
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Don't duplicate me!
|
||||
if ( ! class_exists( 'ReduxFramework_background' ) ) {
|
||||
|
||||
/**
|
||||
* Main ReduxFramework_background class
|
||||
*
|
||||
* @since 3.1.5
|
||||
*/
|
||||
class ReduxFramework_background {
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since 3.1.5
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function __construct( $field = array(), $value = '', $parent ) {
|
||||
|
||||
$this->parent = $parent;
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function render() {
|
||||
|
||||
$defaults = array(
|
||||
'background-color' => true,
|
||||
'background-repeat' => true,
|
||||
'background-attachment' => true,
|
||||
'background-position' => true,
|
||||
'background-image' => true,
|
||||
'background-gradient' => false,
|
||||
'background-clip' => false,
|
||||
'background-origin' => false,
|
||||
'background-size' => true,
|
||||
'preview_media' => false,
|
||||
'preview' => true,
|
||||
'preview_height' => '200px',
|
||||
'transparent' => true,
|
||||
);
|
||||
|
||||
$this->field = wp_parse_args( $this->field, $defaults );
|
||||
|
||||
// No errors please
|
||||
$defaults = array(
|
||||
'background-color' => '',
|
||||
'background-repeat' => '',
|
||||
'background-attachment' => '',
|
||||
'background-position' => '',
|
||||
'background-image' => '',
|
||||
'background-clip' => '',
|
||||
'background-origin' => '',
|
||||
'background-size' => '',
|
||||
'media' => array(),
|
||||
);
|
||||
|
||||
$this->value = wp_parse_args( $this->value, $defaults );
|
||||
|
||||
$defaults = array(
|
||||
'id' => '',
|
||||
'width' => '',
|
||||
'height' => '',
|
||||
'thumbnail' => '',
|
||||
);
|
||||
|
||||
$this->value['media'] = wp_parse_args( $this->value['media'], $defaults );
|
||||
|
||||
// select2 args
|
||||
if ( isset( $this->field['select2'] ) ) { // if there are any let's pass them to js
|
||||
$select2_params = json_encode( $this->field['select2'] );
|
||||
$select2_params = htmlspecialchars( $select2_params, ENT_QUOTES );
|
||||
|
||||
echo '<input type="hidden" class="select2_params" value="' . $select2_params . '">';
|
||||
}
|
||||
|
||||
if ( $this->field['background-color'] === true ) {
|
||||
|
||||
if ( isset( $this->value['color'] ) && empty( $this->value['background-color'] ) ) {
|
||||
$this->value['background-color'] = $this->value['color'];
|
||||
}
|
||||
|
||||
echo '<input data-id="' . $this->field['id'] . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '[background-color]" id="' . $this->field['id'] . '-color" class="redux-color redux-background-input redux-color-init ' . $this->field['class'] . '" type="text" value="' . $this->value['background-color'] . '" data-default-color="' . ( isset( $this->field['default']['background-color'] ) ? $this->field['default']['background-color'] : "" ) . '" />';
|
||||
echo '<input type="hidden" class="redux-saved-color" id="' . $this->field['id'] . '-saved-color' . '" value="">';
|
||||
|
||||
if ( ! isset( $this->field['transparent'] ) || $this->field['transparent'] !== false ) {
|
||||
$tChecked = "";
|
||||
if ( $this->value['background-color'] == "transparent" ) {
|
||||
$tChecked = ' checked="checked"';
|
||||
}
|
||||
echo '<label for="' . $this->field['id'] . '-transparency" class="color-transparency-check"><input type="checkbox" class="checkbox color-transparency redux-background-input ' . $this->field['class'] . '" id="' . $this->field['id'] . '-transparency" data-id="' . $this->field['id'] . '-color" value="1"' . $tChecked . '> ' . __( 'Transparent', 'redux-framework' ) . '</label>';
|
||||
}
|
||||
|
||||
if ( $this->field['background-repeat'] === true || $this->field['background-position'] === true || $this->field['background-attachment'] === true ) {
|
||||
echo '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( $this->field['background-repeat'] === true ) {
|
||||
$array = array(
|
||||
'no-repeat' => 'No Repeat',
|
||||
'repeat' => 'Repeat All',
|
||||
'repeat-x' => 'Repeat Horizontally',
|
||||
'repeat-y' => 'Repeat Vertically',
|
||||
'inherit' => 'Inherit',
|
||||
);
|
||||
echo '<select id="' . $this->field['id'] . '-repeat-select" data-placeholder="' . __( 'Background Repeat', 'redux-framework' ) . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '[background-repeat]" class="redux-select-item redux-background-input redux-background-repeat ' . $this->field['class'] . '">';
|
||||
echo '<option></option>';
|
||||
|
||||
foreach ( $array as $k => $v ) {
|
||||
echo '<option value="' . $k . '"' . selected( $this->value['background-repeat'], $k, false ) . '>' . $v . '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
}
|
||||
|
||||
if ( $this->field['background-clip'] === true ) {
|
||||
$array = array(
|
||||
'inherit' => 'Inherit',
|
||||
'border-box' => 'Border Box',
|
||||
'content-box' => 'Content Box',
|
||||
'padding-box' => 'Padding Box',
|
||||
);
|
||||
echo '<select id="' . $this->field['id'] . '-clip-select" data-placeholder="' . __( 'Background Clip', 'redux-framework' ) . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '[background-clip]" class="redux-select-item redux-background-input redux-background-clip ' . $this->field['class'] . '">';
|
||||
echo '<option></option>';
|
||||
|
||||
foreach ( $array as $k => $v ) {
|
||||
echo '<option value="' . $k . '"' . selected( $this->value['background-clip'], $k, false ) . '>' . $v . '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
}
|
||||
|
||||
if ( $this->field['background-origin'] === true ) {
|
||||
$array = array(
|
||||
'inherit' => 'Inherit',
|
||||
'border-box' => 'Border Box',
|
||||
'content-box' => 'Content Box',
|
||||
'padding-box' => 'Padding Box',
|
||||
);
|
||||
echo '<select id="' . $this->field['id'] . '-origin-select" data-placeholder="' . __( 'Background Origin', 'redux-framework' ) . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '[background-origin]" class="redux-select-item redux-background-input redux-background-origin ' . $this->field['class'] . '">';
|
||||
echo '<option></option>';
|
||||
|
||||
foreach ( $array as $k => $v ) {
|
||||
echo '<option value="' . $k . '"' . selected( $this->value['background-origin'], $k, false ) . '>' . $v . '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
}
|
||||
|
||||
if ( $this->field['background-size'] === true ) {
|
||||
$array = array(
|
||||
'inherit' => 'Inherit',
|
||||
'cover' => 'Cover',
|
||||
'contain' => 'Contain',
|
||||
);
|
||||
echo '<select id="' . $this->field['id'] . '-size-select" data-placeholder="' . __( 'Background Size', 'redux-framework' ) . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '[background-size]" class="redux-select-item redux-background-input redux-background-size ' . $this->field['class'] . '">';
|
||||
echo '<option></option>';
|
||||
|
||||
foreach ( $array as $k => $v ) {
|
||||
echo '<option value="' . $k . '"' . selected( $this->value['background-size'], $k, false ) . '>' . $v . '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
}
|
||||
|
||||
if ( $this->field['background-attachment'] === true ) {
|
||||
$array = array(
|
||||
'fixed' => 'Fixed',
|
||||
'scroll' => 'Scroll',
|
||||
'inherit' => 'Inherit',
|
||||
);
|
||||
echo '<select id="' . $this->field['id'] . '-attachment-select" data-placeholder="' . __( 'Background Attachment', 'redux-framework' ) . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '[background-attachment]" class="redux-select-item redux-background-input redux-background-attachment ' . $this->field['class'] . '">';
|
||||
echo '<option></option>';
|
||||
foreach ( $array as $k => $v ) {
|
||||
echo '<option value="' . $k . '"' . selected( $this->value['background-attachment'], $k, false ) . '>' . $v . '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
}
|
||||
|
||||
if ( $this->field['background-position'] === true ) {
|
||||
$array = array(
|
||||
'left top' => 'Left Top',
|
||||
'left center' => 'Left center',
|
||||
'left bottom' => 'Left Bottom',
|
||||
'center top' => 'Center Top',
|
||||
'center center' => 'Center Center',
|
||||
'center bottom' => 'Center Bottom',
|
||||
'right top' => 'Right Top',
|
||||
'right center' => 'Right center',
|
||||
'right bottom' => 'Right Bottom',
|
||||
);
|
||||
echo '<select id="' . $this->field['id'] . '-position-select" data-placeholder="' . __( 'Background Position', 'redux-framework' ) . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '[background-position]" class="redux-select-item redux-background-input redux-background-position ' . $this->field['class'] . '">';
|
||||
echo '<option></option>';
|
||||
|
||||
foreach ( $array as $k => $v ) {
|
||||
echo '<option value="' . $k . '"' . selected( $this->value['background-position'], $k, false ) . '>' . $v . '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
}
|
||||
|
||||
if ( $this->field['background-image'] === true ) {
|
||||
echo '<br />';
|
||||
|
||||
if ( empty( $this->value ) && ! empty( $this->field['default'] ) ) { // If there are standard values and value is empty
|
||||
if ( is_array( $this->field['default'] ) ) {
|
||||
if ( ! empty( $this->field['default']['media']['id'] ) ) {
|
||||
$this->value['media']['id'] = $this->field['default']['media']['id'];
|
||||
} else if ( ! empty( $this->field['default']['id'] ) ) {
|
||||
$this->value['media']['id'] = $this->field['default']['id'];
|
||||
}
|
||||
|
||||
if ( ! empty( $this->field['default']['url'] ) ) {
|
||||
$this->value['background-image'] = $this->field['default']['url'];
|
||||
} else if ( ! empty( $this->field['default']['media']['url'] ) ) {
|
||||
$this->value['background-image'] = $this->field['default']['media']['url'];
|
||||
} else if ( ! empty( $this->field['default']['background-image'] ) ) {
|
||||
$this->value['background-image'] = $this->field['default']['background-image'];
|
||||
}
|
||||
} else {
|
||||
if ( is_numeric( $this->field['default'] ) ) { // Check if it's an attachment ID
|
||||
$this->value['media']['id'] = $this->field['default'];
|
||||
} else { // Must be a URL
|
||||
$this->value['background-image'] = $this->field['default'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( empty( $this->value['background-image'] ) && ! empty( $this->value['media']['id'] ) ) {
|
||||
$img = wp_get_attachment_image_src( $this->value['media']['id'], 'full' );
|
||||
$this->value['background-image'] = $img[0];
|
||||
$this->value['media']['width'] = $img[1];
|
||||
$this->value['media']['height'] = $img[2];
|
||||
}
|
||||
|
||||
$hide = 'hide ';
|
||||
|
||||
if ( ( isset( $this->field['preview_media'] ) && $this->field['preview_media'] === false ) ) {
|
||||
$this->field['class'] .= " noPreview";
|
||||
}
|
||||
|
||||
if ( ( ! empty( $this->field['background-image'] ) && $this->field['background-image'] === true ) || isset( $this->field['preview'] ) && $this->field['preview'] === false ) {
|
||||
$hide = '';
|
||||
}
|
||||
|
||||
$placeholder = isset( $this->field['placeholder'] ) ? $this->field['placeholder'] : __( 'No media selected', 'redux-framework' );
|
||||
|
||||
echo '<input placeholder="' . $placeholder . '" type="text" class="redux-background-input ' . $hide . 'upload ' . $this->field['class'] . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '[background-image]" id="' . $this->parent->args['opt_name'] . '-' . $this->field['id'] . '-background-image" value="' . $this->value['background-image'] . '" />';
|
||||
echo '<input type="hidden" class="upload-id ' . $this->field['class'] . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '[media][id]" id="' . $this->parent->args['opt_name'] . '-' . $this->field['id'] . '-media-id" value="' . $this->value['media']['id'] . '" />';
|
||||
echo '<input type="hidden" class="upload-height" name="' . $this->field['name'] . $this->field['name_suffix'] . '[media][height]" id="' . $this->parent->args['opt_name'] . '-' . $this->field['id'] . '-media-height" value="' . $this->value['media']['height'] . '" />';
|
||||
echo '<input type="hidden" class="upload-width" name="' . $this->field['name'] . $this->field['name_suffix'] . '[media][width]" id="' . $this->parent->args['opt_name'] . '-' . $this->field['id'] . '-media-width" value="' . $this->value['media']['width'] . '" />';
|
||||
echo '<input type="hidden" class="upload-thumbnail" name="' . $this->field['name'] . $this->field['name_suffix'] . '[media][thumbnail]" id="' . $this->parent->args['opt_name'] . '-' . $this->field['id'] . '-media-thumbnail" value="' . $this->value['media']['thumbnail'] . '" />';
|
||||
|
||||
//Preview
|
||||
$hide = '';
|
||||
|
||||
if ( ( isset( $this->field['preview_media'] ) && $this->field['preview_media'] === false ) || empty( $this->value['background-image'] ) ) {
|
||||
$hide = 'hide ';
|
||||
}
|
||||
|
||||
if ( empty( $this->value['media']['thumbnail'] ) && ! empty( $this->value['background-image'] ) ) { // Just in case
|
||||
if ( ! empty( $this->value['media']['id'] ) ) {
|
||||
$image = wp_get_attachment_image_src( $this->value['media']['id'], array(
|
||||
150,
|
||||
150
|
||||
) );
|
||||
$this->value['media']['thumbnail'] = $image[0];
|
||||
} else {
|
||||
$this->value['media']['thumbnail'] = $this->value['background-image'];
|
||||
}
|
||||
}
|
||||
|
||||
echo '<div class="' . $hide . 'screenshot">';
|
||||
echo '<a class="of-uploaded-image" href="' . $this->value['background-image'] . '" target="_blank">';
|
||||
echo '<img class="redux-option-image" id="image_' . $this->value['media']['id'] . '" src="' . $this->value['media']['thumbnail'] . '" alt="" target="_blank" rel="external" />';
|
||||
echo '</a>';
|
||||
echo '</div>';
|
||||
|
||||
//Upload controls DIV
|
||||
echo '<div class="upload_button_div">';
|
||||
|
||||
//If the user has WP3.5+ show upload/remove button
|
||||
echo '<span class="button redux-background-upload" id="' . $this->field['id'] . '-media">' . __( 'Upload', 'redux-framework' ) . '</span>';
|
||||
|
||||
$hide = '';
|
||||
if ( empty( $this->value['background-image'] ) || $this->value['background-image'] == '' ) {
|
||||
$hide = ' hide';
|
||||
}
|
||||
|
||||
echo '<span class="button removeCSS redux-remove-background' . $hide . '" id="reset_' . $this->field['id'] . '" rel="' . $this->field['id'] . '">' . __( 'Remove', 'redux-framework' ) . '</span>';
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Preview
|
||||
* */
|
||||
if ( ! isset( $this->field['preview'] ) || $this->field['preview'] !== false ):
|
||||
|
||||
$css = $this->getCSS();
|
||||
if ( empty( $css ) ) {
|
||||
$css = "display:none;";
|
||||
}
|
||||
$css .= "height: " . $this->field['preview_height'] . ";";
|
||||
echo '<p class="clear ' . $this->field['id'] . '_previewer background-preview" style="' . $css . '"> </p>';
|
||||
|
||||
endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {
|
||||
if ( function_exists( 'wp_enqueue_media' ) ) {
|
||||
wp_enqueue_media();
|
||||
} else {
|
||||
if (!wp_script_is ( 'media-upload' )) {
|
||||
wp_enqueue_script( 'media-upload' );
|
||||
}
|
||||
}
|
||||
|
||||
if (!wp_style_is ( 'select2-css' )) {
|
||||
wp_enqueue_style( 'select2-css' );
|
||||
}
|
||||
|
||||
if (!wp_style_is ( 'wp-color-picker' )) {
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
}
|
||||
|
||||
if (!wp_script_is ( 'redux-field-background-js' )) {
|
||||
wp_enqueue_script(
|
||||
'redux-field-background-js',
|
||||
ReduxFramework::$_url . 'inc/fields/background/field_background' . Redux_Functions::isMin() . '.js',
|
||||
array( 'jquery', 'wp-color-picker', 'select2-js', 'redux-js' ),
|
||||
time(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->parent->args['dev_mode']) {
|
||||
if (!wp_style_is ( 'redux-field-background-css' )) {
|
||||
wp_enqueue_style(
|
||||
'redux-field-background-css',
|
||||
ReduxFramework::$_url . 'inc/fields/background/field_background.css',
|
||||
array(),
|
||||
time(),
|
||||
'all'
|
||||
);
|
||||
}
|
||||
|
||||
if (!wp_style_is ( 'redux-color-picker-css' )) {
|
||||
wp_enqueue_style( 'redux-color-picker-css' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getCSS( $value = array() ) {
|
||||
|
||||
$css = '';
|
||||
|
||||
if ( ! empty( $value ) && is_array( $value ) ) {
|
||||
foreach ( $value as $key => $value ) {
|
||||
if ( ! empty( $value ) && $key != "media" ) {
|
||||
if ( $key == "background-image" ) {
|
||||
$css .= $key . ":url('" . $value . "');";
|
||||
} else {
|
||||
$css .= $key . ":" . $value . ";";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $css;
|
||||
}
|
||||
|
||||
public function output() {
|
||||
$style = $this->getCSS( $this->value );
|
||||
|
||||
if ( ! empty( $style ) ) {
|
||||
|
||||
if ( ! empty( $this->field['output'] ) && is_array( $this->field['output'] ) ) {
|
||||
$keys = implode( ",", $this->field['output'] );
|
||||
$this->parent->outputCSS .= $keys . "{" . $style . '}';
|
||||
}
|
||||
|
||||
if ( ! empty( $this->field['compiler'] ) && is_array( $this->field['compiler'] ) ) {
|
||||
$keys = implode( ",", $this->field['compiler'] );
|
||||
$this->parent->compilerCSS .= $keys . "{" . $style . '}';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
.redux-main {
|
||||
.redux-container-background {
|
||||
.redux-background-position,
|
||||
.redux-background-position select,
|
||||
.redux-background-attachment,
|
||||
.redux-background-attachment select,
|
||||
.redux-background-clip,
|
||||
.redux-background-clip select,
|
||||
.redux-background-origin,
|
||||
.redux-background-origin select,
|
||||
.redux-background-size,
|
||||
.redux-background-size select,
|
||||
.redux-background-repeat,
|
||||
.redux-background-repeat select {
|
||||
width:200px !important;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 7px;
|
||||
}
|
||||
|
||||
.background-preview {
|
||||
display:block;
|
||||
width: 100%;
|
||||
margin: 5px 0 10px;
|
||||
border:1px dotted lightgray;
|
||||
}
|
||||
|
||||
.select2-container {
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.wp-picker-container {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.upload {
|
||||
width: 100%;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.redux-container-select {
|
||||
li.ui-state-highlight {
|
||||
height: 20px;
|
||||
margin-top:2px;
|
||||
margin-left: 5px;
|
||||
width: 64px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.wp-customizer {
|
||||
.redux-container-background {
|
||||
.redux-background-position, .redux-background-position select, .redux-background-attachment, .redux-background-attachment select, .redux-background-clip, .redux-background-clip select, .redux-background-origin, .redux-background-origin select, .redux-background-size, .redux-background-size select, .redux-background-repeat, .redux-background-repeat select {
|
||||
width: 100% !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
.redux-container-border .select2-container{float:left;display:block;margin-right:10px}.redux-container-border .select_wrapper{float:left;width:inherit}.redux-container-border .select_wrapper select{width:80px;float:left}.redux-container-border .field-border-input{margin-right:10px;margin-bottom:7px}.redux-container-border .wp-picker-container{margin-top:2px}@media screen and (max-width: 782px){.redux-container-border .field-border-input input{display:inline-block !important;width:100px !important}.redux-container-border .field-border-input .add-on{padding:7px 4px;font-size:16px;line-height:1.5}.redux-container-border .select_wrapper{margin-top:6px}}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"mappings": "AACI,0CAAmB;EACf,KAAK,EAAE,IAAI;EACX,OAAO,EAAE,KAAK;EACd,YAAY,EAAE,IAAI;AAGtB,uCAAgB;EACZ,KAAK,EAAE,IAAI;EAMX,KAAK,EAAE,OAAO;EALd,8CAAO;IACH,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;AAMnB,2CAAoB;EAChB,YAAY,EAAE,IAAI;EAClB,aAAa,EAAE,GAAG;AAGtB,4CAAqB;EACjB,UAAU,EAAE,GAAG;;AAIvB,oCAAqC;EAGzB,iDAAM;IACF,OAAO,EAAE,uBAAuB;IAChC,KAAK,EAAE,gBAAgB;EAG3B,mDAAQ;IACJ,OAAO,EAAE,OAAO;IAChB,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,GAAG;EAIxB,uCAAgB;IACZ,UAAU,EAAE,GAAG",
|
||||
"sources": ["field_border.scss"],
|
||||
"names": [],
|
||||
"file": "field_border.css"
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
Field Border (border)
|
||||
*/
|
||||
|
||||
/*global redux_change, wp, redux*/
|
||||
|
||||
(function( $ ) {
|
||||
"use strict";
|
||||
|
||||
redux.field_objects = redux.field_objects || {};
|
||||
redux.field_objects.border = redux.field_objects.border || {};
|
||||
|
||||
redux.field_objects.border.init = function( selector ) {
|
||||
if ( !selector ) {
|
||||
selector = $( document ).find( ".redux-group-tab:visible" ).find( '.redux-container-border:visible' );
|
||||
}
|
||||
|
||||
$( selector ).each(
|
||||
function() {
|
||||
var el = $( this );
|
||||
var parent = el;
|
||||
|
||||
if ( !el.hasClass( 'redux-field-container' ) ) {
|
||||
parent = el.parents( '.redux-field-container:first' );
|
||||
}
|
||||
if ( parent.is( ":hidden" ) ) { // Skip hidden fields
|
||||
return;
|
||||
}
|
||||
if ( parent.hasClass( 'redux-field-init' ) ) {
|
||||
parent.removeClass( 'redux-field-init' );
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
el.find( ".redux-border-top, .redux-border-right, .redux-border-bottom, .redux-border-left, .redux-border-all" ).numeric(
|
||||
{
|
||||
allowMinus: false
|
||||
}
|
||||
);
|
||||
|
||||
var default_params = {
|
||||
triggerChange: true,
|
||||
allowClear: true
|
||||
};
|
||||
|
||||
var select2_handle = el.find( '.redux-container-border' ).find( '.select2_params' );
|
||||
|
||||
if ( select2_handle.size() > 0 ) {
|
||||
var select2_params = select2_handle.val();
|
||||
|
||||
select2_params = JSON.parse( select2_params );
|
||||
default_params = $.extend( {}, default_params, select2_params );
|
||||
}
|
||||
|
||||
el.find( ".redux-border-style" ).select2( default_params );
|
||||
|
||||
el.find( '.redux-border-input' ).on(
|
||||
'change', function() {
|
||||
var units = $( this ).parents( '.redux-field:first' ).find( '.field-units' ).val();
|
||||
if ( $( this ).parents( '.redux-field:first' ).find( '.redux-border-units' ).length !== 0 ) {
|
||||
units = $( this ).parents( '.redux-field:first' ).find( '.redux-border-units option:selected' ).val();
|
||||
}
|
||||
var value = $( this ).val();
|
||||
if ( typeof units !== 'undefined' && value ) {
|
||||
value += units;
|
||||
}
|
||||
if ( $( this ).hasClass( 'redux-border-all' ) ) {
|
||||
$( this ).parents( '.redux-field:first' ).find( '.redux-border-value' ).each(
|
||||
function() {
|
||||
$( this ).val( value );
|
||||
}
|
||||
);
|
||||
} else {
|
||||
$( '#' + $( this ).attr( 'rel' ) ).val( value );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
el.find( '.redux-border-units' ).on(
|
||||
'change', function() {
|
||||
$( this ).parents( '.redux-field:first' ).find( '.redux-border-input' ).change();
|
||||
}
|
||||
);
|
||||
|
||||
el.find( '.redux-color-init' ).wpColorPicker(
|
||||
{
|
||||
change: function( e, ui ) {
|
||||
$( this ).val( ui.color.toString() );
|
||||
redux_change( $( this ) );
|
||||
el.find( '#' + e.target.getAttribute( 'data-id' ) + '-transparency' ).removeAttr( 'checked' );
|
||||
},
|
||||
|
||||
clear: function( e, ui ) {
|
||||
$( this ).val( ui.color.toString() );
|
||||
redux_change( $( this ).parent().find( '.redux-color-init' ) );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
el.find( '.redux-color' ).on(
|
||||
'keyup', function() {
|
||||
var color = colorValidate( this );
|
||||
|
||||
if ( color && color !== $( this ).val() ) {
|
||||
$( this ).val( color );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Replace and validate field on blur
|
||||
el.find( '.redux-color' ).on(
|
||||
'blur', function() {
|
||||
var value = $( this ).val();
|
||||
|
||||
if ( colorValidate( this ) === value ) {
|
||||
if ( value.indexOf( "#" ) !== 0 ) {
|
||||
$( this ).val( $( this ).data( 'oldcolor' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Store the old valid color on keydown
|
||||
el.find( '.redux-color' ).on(
|
||||
'keydown', function() {
|
||||
$( this ).data( 'oldkeypress', $( this ).val() );
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
})( jQuery );
|
||||
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/border/field_border.min.js
vendored
Normal file
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/border/field_border.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(n){"use strict";redux.field_objects=redux.field_objects||{},redux.field_objects.border=redux.field_objects.border||{},redux.field_objects.border.init=function(e){e||(e=n(document).find(".redux-group-tab:visible").find(".redux-container-border:visible")),n(e).each(function(){var i=n(this),e=i;if(i.hasClass("redux-field-container")||(e=i.parents(".redux-field-container:first")),!e.is(":hidden")&&e.hasClass("redux-field-init")){e.removeClass("redux-field-init"),i.find(".redux-border-top, .redux-border-right, .redux-border-bottom, .redux-border-left, .redux-border-all").numeric({allowMinus:!1});var r={triggerChange:!0,allowClear:!0},d=i.find(".redux-container-border").find(".select2_params");if(0<d.size()){var t=d.val();t=JSON.parse(t),r=n.extend({},r,t)}i.find(".redux-border-style").select2(r),i.find(".redux-border-input").on("change",function(){var e=n(this).parents(".redux-field:first").find(".field-units").val();0!==n(this).parents(".redux-field:first").find(".redux-border-units").length&&(e=n(this).parents(".redux-field:first").find(".redux-border-units option:selected").val());var r=n(this).val();void 0!==e&&r&&(r+=e),n(this).hasClass("redux-border-all")?n(this).parents(".redux-field:first").find(".redux-border-value").each(function(){n(this).val(r)}):n("#"+n(this).attr("rel")).val(r)}),i.find(".redux-border-units").on("change",function(){n(this).parents(".redux-field:first").find(".redux-border-input").change()}),i.find(".redux-color-init").wpColorPicker({change:function(e,r){n(this).val(r.color.toString()),redux_change(n(this)),i.find("#"+e.target.getAttribute("data-id")+"-transparency").removeAttr("checked")},clear:function(e,r){n(this).val(r.color.toString()),redux_change(n(this).parent().find(".redux-color-init"))}}),i.find(".redux-color").on("keyup",function(){var e=colorValidate(this);e&&e!==n(this).val()&&n(this).val(e)}),i.find(".redux-color").on("blur",function(){var e=n(this).val();colorValidate(this)===e&&0!==e.indexOf("#")&&n(this).val(n(this).data("oldcolor"))}),i.find(".redux-color").on("keydown",function(){n(this).data("oldkeypress",n(this).val())})}})}}(jQuery);
|
||||
@@ -0,0 +1,323 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Redux Framework is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* any later version.
|
||||
* Redux Framework is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package Redux_Field
|
||||
* @subpackage Border
|
||||
* @version 3.0.0
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Don't duplicate me!
|
||||
if ( ! class_exists( 'ReduxFramework_border' ) ) {
|
||||
|
||||
class ReduxFramework_border {
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since ReduxFramework 1.0.0
|
||||
*/
|
||||
function __construct( $field = array(), $value = '', $parent ) {
|
||||
|
||||
$this->parent = $parent;
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
} //function
|
||||
|
||||
private function stripAlphas($s) {
|
||||
|
||||
// Regex is our friend. THERE ARE FOUR LIGHTS!!
|
||||
return preg_replace('/[^\d.-]/', '', $s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since ReduxFramework 1.0.0
|
||||
*/
|
||||
function render() {
|
||||
|
||||
// No errors please
|
||||
$defaults = array(
|
||||
'top' => true,
|
||||
'bottom' => true,
|
||||
'all' => true,
|
||||
'style' => true,
|
||||
'color' => true,
|
||||
'left' => true,
|
||||
'right' => true,
|
||||
);
|
||||
|
||||
$this->field = wp_parse_args( $this->field, $defaults );
|
||||
|
||||
$defaults = array(
|
||||
'top' => '',
|
||||
'right' => '',
|
||||
'bottom' => '',
|
||||
'left' => '',
|
||||
'color' => '',
|
||||
'style' => '',
|
||||
);
|
||||
|
||||
$this->value = wp_parse_args( $this->value, $defaults );
|
||||
|
||||
$value = array(
|
||||
'top' => isset( $this->value['border-top'] ) ? filter_var( $this->value['border-top'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['top'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
|
||||
'right' => isset( $this->value['border-right'] ) ? filter_var( $this->value['border-right'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['right'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
|
||||
'bottom' => isset( $this->value['border-bottom'] ) ? filter_var( $this->value['border-bottom'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['bottom'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
|
||||
'left' => isset( $this->value['border-left'] ) ? filter_var( $this->value['border-left'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : filter_var( $this->value['left'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ),
|
||||
'color' => isset( $this->value['border-color'] ) ? $this->value['border-color'] : $this->value['color'],
|
||||
'style' => isset( $this->value['border-style'] ) ? $this->value['border-style'] : $this->value['style']
|
||||
);
|
||||
|
||||
if ( ( isset( $this->value['width'] ) || isset( $this->value['border-width'] ) ) ) {
|
||||
if ( isset( $this->value['border-width'] ) && ! empty( $this->value['border-width'] ) ) {
|
||||
$this->value['width'] = $this->value['border-width'];
|
||||
}
|
||||
|
||||
$this->value['width'] = $this->stripAlphas($this->value['width']);
|
||||
|
||||
$value['top'] = $this->value['width'];
|
||||
$value['right'] = $this->value['width'];
|
||||
$value['bottom'] = $this->value['width'];
|
||||
$value['left'] = $this->value['width'];
|
||||
}
|
||||
|
||||
$this->value = $value;
|
||||
|
||||
$defaults = array(
|
||||
'top' => '',
|
||||
'right' => '',
|
||||
'bottom' => '',
|
||||
'left' => '',
|
||||
);
|
||||
|
||||
$this->value = wp_parse_args( $this->value, $defaults );
|
||||
|
||||
if ( isset( $this->field['select2'] ) ) { // if there are any let's pass them to js
|
||||
$select2_params = json_encode( $this->field['select2'] );
|
||||
$select2_params = htmlspecialchars( $select2_params, ENT_QUOTES );
|
||||
|
||||
echo '<input type="hidden" class="select2_params" value="' . $select2_params . '">';
|
||||
}
|
||||
|
||||
|
||||
echo '<input type="hidden" class="field-units" value="px">';
|
||||
|
||||
if ( isset( $this->field['all'] ) && $this->field['all'] == true ) {
|
||||
echo '<div class="field-border-input input-prepend"><span class="add-on"><i class="el el-fullscreen icon-large"></i></span><input type="text" class="redux-border-all redux-border-input mini ' . $this->field['class'] . '" placeholder="' . __( 'All', 'redux-framework' ) . '" rel="' . $this->field['id'] . '-all" value="' . $this->value['top'] . '"></div>';
|
||||
}
|
||||
|
||||
echo '<input type="hidden" class="redux-border-value" id="' . $this->field['id'] . '-top" name="' . $this->field['name'] . $this->field['name_suffix'] . '[border-top]" value="' . ( isset($this->value['top']) && $this->value['top'] != '' ? $this->value['top'] . 'px' : '' ) . '">';
|
||||
echo '<input type="hidden" class="redux-border-value" id="' . $this->field['id'] . '-right" name="' . $this->field['name'] . $this->field['name_suffix'] . '[border-right]" value="' . ( isset($this->value['right']) && $this->value['right'] != '' ? $this->value['right'] . 'px' : '' ) . '">';
|
||||
echo '<input type="hidden" class="redux-border-value" id="' . $this->field['id'] . '-bottom" name="' . $this->field['name'] . $this->field['name_suffix'] . '[border-bottom]" value="' . ( isset($this->value['bottom']) && $this->value['bottom'] != '' ? $this->value['bottom'] . 'px' : '' ) . '">';
|
||||
echo '<input type="hidden" class="redux-border-value" id="' . $this->field['id'] . '-left" name="' . $this->field['name'] . $this->field['name_suffix'] . '[border-left]" value="' . ( isset($this->value['left']) && $this->value['left'] != '' ? $this->value['left'] . 'px' : '' ) . '">';
|
||||
|
||||
if ( ! isset( $this->field['all'] ) || $this->field['all'] !== true ) {
|
||||
/**
|
||||
* Top
|
||||
* */
|
||||
if ( $this->field['top'] === true ) {
|
||||
echo '<div class="field-border-input input-prepend"><span class="add-on"><i class="el el-arrow-up icon-large"></i></span><input type="text" class="redux-border-top redux-border-input mini ' . $this->field['class'] . '" placeholder="' . __( 'Top', 'redux-framework' ) . '" rel="' . $this->field['id'] . '-top" value="' . $this->value['top'] . '"></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Right
|
||||
* */
|
||||
if ( $this->field['right'] === true ) {
|
||||
echo '<div class="field-border-input input-prepend"><span class="add-on"><i class="el el-arrow-right icon-large"></i></span><input type="text" class="redux-border-right redux-border-input mini ' . $this->field['class'] . '" placeholder="' . __( 'Right', 'redux-framework' ) . '" rel="' . $this->field['id'] . '-right" value="' . $this->value['right'] . '"></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Bottom
|
||||
* */
|
||||
if ( $this->field['bottom'] === true ) {
|
||||
echo '<div class="field-border-input input-prepend"><span class="add-on"><i class="el el-arrow-down icon-large"></i></span><input type="text" class="redux-border-bottom redux-border-input mini ' . $this->field['class'] . '" placeholder="' . __( 'Bottom', 'redux-framework' ) . '" rel="' . $this->field['id'] . '-bottom" value="' . $this->value['bottom'] . '"></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Left
|
||||
* */
|
||||
if ( $this->field['left'] === true ) {
|
||||
echo '<div class="field-border-input input-prepend"><span class="add-on"><i class="el el-arrow-left icon-large"></i></span><input type="text" class="redux-border-left redux-border-input mini ' . $this->field['class'] . '" placeholder="' . __( 'Left', 'redux-framework' ) . '" rel="' . $this->field['id'] . '-left" value="' . $this->value['left'] . '"></div>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Border-style
|
||||
* */
|
||||
if ( $this->field['style'] != false ) {
|
||||
$options = array(
|
||||
'solid' => 'Solid',
|
||||
'dashed' => 'Dashed',
|
||||
'dotted' => 'Dotted',
|
||||
'double' => "Double",
|
||||
'none' => 'None'
|
||||
);
|
||||
echo '<select original-title="' . __( 'Border style', 'redux-framework' ) . '" id="' . $this->field['id'] . '[border-style]" name="' . $this->field['name'] . $this->field['name_suffix'] . '[border-style]" class="tips redux-border-style ' . $this->field['class'] . '" rows="6" data-id="' . $this->field['id'] . '">';
|
||||
foreach ( $options as $k => $v ) {
|
||||
echo '<option value="' . $k . '"' . selected( $value['style'], $k, false ) . '>' . $v . '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
} else {
|
||||
echo '<input type="hidden" id="' . $this->field['id'] . '[border-style]" name="' . $this->field['name'] . $this->field['name_suffix'] . '[border-style]" value="' . $this->value['style'] . '" data-id="' . $this->field['id'] . '">';
|
||||
}
|
||||
|
||||
/**
|
||||
* Color
|
||||
* */
|
||||
if ( $this->field['color'] != false ) {
|
||||
$default = isset( $this->field['default']['border-color'] ) ? $this->field['default']['border-color'] : '';
|
||||
|
||||
|
||||
if ( empty( $default ) ) {
|
||||
$default = ( isset( $this->field['default']['color'] ) ) ? $this->field['default']['color'] : '#ffffff';
|
||||
}
|
||||
|
||||
echo '<input name="' . $this->field['name'] . $this->field['name_suffix'] . '[border-color]" id="' . $this->field['id'] . '-border" class="redux-border-color redux-color redux-color-init ' . $this->field['class'] . '" type="text" value="' . $this->value['color'] . '" data-default-color="' . $default . '" data-id="' . $this->field['id'] . '" />';
|
||||
} else {
|
||||
echo '<input type="hidden" id="' . $this->field['id'] . '[border-color]" name="' . $this->field['name'] . $this->field['name_suffix'] . '[border-color]" value="' . $this->value['color'] . '" data-id="' . $this->field['id'] . '">';
|
||||
}
|
||||
}
|
||||
|
||||
//function
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since ReduxFramework 1.0.0
|
||||
*/
|
||||
function enqueue() {
|
||||
$min = Redux_Functions::isMin();
|
||||
|
||||
if (!wp_style_is ( 'select2-css' )) {
|
||||
wp_enqueue_style( 'select2-css' );
|
||||
}
|
||||
|
||||
if (!wp_style_is ( 'wp-color-picker' )) {
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
}
|
||||
|
||||
if (!wp_script_is ( 'redux-field-border-js' )) {
|
||||
wp_enqueue_script(
|
||||
'redux-field-border-js',
|
||||
ReduxFramework::$_url . 'inc/fields/border/field_border' . $min . '.js',
|
||||
array( 'jquery', 'select2-js', 'wp-color-picker', 'redux-js' ),
|
||||
time(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->parent->args['dev_mode']) {
|
||||
if (!wp_style_is ( 'redux-color-picker-css' )) {
|
||||
wp_enqueue_style( 'redux-color-picker-css' );
|
||||
}
|
||||
|
||||
if (!wp_style_is ( 'redux-field-border-css' )) {
|
||||
wp_enqueue_style(
|
||||
'redux-field-border-css',
|
||||
ReduxFramework::$_url . 'inc/fields/border/field_border.css',
|
||||
array(),
|
||||
time(),
|
||||
'all'
|
||||
);
|
||||
}
|
||||
}
|
||||
} //function
|
||||
|
||||
public function output() {
|
||||
if ( isset( $this->field['all'] ) && true == $this->field['all'] ) {
|
||||
$borderWidth = isset( $this->value['border-width'] ) ? $this->value['border-width'] : '0px';
|
||||
$val = isset( $this->value['border-top'] ) ? $this->value['border-top'] : $borderWidth;
|
||||
|
||||
$this->value['border-top'] = $val;
|
||||
$this->value['border-bottom'] = $val;
|
||||
$this->value['border-left'] = $val;
|
||||
$this->value['border-right'] = $val;
|
||||
}
|
||||
|
||||
$cleanValue = array(
|
||||
'color' => ! empty( $this->value['border-color'] ) ? $this->value['border-color'] : '',
|
||||
'style' => ! empty( $this->value['border-style'] ) ? $this->value['border-style'] : ''
|
||||
);
|
||||
|
||||
$borderWidth = '';
|
||||
if ( isset( $this->value['border-width'] ) ) {
|
||||
$borderWidth = $this->value['border-width'];
|
||||
}
|
||||
|
||||
$this->field['top'] = isset( $this->field['top'] ) ? $this->field['top'] : true;
|
||||
$this->field['bottom'] = isset( $this->field['bottom'] ) ? $this->field['bottom'] : true;
|
||||
$this->field['left'] = isset( $this->field['left'] ) ? $this->field['left'] : true;
|
||||
$this->field['right'] = isset( $this->field['right'] ) ? $this->field['right'] : true;
|
||||
|
||||
if ( $this->field['top'] === true ) {
|
||||
$cleanValue['top'] = ! empty( $this->value['border-top'] ) ? $this->value['border-top'] : $borderWidth;
|
||||
}
|
||||
|
||||
if ( $this->field['bottom'] == true ) {
|
||||
$cleanValue['bottom'] = ! empty( $this->value['border-bottom'] ) ? $this->value['border-bottom'] : $borderWidth;
|
||||
}
|
||||
|
||||
if ( $this->field['left'] === true ) {
|
||||
$cleanValue['left'] = ! empty( $this->value['border-left'] ) ? $this->value['border-left'] : $borderWidth;
|
||||
}
|
||||
|
||||
if ( $this->field['right'] === true ) {
|
||||
$cleanValue['right'] = ! empty( $this->value['border-right'] ) ? $this->value['border-right'] : $borderWidth;
|
||||
}
|
||||
|
||||
$style = "";
|
||||
|
||||
//absolute, padding, margin
|
||||
if ( ! isset( $this->field['all'] ) || $this->field['all'] != true ) {
|
||||
foreach ( $cleanValue as $key => $value ) {
|
||||
if ( $key == "color" || $key == "style" ) {
|
||||
continue;
|
||||
}
|
||||
if (!empty($value)) {
|
||||
$style .= 'border-' . $key . ':' . $value . ' ' . $cleanValue['style'] . ' ' . $cleanValue['color'] . ';';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!empty($cleanValue['top'])) {
|
||||
$style .= 'border:' . $cleanValue['top'] . ' ' . $cleanValue['style'] . ' ' . $cleanValue['color'] . ';';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $this->field['output'] ) && is_array( $this->field['output'] ) ) {
|
||||
$keys = implode( ",", $this->field['output'] );
|
||||
|
||||
if (!empty($style)) {
|
||||
$this->parent->outputCSS .= $keys . "{" . $style . '}';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $this->field['compiler'] ) && is_array( $this->field['compiler'] ) ) {
|
||||
$keys = implode( ",", $this->field['compiler'] );
|
||||
|
||||
if (!empty($style)) {
|
||||
$this->parent->compilerCSS .= $keys . "{" . $style . '}';
|
||||
}
|
||||
}
|
||||
}
|
||||
} //class
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
.redux-container-border {
|
||||
.select2-container {
|
||||
float: left;
|
||||
display: block;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.select_wrapper {
|
||||
float: left;
|
||||
select {
|
||||
width: 80px;
|
||||
float: left;
|
||||
|
||||
}
|
||||
width: inherit;
|
||||
}
|
||||
|
||||
.field-border-input {
|
||||
margin-right: 10px;
|
||||
margin-bottom: 7px;
|
||||
}
|
||||
|
||||
.wp-picker-container {
|
||||
margin-top: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 782px) {
|
||||
.redux-container-border {
|
||||
.field-border-input {
|
||||
input {
|
||||
display: inline-block !important;
|
||||
width: 100px !important;
|
||||
}
|
||||
|
||||
.add-on {
|
||||
padding: 7px 4px;
|
||||
font-size: 16px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
.select_wrapper {
|
||||
margin-top: 6px;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
Field Button Set (button_set)
|
||||
*/
|
||||
|
||||
/*global jQuery, document, redux*/
|
||||
|
||||
(function( $ ) {
|
||||
"use strict";
|
||||
|
||||
redux.field_objects = redux.field_objects || {};
|
||||
redux.field_objects.button_set = redux.field_objects.button_set || {};
|
||||
|
||||
$( document ).ready(
|
||||
function() {
|
||||
if ( $.fn.button.noConflict !== undefined ) {
|
||||
var btn = $.fn.button.noConflict();
|
||||
$.fn.btn = btn;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
redux.field_objects.button_set.init = function( selector ) {
|
||||
if ( !selector ) {
|
||||
selector = $( document ).find( ".redux-group-tab:visible" ).find( '.redux-container-button_set:visible' );
|
||||
}
|
||||
|
||||
$( selector ).each(
|
||||
function() {
|
||||
var el = $( this );
|
||||
var parent = el;
|
||||
|
||||
if ( !el.hasClass( 'redux-field-container' ) ) {
|
||||
parent = el.parents( '.redux-field-container:first' );
|
||||
}
|
||||
|
||||
if ( parent.is( ":hidden" ) ) { // Skip hidden fields
|
||||
return;
|
||||
}
|
||||
|
||||
if ( parent.hasClass( 'redux-field-init' ) ) {
|
||||
parent.removeClass( 'redux-field-init' );
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
el.find( '.buttonset' ).each(
|
||||
function() {
|
||||
if ( $( this ).is( ':checkbox' ) ) {
|
||||
$( this ).find( '.buttonset-item' ).button();
|
||||
}
|
||||
|
||||
$( this ).buttonset();
|
||||
}
|
||||
);
|
||||
|
||||
el.find( '.buttonset-item.multi' ).on(
|
||||
'click', function( e ) {
|
||||
var val = '';
|
||||
var name = '';
|
||||
|
||||
var id = $(this).attr('id');
|
||||
var empty = $( this ).parent().find( '.buttonset-empty' );
|
||||
var idName = empty.attr( 'data-name' );
|
||||
var isChecked = false;
|
||||
|
||||
$( this ).parent().find('.buttonset-item').each(function(){
|
||||
if ($( this ).is( ':checked' )) {
|
||||
isChecked = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (isChecked) {
|
||||
empty.attr('name', '');
|
||||
} else {
|
||||
empty.attr('name', idName);
|
||||
}
|
||||
|
||||
if ( $( this ).is( ':checked' ) ) {
|
||||
val = $( this ).attr( 'data-val' );
|
||||
name = idName + '[]';
|
||||
|
||||
}
|
||||
|
||||
$( this ).parent().find( '#' + id + '-hidden.buttonset-check' ).val( val );
|
||||
$( this ).parent().find( '#' + id + '-hidden.buttonset-check' ).attr( 'name', name );
|
||||
|
||||
redux_change( $( this ) );
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
})( jQuery );
|
||||
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/button_set/field_button_set.min.js
vendored
Normal file
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/button_set/field_button_set.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(u){"use strict";redux.field_objects=redux.field_objects||{},redux.field_objects.button_set=redux.field_objects.button_set||{},u(document).ready(function(){if(void 0!==u.fn.button.noConflict){var t=u.fn.button.noConflict();u.fn.btn=t}}),redux.field_objects.button_set.init=function(t){t||(t=u(document).find(".redux-group-tab:visible").find(".redux-container-button_set:visible")),u(t).each(function(){var t=u(this),e=t;t.hasClass("redux-field-container")||(e=t.parents(".redux-field-container:first")),e.is(":hidden")||e.hasClass("redux-field-init")&&(e.removeClass("redux-field-init"),t.find(".buttonset").each(function(){u(this).is(":checkbox")&&u(this).find(".buttonset-item").button(),u(this).buttonset()}),t.find(".buttonset-item.multi").on("click",function(t){var e="",n="",i=u(this).attr("id"),s=u(this).parent().find(".buttonset-empty"),d=s.attr("data-name"),o=!1;u(this).parent().find(".buttonset-item").each(function(){u(this).is(":checked")&&(o=!0)}),o?s.attr("name",""):s.attr("name",d),u(this).is(":checked")&&(e=u(this).attr("data-val"),n=d+"[]"),u(this).parent().find("#"+i+"-hidden.buttonset-check").val(e),u(this).parent().find("#"+i+"-hidden.buttonset-check").attr("name",n),redux_change(u(this))}))})}}(jQuery);
|
||||
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Redux Framework is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* any later version.
|
||||
* Redux Framework is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package Redux_Field
|
||||
* @subpackage Button_Set
|
||||
* @author Daniel J Griffiths (Ghost1227)
|
||||
* @author Dovy Paukstys
|
||||
* @author Kevin Provance (kprovance)
|
||||
* @version 3.0.0
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Don't duplicate me!
|
||||
if ( ! class_exists( 'ReduxFramework_button_set' ) ) {
|
||||
|
||||
/**
|
||||
* Main ReduxFramework_button_set class
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ReduxFramework_button_set {
|
||||
|
||||
/**
|
||||
* Holds configuration settings for each field in a model.
|
||||
* Defining the field options
|
||||
* @param array $arr (See above)
|
||||
*
|
||||
* @return Object A new editor object.
|
||||
* */
|
||||
static $_properties = array(
|
||||
'id' => 'Identifier',
|
||||
);
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function __construct( $field = array(), $value = '', $parent ) {
|
||||
|
||||
$this->parent = $parent;
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function render() {
|
||||
if ( !empty( $this->field['data'] ) && empty( $this->field['options'] ) ) {
|
||||
if ( empty( $this->field['args'] ) ) {
|
||||
$this->field['args'] = array();
|
||||
}
|
||||
|
||||
$this->field['options'] = $this->parent->get_wordpress_data( $this->field['data'], $this->field['args'] );
|
||||
|
||||
if ( empty( $this->field['options'] ) ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$is_multi = (isset( $this->field['multi'] ) && $this->field['multi'] == true) ? true: false;
|
||||
|
||||
$name = $this->field['name'] . $this->field['name_suffix'];
|
||||
|
||||
// multi => true renders the field multi-selectable (checkbox vs radio)
|
||||
echo '<div class="buttonset ui-buttonset">';
|
||||
|
||||
if ($is_multi) {
|
||||
$s = '';
|
||||
|
||||
if (empty($this->value)) {
|
||||
$s = $name;
|
||||
}
|
||||
|
||||
echo '<input type="hidden" data-name="' . $name . '" class="buttonset-empty" name="' . $s . '" value=""/>';
|
||||
|
||||
$name = $name . '[]';
|
||||
}
|
||||
|
||||
foreach ( $this->field['options'] as $k => $v ) {
|
||||
$selected = '';
|
||||
|
||||
if ( $is_multi ) {
|
||||
$post_value = '';
|
||||
$type = "checkbox";
|
||||
|
||||
if ( ! empty( $this->value ) && ! is_array( $this->value ) ) {
|
||||
$this->value = array( $this->value );
|
||||
}
|
||||
|
||||
if ( is_array( $this->value ) && in_array( $k, $this->value ) ) {
|
||||
$selected = 'checked="checked"';
|
||||
$post_value = $k;
|
||||
}
|
||||
} else {
|
||||
$type = "radio";
|
||||
|
||||
if ( is_scalar( $this->value ) ) {
|
||||
$selected = checked( $this->value, $k, false );
|
||||
}
|
||||
}
|
||||
|
||||
$the_val = $k;
|
||||
$the_name = $name;
|
||||
$data_val = '';
|
||||
$multi_class = '';
|
||||
|
||||
if ($is_multi) {
|
||||
$the_val = '';
|
||||
$the_name = '';
|
||||
$data_val = ' data-val="' . $k . '"';
|
||||
$hidden_name = $name;
|
||||
$multi_class = 'multi ';
|
||||
|
||||
if ($post_value == '') {
|
||||
$hidden_name = '';
|
||||
}
|
||||
|
||||
echo '<input type="hidden" class="buttonset-check" id="' . $this->field['id'] . '-buttonset' . $k . '-hidden" name="' .$hidden_name . '" value="' . $post_value . '"/>';
|
||||
}
|
||||
|
||||
echo '<input' . $data_val . ' data-id="' . $this->field['id'] . '" type="' . $type . '" id="' . $this->field['id'] . '-buttonset' . $k . '" name="' . $the_name . '" class="buttonset-item ' . $multi_class . $this->field['class'] . '" value="' . $the_val . '" ' . $selected . '/>';
|
||||
echo '<label for="' . $this->field['id'] . '-buttonset' . $k . '">' . $v . '</label>';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {
|
||||
|
||||
if (!wp_script_is ( 'redux-field-button-set-js' )) {
|
||||
wp_enqueue_script(
|
||||
'redux-field-button-set-js',
|
||||
ReduxFramework::$_url . 'inc/fields/button_set/field_button_set' . Redux_Functions::isMin() . '.js',
|
||||
array( 'jquery', 'jquery-ui-core', 'redux-js' ),
|
||||
time(),
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
.redux-container-checkbox label{vertical-align:top;width:100%}.redux-container-checkbox label .field-desc{margin-top:0;float:left;width:93%;clear:none}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"mappings": "AACI,+BAAM;EACF,cAAc,EAAE,GAAG;EACnB,KAAK,EAAE,IAAI;EAEX,2CAAY;IACR,UAAU,EAAE,CAAC;IACb,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,GAAG;IACV,KAAK,EAAE,IAAI",
|
||||
"sources": ["field_checkbox.scss"],
|
||||
"names": [],
|
||||
"file": "field_checkbox.css"
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Redux Checkbox
|
||||
* Dependencies : jquery
|
||||
* Feature added by : Dovy Paukstys
|
||||
* Date : 17 June 2014
|
||||
*/
|
||||
|
||||
/*global redux_change, wp, redux*/
|
||||
|
||||
(function( $ ) {
|
||||
"use strict";
|
||||
|
||||
redux.field_objects = redux.field_objects || {};
|
||||
redux.field_objects.checkbox = redux.field_objects.checkbox || {};
|
||||
|
||||
$( document ).ready(
|
||||
function() {
|
||||
//redux.field_objects.checkbox.init();
|
||||
}
|
||||
);
|
||||
|
||||
redux.field_objects.checkbox.init = function( selector ) {
|
||||
if ( !selector ) {
|
||||
selector = $( document ).find( ".redux-group-tab:visible" ).find( '.redux-container-checkbox:visible' );
|
||||
}
|
||||
|
||||
$( selector ).each(
|
||||
function() {
|
||||
var el = $( this );
|
||||
var parent = el;
|
||||
if ( !el.hasClass( 'redux-field-container' ) ) {
|
||||
parent = el.parents( '.redux-field-container:first' );
|
||||
}
|
||||
if ( parent.is( ":hidden" ) ) { // Skip hidden fields
|
||||
return;
|
||||
}
|
||||
if ( parent.hasClass( 'redux-field-init' ) ) {
|
||||
parent.removeClass( 'redux-field-init' );
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
el.find( '.checkbox' ).on(
|
||||
'click', function( e ) {
|
||||
var val = 0;
|
||||
if ( $( this ).is( ':checked' ) ) {
|
||||
val = $( this ).parent().find( '.checkbox-check' ).attr( 'data-val' );
|
||||
}
|
||||
$( this ).parent().find( '.checkbox-check' ).val( val );
|
||||
redux_change( $( this ) );
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
})( jQuery );
|
||||
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/checkbox/field_checkbox.min.js
vendored
Normal file
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/checkbox/field_checkbox.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(c){"use strict";redux.field_objects=redux.field_objects||{},redux.field_objects.checkbox=redux.field_objects.checkbox||{},c(document).ready(function(){}),redux.field_objects.checkbox.init=function(e){e||(e=c(document).find(".redux-group-tab:visible").find(".redux-container-checkbox:visible")),c(e).each(function(){var e=c(this),i=e;e.hasClass("redux-field-container")||(i=e.parents(".redux-field-container:first")),i.is(":hidden")||i.hasClass("redux-field-init")&&(i.removeClass("redux-field-init"),e.find(".checkbox").on("click",function(e){var i=0;c(this).is(":checked")&&(i=c(this).parent().find(".checkbox-check").attr("data-val")),c(this).parent().find(".checkbox-check").val(i),redux_change(c(this))}))})}}(jQuery);
|
||||
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Redux Framework is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* any later version.
|
||||
* Redux Framework is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package ReduxFramework
|
||||
* @subpackage Field_Checkbox
|
||||
* @author Daniel J Griffiths (Ghost1227)
|
||||
* @author Dovy Paukstys
|
||||
* @version 3.0.0
|
||||
*/
|
||||
// Exit if accessed directly
|
||||
if ( !defined ( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Don't duplicate me!
|
||||
if ( !class_exists ( 'ReduxFramework_checkbox' ) ) {
|
||||
|
||||
/**
|
||||
* Main ReduxFramework_checkbox class
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ReduxFramework_checkbox {
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function __construct ( $field = array(), $value = '', $parent ) {
|
||||
|
||||
$this->parent = $parent;
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function render () {
|
||||
if( !empty( $this->field['data'] ) && empty( $this->field['options'] ) ) {
|
||||
if (empty($this->field['args'])) {
|
||||
$this->field['args'] = array();
|
||||
}
|
||||
|
||||
$this->field['options'] = $this->parent->get_wordpress_data($this->field['data'], $this->field['args']);
|
||||
if (empty($this->field['options'])) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$this->field[ 'data_class' ] = ( isset ( $this->field[ 'multi_layout' ] ) ) ? 'data-' . $this->field[ 'multi_layout' ] : 'data-full';
|
||||
|
||||
if ( !empty ( $this->field[ 'options' ] ) && ( is_array ( $this->field[ 'options' ] ) || is_array ( $this->field[ 'default' ] ) ) ) {
|
||||
|
||||
echo '<ul class="' . $this->field[ 'data_class' ] . '">';
|
||||
|
||||
if ( !isset ( $this->value ) ) {
|
||||
$this->value = array();
|
||||
}
|
||||
|
||||
if ( !is_array ( $this->value ) ) {
|
||||
$this->value = array();
|
||||
}
|
||||
|
||||
if ( empty ( $this->field[ 'options' ] ) && isset ( $this->field[ 'default' ] ) && is_array ( $this->field[ 'default' ] ) ) {
|
||||
$this->field[ 'options' ] = $this->field[ 'default' ];
|
||||
}
|
||||
|
||||
foreach ( $this->field[ 'options' ] as $k => $v ) {
|
||||
|
||||
if ( empty ( $this->value[ $k ] ) ) {
|
||||
$this->value[ $k ] = "";
|
||||
}
|
||||
|
||||
echo '<li>';
|
||||
echo '<label for="' . strtr ( $this->parent->args[ 'opt_name' ] . '[' . $this->field[ 'id' ] . '][' . $k . ']', array(
|
||||
'[' => '_',
|
||||
']' => ''
|
||||
) ) . '_' . array_search ( $k, array_keys ( $this->field[ 'options' ] ) ) . '">';
|
||||
echo '<input type="hidden" class="checkbox-check" data-val="1" name="' . $this->field[ 'name' ] . '[' . $k . ']' . $this->field[ 'name_suffix' ] . '" value="' . $this->value[ $k ] . '" ' . '/>';
|
||||
echo '<input type="checkbox" class="checkbox ' . $this->field[ 'class' ] . '" id="' . strtr ( $this->parent->args[ 'opt_name' ] . '[' . $this->field[ 'id' ] . '][' . $k . ']', array(
|
||||
'[' => '_',
|
||||
']' => ''
|
||||
) ) . '_' . array_search ( $k, array_keys ( $this->field[ 'options' ] ) ) . '" value="1" ' . checked ( $this->value[ $k ], '1', false ) . '/>';
|
||||
echo ' ' . $v . '</label>';
|
||||
echo '</li>';
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
} else if ( empty ( $this->field[ 'data' ] ) ) {
|
||||
echo '<ul class="data-full"><li>';
|
||||
|
||||
if ( !empty( $this->field[ 'label' ] ) ) {
|
||||
echo '<label>';
|
||||
}
|
||||
|
||||
// Got the "Checked" status as "0" or "1" then insert it as the "value" option
|
||||
//$ch_value = 1; // checked($this->value, '1', false) == "" ? "0" : "1";
|
||||
echo '<input type="hidden" class="checkbox-check" data-val="1" name="' . $this->field[ 'name' ] . $this->field[ 'name_suffix' ] . '" value="' . $this->value . '" ' . '/>';
|
||||
echo '<input type="checkbox" id="' . strtr ( $this->parent->args[ 'opt_name' ] . '[' . $this->field[ 'id' ] . ']', array(
|
||||
'[' => '_',
|
||||
']' => ''
|
||||
) ) . '" value="1" class="checkbox ' . $this->field[ 'class' ] . '" ' . checked ( $this->value, '1', false ) . '/>';
|
||||
|
||||
if ( !empty( $this->field[ 'label' ] ) ) {
|
||||
echo ' ' . $this->field[ 'label' ];
|
||||
echo '</label>';
|
||||
}
|
||||
|
||||
echo '</li></ul>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue () {
|
||||
|
||||
if ($this->parent->args['dev_mode']) {
|
||||
wp_enqueue_style (
|
||||
'redux-field-checkbox-css',
|
||||
ReduxFramework::$_url . 'inc/fields/checkbox/field_checkbox.css',
|
||||
array(),
|
||||
time (),
|
||||
'all'
|
||||
);
|
||||
}
|
||||
|
||||
wp_enqueue_script (
|
||||
'redux-field-checkbox-js',
|
||||
ReduxFramework::$_url . 'inc/fields/checkbox/field_checkbox' . Redux_Functions::isMin () . '.js',
|
||||
array( 'jquery', 'redux-js' ),
|
||||
time (),
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
.redux-container-checkbox {
|
||||
label {
|
||||
vertical-align: top;
|
||||
width: 100%;
|
||||
|
||||
.field-desc {
|
||||
margin-top: 0;
|
||||
float: left;
|
||||
width: 93%;
|
||||
clear: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
Field Color (color)
|
||||
*/
|
||||
|
||||
/*global jQuery, document, redux_change, redux*/
|
||||
|
||||
(function( $ ) {
|
||||
'use strict';
|
||||
|
||||
redux.field_objects = redux.field_objects || {};
|
||||
redux.field_objects.color = redux.field_objects.color || {};
|
||||
|
||||
$( document ).ready(
|
||||
function() {
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
redux.field_objects.color.init = function( selector ) {
|
||||
|
||||
if ( !selector ) {
|
||||
selector = $( document ).find( ".redux-group-tab:visible" ).find( '.redux-container-color:visible' );
|
||||
}
|
||||
|
||||
$( selector ).each(
|
||||
function() {
|
||||
|
||||
var el = $( this );
|
||||
var parent = el;
|
||||
|
||||
if ( !el.hasClass( 'redux-field-container' ) ) {
|
||||
parent = el.parents( '.redux-field-container:first' );
|
||||
}
|
||||
if ( parent.is( ":hidden" ) ) { // Skip hidden fields
|
||||
return;
|
||||
}
|
||||
if ( parent.hasClass( 'redux-field-init' ) ) {
|
||||
parent.removeClass( 'redux-field-init' );
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
// var $control = el.find( '.redux-color-init' ),
|
||||
//
|
||||
// value = $control.val().replace( /\s+/g, '' ),
|
||||
// alpha_val = 100,
|
||||
// $alpha, $alpha_output;
|
||||
// //console.log($control);
|
||||
// if ( value.match( /rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/ ) ) {
|
||||
// alpha_val = parseFloat( value.match( /rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/ )[ 1 ] ) * 100;
|
||||
// }
|
||||
el.find( '.redux-color-init' ).wpColorPicker(
|
||||
{
|
||||
change: function( e, ui ) {
|
||||
$( this ).val( ui.color.toString() );
|
||||
redux_change( $( this ) );
|
||||
el.find( '#' + e.target.getAttribute( 'data-id' ) + '-transparency' ).removeAttr( 'checked' );
|
||||
},
|
||||
clear: function( e, ui ) {
|
||||
$( this ).val( '' );
|
||||
redux_change( $( this ).parent().find( '.redux-color-init' ) );
|
||||
}
|
||||
}
|
||||
);
|
||||
// $( '<div class="redux-alpha-container">'
|
||||
// + '<label>Alpha: <output class="rangevalue">' + alpha_val + '%</output></label>'
|
||||
// + '<input type="range" min="1" max="100" value="' + alpha_val + '" name="alpha" class="vc_alpha-field">'
|
||||
// + '</div>' ).appendTo( $control.parents( '.wp-picker-container:first' ).addClass( 'vc_color-picker' ).find( '.iris-picker' ) );
|
||||
// $alpha = $control.parents( '.wp-picker-container:first' ).find( '.vc_alpha-field' );
|
||||
// //console.log($alpha);
|
||||
// $alpha_output = $control.parents( '.wp-picker-container:first' ).find( '.redux-alpha-container output' );
|
||||
// $alpha.bind( 'change keyup', function () {
|
||||
// var alpha_val = parseFloat( $alpha.val() ),
|
||||
// iris = $control.data( 'a8cIris' ),
|
||||
// color_picker = $control.data( 'wp-wpColorPicker' );
|
||||
// //console.log(alpha_val);
|
||||
// $alpha_output.val( $alpha.val() + '%' );
|
||||
// console.log(alpha_val / 100.0);
|
||||
// iris._color._alpha = parseFloat(alpha_val / 100.0);
|
||||
// console.log(iris._color);
|
||||
// //$control.val( iris._color.toString() );
|
||||
// el.find( '.redux-color-init' ).wpColorPicker( 'color', iris._color.toString() );
|
||||
// //console.log($control.val());
|
||||
// //color_picker.toggler.css( { backgroundColor: $control.val() } );
|
||||
// } ).val( alpha_val ).trigger( 'change' );
|
||||
|
||||
el.find( '.redux-color' ).on(
|
||||
'focus', function() {
|
||||
$( this ).data( 'oldcolor', $( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
el.find( '.redux-color' ).on(
|
||||
'keyup', function() {
|
||||
var value = $( this ).val();
|
||||
var color = colorValidate( this );
|
||||
var id = '#' + $( this ).attr( 'id' );
|
||||
|
||||
if ( value === "transparent" ) {
|
||||
$( this ).parent().parent().find( '.wp-color-result' ).css(
|
||||
'background-color', 'transparent'
|
||||
);
|
||||
|
||||
el.find( id + '-transparency' ).attr( 'checked', 'checked' );
|
||||
} else {
|
||||
el.find( id + '-transparency' ).removeAttr( 'checked' );
|
||||
|
||||
if ( color && color !== $( this ).val() ) {
|
||||
$( this ).val( color );
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Replace and validate field on blur
|
||||
el.find( '.redux-color' ).on(
|
||||
'blur', function() {
|
||||
var value = $( this ).val();
|
||||
var id = '#' + $( this ).attr( 'id' );
|
||||
|
||||
if ( value === "transparent" ) {
|
||||
$( this ).parent().parent().find( '.wp-color-result' ).css(
|
||||
'background-color', 'transparent'
|
||||
);
|
||||
|
||||
el.find( id + '-transparency' ).attr( 'checked', 'checked' );
|
||||
} else {
|
||||
if ( colorValidate( this ) === value ) {
|
||||
if ( value.indexOf( "#" ) !== 0 ) {
|
||||
$( this ).val( $( this ).data( 'oldcolor' ) );
|
||||
}
|
||||
}
|
||||
|
||||
el.find( id + '-transparency' ).removeAttr( 'checked' );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Store the old valid color on keydown
|
||||
el.find( '.redux-color' ).on(
|
||||
'keydown', function() {
|
||||
$( this ).data( 'oldkeypress', $( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
// When transparency checkbox is clicked
|
||||
el.find( '.color-transparency' ).on(
|
||||
'click', function() {
|
||||
if ( $( this ).is( ":checked" ) ) {
|
||||
el.find( '.redux-saved-color' ).val( $( '#' + $( this ).data( 'id' ) ).val() );
|
||||
el.find( '#' + $( this ).data( 'id' ) ).val( 'transparent' );
|
||||
el.find( '#' + $( this ).data( 'id' ) ).parent().parent().find( '.wp-color-result' ).css(
|
||||
'background-color', 'transparent'
|
||||
);
|
||||
} else {
|
||||
if ( el.find( '#' + $( this ).data( 'id' ) ).val() === 'transparent' ) {
|
||||
var prevColor = $( '.redux-saved-color' ).val();
|
||||
|
||||
if ( prevColor === '' ) {
|
||||
prevColor = $( '#' + $( this ).data( 'id' ) ).data( 'default-color' );
|
||||
}
|
||||
|
||||
el.find( '#' + $( this ).data( 'id' ) ).parent().parent().find( '.wp-color-result' ).css(
|
||||
'background-color', prevColor
|
||||
);
|
||||
|
||||
el.find( '#' + $( this ).data( 'id' ) ).val( prevColor );
|
||||
}
|
||||
}
|
||||
redux_change( $( this ) );
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
})( jQuery );
|
||||
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/color/field_color.min.js
vendored
Normal file
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/color/field_color.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(n){"use strict";redux.field_objects=redux.field_objects||{},redux.field_objects.color=redux.field_objects.color||{},n(document).ready(function(){}),redux.field_objects.color.init=function(t){t||(t=n(document).find(".redux-group-tab:visible").find(".redux-container-color:visible")),n(t).each(function(){var i=n(this),t=i;i.hasClass("redux-field-container")||(t=i.parents(".redux-field-container:first")),t.is(":hidden")||t.hasClass("redux-field-init")&&(t.removeClass("redux-field-init"),i.find(".redux-color-init").wpColorPicker({change:function(t,r){n(this).val(r.color.toString()),redux_change(n(this)),i.find("#"+t.target.getAttribute("data-id")+"-transparency").removeAttr("checked")},clear:function(t,r){n(this).val(""),redux_change(n(this).parent().find(".redux-color-init"))}}),i.find(".redux-color").on("focus",function(){n(this).data("oldcolor",n(this).val())}),i.find(".redux-color").on("keyup",function(){var t=n(this).val(),r=colorValidate(this),e="#"+n(this).attr("id");"transparent"===t?(n(this).parent().parent().find(".wp-color-result").css("background-color","transparent"),i.find(e+"-transparency").attr("checked","checked")):(i.find(e+"-transparency").removeAttr("checked"),r&&r!==n(this).val()&&n(this).val(r))}),i.find(".redux-color").on("blur",function(){var t=n(this).val(),r="#"+n(this).attr("id");"transparent"===t?(n(this).parent().parent().find(".wp-color-result").css("background-color","transparent"),i.find(r+"-transparency").attr("checked","checked")):(colorValidate(this)===t&&0!==t.indexOf("#")&&n(this).val(n(this).data("oldcolor")),i.find(r+"-transparency").removeAttr("checked"))}),i.find(".redux-color").on("keydown",function(){n(this).data("oldkeypress",n(this).val())}),i.find(".color-transparency").on("click",function(){if(n(this).is(":checked"))i.find(".redux-saved-color").val(n("#"+n(this).data("id")).val()),i.find("#"+n(this).data("id")).val("transparent"),i.find("#"+n(this).data("id")).parent().parent().find(".wp-color-result").css("background-color","transparent");else if("transparent"===i.find("#"+n(this).data("id")).val()){var t=n(".redux-saved-color").val();""===t&&(t=n("#"+n(this).data("id")).data("default-color")),i.find("#"+n(this).data("id")).parent().parent().find(".wp-color-result").css("background-color",t),i.find("#"+n(this).data("id")).val(t)}redux_change(n(this))}))})}}(jQuery);
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Redux Framework is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* any later version.
|
||||
* Redux Framework is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package ReduxFramework
|
||||
* @subpackage Field_Color
|
||||
* @author Daniel J Griffiths (Ghost1227)
|
||||
* @author Dovy Paukstys
|
||||
* @version 3.0.0
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Don't duplicate me!
|
||||
if ( ! class_exists( 'ReduxFramework_color' ) ) {
|
||||
|
||||
/**
|
||||
* Main ReduxFramework_color class
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ReduxFramework_color {
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function __construct( $field = array(), $value = '', $parent ) {
|
||||
|
||||
$this->parent = $parent;
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function render() {
|
||||
|
||||
echo '<input data-id="' . $this->field['id'] . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '" id="' . $this->field['id'] . '-color" class="redux-color redux-color-init ' . $this->field['class'] . '" type="text" value="' . $this->value . '" data-oldcolor="" data-default-color="' . ( isset( $this->field['default'] ) ? $this->field['default'] : "" ) . '" />';
|
||||
echo '<input type="hidden" class="redux-saved-color" id="' . $this->field['id'] . '-saved-color' . '" value="">';
|
||||
|
||||
if ( ! isset( $this->field['transparent'] ) || $this->field['transparent'] !== false ) {
|
||||
|
||||
$tChecked = "";
|
||||
|
||||
if ( $this->value == "transparent" ) {
|
||||
$tChecked = ' checked="checked"';
|
||||
}
|
||||
|
||||
echo '<label for="' . $this->field['id'] . '-transparency" class="color-transparency-check"><input type="checkbox" class="checkbox color-transparency ' . $this->field['class'] . '" id="' . $this->field['id'] . '-transparency" data-id="' . $this->field['id'] . '-color" value="1"' . $tChecked . '> ' . __( 'Transparent', 'redux-framework' ) . '</label>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {
|
||||
if ($this->parent->args['dev_mode']) {
|
||||
wp_enqueue_style( 'redux-color-picker-css' );
|
||||
}
|
||||
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
|
||||
wp_enqueue_script(
|
||||
'redux-field-color-js',
|
||||
ReduxFramework::$_url . 'inc/fields/color/field_color' . Redux_Functions::isMin() . '.js',
|
||||
array( 'jquery', 'wp-color-picker', 'redux-js' ),
|
||||
time(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
public function output() {
|
||||
$style = '';
|
||||
|
||||
if ( ! empty( $this->value ) ) {
|
||||
$mode = ( isset( $this->field['mode'] ) && ! empty( $this->field['mode'] ) ? $this->field['mode'] : 'color' );
|
||||
|
||||
$style .= $mode . ':' . $this->value . ';';
|
||||
|
||||
if ( ! empty( $this->field['output'] ) && is_array( $this->field['output'] ) ) {
|
||||
$css = Redux_Functions::parseCSS( $this->field['output'], $style, $this->value );
|
||||
$this->parent->outputCSS .= $css;
|
||||
}
|
||||
|
||||
if ( ! empty( $this->field['compiler'] ) && is_array( $this->field['compiler'] ) ) {
|
||||
$css = Redux_Functions::parseCSS( $this->field['compiler'], $style, $this->value );
|
||||
$this->parent->compilerCSS .= $css;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
.redux-container-color_gradient .colorGradient{display:inline-block}.redux-container-color_gradient .toLabel{padding-left:18px}@media screen and (max-width: 660px){.redux-container-color_gradient .colorGradient{display:block;text-align:center !important}}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"mappings": "AACI,8CAAe;EACX,OAAO,EAAE,YAAY;AAEzB,wCAAS;EACL,YAAY,EAAE,IAAI;;AAI1B,oCAAqC;EAE7B,8CAAe;IACX,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,iBAAiB",
|
||||
"sources": ["field_color_gradient.scss"],
|
||||
"names": [],
|
||||
"file": "field_color_gradient.css"
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
Field Color Gradient
|
||||
*/
|
||||
|
||||
/*global jQuery, document, redux_change, redux*/
|
||||
|
||||
(function( $ ) {
|
||||
'use strict';
|
||||
|
||||
redux.field_objects = redux.field_objects || {};
|
||||
redux.field_objects.color_gradient = redux.field_objects.color_gradient || {};
|
||||
|
||||
redux.field_objects.color_gradient.init = function( selector ) {
|
||||
|
||||
if ( !selector ) {
|
||||
selector = $( document ).find( ".redux-group-tab:visible" ).find( '.redux-container-color_gradient:visible' );
|
||||
}
|
||||
|
||||
$( selector ).each(
|
||||
function() {
|
||||
var el = $( this );
|
||||
var parent = el;
|
||||
|
||||
if ( !el.hasClass( 'redux-field-container' ) ) {
|
||||
parent = el.parents( '.redux-field-container:first' );
|
||||
}
|
||||
if ( parent.is( ":hidden" ) ) { // Skip hidden fields
|
||||
return;
|
||||
}
|
||||
if ( parent.hasClass( 'redux-field-init' ) ) {
|
||||
parent.removeClass( 'redux-field-init' );
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
el.find( '.redux-color-init' ).wpColorPicker(
|
||||
{
|
||||
change: function( e, ui ) {
|
||||
$( this ).val( ui.color.toString() );
|
||||
redux_change( $( this ) );
|
||||
el.find( '#' + e.target.getAttribute( 'data-id' ) + '-transparency' ).removeAttr( 'checked' );
|
||||
},
|
||||
clear: function( e, ui ) {
|
||||
$( this ).val( '' );
|
||||
redux_change( $( this ).parent().find( '.redux-color-init' ) );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
el.find( '.redux-color' ).on(
|
||||
'keyup', function() {
|
||||
var value = $( this ).val();
|
||||
var color = colorValidate( this );
|
||||
var id = '#' + $( this ).attr( 'id' );
|
||||
|
||||
if ( value === "transparent" ) {
|
||||
$( this ).parent().parent().find( '.wp-color-result' ).css(
|
||||
'background-color', 'transparent'
|
||||
);
|
||||
|
||||
el.find( id + '-transparency' ).attr( 'checked', 'checked' );
|
||||
} else {
|
||||
el.find( id + '-transparency' ).removeAttr( 'checked' );
|
||||
|
||||
if ( color && color !== $( this ).val() ) {
|
||||
$( this ).val( color );
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Replace and validate field on blur
|
||||
el.find( '.redux-color' ).on(
|
||||
'blur', function() {
|
||||
var value = $( this ).val();
|
||||
var id = '#' + $( this ).attr( 'id' );
|
||||
|
||||
if ( value === "transparent" ) {
|
||||
$( this ).parent().parent().find( '.wp-color-result' ).css(
|
||||
'background-color', 'transparent'
|
||||
);
|
||||
|
||||
el.find( id + '-transparency' ).attr( 'checked', 'checked' );
|
||||
} else {
|
||||
if ( colorValidate( this ) === value ) {
|
||||
if ( value.indexOf( "#" ) !== 0 ) {
|
||||
$( this ).val( $( this ).data( 'oldcolor' ) );
|
||||
}
|
||||
}
|
||||
|
||||
el.find( id + '-transparency' ).removeAttr( 'checked' );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Store the old valid color on keydown
|
||||
el.find( '.redux-color' ).on(
|
||||
'keydown', function() {
|
||||
$( this ).data( 'oldkeypress', $( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
// When transparency checkbox is clicked
|
||||
el.find( '.color-transparency' ).on(
|
||||
'click', function() {
|
||||
if ( $( this ).is( ":checked" ) ) {
|
||||
|
||||
el.find( '.redux-saved-color' ).val( $( '#' + $( this ).data( 'id' ) ).val() );
|
||||
el.find( '#' + $( this ).data( 'id' ) ).val( 'transparent' );
|
||||
el.find( '#' + $( this ).data( 'id' ) ).parent().parent().find( '.wp-color-result' ).css(
|
||||
'background-color', 'transparent'
|
||||
);
|
||||
} else {
|
||||
if ( el.find( '#' + $( this ).data( 'id' ) ).val() === 'transparent' ) {
|
||||
var prevColor = $( '.redux-saved-color' ).val();
|
||||
|
||||
if ( prevColor === '' ) {
|
||||
prevColor = $( '#' + $( this ).data( 'id' ) ).data( 'default-color' );
|
||||
}
|
||||
|
||||
el.find( '#' + $( this ).data( 'id' ) ).parent().parent().find( '.wp-color-result' ).css(
|
||||
'background-color', prevColor
|
||||
);
|
||||
|
||||
el.find( '#' + $( this ).data( 'id' ) ).val( prevColor );
|
||||
}
|
||||
}
|
||||
redux_change( $( this ) );
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
})( jQuery );
|
||||
@@ -0,0 +1 @@
|
||||
!function(a){"use strict";redux.field_objects=redux.field_objects||{},redux.field_objects.color_gradient=redux.field_objects.color_gradient||{},redux.field_objects.color_gradient.init=function(t){t||(t=a(document).find(".redux-group-tab:visible").find(".redux-container-color_gradient:visible")),a(t).each(function(){var i=a(this),t=i;i.hasClass("redux-field-container")||(t=i.parents(".redux-field-container:first")),t.is(":hidden")||t.hasClass("redux-field-init")&&(t.removeClass("redux-field-init"),i.find(".redux-color-init").wpColorPicker({change:function(t,r){a(this).val(r.color.toString()),redux_change(a(this)),i.find("#"+t.target.getAttribute("data-id")+"-transparency").removeAttr("checked")},clear:function(t,r){a(this).val(""),redux_change(a(this).parent().find(".redux-color-init"))}}),i.find(".redux-color").on("keyup",function(){var t=a(this).val(),r=colorValidate(this),e="#"+a(this).attr("id");"transparent"===t?(a(this).parent().parent().find(".wp-color-result").css("background-color","transparent"),i.find(e+"-transparency").attr("checked","checked")):(i.find(e+"-transparency").removeAttr("checked"),r&&r!==a(this).val()&&a(this).val(r))}),i.find(".redux-color").on("blur",function(){var t=a(this).val(),r="#"+a(this).attr("id");"transparent"===t?(a(this).parent().parent().find(".wp-color-result").css("background-color","transparent"),i.find(r+"-transparency").attr("checked","checked")):(colorValidate(this)===t&&0!==t.indexOf("#")&&a(this).val(a(this).data("oldcolor")),i.find(r+"-transparency").removeAttr("checked"))}),i.find(".redux-color").on("keydown",function(){a(this).data("oldkeypress",a(this).val())}),i.find(".color-transparency").on("click",function(){if(a(this).is(":checked"))i.find(".redux-saved-color").val(a("#"+a(this).data("id")).val()),i.find("#"+a(this).data("id")).val("transparent"),i.find("#"+a(this).data("id")).parent().parent().find(".wp-color-result").css("background-color","transparent");else if("transparent"===i.find("#"+a(this).data("id")).val()){var t=a(".redux-saved-color").val();""===t&&(t=a("#"+a(this).data("id")).data("default-color")),i.find("#"+a(this).data("id")).parent().parent().find(".wp-color-result").css("background-color",t),i.find("#"+a(this).data("id")).val(t)}redux_change(a(this))}))})}}(jQuery);
|
||||
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Redux Framework is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* any later version.
|
||||
* Redux Framework is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package ReduxFramework
|
||||
* @subpackage Field_Color_Gradient
|
||||
* @author Daniel J Griffiths (Ghost1227)
|
||||
* @author Dovy Paukstys
|
||||
* @version 3.0.0
|
||||
*/
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Don't duplicate me!
|
||||
if ( ! class_exists( 'ReduxFramework_color_gradient' ) ) {
|
||||
|
||||
/**
|
||||
* Main ReduxFramework_color_gradient class
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ReduxFramework_color_gradient {
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function __construct( $field = array(), $value = '', $parent ) {
|
||||
$this->parent = $parent;
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function render() {
|
||||
|
||||
// No errors please
|
||||
$defaults = array(
|
||||
'from' => '',
|
||||
'to' => ''
|
||||
);
|
||||
|
||||
$this->value = wp_parse_args( $this->value, $defaults );
|
||||
|
||||
echo '<div class="colorGradient"><strong>' . __( 'From ', 'redux-framework' ) . '</strong> ';
|
||||
echo '<input data-id="' . $this->field['id'] . '" id="' . $this->field['id'] . '-from" name="' . $this->field['name'] . $this->field['name_suffix'] . '[from]' . '" value="' . $this->value['from'] . '" class="redux-color redux-color-init ' . $this->field['class'] . '" type="text" data-default-color="' . $this->field['default']['from'] . '" />';
|
||||
echo '<input type="hidden" class="redux-saved-color" id="' . $this->field['id'] . '-saved-color' . '" value="">';
|
||||
|
||||
if ( ! isset( $this->field['transparent'] ) || $this->field['transparent'] !== false ) {
|
||||
$tChecked = "";
|
||||
|
||||
if ( $this->value['from'] == "transparent" ) {
|
||||
$tChecked = ' checked="checked"';
|
||||
}
|
||||
|
||||
echo '<label for="' . $this->field['id'] . '-from-transparency" class="color-transparency-check"><input type="checkbox" class="checkbox color-transparency ' . $this->field['class'] . '" id="' . $this->field['id'] . '-from-transparency" data-id="' . $this->field['id'] . '-from" value="1"' . $tChecked . '> ' . __( 'Transparent', 'redux-framework' ) . '</label>';
|
||||
}
|
||||
echo "</div>";
|
||||
echo '<div class="colorGradient toLabel"><strong>' . __( 'To ', 'redux-framework' ) . '</strong> <input data-id="' . $this->field['id'] . '" id="' . $this->field['id'] . '-to" name="' . $this->field['name'] . $this->field['name_suffix'] . '[to]' . '" value="' . $this->value['to'] . '" class="redux-color redux-color-init ' . $this->field['class'] . '" type="text" data-default-color="' . $this->field['default']['to'] . '" />';
|
||||
|
||||
if ( ! isset( $this->field['transparent'] ) || $this->field['transparent'] !== false ) {
|
||||
$tChecked = "";
|
||||
|
||||
if ( $this->value['to'] == "transparent" ) {
|
||||
$tChecked = ' checked="checked"';
|
||||
}
|
||||
|
||||
echo '<label for="' . $this->field['id'] . '-to-transparency" class="color-transparency-check"><input type="checkbox" class="checkbox color-transparency" id="' . $this->field['id'] . '-to-transparency" data-id="' . $this->field['id'] . '-to" value="1"' . $tChecked . '> ' . __( 'Transparent', 'redux-framework' ) . '</label>';
|
||||
}
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
|
||||
wp_enqueue_script(
|
||||
'redux-field-color-gradient-js',
|
||||
ReduxFramework::$_url . 'inc/fields/color_gradient/field_color_gradient' . Redux_Functions::isMin() . '.js',
|
||||
array( 'jquery', 'wp-color-picker', 'redux-js' ),
|
||||
time(),
|
||||
'all'
|
||||
);
|
||||
|
||||
if ($this->parent->args['dev_mode']) {
|
||||
wp_enqueue_style( 'redux-color-picker-css' );
|
||||
|
||||
wp_enqueue_style(
|
||||
'redux-field-color_gradient-css',
|
||||
ReduxFramework::$_url . 'inc/fields/color_gradient/field_color_gradient.css',
|
||||
array(),
|
||||
time(),
|
||||
'all'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
.redux-container-color_gradient {
|
||||
.colorGradient {
|
||||
display: inline-block;
|
||||
}
|
||||
.toLabel {
|
||||
padding-left: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 660px) {
|
||||
.redux-container-color_gradient {
|
||||
.colorGradient {
|
||||
display: block;
|
||||
text-align: center !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
.sp-container{color:#555;border-color:#cccccc;background:#f7f7f7;-webkit-box-shadow:inset 0 1px 0 #fff,0 1px 0 rgba(0,0,0,0.08);box-shadow:inset 0 1px 0 #fff,0 1px 0 rgba(0,0,0,0.08);vertical-align:top}.sp-replacer{color:#555;border-color:#cccccc;background:#f7f7f7;-webkit-box-shadow:inset 0 1px 0 #fff,0 1px 0 rgba(0,0,0,0.08);box-shadow:inset 0 1px 0 #fff,0 1px 0 rgba(0,0,0,0.08);vertical-align:top}.sp-replacer:focus,.sp-replacer:hover,.sp-replacer.focus,.sp-replacer.hover{background:#fafafa;border-color:#999;color:#222}.sp-replacer:focus,.sp-replacer.focus{-webkit-box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,0.8);box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,0.8)}.sp-replacer.active:focus{-webkit-box-shadow:inset 0 2px 5px -3px rgba(0,0,0,0.5),0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,0.8);box-shadow:inset 0 2px 5px -3px rgba(0,0,0,0.5),0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,0.8)}.sp-replacer.active,.sp-replacer.active:hover,.sp-replacer:active{background:#eee;border-color:#999;color:#333;-webkit-box-shadow:inset 0 2px 5px -3px rgba(0,0,0,0.5);box-shadow:inset 0 2px 5px -3px rgba(0,0,0,0.5)}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"mappings": "AAAA,aAAc;EACd;;oHAEkH;EACjH,KAAK,EAAE,IAAI;EACX,YAAY,EAAE,OAAO;EACrB,UAAU,EAAE,OAAO;EACnB,kBAAkB,EAAE,+CAAiD;EACrE,UAAU,EAAE,+CAAiD;EAC5D,cAAc,EAAE,GAAG;;AAGrB,YAAa;EACT,KAAK,EAAE,IAAI;EACX,YAAY,EAAE,OAAO;EACrB,UAAU,EAAE,OAAO;EACnB,kBAAkB,EAAE,+CAAiD;EACrE,UAAU,EAAE,+CAAiD;EAC7D,cAAc,EAAE,GAAG;;AAGvB;;;kBAGmB;EACf,UAAU,EAAE,OAAO;EACnB,YAAY,EAAE,IAAI;EAClB,KAAK,EAAE,IAAI;;AAGf;kBACmB;EACf,kBAAkB,EACV,sDACkC;EAC1C,UAAU,EACF,sDACkC;;AAI9C,yBAA0B;EACzB,kBAAkB,EACjB,+FAEkC;EACnC,UAAU,EACT,+FAEkC;;AAGpC;;mBAEmB;EACf,UAAU,EAAE,IAAI;EAChB,YAAY,EAAE,IAAI;EAClB,KAAK,EAAE,IAAI;EACX,kBAAkB,EAAE,uCAAyC;EAC7D,UAAU,EAAE,uCAAyC",
|
||||
"sources": ["field_color_rgba.scss"],
|
||||
"names": [],
|
||||
"file": "field_color_rgba.css"
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
(function($){
|
||||
'use strict';
|
||||
|
||||
redux.field_objects = redux.field_objects || {};
|
||||
redux.field_objects.color_rgba = redux.field_objects.color_rgba || {};
|
||||
redux.field_objects.color_rgba.fieldID = '';
|
||||
|
||||
redux.field_objects.color_rgba.hexToRGBA = function( hex, alpha ) {
|
||||
var result;
|
||||
|
||||
if (hex === null) {
|
||||
result = '';
|
||||
} else {
|
||||
hex = hex.replace('#', '');
|
||||
var r = parseInt(hex.substring(0, 2), 16);
|
||||
var g = parseInt(hex.substring(2, 4), 16);
|
||||
var b = parseInt(hex.substring(4, 6), 16);
|
||||
|
||||
result = 'rgba(' + r + ',' + g + ',' + b + ',' + alpha + ')';
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
redux.field_objects.color_rgba.init = function( selector ) {
|
||||
if ( !selector ) {
|
||||
selector = $( document ).find( ".redux-group-tab:visible" ).find( '.redux-container-color_rgba:visible' );
|
||||
}
|
||||
|
||||
$( selector ).each(
|
||||
function() {
|
||||
var el = $( this );
|
||||
var parent = el;
|
||||
|
||||
if ( !el.hasClass( 'redux-field-container' ) ) {
|
||||
parent = el.parents( '.redux-field-container:first' );
|
||||
}
|
||||
|
||||
if ( parent.is( ":hidden" ) ) { // Skip hidden fields
|
||||
return;
|
||||
}
|
||||
|
||||
if ( parent.hasClass( 'redux-field-init' ) ) {
|
||||
parent.removeClass( 'redux-field-init' );
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
redux.field_objects.color_rgba.modInit(el);
|
||||
redux.field_objects.color_rgba.initColorPicker(el);
|
||||
});
|
||||
};
|
||||
|
||||
redux.field_objects.color_rgba.modInit = function(el) {
|
||||
|
||||
redux.field_objects.color_rgba.fieldID = el.find('.redux-color_rgba-container').data('id');
|
||||
|
||||
};
|
||||
|
||||
// Initialize colour picker
|
||||
redux.field_objects.color_rgba.initColorPicker = function(el){
|
||||
|
||||
// Get field ID
|
||||
var field_id = redux.field_objects.color_rgba.fieldID;
|
||||
|
||||
// Get the color scheme container
|
||||
var colorpickerInput = el.find('.redux-color-rgba');
|
||||
|
||||
// Get alpha value and sanitize it
|
||||
var currentAlpha = colorpickerInput.data('current-alpha');
|
||||
currentAlpha = Number((currentAlpha === null || currentAlpha === undefined) ? 1 : currentAlpha);
|
||||
|
||||
// Get colour value and sanitize it
|
||||
var currentColor = colorpickerInput.data('current-color');
|
||||
currentColor = (currentColor === '' || currentColor === 'transparent') ? '' : currentColor;
|
||||
|
||||
var outputTransparent = colorpickerInput.data('output-transparent');
|
||||
outputTransparent = Boolean((outputTransparent === '') ? false : outputTransparent);
|
||||
|
||||
// Color picker arguments
|
||||
var container = el.find('.redux-color-rgba-container');
|
||||
|
||||
// Get, decode and parse palette.
|
||||
var palette = container.data('palette');
|
||||
palette = decodeURIComponent(palette);
|
||||
palette = JSON.parse(palette);
|
||||
|
||||
// Default palette
|
||||
if (palette === null) {
|
||||
palette = [
|
||||
["#000000", "#434343", "#666666", "#999999", "#b7b7b7", "#cccccc", "#d9d9d9", "#efefef", "#f3f3f3", "#ffffff"],
|
||||
["#980000", "#ff0000", "#ff9900", "#ffff00", "#00ff00", "#00ffff", "#4a86e8", "#0000ff", "#9900ff", "#ff00ff"],
|
||||
["#e6b8af", "#f4cccc", "#fce5cd", "#fff2cc", "#d9ead3", "#d9ead3", "#c9daf8", "#cfe2f3", "#d9d2e9", "#ead1dc"],
|
||||
["#dd7e6b", "#ea9999", "#f9cb9c", "#ffe599", "#b6d7a8", "#a2c4c9", "#a4c2f4", "#9fc5e8", "#b4a7d6", "#d5a6bd"],
|
||||
["#cc4125", "#e06666", "#f6b26b", "#ffd966", "#93c47d", "#76a5af", "#6d9eeb", "#6fa8dc", "#8e7cc3", "#c27ba0"],
|
||||
["#a61c00", "#cc0000", "#e69138", "#f1c232", "#6aa84f", "#45818e", "#3c78d8", "#3d85c6", "#674ea7", "#a64d79"],
|
||||
["#85200c", "#990000", "#b45f06", "#bf9000", "#38761d", "#134f5c", "#1155cc", "#0b5394", "#351c75", "#741b47"],
|
||||
["#5b0f00", "#660000", "#783f04", "#7f6000", "#274e13", "#0c343d", "#1c4587", "#073763", "#20124d", "#4c1130"]
|
||||
];
|
||||
}
|
||||
|
||||
// Get and sanitize show input argument
|
||||
var showInput = container.data('show-input');
|
||||
showInput = Boolean((showInput === '') ? false : showInput);
|
||||
|
||||
// Get and sanitize show initial argument
|
||||
var showInitial = container.data('show-initial');
|
||||
showInitial = Boolean((showInitial === '') ? false : showInitial);
|
||||
|
||||
// Get and sanitize show alpha argument
|
||||
var showAlpha = container.data('show-alpha');
|
||||
showAlpha = Boolean((showAlpha === '') ? false : showAlpha);
|
||||
|
||||
// Get and sanitize allow empty argument
|
||||
var allowEmpty = container.data('allow-empty');
|
||||
allowEmpty = Boolean((allowEmpty === '') ? false : allowEmpty);
|
||||
|
||||
// Get and sanitize show palette argument
|
||||
var showPalette = container.data('show-palette');
|
||||
showPalette = Boolean((showPalette === '') ? false : showPalette);
|
||||
|
||||
// Get and sanitize show palette only argument
|
||||
var showPaletteOnly = container.data('show-palette-only');
|
||||
showPaletteOnly = Boolean((showPaletteOnly === '') ? false : showPaletteOnly);
|
||||
|
||||
// Get and sanitize show selection palette argument
|
||||
var showSelectionPalette = container.data('show-selection-palette');
|
||||
showSelectionPalette = Boolean((showSelectionPalette === '') ? false : showSelectionPalette);
|
||||
|
||||
// Get max palette size
|
||||
var maxPaletteSize = Number(container.data('max-palette-size'));
|
||||
|
||||
// Get and sanitize clickout fires change argument
|
||||
var clickoutFiresChange = container.data('clickout-fires-change');
|
||||
clickoutFiresChange = Boolean((clickoutFiresChange === '') ? false : clickoutFiresChange);
|
||||
|
||||
// Get choose button text
|
||||
var chooseText = String(container.data('choose-text'));
|
||||
|
||||
// Get cancel button text
|
||||
var cancelText = String(container.data('cancel-text'));
|
||||
|
||||
// Get cancel button text
|
||||
var inputText = String(container.data('input-text'));
|
||||
|
||||
|
||||
// Get and sanitize show buttons argument
|
||||
var showButtons = container.data('show-buttons');
|
||||
showButtons = Boolean((showButtons === '') ? false : showButtons);
|
||||
|
||||
// Get container class
|
||||
var containerClass = String(container.data('container-class'));
|
||||
|
||||
// Get replacer class
|
||||
var replacerClass = String(container.data('replacer-class'));
|
||||
|
||||
// Color picker options
|
||||
colorpickerInput.spectrum({
|
||||
color: currentColor, //'#ffffff',
|
||||
showAlpha: showAlpha,
|
||||
showInput: showInput,
|
||||
allowEmpty: allowEmpty,
|
||||
className: 'redux-color-rgba',
|
||||
showInitial: showInitial,
|
||||
showPalette: showPalette,
|
||||
showSelectionPalette: showSelectionPalette,
|
||||
maxPaletteSize: maxPaletteSize,
|
||||
showPaletteOnly: showPaletteOnly,
|
||||
clickoutFiresChange: clickoutFiresChange,
|
||||
chooseText: chooseText,
|
||||
cancelText: cancelText,
|
||||
showButtons: showButtons,
|
||||
containerClassName: containerClass,
|
||||
replacerClassName: replacerClass,
|
||||
preferredFormat: 'hex6',
|
||||
localStorageKey: 'redux.color-rgba.' + field_id,
|
||||
palette: palette,
|
||||
inputText: inputText,
|
||||
|
||||
// on change
|
||||
change: function(color) {
|
||||
var colorVal, alphaVal, rgbaVal;
|
||||
|
||||
if (color === null) {
|
||||
if (outputTransparent === true) {
|
||||
colorVal = 'transparent';
|
||||
} else {
|
||||
colorVal = null;
|
||||
}
|
||||
alphaVal = null;
|
||||
} else {
|
||||
colorVal = color.toHexString();
|
||||
alphaVal = color.alpha;
|
||||
}
|
||||
|
||||
if (colorVal != 'transparent') {
|
||||
rgbaVal = redux.field_objects.color_rgba.hexToRGBA(colorVal, alphaVal);
|
||||
} else {
|
||||
rgbaVal = 'transparent';
|
||||
}
|
||||
|
||||
var blockID = $(this).data('block-id');
|
||||
|
||||
// Update HTML color value
|
||||
el.find('input#' + blockID + '-color').val(colorVal);
|
||||
|
||||
// Update HTML alpha value
|
||||
el.find('input#' + blockID + '-alpha').val(alphaVal);
|
||||
|
||||
// Update RGBA alpha value
|
||||
el.find('input#' + blockID + '-rgba').val(rgbaVal);
|
||||
|
||||
redux_change(el.find('.redux-color-rgba-container'));
|
||||
}
|
||||
});
|
||||
};
|
||||
})(jQuery);
|
||||
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/color_rgba/field_color_rgba.min.js
vendored
Normal file
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/color_rgba/field_color_rgba.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(B){"use strict";redux.field_objects=redux.field_objects||{},redux.field_objects.color_rgba=redux.field_objects.color_rgba||{},redux.field_objects.color_rgba.fieldID="",redux.field_objects.color_rgba.hexToRGBA=function(e,a){var r;null===e?r="":(e=e.replace("#",""),r="rgba("+parseInt(e.substring(0,2),16)+","+parseInt(e.substring(2,4),16)+","+parseInt(e.substring(4,6),16)+","+a+")");return r},redux.field_objects.color_rgba.init=function(e){e||(e=B(document).find(".redux-group-tab:visible").find(".redux-container-color_rgba:visible")),B(e).each(function(){var e=B(this),a=e;e.hasClass("redux-field-container")||(a=e.parents(".redux-field-container:first")),a.is(":hidden")||a.hasClass("redux-field-init")&&(a.removeClass("redux-field-init"),redux.field_objects.color_rgba.modInit(e),redux.field_objects.color_rgba.initColorPicker(e))})},redux.field_objects.color_rgba.modInit=function(e){redux.field_objects.color_rgba.fieldID=e.find(".redux-color_rgba-container").data("id")},redux.field_objects.color_rgba.initColorPicker=function(c){var e=redux.field_objects.color_rgba.fieldID,a=c.find(".redux-color-rgba"),r=a.data("current-alpha");r=Number(null==r?1:r);var t=a.data("current-color");t=""===t||"transparent"===t?"":t;var d=a.data("output-transparent");d=Boolean(""!==d&&d);var o=c.find(".redux-color-rgba-container"),l=o.data("palette");l=decodeURIComponent(l),null===(l=JSON.parse(l))&&(l=[["#000000","#434343","#666666","#999999","#b7b7b7","#cccccc","#d9d9d9","#efefef","#f3f3f3","#ffffff"],["#980000","#ff0000","#ff9900","#ffff00","#00ff00","#00ffff","#4a86e8","#0000ff","#9900ff","#ff00ff"],["#e6b8af","#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d9ead3","#c9daf8","#cfe2f3","#d9d2e9","#ead1dc"],["#dd7e6b","#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#a4c2f4","#9fc5e8","#b4a7d6","#d5a6bd"],["#cc4125","#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6d9eeb","#6fa8dc","#8e7cc3","#c27ba0"],["#a61c00","#cc0000","#e69138","#f1c232","#6aa84f","#45818e","#3c78d8","#3d85c6","#674ea7","#a64d79"],["#85200c","#990000","#b45f06","#bf9000","#38761d","#134f5c","#1155cc","#0b5394","#351c75","#741b47"],["#5b0f00","#660000","#783f04","#7f6000","#274e13","#0c343d","#1c4587","#073763","#20124d","#4c1130"]]);var n=o.data("show-input");n=Boolean(""!==n&&n);var f=o.data("show-initial");f=Boolean(""!==f&&f);var i=o.data("show-alpha");i=Boolean(""!==i&&i);var s=o.data("allow-empty");s=Boolean(""!==s&&s);var u=o.data("show-palette");u=Boolean(""!==u&&u);var b=o.data("show-palette-only");b=Boolean(""!==b&&b);var x=o.data("show-selection-palette");x=Boolean(""!==x&&x);var p=Number(o.data("max-palette-size")),g=o.data("clickout-fires-change");g=Boolean(""!==g&&g);var h=String(o.data("choose-text")),_=String(o.data("cancel-text")),v=String(o.data("input-text")),m=o.data("show-buttons");m=Boolean(""!==m&&m);var w=String(o.data("container-class")),j=String(o.data("replacer-class"));a.spectrum({color:t,showAlpha:i,showInput:n,allowEmpty:s,className:"redux-color-rgba",showInitial:f,showPalette:u,showSelectionPalette:x,maxPaletteSize:p,showPaletteOnly:b,clickoutFiresChange:g,chooseText:h,cancelText:_,showButtons:m,containerClassName:w,replacerClassName:j,preferredFormat:"hex6",localStorageKey:"redux.color-rgba."+e,palette:l,inputText:v,change:function(e){var a,r,t;r=null===e?(a=!0===d?"transparent":null,null):(a=e.toHexString(),e.alpha),t="transparent"!=a?redux.field_objects.color_rgba.hexToRGBA(a,r):"transparent";var o=B(this).data("block-id");c.find("input#"+o+"-color").val(a),c.find("input#"+o+"-alpha").val(r),c.find("input#"+o+"-rgba").val(t),redux_change(c.find(".redux-color-rgba-container"))}})}}(jQuery);
|
||||
@@ -0,0 +1,295 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Redux Framework is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* any later version.
|
||||
* Redux Framework is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package Redux Framework
|
||||
* @subpackage Spectrum Color Picker
|
||||
* @author Kevin Provance (kprovance)
|
||||
* @version 1.0.0
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Don't duplicate me!
|
||||
if ( ! class_exists( 'ReduxFramework_color_rgba' ) ) {
|
||||
|
||||
/**
|
||||
* Main ReduxFramework_color_rgba class
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ReduxFramework_color_rgba {
|
||||
|
||||
/**
|
||||
* Class Constructor. Defines the args for the extions class
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*
|
||||
* @param array $field Field sections.
|
||||
* @param array $value Values.
|
||||
* @param array $parent Parent object.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $field = array(), $value = '', $parent ) {
|
||||
|
||||
// Set required variables
|
||||
$this->parent = $parent;
|
||||
$this->field = (array) $field;
|
||||
$this->value = $value;
|
||||
|
||||
$defaults = array(
|
||||
'color' => '',
|
||||
'alpha' => 1,
|
||||
'rgba' => ''
|
||||
);
|
||||
|
||||
$option_defaults = array(
|
||||
"show_input" => true,
|
||||
"show_initial" => false,
|
||||
"show_alpha" => true,
|
||||
"show_palette" => false,
|
||||
"show_palette_only" => false,
|
||||
"max_palette_size" => 10,
|
||||
"show_selection_palette" => false,
|
||||
"allow_empty" => true,
|
||||
"clickout_fires_change" => false,
|
||||
"choose_text" => __( 'Choose', 'redux-framework' ),
|
||||
"cancel_text" => __( 'Cancel', 'redux-framework' ),
|
||||
"show_buttons" => true,
|
||||
"input_text" => __( 'Select Color', 'redux-framework' ),
|
||||
"palette" => null,
|
||||
);
|
||||
|
||||
$this->value = wp_parse_args( $this->value, $defaults );
|
||||
|
||||
$this->field['options'] = isset( $this->field['options'] ) ? wp_parse_args( $this->field['options'], $option_defaults ) : $option_defaults;
|
||||
|
||||
// Convert empty array to null, if there.
|
||||
$this->field['options']['palette'] = empty( $this->field['options']['palette'] ) ? null : $this->field['options']['palette'];
|
||||
|
||||
$this->field['output_transparent'] = isset( $this->field['output_transparent'] ) ? $this->field['output_transparent'] : false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function render() {
|
||||
|
||||
$field_id = $this->field['id'];
|
||||
|
||||
// Color picker container
|
||||
echo '<div
|
||||
class="redux-color-rgba-container ' . $this->field['class'] . '"
|
||||
data-id="' . $field_id . '"
|
||||
data-show-input="' . $this->field['options']['show_input'] . '"
|
||||
data-show-initial="' . $this->field['options']['show_initial'] . '"
|
||||
data-show-alpha="' . $this->field['options']['show_alpha'] . '"
|
||||
data-show-palette="' . $this->field['options']['show_palette'] . '"
|
||||
data-show-palette-only="' . $this->field['options']['show_palette_only'] . '"
|
||||
data-show-selection-palette="' . $this->field['options']['show_selection_palette'] . '"
|
||||
data-max-palette-size="' . $this->field['options']['max_palette_size'] . '"
|
||||
data-allow-empty="' . $this->field['options']['allow_empty'] . '"
|
||||
data-clickout-fires-change="' . $this->field['options']['clickout_fires_change'] . '"
|
||||
data-choose-text="' . $this->field['options']['choose_text'] . '"
|
||||
data-cancel-text="' . $this->field['options']['cancel_text'] . '"
|
||||
data-input-text="' . $this->field['options']['input_text'] . '"
|
||||
data-show-buttons="' . $this->field['options']['show_buttons'] . '"
|
||||
data-palette="' . urlencode( json_encode( $this->field['options']['palette'] ) ) . '"
|
||||
>';
|
||||
|
||||
// Colour picker layout
|
||||
$opt_name = $this->parent->args['opt_name'];
|
||||
|
||||
if ( '' == $this->value['color'] || 'transparent' == $this->value['color'] ) {
|
||||
$color = '';
|
||||
} else {
|
||||
$color = Redux_Helpers::hex2rgba( $this->value['color'], $this->value['alpha'] );
|
||||
}
|
||||
|
||||
if ( $this->value['rgba'] == '' && $this->value['color'] != '' ) {
|
||||
$this->value['rgba'] = Redux_Helpers::hex2rgba( $this->value['color'], $this->value['alpha'] );
|
||||
}
|
||||
|
||||
echo '<input
|
||||
name="' . $this->field['name'] . $this->field['name_suffix'] . '[color]"
|
||||
id="' . $field_id . '-color"
|
||||
class="redux-color-rgba"
|
||||
type="text"
|
||||
value="' . $this->value['color'] . '"
|
||||
data-color="' . $color . '"
|
||||
data-id="' . $field_id . '"
|
||||
data-current-color="' . $this->value['color'] . '"
|
||||
data-block-id="' . $field_id . '"
|
||||
data-output-transparent="' . $this->field['output_transparent'] . '"
|
||||
/>';
|
||||
|
||||
echo '<input
|
||||
type="hidden"
|
||||
class="redux-hidden-color"
|
||||
data-id="' . $field_id . '-color"
|
||||
id="' . $field_id . '-color-hidden"
|
||||
value="' . $this->value['color'] . '"
|
||||
/>';
|
||||
|
||||
// Hidden input for alpha channel
|
||||
echo '<input
|
||||
type="hidden"
|
||||
class="redux-hidden-alpha"
|
||||
data-id="' . $field_id . '-alpha"
|
||||
name="' . $this->field['name'] . $this->field['name_suffix'] . '[alpha]' . '"
|
||||
id="' . $field_id . '-alpha"
|
||||
value="' . $this->value['alpha'] . '"
|
||||
/>';
|
||||
|
||||
// Hidden input for rgba
|
||||
echo '<input
|
||||
type="hidden"
|
||||
class="redux-hidden-rgba"
|
||||
data-id="' . $field_id . '-rgba"
|
||||
name="' . $this->field['name'] . $this->field['name_suffix'] . '[rgba]' . '"
|
||||
id="' . $field_id . '-rgba"
|
||||
value="' . $this->value['rgba'] . '"
|
||||
/>';
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {
|
||||
|
||||
// Set up min files for dev_mode = false.
|
||||
$min = Redux_Functions::isMin();
|
||||
|
||||
// Field dependent JS
|
||||
if ( ! wp_script_is( 'redux-field-color-rgba-js' ) ) {
|
||||
wp_enqueue_script(
|
||||
'redux-field-color-rgba-js',
|
||||
ReduxFramework::$_url . 'inc/fields/color_rgba/field_color_rgba' . Redux_Functions::isMin() . '.js',
|
||||
array( 'jquery', 'redux-spectrum-js' ),
|
||||
time(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
// Spectrum CSS
|
||||
if ( ! wp_style_is( 'redux-spectrum-css' ) ) {
|
||||
wp_enqueue_style( 'redux-spectrum-css' );
|
||||
}
|
||||
|
||||
if ( $this->parent->args['dev_mode'] ) {
|
||||
if ( ! wp_style_is( 'redux-field-color-rgba-css' ) ) {
|
||||
wp_enqueue_style(
|
||||
'redux-field-color-rgba-css',
|
||||
ReduxFramework::$_url . 'inc/fields/color_rgba/field_color_rgba.css',
|
||||
array(),
|
||||
time(),
|
||||
'all'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getColorVal. Returns formatted color val in hex or rgba.
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
* @return string
|
||||
*/
|
||||
private function getColorVal() {
|
||||
|
||||
// No notices
|
||||
$color = '';
|
||||
$alpha = 1;
|
||||
$rgba = '';
|
||||
|
||||
// Must be an array
|
||||
if ( is_array( $this->value ) ) {
|
||||
|
||||
// Enum array to parse values
|
||||
foreach ( $this->value as $id => $val ) {
|
||||
|
||||
// Sanitize alpha
|
||||
if ( $id == 'alpha' ) {
|
||||
$alpha = ! empty( $val ) ? $val : 1;
|
||||
} elseif ( $id == 'color' ) {
|
||||
$color = ! empty( $val ) ? $val : '';
|
||||
} elseif ( $id == 'rgba' ) {
|
||||
$rgba = ! empty( $val ) ? $val : '';
|
||||
$rgba = Redux_Helpers::hex2rgba( $color, $alpha );
|
||||
}
|
||||
}
|
||||
|
||||
// Only build rgba output if alpha ia less than 1
|
||||
if ( $alpha < 1 && $alpha <> '' ) {
|
||||
$color = $rgba;
|
||||
}
|
||||
}
|
||||
|
||||
return $color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output Function.
|
||||
* Used to enqueue to the front-end
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
if ( ! empty( $this->value ) ) {
|
||||
$style = '';
|
||||
|
||||
$mode = ( isset( $this->field['mode'] ) && ! empty( $this->field['mode'] ) ? $this->field['mode'] : 'color' );
|
||||
|
||||
$color_val = $this->getColorVal();
|
||||
|
||||
$style .= $mode . ':' . $color_val . ';';
|
||||
|
||||
if ( ! empty( $this->field['output'] ) && is_array( $this->field['output'] ) ) {
|
||||
if ( ! empty( $color_val ) ) {
|
||||
$css = Redux_Functions::parseCSS( $this->field['output'], $style, $color_val );
|
||||
$this->parent->outputCSS .= $css;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $this->field['compiler'] ) && is_array( $this->field['compiler'] ) ) {
|
||||
if ( ! empty( $color_val ) ) {
|
||||
$css = Redux_Functions::parseCSS( $this->field['compiler'], $style, $color_val );
|
||||
$this->parent->compilerCSS .= $css;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
.sp-container {
|
||||
/* border: solid 1px black;
|
||||
-webkit-box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5), 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, 0.8);
|
||||
box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5), 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, 0.8);*/
|
||||
color: #555;
|
||||
border-color: #cccccc;
|
||||
background: #f7f7f7;
|
||||
-webkit-box-shadow: inset 0 1px 0 #fff, 0 1px 0 rgba( 0, 0, 0, 0.08 );
|
||||
box-shadow: inset 0 1px 0 #fff, 0 1px 0 rgba( 0, 0, 0, 0.08 );
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.sp-replacer {
|
||||
color: #555;
|
||||
border-color: #cccccc;
|
||||
background: #f7f7f7;
|
||||
-webkit-box-shadow: inset 0 1px 0 #fff, 0 1px 0 rgba( 0, 0, 0, 0.08 );
|
||||
box-shadow: inset 0 1px 0 #fff, 0 1px 0 rgba( 0, 0, 0, 0.08 );
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.sp-replacer:focus,
|
||||
.sp-replacer:hover,
|
||||
.sp-replacer.focus,
|
||||
.sp-replacer.hover {
|
||||
background: #fafafa;
|
||||
border-color: #999;
|
||||
color: #222;
|
||||
}
|
||||
|
||||
.sp-replacer:focus,
|
||||
.sp-replacer.focus {
|
||||
-webkit-box-shadow:
|
||||
0 0 0 1px #5b9dd9,
|
||||
0 0 2px 1px rgba(30, 140, 190, .8);
|
||||
box-shadow:
|
||||
0 0 0 1px #5b9dd9,
|
||||
0 0 2px 1px rgba(30, 140, 190, .8);
|
||||
|
||||
}
|
||||
|
||||
.sp-replacer.active:focus {
|
||||
-webkit-box-shadow:
|
||||
inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 ),
|
||||
0 0 0 1px #5b9dd9,
|
||||
0 0 2px 1px rgba(30, 140, 190, .8);
|
||||
box-shadow:
|
||||
inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 ),
|
||||
0 0 0 1px #5b9dd9,
|
||||
0 0 2px 1px rgba(30, 140, 190, .8);
|
||||
}
|
||||
|
||||
.sp-replacer.active,
|
||||
.sp-replacer.active:hover,
|
||||
.sp-replacer:active{
|
||||
background: #eee;
|
||||
border-color: #999;
|
||||
color: #333;
|
||||
-webkit-box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 );
|
||||
box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 );
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
#ui-datepicker-div{z-index:15 !important}.ui-datepicker-header{background-color:#00abef}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"mappings": "AAAA,kBAAmB;EACf,OAAO,EAAE,aAAa;;AAG1B,qBAAsB;EAClB,gBAAgB,EAAE,OAAO",
|
||||
"sources": ["field_date.scss"],
|
||||
"names": [],
|
||||
"file": "field_date.css"
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*global jQuery, document, redux*/
|
||||
|
||||
(function( $ ) {
|
||||
"use strict";
|
||||
|
||||
redux.field_objects = redux.field_objects || {};
|
||||
redux.field_objects.date = redux.field_objects.date || {};
|
||||
|
||||
$( document ).ready(
|
||||
function() {
|
||||
//redux.field_objects.date.init();
|
||||
}
|
||||
);
|
||||
|
||||
redux.field_objects.date.init = function( selector ) {
|
||||
if ( !selector ) {
|
||||
selector = $( document ).find( '.redux-container-date:visible' );
|
||||
}
|
||||
$( selector ).each(
|
||||
function() {
|
||||
var el = $( this );
|
||||
var parent = el;
|
||||
if ( !el.hasClass( 'redux-field-container' ) ) {
|
||||
parent = el.parents( '.redux-field-container:first' );
|
||||
}
|
||||
if ( parent.is( ":hidden" ) ) { // Skip hidden fields
|
||||
return;
|
||||
}
|
||||
if ( parent.hasClass( 'redux-field-init' ) ) {
|
||||
parent.removeClass( 'redux-field-init' );
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
el.find( '.redux-datepicker' ).each( function() {
|
||||
$( this ).datepicker({
|
||||
"dateFormat":"mm/dd/yy",
|
||||
beforeShow: function(input, instance){
|
||||
var el = $('#ui-datepicker-div');
|
||||
var popover = instance.dpDiv;
|
||||
//$('.redux-container:first').append(el);
|
||||
$(this).parent().append(el);
|
||||
$('#ui-datepicker-div').hide();
|
||||
setTimeout(function() {
|
||||
popover.position({
|
||||
my: 'left top',
|
||||
at: 'left bottom',
|
||||
collision: 'none',
|
||||
of: input
|
||||
});
|
||||
}, 1);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
};
|
||||
})( jQuery );
|
||||
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/date/field_date.min.js
vendored
Normal file
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/date/field_date.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(n){"use strict";redux.field_objects=redux.field_objects||{},redux.field_objects.date=redux.field_objects.date||{},n(document).ready(function(){}),redux.field_objects.date.init=function(e){e||(e=n(document).find(".redux-container-date:visible")),n(e).each(function(){var e=n(this),i=e;e.hasClass("redux-field-container")||(i=e.parents(".redux-field-container:first")),i.is(":hidden")||i.hasClass("redux-field-init")&&(i.removeClass("redux-field-init"),e.find(".redux-datepicker").each(function(){n(this).datepicker({dateFormat:"mm/dd/yy",beforeShow:function(e,i){var t=n("#ui-datepicker-div"),d=i.dpDiv;n(this).parent().append(t),n("#ui-datepicker-div").hide(),setTimeout(function(){d.position({my:"left top",at:"left bottom",collision:"none",of:e})},1)}})}))})}}(jQuery);
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Redux Framework is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* any later version.
|
||||
* Redux Framework is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package ReduxFramework
|
||||
* @subpackage Field_Date
|
||||
* @author Daniel J Griffiths (Ghost1227)
|
||||
* @author Dovy Paukstys
|
||||
* @author Kevin Provance (kprovance)
|
||||
* @version 3.0.0
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Don't duplicate me!
|
||||
if ( ! class_exists( 'ReduxFramework_date' ) ) {
|
||||
|
||||
/**
|
||||
* Main ReduxFramework_date class
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ReduxFramework_date {
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function __construct( $field = array(), $value = '', $parent ) {
|
||||
$this->parent = $parent;
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function render() {
|
||||
$placeholder = ( isset( $this->field['placeholder'] ) ) ? ' placeholder="' . esc_attr( $this->field['placeholder'] ) . '" ' : '';
|
||||
|
||||
echo '<input data-id="' . $this->field['id'] . '" type="text" id="' . $this->field['id'] . '-date" name="' . $this->field['name'] . $this->field['name_suffix'] . '"' . $placeholder . 'value="' . $this->value . '" class="redux-datepicker regular-text ' . $this->field['class'] . '" />';
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {
|
||||
|
||||
if ($this->parent->args['dev_mode']) {
|
||||
wp_enqueue_style(
|
||||
'redux-field-date-css',
|
||||
ReduxFramework::$_url . 'inc/fields/date/field_date.css',
|
||||
array(),
|
||||
time(),
|
||||
'all'
|
||||
);
|
||||
}
|
||||
|
||||
wp_enqueue_script(
|
||||
'redux-field-date-js',
|
||||
ReduxFramework::$_url . 'inc/fields/date/field_date' . Redux_Functions::isMin() . '.js',
|
||||
array( 'jquery', 'jquery-ui-core', 'jquery-ui-datepicker', 'redux-js' ),
|
||||
time(),
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#ui-datepicker-div {
|
||||
z-index: 15 !important;
|
||||
}
|
||||
|
||||
.ui-datepicker-header {
|
||||
background-color: #00abef;
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
.redux-dimensions-container select,.redux-dimensions-container .select_wrapper{width:65px !important;float:left}.redux-dimensions-container .field-dimensions-input{margin-right:10px;margin-bottom:7px}@media screen and (max-width: 782px){.redux-dimensions-container .field-dimensions-input input{display:inline-block !important;width:100px !important}.redux-dimensions-container .field-dimensions-input .add-on{padding:7px 4px;font-size:16px;line-height:1.5}.redux-dimensions-container .select_wrapper{margin-top:6px}}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"mappings": "AACI;2CACgB;EACZ,KAAK,EAAE,eAAe;EACtB,KAAK,EAAE,IAAI;AAGf,mDAAwB;EACpB,YAAY,EAAE,IAAI;EAClB,aAAa,EAAE,GAAG;;AAI1B,oCAAqC;EAGzB,yDAAM;IACF,OAAO,EAAE,uBAAuB;IAChC,KAAK,EAAE,gBAAgB;EAG3B,2DAAQ;IACJ,OAAO,EAAE,OAAO;IAChB,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,GAAG;EAIxB,2CAAgB;IACZ,UAAU,EAAE,GAAG",
|
||||
"sources": ["field_dimensions.scss"],
|
||||
"names": [],
|
||||
"file": "field_dimensions.css"
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
|
||||
/*global jQuery, document, redux*/
|
||||
|
||||
(function( $ ) {
|
||||
"use strict";
|
||||
|
||||
redux.field_objects = redux.field_objects || {};
|
||||
redux.field_objects.dimensions = redux.field_objects.dimensions || {};
|
||||
|
||||
$( document ).ready(
|
||||
function() {
|
||||
//redux.field_objects.dimensions.init();
|
||||
}
|
||||
);
|
||||
|
||||
redux.field_objects.dimensions.init = function( selector ) {
|
||||
|
||||
if ( !selector ) {
|
||||
selector = $( document ).find( '.redux-container-dimensions:visible' );
|
||||
}
|
||||
$( selector ).each(
|
||||
function() {
|
||||
var el = $( this );
|
||||
var parent = el;
|
||||
if ( !el.hasClass( 'redux-field-container' ) ) {
|
||||
parent = el.parents( '.redux-field-container:first' );
|
||||
}
|
||||
if ( parent.is( ":hidden" ) ) { // Skip hidden fields
|
||||
return;
|
||||
}
|
||||
if ( parent.hasClass( 'redux-field-init' ) ) {
|
||||
parent.removeClass( 'redux-field-init' );
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
var default_params = {
|
||||
width: 'resolve',
|
||||
triggerChange: true,
|
||||
allowClear: true
|
||||
};
|
||||
|
||||
var select2_handle = el.find( '.select2_params' );
|
||||
if ( select2_handle.size() > 0 ) {
|
||||
var select2_params = select2_handle.val();
|
||||
|
||||
select2_params = JSON.parse( select2_params );
|
||||
default_params = $.extend( {}, default_params, select2_params );
|
||||
}
|
||||
|
||||
el.find( ".redux-dimensions-units" ).select2( default_params );
|
||||
|
||||
el.find( '.redux-dimensions-input' ).on(
|
||||
'change', function() {
|
||||
var units = $( this ).parents( '.redux-field:first' ).find( '.field-units' ).val();
|
||||
if ( $( this ).parents( '.redux-field:first' ).find( '.redux-dimensions-units' ).length !== 0 ) {
|
||||
units = $( this ).parents( '.redux-field:first' ).find( '.redux-dimensions-units option:selected' ).val();
|
||||
}
|
||||
if ( typeof units !== 'undefined' ) {
|
||||
el.find( '#' + $( this ).attr( 'rel' ) ).val( $( this ).val() + units );
|
||||
} else {
|
||||
el.find( '#' + $( this ).attr( 'rel' ) ).val( $( this ).val() );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
el.find( '.redux-dimensions-units' ).on(
|
||||
'change', function() {
|
||||
$( this ).parents( '.redux-field:first' ).find( '.redux-dimensions-input' ).change();
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
};
|
||||
})( jQuery );
|
||||
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/dimensions/field_dimensions.min.js
vendored
Normal file
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/dimensions/field_dimensions.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(t){"use strict";redux.field_objects=redux.field_objects||{},redux.field_objects.dimensions=redux.field_objects.dimensions||{},t(document).ready(function(){}),redux.field_objects.dimensions.init=function(i){i||(i=t(document).find(".redux-container-dimensions:visible")),t(i).each(function(){var e=t(this),i=e;if(e.hasClass("redux-field-container")||(i=e.parents(".redux-field-container:first")),!i.is(":hidden")&&i.hasClass("redux-field-init")){i.removeClass("redux-field-init");var n={width:"resolve",triggerChange:!0,allowClear:!0},s=e.find(".select2_params");if(0<s.size()){var d=s.val();d=JSON.parse(d),n=t.extend({},n,d)}e.find(".redux-dimensions-units").select2(n),e.find(".redux-dimensions-input").on("change",function(){var i=t(this).parents(".redux-field:first").find(".field-units").val();0!==t(this).parents(".redux-field:first").find(".redux-dimensions-units").length&&(i=t(this).parents(".redux-field:first").find(".redux-dimensions-units option:selected").val()),void 0!==i?e.find("#"+t(this).attr("rel")).val(t(this).val()+i):e.find("#"+t(this).attr("rel")).val(t(this).val())}),e.find(".redux-dimensions-units").on("change",function(){t(this).parents(".redux-field:first").find(".redux-dimensions-input").change()})}})}}(jQuery);
|
||||
@@ -0,0 +1,305 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'ReduxFramework_dimensions' ) ) {
|
||||
class ReduxFramework_dimensions {
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since ReduxFramework 1.0.0
|
||||
*/
|
||||
function __construct( $field = array(), $value = '', $parent ) {
|
||||
$this->parent = $parent;
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
|
||||
// No errors please
|
||||
$defaults = array(
|
||||
'width' => true,
|
||||
'height' => true,
|
||||
'units_extended' => false,
|
||||
'units' => 'px',
|
||||
'mode' => array(
|
||||
'width' => false,
|
||||
'height' => false,
|
||||
),
|
||||
);
|
||||
|
||||
$this->field = wp_parse_args( $this->field, $defaults );
|
||||
|
||||
$defaults = array(
|
||||
'width' => '',
|
||||
'height' => '',
|
||||
'units' => 'px'
|
||||
);
|
||||
|
||||
$this->value = wp_parse_args( $this->value, $defaults );
|
||||
|
||||
if ( isset( $this->value['unit'] ) ) {
|
||||
$this->value['units'] = $this->value['unit'];
|
||||
}
|
||||
|
||||
} //function
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since ReduxFramework 1.0.0
|
||||
*/
|
||||
function render() {
|
||||
|
||||
/*
|
||||
* Acceptable values checks. If the passed variable doesn't pass muster, we unset them
|
||||
* and reset them with default values to avoid errors.
|
||||
*/
|
||||
|
||||
// If units field has a value but is not an acceptable value, unset the variable
|
||||
if ( isset( $this->field['units'] ) && ! Redux_Helpers::array_in_array( $this->field['units'], array(
|
||||
'',
|
||||
false,
|
||||
'%',
|
||||
'in',
|
||||
'cm',
|
||||
'mm',
|
||||
'em',
|
||||
'ex',
|
||||
'pt',
|
||||
'pc',
|
||||
'px',
|
||||
'rem'
|
||||
) )
|
||||
) {
|
||||
unset( $this->field['units'] );
|
||||
}
|
||||
|
||||
//if there is a default unit value but is not an accepted value, unset the variable
|
||||
if ( isset( $this->value['units'] ) && ! Redux_Helpers::array_in_array( $this->value['units'], array(
|
||||
'',
|
||||
'%',
|
||||
'in',
|
||||
'cm',
|
||||
'mm',
|
||||
'em',
|
||||
'ex',
|
||||
'pt',
|
||||
'pc',
|
||||
'px'
|
||||
) )
|
||||
) {
|
||||
unset( $this->value['units'] );
|
||||
}
|
||||
|
||||
/*
|
||||
* Since units field could be an array, string value or bool (to hide the unit field)
|
||||
* we need to separate our functions to avoid those nasty PHP index notices!
|
||||
*/
|
||||
|
||||
// if field units has a value and IS an array, then evaluate as needed.
|
||||
if ( isset( $this->field['units'] ) && ! is_array( $this->field['units'] ) ) {
|
||||
|
||||
//if units fields has a value but units value does not then make units value the field value
|
||||
if ( isset( $this->field['units'] ) && ! isset( $this->value['units'] ) || $this->field['units'] == false ) {
|
||||
$this->value['units'] = $this->field['units'];
|
||||
|
||||
// If units field does NOT have a value and units value does NOT have a value, set both to blank (default?)
|
||||
} else if ( ! isset( $this->field['units'] ) && ! isset( $this->value['units'] ) ) {
|
||||
$this->field['units'] = 'px';
|
||||
$this->value['units'] = 'px';
|
||||
|
||||
// If units field has NO value but units value does, then set unit field to value field
|
||||
} else if ( ! isset( $this->field['units'] ) && isset( $this->value['units'] ) ) {
|
||||
$this->field['units'] = $this->value['units'];
|
||||
|
||||
// if unit value is set and unit value doesn't equal unit field (coz who knows why)
|
||||
// then set unit value to unit field
|
||||
} elseif ( isset( $this->value['units'] ) && $this->value['units'] !== $this->field['units'] ) {
|
||||
$this->value['units'] = $this->field['units'];
|
||||
}
|
||||
|
||||
// do stuff based on unit field NOT set as an array
|
||||
} elseif ( isset( $this->field['units'] ) && is_array( $this->field['units'] ) ) {
|
||||
// nothing to do here, but I'm leaving the construct just in case I have to debug this again.
|
||||
}
|
||||
|
||||
echo '<fieldset id="' . $this->field['id'] . '-fieldset" class="redux-dimensions-container" data-id="' . $this->field['id'] . '">';
|
||||
|
||||
if ( isset( $this->field['select2'] ) ) { // if there are any let's pass them to js
|
||||
$select2_params = json_encode( $this->field['select2'] );
|
||||
$select2_params = htmlspecialchars( $select2_params, ENT_QUOTES );
|
||||
|
||||
echo '<input type="hidden" class="select2_params" value="' . $select2_params . '">';
|
||||
}
|
||||
|
||||
|
||||
// This used to be unit field, but was giving the PHP index error when it was an array,
|
||||
// so I changed it.
|
||||
echo '<input type="hidden" class="field-units" value="' . $this->value['units'] . '">';
|
||||
|
||||
/**
|
||||
* Width
|
||||
* */
|
||||
if ( $this->field['width'] === true ) {
|
||||
if ( ! empty( $this->value['width'] ) && strpos( $this->value['width'], $this->value['units'] ) === false ) {
|
||||
$this->value['width'] = filter_var( $this->value['width'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION );
|
||||
if ( $this->field['units'] !== false ) {
|
||||
$this->value['width'] .= $this->value['units'];
|
||||
}
|
||||
}
|
||||
echo '<div class="field-dimensions-input input-prepend">';
|
||||
echo '<span class="add-on"><i class="el el-resize-horizontal icon-large"></i></span>';
|
||||
echo '<input type="text" class="redux-dimensions-input redux-dimensions-width mini ' . $this->field['class'] . '" placeholder="' . __( 'Width', 'redux-framework' ) . '" rel="' . $this->field['id'] . '-width" value="' . filter_var( $this->value['width'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) . '">';
|
||||
echo '<input data-id="' . $this->field['id'] . '" type="hidden" id="' . $this->field['id'] . '-width" name="' . $this->field['name'] . $this->field['name_suffix'] . '[width]' . '" value="' . $this->value['width'] . '"></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Height
|
||||
* */
|
||||
if ( $this->field['height'] === true ) {
|
||||
if ( ! empty( $this->value['height'] ) && strpos( $this->value['height'], $this->value['units'] ) === false ) {
|
||||
$this->value['height'] = filter_var( $this->value['height'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION );
|
||||
if ( $this->field['units'] !== false ) {
|
||||
$this->value['height'] .= $this->value['units'];
|
||||
}
|
||||
}
|
||||
echo '<div class="field-dimensions-input input-prepend">';
|
||||
echo '<span class="add-on"><i class="el el-resize-vertical icon-large"></i></span>';
|
||||
echo '<input type="text" class="redux-dimensions-input redux-dimensions-height mini ' . $this->field['class'] . '" placeholder="' . __( 'Height', 'redux-framework' ) . '" rel="' . $this->field['id'] . '-height" value="' . filter_var( $this->value['height'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) . '">';
|
||||
echo '<input data-id="' . $this->field['id'] . '" type="hidden" id="' . $this->field['id'] . '-height" name="' . $this->field['name'] . $this->field['name_suffix'] . '[height]' . '" value="' . $this->value['height'] . '"></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Units
|
||||
* */
|
||||
// If units field is set and units field NOT false then
|
||||
// fill out the options object and show it, otherwise it's hidden
|
||||
// and the default units value will apply.
|
||||
if ( isset( $this->field['units'] ) && $this->field['units'] !== false ) {
|
||||
echo '<div class="select_wrapper dimensions-units" original-title="' . __( 'Units', 'redux-framework' ) . '">';
|
||||
echo '<select data-id="' . $this->field['id'] . '" data-placeholder="' . __( 'Units', 'redux-framework' ) . '" class="redux-dimensions redux-dimensions-units select ' . $this->field['class'] . '" original-title="' . __( 'Units', 'redux-framework' ) . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '[units]' . '">';
|
||||
|
||||
// Extended units, show 'em all
|
||||
if ( $this->field['units_extended'] ) {
|
||||
$testUnits = array( 'px', 'em', 'rem', '%', 'in', 'cm', 'mm', 'ex', 'pt', 'pc' );
|
||||
} else {
|
||||
$testUnits = array( 'px', 'em', 'rem', '%' );
|
||||
}
|
||||
|
||||
if ( $this->field['units'] != "" && is_array( $this->field['units'] ) ) {
|
||||
$testUnits = $this->field['units'];
|
||||
}
|
||||
|
||||
if ( in_array( $this->field['units'], $testUnits ) ) {
|
||||
echo '<option value="' . $this->field['units'] . '" selected="selected">' . $this->field['units'] . '</option>';
|
||||
} else {
|
||||
foreach ( $testUnits as $aUnit ) {
|
||||
echo '<option value="' . $aUnit . '" ' . selected( $this->value['units'], $aUnit, false ) . '>' . $aUnit . '</option>';
|
||||
}
|
||||
}
|
||||
echo '</select></div>';
|
||||
};
|
||||
echo "</fieldset>";
|
||||
} //function
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since ReduxFramework 1.0.0
|
||||
*/
|
||||
function enqueue() {
|
||||
wp_enqueue_style( 'select2-css' );
|
||||
|
||||
wp_enqueue_script(
|
||||
'redux-field-dimensions-js',
|
||||
ReduxFramework::$_url . 'inc/fields/dimensions/field_dimensions' . Redux_Functions::isMin() . '.js',
|
||||
array( 'jquery', 'select2-js', 'redux-js' ),
|
||||
time(),
|
||||
true
|
||||
);
|
||||
|
||||
if ( $this->parent->args['dev_mode'] ) {
|
||||
wp_enqueue_style(
|
||||
'redux-field-dimensions-css',
|
||||
ReduxFramework::$_url . 'inc/fields/dimensions/field_dimensions.css',
|
||||
array(),
|
||||
time(),
|
||||
'all'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function output() {
|
||||
|
||||
// if field units has a value and IS an array, then evaluate as needed.
|
||||
if ( isset( $this->field['units'] ) && ! is_array( $this->field['units'] ) ) {
|
||||
|
||||
//if units fields has a value but units value does not then make units value the field value
|
||||
if ( isset( $this->field['units'] ) && ! isset( $this->value['units'] ) || $this->field['units'] == false ) {
|
||||
$this->value['units'] = $this->field['units'];
|
||||
|
||||
// If units field does NOT have a value and units value does NOT have a value, set both to blank (default?)
|
||||
} else if ( ! isset( $this->field['units'] ) && ! isset( $this->value['units'] ) ) {
|
||||
$this->field['units'] = 'px';
|
||||
$this->value['units'] = 'px';
|
||||
|
||||
// If units field has NO value but units value does, then set unit field to value field
|
||||
} else if ( ! isset( $this->field['units'] ) && isset( $this->value['units'] ) ) {
|
||||
$this->field['units'] = $this->value['units'];
|
||||
|
||||
// if unit value is set and unit value doesn't equal unit field (coz who knows why)
|
||||
// then set unit value to unit field
|
||||
} elseif ( isset( $this->value['units'] ) && $this->value['units'] !== $this->field['units'] ) {
|
||||
$this->value['units'] = $this->field['units'];
|
||||
}
|
||||
|
||||
// do stuff based on unit field NOT set as an array
|
||||
} elseif ( isset( $this->field['units'] ) && is_array( $this->field['units'] ) ) {
|
||||
// nothing to do here, but I'm leaving the construct just in case I have to debug this again.
|
||||
}
|
||||
|
||||
$units = isset( $this->value['units'] ) ? $this->value['units'] : "";
|
||||
|
||||
if (!is_array($this->field['mode'])) {
|
||||
$height = isset( $this->field['mode'] ) && ! empty( $this->field['mode'] ) ? $this->field['mode'] : 'height';
|
||||
$width = isset( $this->field['mode'] ) && ! empty( $this->field['mode'] ) ? $this->field['mode'] : 'width';
|
||||
} else {
|
||||
$height = $this->field['mode']['height'] != false ? $this->field['mode']['height'] : 'height';
|
||||
$width = $this->field['mode']['width'] != false ? $this->field['mode']['width'] : 'width';
|
||||
}
|
||||
|
||||
$cleanValue = array(
|
||||
$height => isset( $this->value['height'] ) ? filter_var( $this->value['height'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : '',
|
||||
$width => isset( $this->value['width'] ) ? filter_var( $this->value['width'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : '',
|
||||
);
|
||||
|
||||
$style = "";
|
||||
|
||||
foreach ( $cleanValue as $key => $value ) {
|
||||
// Output if it's a numeric entry
|
||||
if ( isset( $value ) && is_numeric( $value ) ) {
|
||||
$style .= $key . ':' . $value . $units . ';';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $style ) ) {
|
||||
if ( ! empty( $this->field['output'] ) && is_array( $this->field['output'] ) ) {
|
||||
$keys = implode( ",", $this->field['output'] );
|
||||
$this->parent->outputCSS .= $keys . "{" . $style . '}';
|
||||
}
|
||||
|
||||
if ( ! empty( $this->field['compiler'] ) && is_array( $this->field['compiler'] ) ) {
|
||||
$keys = implode( ",", $this->field['compiler'] );
|
||||
$this->parent->compilerCSS .= $keys . "{" . $style . '}';
|
||||
}
|
||||
}
|
||||
} //function
|
||||
} //class
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
.redux-dimensions-container {
|
||||
select,
|
||||
.select_wrapper {
|
||||
width: 65px !important;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.field-dimensions-input {
|
||||
margin-right: 10px;
|
||||
margin-bottom: 7px;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 782px) {
|
||||
.redux-dimensions-container {
|
||||
.field-dimensions-input {
|
||||
input {
|
||||
display: inline-block !important;
|
||||
width: 100px !important;
|
||||
}
|
||||
|
||||
.add-on {
|
||||
padding: 7px 4px;
|
||||
font-size: 16px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
.select_wrapper {
|
||||
margin-top: 6px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
.redux-main .divide{height:20px;line-height:20px;float:none;border-color:#E7E7E7;display:block;width:100%;height:35px !important;line-height:35px !important;position:relative;margin:15px 0 10px 0}.redux-main .divide .inner{width:42% !important;left:40% !important;margin-left:-6%;background-color:#FCFCFC;border-color:#E7E7E7;position:absolute;height:1px;top:50%;width:100%;margin-top:-1px;border-top-width:1px;border-top-style:solid}.redux-main .divide .inner span{background-color:#FCFCFC;border-color:#E7E7E7;height:5px;width:5px;border-width:2px;border-style:solid;display:block;position:absolute;left:50%;margin-left:-5px;margin-top:-5px}.wp-customizer .redux-container-divide .divide .inner{width:82% !important;left:18% !important;margin-left:-8%}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"mappings": "AACI,mBAAQ;EACJ,MAAM,EAAE,IAAI;EACZ,WAAW,EAAE,IAAI;EACjB,KAAK,EAAE,IAAI;EACX,YAAY,EAAE,OAAO;EACrB,OAAO,EAAE,KAAK;EACd,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,eAAe;EACvB,WAAW,EAAE,eAAe;EAC5B,QAAQ,EAAE,QAAQ;EAClB,MAAM,EAAE,aAAa;EAErB,0BAAO;IACH,KAAK,EAAE,cAAc;IACrB,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,GAAG;IAChB,gBAAgB,EAAE,OAAO;IACzB,YAAY,EAAE,OAAO;IACrB,QAAQ,EAAE,QAAQ;IAClB,MAAM,EAAE,GAAG;IACX,GAAG,EAAE,GAAG;IACR,KAAK,EAAE,IAAI;IACX,UAAU,EAAE,IAAI;IAChB,gBAAgB,EAAE,GAAG;IACrB,gBAAgB,EAAE,KAAK;IACvB,+BAAK;MACD,gBAAgB,EAAE,OAAO;MACzB,YAAY,EAAE,OAAO;MACrB,MAAM,EAAE,GAAG;MACX,KAAK,EAAE,GAAG;MACV,YAAY,EAAE,GAAG;MACjB,YAAY,EAAE,KAAK;MACnB,OAAO,EAAE,KAAK;MACd,QAAQ,EAAE,QAAQ;MAClB,IAAI,EAAE,GAAG;MACT,WAAW,EAAE,IAAI;MACjB,UAAU,EAAE,IAAI;;AAO5B,qDAAe;EACX,KAAK,EAAE,cAAc;EACrB,IAAI,EAAE,cAAc;EACpB,WAAW,EAAE,GAAG",
|
||||
"sources": ["field_divide.scss"],
|
||||
"names": [],
|
||||
"file": "field_divide.css"
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Redux Framework is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* any later version.
|
||||
* Redux Framework is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package ReduxFramework
|
||||
* @subpackage Field_Divide
|
||||
* @author Daniel J Griffiths (Ghost1227)
|
||||
* @author Dovy Paukstys
|
||||
* @version 3.0.0
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( !defined ( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Don't duplicate me!
|
||||
if ( !class_exists ( 'ReduxFramework_divide' ) ) {
|
||||
|
||||
/**
|
||||
* Main ReduxFramework_divide class
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ReduxFramework_divide {
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function __construct ( $field = array(), $value = '', $parent ) {
|
||||
$this->parent = $parent;
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function render () {
|
||||
echo '</td></tr></table>';
|
||||
echo '<div data-id="' . $this->field[ 'id' ] . '" id="divide-' . $this->field[ 'id' ] . '" class="divide ' . $this->field[ 'class' ] . '"><div class="inner"><span> </span></div></div>';
|
||||
echo '<table class="form-table no-border"><tbody><tr><th></th><td>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {
|
||||
if ($this->parent->args['dev_mode']) {
|
||||
wp_enqueue_style(
|
||||
'redux-field-divide',
|
||||
ReduxFramework::$_url . 'inc/fields/divide/field_divide.css',
|
||||
array(),
|
||||
time(),
|
||||
'all'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
.redux-main {
|
||||
.divide {
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
float: none;
|
||||
border-color: #E7E7E7;
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 35px !important;
|
||||
line-height: 35px !important;
|
||||
position: relative;
|
||||
margin: 15px 0 10px 0;
|
||||
|
||||
.inner {
|
||||
width: 42% !important;
|
||||
left: 40% !important;
|
||||
margin-left: -6%;
|
||||
background-color: #FCFCFC;
|
||||
border-color: #E7E7E7;
|
||||
position: absolute;
|
||||
height: 1px;
|
||||
top: 50%;
|
||||
width: 100%;
|
||||
margin-top: -1px;
|
||||
border-top-width: 1px;
|
||||
border-top-style: solid;
|
||||
span {
|
||||
background-color: #FCFCFC;
|
||||
border-color: #E7E7E7;
|
||||
height: 5px;
|
||||
width: 5px;
|
||||
border-width: 2px;
|
||||
border-style: solid;
|
||||
display: block;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
margin-left: -5px;
|
||||
margin-top: -5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.wp-customizer .redux-container-divide {
|
||||
.divide .inner {
|
||||
width: 82% !important;
|
||||
left: 18% !important;
|
||||
margin-left: -8%;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
.redux-container-editor .mceLayout td{border-width:1px;margin:0;padding:1px}.redux-container-editor input,.redux-container-editor textarea{margin:inherit}.redux-container-editor textarea{border-style:none;border:0;border-width:0}.redux-container-editor .wp-editor-container{-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.redux-container-editor .wp-editor-container textarea{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;border-style:inherit}.redux-container-editor .quicktags-toolbar input{margin:2px 1px 4px;line-height:18px;display:inline-block;min-width:26px;padding:2px 4px;font:12px/18px Arial, Helvetica, sans-serif normal;color:#464646;border:1px solid #c3c3c3;-webkit-border-radius:3px;border-radius:3px;background:#eee;background-image:-webkit-gradient(linear, left bottom, left top, from(#e3e3e3), to(#fff));background-image:-webkit-linear-gradient(bottom, #e3e3e3, #fff);background-image:-moz-linear-gradient(bottom, #e3e3e3, #fff);background-image:-o-linear-gradient(bottom, #e3e3e3, #fff);background-image:linear-gradient(to top, #e3e3e3, #fff)}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"mappings": "AACI,qCAAc;EACV,YAAY,EAAE,GAAG;EACjB,MAAM,EAAE,CAAC;EACT,OAAO,EAAE,GAAG;AAGhB;gCACS;EACL,MAAM,EAAE,OAAO;AAGnB,gCAAS;EACL,YAAY,EAAE,IAAI;EAClB,MAAM,EAAE,CAAC;EACT,YAAY,EAAE,CAAC;AAGnB,4CAAqB;EACjB,qBAAqB,EAAE,GAAG;EAC1B,kBAAkB,EAAE,GAAG;EACvB,aAAa,EAAE,GAAG;EAElB,qDAAS;IACL,qBAAqB,EAAE,CAAC;IACxB,kBAAkB,EAAE,CAAC;IACrB,aAAa,EAAE,CAAC;IAChB,YAAY,EAAE,OAAO;AAI7B,gDAAyB;EACrB,MAAM,EAAE,WAAW;EACnB,WAAW,EAAE,IAAI;EACjB,OAAO,EAAE,YAAY;EACrB,SAAS,EAAE,IAAI;EACf,OAAO,EAAE,OAAO;EAChB,IAAI,EAAE,6CAA6C;EACnD,KAAK,EAAE,OAAO;EACd,MAAM,EAAE,iBAAiB;EACzB,qBAAqB,EAAE,GAAG;EAC1B,aAAa,EAAE,GAAG;EAClB,UAAU,EAAE,IAAI;EAChB,gBAAgB,EAAE,wEAAwE;EAC1F,gBAAgB,EAAE,8CAA8C;EAChE,gBAAgB,EAAE,2CAA2C;EAC7D,gBAAgB,EAAE,yCAAyC;EAC3D,gBAAgB,EAAE,sCAAsC",
|
||||
"sources": ["field_editor.scss"],
|
||||
"names": [],
|
||||
"file": "field_editor.css"
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Redux Editor on change callback
|
||||
* Dependencies : jquery
|
||||
* Feature added by : Dovy Paukstys
|
||||
* : Kevin Provance (who helped) :P
|
||||
* Date : 07 June 2014
|
||||
*/
|
||||
|
||||
/*global redux_change, wp, tinymce, redux*/
|
||||
(function( $ ) {
|
||||
"use strict";
|
||||
|
||||
redux.field_objects = redux.field_objects || {};
|
||||
redux.field_objects.editor = redux.field_objects.editor || {};
|
||||
|
||||
$( document ).ready(
|
||||
function() {
|
||||
//redux.field_objects.editor.init();
|
||||
}
|
||||
);
|
||||
|
||||
redux.field_objects.editor.init = function( selector ) {
|
||||
setTimeout(
|
||||
function() {
|
||||
if (typeof(tinymce) !== 'undefined') {
|
||||
for ( var i = 0; i < tinymce.editors.length; i++ ) {
|
||||
redux.field_objects.editor.onChange( i );
|
||||
}
|
||||
}
|
||||
}, 1000
|
||||
);
|
||||
};
|
||||
|
||||
redux.field_objects.editor.onChange = function( i ) {
|
||||
tinymce.editors[i].on(
|
||||
'change', function( e ) {
|
||||
var el = jQuery( e.target.contentAreaContainer );
|
||||
if ( el.parents( '.redux-container-editor:first' ).length !== 0 ) {
|
||||
redux_change( $( '.wp-editor-area' ) );
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
})( jQuery );
|
||||
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/editor/field_editor.min.js
vendored
Normal file
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/editor/field_editor.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(t){"use strict";redux.field_objects=redux.field_objects||{},redux.field_objects.editor=redux.field_objects.editor||{},t(document).ready(function(){}),redux.field_objects.editor.init=function(e){setTimeout(function(){if("undefined"!=typeof tinymce)for(var e=0;e<tinymce.editors.length;e++)redux.field_objects.editor.onChange(e)},1e3)},redux.field_objects.editor.onChange=function(e){tinymce.editors[e].on("change",function(e){0!==jQuery(e.target.contentAreaContainer).parents(".redux-container-editor:first").length&&redux_change(t(".wp-editor-area"))})}}(jQuery);
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Redux Framework is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* any later version.
|
||||
* Redux Framework is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package ReduxFramework
|
||||
* @subpackage Field_Editor
|
||||
* @author Daniel J Griffiths (Ghost1227)
|
||||
* @author Dovy Paukstys
|
||||
* @author Kevin Provance (kprovance)
|
||||
* @version 3.0.0
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Don't duplicate me!
|
||||
if ( ! class_exists( 'ReduxFramework_editor' ) ) {
|
||||
|
||||
/**
|
||||
* Main ReduxFramework_editor class
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ReduxFramework_editor {
|
||||
|
||||
/**
|
||||
* Field Constructor.
|
||||
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function __construct( $field = array(), $value = '', $parent ) {
|
||||
$this->parent = $parent;
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function render() {
|
||||
|
||||
if ( ! isset( $this->field['args'] ) ) {
|
||||
$this->field['args'] = array();
|
||||
}
|
||||
|
||||
$this->field['args']['onchange_callback'] = "alert('here')";
|
||||
|
||||
// Setup up default args
|
||||
$defaults = array(
|
||||
'textarea_name' => $this->field['name'] . $this->field['name_suffix'],
|
||||
'editor_class' => $this->field['class'],
|
||||
'textarea_rows' => 10, //Wordpress default
|
||||
'teeny' => true,
|
||||
);
|
||||
|
||||
if ( isset( $this->field['editor_options'] ) && empty( $this->field['args'] ) ) {
|
||||
$this->field['args'] = $this->field['editor_options'];
|
||||
unset( $this->field['editor_options'] );
|
||||
}
|
||||
|
||||
$this->field['args'] = wp_parse_args( $this->field['args'], $defaults );
|
||||
|
||||
wp_editor( $this->value, $this->field['id'], $this->field['args'] );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {
|
||||
if ($this->parent->args['dev_mode']) {
|
||||
wp_enqueue_style(
|
||||
'redux-field-editor-css',
|
||||
ReduxFramework::$_url . 'inc/fields/editor/field_editor.css',
|
||||
array(),
|
||||
time(),
|
||||
'all'
|
||||
);
|
||||
}
|
||||
|
||||
wp_enqueue_script(
|
||||
'redux-field-editor-js',
|
||||
ReduxFramework::$_url . 'inc/fields/editor/field_editor' . Redux_Functions::isMin() . '.js',
|
||||
array( 'jquery', 'redux-js' ),
|
||||
time(),
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
.redux-container-editor {
|
||||
.mceLayout td {
|
||||
border-width: 1px;
|
||||
margin: 0;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
input,
|
||||
textarea {
|
||||
margin: inherit;
|
||||
}
|
||||
|
||||
textarea {
|
||||
border-style: none;
|
||||
border: 0;
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
.wp-editor-container {
|
||||
-webkit-border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
|
||||
textarea {
|
||||
-webkit-border-radius: 0;
|
||||
-moz-border-radius: 0;
|
||||
border-radius: 0;
|
||||
border-style: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
.quicktags-toolbar input {
|
||||
margin: 2px 1px 4px;
|
||||
line-height: 18px;
|
||||
display: inline-block;
|
||||
min-width: 26px;
|
||||
padding: 2px 4px;
|
||||
font: 12px/18px Arial, Helvetica, sans-serif normal;
|
||||
color: #464646;
|
||||
border: 1px solid #c3c3c3;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
background: #eee;
|
||||
background-image: -webkit-gradient(linear, left bottom, left top, from(#e3e3e3), to(#fff));
|
||||
background-image: -webkit-linear-gradient(bottom, #e3e3e3, #fff);
|
||||
background-image: -moz-linear-gradient(bottom, #e3e3e3, #fff);
|
||||
background-image: -o-linear-gradient(bottom, #e3e3e3, #fff);
|
||||
background-image: linear-gradient(to top, #e3e3e3, #fff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/* global redux_change, wp */
|
||||
|
||||
/*global redux_change, redux*/
|
||||
|
||||
(function( $ ) {
|
||||
"use strict";
|
||||
|
||||
redux.field_objects = redux.field_objects || {};
|
||||
redux.field_objects.gallery = redux.field_objects.gallery || {};
|
||||
|
||||
redux.field_objects.gallery.init = function( selector ) {
|
||||
|
||||
|
||||
if ( !selector ) {
|
||||
selector = $( document ).find( '.redux-container-gallery:visible' );
|
||||
}
|
||||
|
||||
$( selector ).each(
|
||||
function() {
|
||||
var el = $( this );
|
||||
var parent = el;
|
||||
if ( !el.hasClass( 'redux-field-container' ) ) {
|
||||
parent = el.parents( '.redux-field-container:first' );
|
||||
}
|
||||
if ( parent.is( ":hidden" ) ) { // Skip hidden fields
|
||||
return;
|
||||
}
|
||||
if ( parent.hasClass( 'redux-field-init' ) ) {
|
||||
parent.removeClass( 'redux-field-init' );
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
// When the user clicks on the Add/Edit gallery button, we need to display the gallery editing
|
||||
el.on(
|
||||
{
|
||||
click: function( event ) {
|
||||
//console.log(event);
|
||||
// hide gallery settings used for posts/pages
|
||||
wp.media.view.Settings.Gallery = wp.media.view.Settings.Gallery.extend({
|
||||
// render: function(){
|
||||
// console.log(wp.media.view);
|
||||
// this.update.apply( this, ['size'] );
|
||||
// return this;
|
||||
// },
|
||||
template: function(view){
|
||||
//console.log(view);
|
||||
|
||||
return;// wp.media.template('gallery-settings')(view);
|
||||
}
|
||||
});
|
||||
|
||||
var current_gallery = $( this ).closest( 'fieldset' );
|
||||
|
||||
if ( event.currentTarget.id === 'clear-gallery' ) {
|
||||
//remove value from input
|
||||
|
||||
var rmVal = current_gallery.find( '.gallery_values' ).val( '' );
|
||||
|
||||
//remove preview images
|
||||
current_gallery.find( ".screenshot" ).html( "" );
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// Make sure the media gallery API exists
|
||||
if ( typeof wp === 'undefined' || !wp.media || !wp.media.gallery ) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
|
||||
// Activate the media editor
|
||||
var $$ = $( this );
|
||||
|
||||
var val = current_gallery.find( '.gallery_values' ).val();
|
||||
var final;
|
||||
|
||||
if ( !val ) {
|
||||
final = '[gallery ids="0"]';
|
||||
} else {
|
||||
final = '[gallery ids="' + val + '"]';
|
||||
}
|
||||
|
||||
|
||||
var frame = wp.media.gallery.edit( final );
|
||||
|
||||
if (!val) {
|
||||
var uploader = $('body').find('#' + frame.el.id);
|
||||
var inline = uploader.find('.uploader-inline');
|
||||
var spinner = uploader.find('.media-toolbar .spinner');
|
||||
|
||||
setTimeout(
|
||||
function(){
|
||||
if (inline.hasClass('hidden')) {
|
||||
inline.removeClass('hidden');
|
||||
spinner.removeClass('is-active');
|
||||
}
|
||||
}, 400
|
||||
);
|
||||
}
|
||||
|
||||
// When the gallery-edit state is updated, copy the attachment ids across
|
||||
frame.state( 'gallery-edit' ).on(
|
||||
'update', function( selection ) {
|
||||
|
||||
//clear screenshot div so we can append new selected images
|
||||
current_gallery.find( ".screenshot" ).html( "" );
|
||||
|
||||
var element, preview_html = "", preview_img;
|
||||
var ids = selection.models.map(
|
||||
function( e ) {
|
||||
element = e.toJSON();
|
||||
//preview_img = typeof element.sizes.thumbnail !== 'undefined' ? element.sizes.thumbnail.url : element.url;
|
||||
preview_img = (typeof element.sizes !== "undefined" && typeof element.sizes.thumbnail !== 'undefined') ? element.sizes.thumbnail.url : element.url;
|
||||
|
||||
preview_html = "<a class='of-uploaded-image' href='" + preview_img + "'><img class='redux-option-image' src='" + preview_img + "' alt='' /></a>";
|
||||
current_gallery.find( ".screenshot" ).append( preview_html );
|
||||
|
||||
return e.id;
|
||||
}
|
||||
);
|
||||
|
||||
current_gallery.find( '.gallery_values' ).val( ids.join( ',' ) );
|
||||
redux_change( current_gallery.find( '.gallery_values' ) );
|
||||
frame.detach();
|
||||
}
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
}, '.gallery-attachments'
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
};
|
||||
})( jQuery );
|
||||
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/gallery/field_gallery.min.js
vendored
Normal file
1
wp-content/plugins/redux-framework/ReduxCore/inc/fields/gallery/field_gallery.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(s){"use strict";redux.field_objects=redux.field_objects||{},redux.field_objects.gallery=redux.field_objects.gallery||{},redux.field_objects.gallery.init=function(e){e||(e=s(document).find(".redux-container-gallery:visible")),s(e).each(function(){var e=s(this),i=e;e.hasClass("redux-field-container")||(i=e.parents(".redux-field-container:first")),i.is(":hidden")||i.hasClass("redux-field-init")&&(i.removeClass("redux-field-init"),e.on({click:function(e){wp.media.view.Settings.Gallery=wp.media.view.Settings.Gallery.extend({template:function(e){}});var n=s(this).closest("fieldset");if("clear-gallery"!==e.currentTarget.id){if("undefined"!=typeof wp&&wp.media&&wp.media.gallery){e.preventDefault();s(this);var i,l=n.find(".gallery_values").val();i=l?'[gallery ids="'+l+'"]':'[gallery ids="0"]';var t=wp.media.gallery.edit(i);if(!l){var a=s("body").find("#"+t.el.id),d=a.find(".uploader-inline"),r=a.find(".media-toolbar .spinner");setTimeout(function(){d.hasClass("hidden")&&(d.removeClass("hidden"),r.removeClass("is-active"))},400)}return t.state("gallery-edit").on("update",function(e){n.find(".screenshot").html("");var i,l,a="",d=e.models.map(function(e){return i=e.toJSON(),l=void 0!==i.sizes&&void 0!==i.sizes.thumbnail?i.sizes.thumbnail.url:i.url,a="<a class='of-uploaded-image' href='"+l+"'><img class='redux-option-image' src='"+l+"' alt='' /></a>",n.find(".screenshot").append(a),e.id});n.find(".gallery_values").val(d.join(",")),redux_change(n.find(".gallery_values")),t.detach()}),!1}}else{n.find(".gallery_values").val("");n.find(".screenshot").html("")}}},".gallery-attachments"))})}}(jQuery);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user