Merge with branch01 + update version/readme

This commit is contained in:
ruben- 2016-01-18 19:40:51 +01:00
parent 2281b39cc1
commit e182da8e01
6 changed files with 133 additions and 17 deletions

View file

@ -498,14 +498,14 @@ class MainWP_Child_Branding {
} }
if ( ! empty( $header_css ) ) { if ( ! empty( $header_css ) ) {
echo '<style>' . esc_html( $header_css ) . '</style>'; echo '<style>' . MainWP_Helper::parse_css( $header_css ) . '</style>';
} }
} }
function custom_login_css() { function custom_login_css() {
$extra_setting = $this->settings['extra_settings']; $extra_setting = $this->settings['extra_settings'];
if ( is_array( $extra_setting ) && isset( $extra_setting['login_css'] ) && ! empty( $extra_setting['login_css'] ) ) { 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> <h2><?php echo esc_html( $this->settings['contact_support_label'] ); ?></h2>
<div style="height: auto; margin-bottom: 10px; text-align: left"> <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;"> <div style="max-width: 650px;">
<?php <?php

View file

@ -78,7 +78,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
} }
class MainWP_Child { class MainWP_Child {
public static $version = '3.0'; public static $version = '3.0.1';
private $update_version = '1.3'; private $update_version = '1.3';
private $callableFunctions = array( private $callableFunctions = array(
@ -1127,9 +1127,11 @@ class MainWP_Child {
$result = array(); $result = array();
foreach ( $urls as $url ) { foreach ( $urls as $url ) {
$installer = new WP_Upgrader(); $installer = new WP_Upgrader();
$ssl_verify = true;
//@see wp-admin/includes/class-wp-upgrader.php //@see wp-admin/includes/class-wp-upgrader.php
if ( isset( $_POST['sslVerify'] ) && '0' === $_POST['sslVerify'] ) { if ( isset( $_POST['sslVerify'] ) && '0' === $_POST['sslVerify'] ) {
add_filter( 'http_request_args', array( &$this, 'noSSLFilterFunction' ), 99, 2 ); 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 ); add_filter( 'http_request_args', array( &$this, 'http_request_reject_unsafe_urls' ), 99, 2 );
@ -1143,17 +1145,36 @@ class MainWP_Child {
'hook_extra' => array(), '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 ) ) { if ( is_wp_error( $result ) ) {
$error = $result->get_error_codes(); if ( true == $ssl_verify && strpos( $url, 'https://' ) === 0) {
if ( is_array( $error ) ) { // retry
MainWP_Helper::error( implode( ', ', $error ) ); add_filter( 'http_request_args', array( &$this, 'noSSLFilterFunction' ), 99, 2 );
} else { $ssl_verify = false;
MainWP_Helper::error( $error ); $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' ); $args = array( 'success' => 1, 'action' => 'install' );

View file

@ -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) ); $var = $wpdb->get_var( $wpdb->prepare( 'SELECT option_value FROM ' . $this->config['prefix'] . 'options WHERE option_name = %s', $name) );
if ( null === $var ) { 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 { } 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) );
} }
} }

View file

@ -29,6 +29,96 @@ class MainWP_Helper {
MainWP_Helper::write( $information ); 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 ) { static function uploadImage( $img_url ) {
include_once( ABSPATH . 'wp-admin/includes/file.php' ); //Contains download_url include_once( ABSPATH . 'wp-admin/includes/file.php' ); //Contains download_url
//Download $img_url //Download $img_url

View file

@ -6,7 +6,7 @@
Author: MainWP Author: MainWP
Author URI: http://mainwp.com Author URI: http://mainwp.com
Text Domain: mainwp-child Text Domain: mainwp-child
Version: 3.0 Version: 3.0.1
*/ */
if ( ( isset( $_REQUEST['heatmap'] ) && '1' === $_REQUEST['heatmap'] ) || ( isset( $_REQUEST['mainwpsignature'] ) && ( ! empty( $_REQUEST['mainwpsignature'] ) ) ) ) { if ( ( isset( $_REQUEST['heatmap'] ) && '1' === $_REQUEST['heatmap'] ) || ( isset( $_REQUEST['mainwpsignature'] ) && ( ! empty( $_REQUEST['mainwpsignature'] ) ) ) ) {
header( 'X-Frame-Options: ALLOWALL' ); header( 'X-Frame-Options: ALLOWALL' );

View file

@ -7,7 +7,7 @@ Author URI: https://mainwp.com
Plugin URI: https://mainwp.com Plugin URI: https://mainwp.com
Requires at least: 3.6 Requires at least: 3.6
Tested up to: 4.4.1 Tested up to: 4.4.1
Stable tag: 3.0 Stable tag: 3.0.1
License: GPLv2 or later License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html 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 == == 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 = = 3.0 - 1-12-16 =
* Fixed: Refactored code to meet WordPress Coding standards * Fixed: Refactored code to meet WordPress Coding standards
* Fixed: Deprecated Function * Fixed: Deprecated Function