mirror of
https://github.com/mainwp/mainwp-child.git
synced 2025-09-06 09:20:28 +08:00
Merge with branch01 + update version/readme
This commit is contained in:
parent
2281b39cc1
commit
e182da8e01
6 changed files with 133 additions and 17 deletions
|
@ -498,14 +498,14 @@ class MainWP_Child_Branding {
|
|||
}
|
||||
|
||||
if ( ! empty( $header_css ) ) {
|
||||
echo '<style>' . esc_html( $header_css ) . '</style>';
|
||||
echo '<style>' . MainWP_Helper::parse_css( $header_css ) . '</style>';
|
||||
}
|
||||
}
|
||||
|
||||
function custom_login_css() {
|
||||
$extra_setting = $this->settings['extra_settings'];
|
||||
if ( is_array( $extra_setting ) && isset( $extra_setting['login_css'] ) && ! empty( $extra_setting['login_css'] ) ) {
|
||||
echo '<style>' . esc_html( $extra_setting['login_css'] ) . '</style>';
|
||||
echo '<style>' . MainWP_Helper::parse_css( $extra_setting['login_css'] ) . '</style>';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -658,7 +658,7 @@ class MainWP_Child_Branding {
|
|||
<h2><?php echo esc_html( $this->settings['contact_support_label'] ); ?></h2>
|
||||
|
||||
<div style="height: auto; margin-bottom: 10px; text-align: left">
|
||||
<p><?php echo esc_html( $support_message ); ?></p>
|
||||
<p><?php echo wp_kses_post( $support_message ); ?></p>
|
||||
|
||||
<div style="max-width: 650px;">
|
||||
<?php
|
||||
|
|
|
@ -78,7 +78,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
|
|||
}
|
||||
|
||||
class MainWP_Child {
|
||||
public static $version = '3.0';
|
||||
public static $version = '3.0.1';
|
||||
private $update_version = '1.3';
|
||||
|
||||
private $callableFunctions = array(
|
||||
|
@ -1127,9 +1127,11 @@ class MainWP_Child {
|
|||
$result = array();
|
||||
foreach ( $urls as $url ) {
|
||||
$installer = new WP_Upgrader();
|
||||
$ssl_verify = true;
|
||||
//@see wp-admin/includes/class-wp-upgrader.php
|
||||
if ( isset( $_POST['sslVerify'] ) && '0' === $_POST['sslVerify'] ) {
|
||||
add_filter( 'http_request_args', array( &$this, 'noSSLFilterFunction' ), 99, 2 );
|
||||
$ssl_verify = false;
|
||||
}
|
||||
add_filter( 'http_request_args', array( &$this, 'http_request_reject_unsafe_urls' ), 99, 2 );
|
||||
|
||||
|
@ -1143,17 +1145,36 @@ class MainWP_Child {
|
|||
'hook_extra' => array(),
|
||||
) );
|
||||
|
||||
remove_filter( 'http_request_args', array( &$this, 'http_request_reject_unsafe_urls' ), 99, 2 );
|
||||
if ( isset( $_POST['sslVerify'] ) && '0' === $_POST['sslVerify'] ) {
|
||||
remove_filter( 'http_request_args', array( &$this, 'noSSLFilterFunction' ), 99 );
|
||||
}
|
||||
if ( is_wp_error( $result ) ) {
|
||||
$error = $result->get_error_codes();
|
||||
if ( is_array( $error ) ) {
|
||||
MainWP_Helper::error( implode( ', ', $error ) );
|
||||
} else {
|
||||
MainWP_Helper::error( $error );
|
||||
if ( true == $ssl_verify && strpos( $url, 'https://' ) === 0) {
|
||||
// retry
|
||||
add_filter( 'http_request_args', array( &$this, 'noSSLFilterFunction' ), 99, 2 );
|
||||
$ssl_verify = false;
|
||||
$result = $installer->run( array(
|
||||
'package' => $url,
|
||||
'destination' => ( 'plugin' === $_POST['type'] ? WP_PLUGIN_DIR
|
||||
: WP_CONTENT_DIR . '/themes' ),
|
||||
'clear_destination' => ( isset( $_POST['overwrite'] ) && $_POST['overwrite'] ),
|
||||
//overwrite files?
|
||||
'clear_working' => true,
|
||||
'hook_extra' => array(),
|
||||
) );
|
||||
}
|
||||
|
||||
if ( is_wp_error( $result ) ) {
|
||||
if ( $result->get_error_data() && is_string( $result->get_error_data() ) ) {
|
||||
$error = $result->get_error_data();
|
||||
MainWP_Helper::error( $error );
|
||||
} else {
|
||||
$error = $result->get_error_code();
|
||||
MainWP_Helper::error( implode( ', ', $error ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
remove_filter( 'http_request_args', array( &$this, 'http_request_reject_unsafe_urls' ), 99, 2 );
|
||||
if ( false == $ssl_verify ) {
|
||||
remove_filter( 'http_request_args', array( &$this, 'noSSLFilterFunction' ), 99 );
|
||||
}
|
||||
|
||||
$args = array( 'success' => 1, 'action' => 'install' );
|
||||
|
|
|
@ -207,9 +207,9 @@ class MainWP_Clone_Install {
|
|||
|
||||
$var = $wpdb->get_var( $wpdb->prepare( 'SELECT option_value FROM ' . $this->config['prefix'] . 'options WHERE option_name = %s', $name) );
|
||||
if ( null === $var ) {
|
||||
$wpdb->query( $wpdb->prepare( 'INSERT INTO ' . $this->config['prefix'] . 'options (`option_name`, `option_value`) VALUES (%s, "' . MainWPChildDB::real_escape_string( maybe_serialize( $value ) ) . '")', $name) );
|
||||
$wpdb->query( $wpdb->prepare( 'INSERT INTO ' . $this->config['prefix'] . 'options (`option_name`, `option_value`) VALUES (%s, "' . MainWP_Child_DB::real_escape_string( maybe_serialize( $value ) ) . '")', $name) );
|
||||
} else {
|
||||
$wpdb->query( $wpdb->prepare( 'UPDATE ' . $this->config['prefix'] . 'options SET option_value = "' . MainWPChildDB::real_escape_string( maybe_serialize( $value ) ) . '" WHERE option_name = %s', $name) );
|
||||
$wpdb->query( $wpdb->prepare( 'UPDATE ' . $this->config['prefix'] . 'options SET option_value = "' . MainWP_Child_DB::real_escape_string( maybe_serialize( $value ) ) . '" WHERE option_name = %s', $name) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,96 @@ class MainWP_Helper {
|
|||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
||||
/**
|
||||
* PARSE
|
||||
* Parses some CSS into an array
|
||||
* CSSPARSER
|
||||
* Copyright (C) 2009 Peter Kröner
|
||||
*/
|
||||
public static function parse_css($css){
|
||||
|
||||
// Remove CSS-Comments
|
||||
$css = preg_replace('/\/\*.*?\*\//ms', '', $css);
|
||||
// Remove HTML-Comments
|
||||
$css = preg_replace('/([^\'"]+?)(\<!--|--\>)([^\'"]+?)/ms', '$1$3', $css);
|
||||
// Extract @media-blocks into $blocks
|
||||
preg_match_all('/@.+?\}[^\}]*?\}/ms',$css, $blocks);
|
||||
// Append the rest to $blocks
|
||||
array_push($blocks[0],preg_replace('/@.+?\}[^\}]*?\}/ms','',$css));
|
||||
$ordered = array();
|
||||
for($i=0;$i<count($blocks[0]);$i++){
|
||||
// If @media-block, strip declaration and parenthesis
|
||||
if(substr($blocks[0][$i],0,6) === '@media')
|
||||
{
|
||||
$ordered_key = preg_replace('/^(@media[^\{]+)\{.*\}$/ms','$1',$blocks[0][$i]);
|
||||
$ordered_value = preg_replace('/^@media[^\{]+\{(.*)\}$/ms','$1',$blocks[0][$i]);
|
||||
}
|
||||
// Rule-blocks of the sort @import or @font-face
|
||||
elseif(substr($blocks[0][$i],0,1) === '@')
|
||||
{
|
||||
$ordered_key = $blocks[0][$i];
|
||||
$ordered_value = $blocks[0][$i];
|
||||
}
|
||||
else
|
||||
{
|
||||
$ordered_key = 'main';
|
||||
$ordered_value = $blocks[0][$i];
|
||||
}
|
||||
// Split by parenthesis, ignoring those inside content-quotes
|
||||
$ordered[$ordered_key] = preg_split('/([^\'"\{\}]*?[\'"].*?(?<!\\\)[\'"][^\'"\{\}]*?)[\{\}]|([^\'"\{\}]*?)[\{\}]/',trim($ordered_value," \r\n\t"),-1,PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
|
||||
}
|
||||
|
||||
// Beginning to rebuild new slim CSS-Array
|
||||
foreach($ordered as $key => $val){
|
||||
$new = array();
|
||||
for($i = 0; $i<count($val); $i++){
|
||||
// Split selectors and rules and split properties and values
|
||||
$selector = trim($val[$i]," \r\n\t");
|
||||
|
||||
if(!empty($selector)){
|
||||
if(!isset($new[$selector])) $new[$selector] = array();
|
||||
$rules = explode(';',$val[++$i]);
|
||||
foreach($rules as $rule){
|
||||
$rule = trim($rule," \r\n\t");
|
||||
if(!empty($rule)){
|
||||
$rule = array_reverse(explode(':', $rule));
|
||||
$property = trim(array_pop($rule)," \r\n\t");
|
||||
$value = implode(':', array_reverse($rule));
|
||||
|
||||
if(!isset($new[$selector][$property]) || !preg_match('/!important/',$new[$selector][$property])) $new[$selector][$property] = $value;
|
||||
elseif(preg_match('/!important/',$new[$selector][$property]) && preg_match('/!important/',$value)) $new[$selector][$property] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$ordered[$key] = $new;
|
||||
}
|
||||
$parsed = $ordered;
|
||||
|
||||
$output = '';
|
||||
foreach($parsed as $media => $content){
|
||||
if(substr($media,0,6) === '@media'){
|
||||
$output .= $media . " {\n";
|
||||
$prefix = "\t";
|
||||
}
|
||||
else $prefix = "";
|
||||
|
||||
foreach($content as $selector => $rules){
|
||||
$output .= $prefix.$selector . " {\n";
|
||||
foreach($rules as $property => $value){
|
||||
$output .= $prefix."\t".$property.': '.$value;
|
||||
$output .= ";\n";
|
||||
}
|
||||
$output .= $prefix."}\n\n";
|
||||
}
|
||||
if(substr($media,0,6) === '@media'){
|
||||
$output .= "}\n\n";
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
static function uploadImage( $img_url ) {
|
||||
include_once( ABSPATH . 'wp-admin/includes/file.php' ); //Contains download_url
|
||||
//Download $img_url
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
Author: MainWP
|
||||
Author URI: http://mainwp.com
|
||||
Text Domain: mainwp-child
|
||||
Version: 3.0
|
||||
Version: 3.0.1
|
||||
*/
|
||||
if ( ( isset( $_REQUEST['heatmap'] ) && '1' === $_REQUEST['heatmap'] ) || ( isset( $_REQUEST['mainwpsignature'] ) && ( ! empty( $_REQUEST['mainwpsignature'] ) ) ) ) {
|
||||
header( 'X-Frame-Options: ALLOWALL' );
|
||||
|
|
|
@ -7,7 +7,7 @@ Author URI: https://mainwp.com
|
|||
Plugin URI: https://mainwp.com
|
||||
Requires at least: 3.6
|
||||
Tested up to: 4.4.1
|
||||
Stable tag: 3.0
|
||||
Stable tag: 3.0.1
|
||||
License: GPLv2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
|
@ -57,6 +57,11 @@ To see full documentation and FAQs please visit [MainWP Documentation](http://do
|
|||
|
||||
== Changelog ==
|
||||
|
||||
= 3.0.1 - 1-18-16 =
|
||||
* Fixed: HTML output of branding contact form
|
||||
* Added: Auto retry install plugin/theme if installation fails
|
||||
* Fixed: Issue with rendering CSS used in the Branding extension
|
||||
|
||||
= 3.0 - 1-12-16 =
|
||||
* Fixed: Refactored code to meet WordPress Coding standards
|
||||
* Fixed: Deprecated Function
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue