/**
* 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 Redux Vendor Support plugin/extension to bypass the our CDN and avoid this warning', 'redux-framework' ), 'https://github.com/reduxframework/redux-vendor-support' );
}
$msg = '' . __( 'Redux Framework Warning', 'redux-framework' ) . ' ' . 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 Vendor Support plugin (or extension) is either not installed or not activated and thus, some controls may not render properly. Please ensure that it is installed and activated', '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 );
}
}
}
}
/**
* 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 = 'A new build of Redux is now available!
Your version: ' . $curVer . ' New version: ' . $ver . '
If you are not a developer, your theme/plugin author shipped with dev_mode on. Contact them to fix it, but in the meantime you can use our dev_mode disabler.
‘‘You’re completely surrounded!’’ The voice on the bullhorn roared. ‘‘Throw out your weapons and march out, one at a time, hands in the air!’’
Jackson looked at his men, his bulging eyes hell-red. He held his Uzi submachine gun firmly. He was six foot three and as wide as the door of a prosperous Igbo yam farmer’s barn. He wondered what was racing through the minds of his gangsters now that they were truly trapped. Only Beelzebub knew how many soldiers and policemen had thrown a ring round them. This was the kind of ring that covered all pathways and byways.
Ernest, the small, slick driver, was shaking, almost unable to hold onto the .45 automatic pistol that looked ridiculously large in his right hand. Okata looked like the god of war, with his bandolier crisscrossing his massive chest and assault rifle. Tomi, the tall, slim bookworm who had never stopped reading even though his degree never got him a job, bit his lips nervously. He had not removed his .38 Colt from his holster. The only female member, Linda, had not lost any of her sultry, take-me-to-bed appeal as she crouched by the door leading to the bedroom passage, clad in denim shorts and a half-unbuttoned black shirt.
‘‘How did they outwit Bobi and Adama?’’ Ernest muttered. The two guys had been posted outside on the lookout. If they were not dead, they were by now cuffed and gagged. The commando style of the security forces meant a totally new ballgame. The new bosses of the army and police had decided to wipe them out.
‘‘It doesn’t matter.’’ snarled Okata.
Jackson took a deep breath. ‘‘Take positions.’’ he ordered.
‘‘Your head correct?’’ Linda’s voice was a whiplash. ‘‘They will massacre us.’’
The men looked at her. They knew better than to challenge Jackson so blatantly, even now they were at hell’s gate. But Linda had always been too bold for her own good. Perhaps that was why she was so effective in the gang.
Jackson did not explode. ‘‘Do you think we’ll escape if we surrender? These bastards no be oyibo police.” he said reasonably. Tomi’s stomach played unwholesome konga. Extralegal executions by Nigerian cops were not uncommon. Besides, he and his colleagues had so shamed them, they were safer dead.
‘‘Nobody’s taking me alive.’’ Okata’s voice was grim.
‘‘Then die alone!’’ Linda‘s funk was unalloyed.
The bullhorn cut in relentlessly. ‘‘Six minutes!’’
Jackson set his gun at full automatic to restrain the panic seizing his head. His eyes roamed over his operatives. He had set out to be a Robin Hood and for the last one and a half years he had succeeded. But three months ago, it turned bloody when an army Colonel tried to play hero during a successful bank robbery. Tomi, the newest member, shot him dead.
Okata cocked his rifle and looked at the backdoor. Tomi looked furtively at Linda. She felt his gaze and gave him a soft glance. Okata saw it and bristled.
‘‘See these ones, boss, doing love nwantiti.’’
‘‘You dey craze.’’ Tomi snarled. He knew the love between him and Linda was knife-edged. Okata had always desired Linda and was devastated when she fell ayakata for Tomi. His handsomeness and degree gave him an advantage. Only Jackson’s intervention stopped the two men from drawing pistols after the aggrieved older member caught his rival and Linda in bed the night after a spectacularly successful operation.
‘‘Sharrap!’’ Jackson growled. ‘‘I will shoot both of you and save the cops the stress.’’ He meant every word.
Tomi spoke quietly. ‘‘Boss, if one of us can hold them the others can cut out through Route B.’’
Everyone looked at him as if he was crazy.
‘‘This no be James Bond movie.’’ Jackson said harshly.
‘‘Yes, but it’s a chance. Route B’s the only way out if there is covering fire.’’
Linda’s eyes rested on Tomi, brimming with tears of undiluted love. You are doing this for me, they declared. Tomi’s hard face concealed the feeling of joyful lightness that filled his heart.
‘‘Four minutes!’’ boomed the bullhorn.
The robbers looked at each other. Who would stay behind?
‘‘Boss, give me your Uzi.’’ said Tomi decisively. ‘‘I’ll cover you. Everyone, zap.’’ The authority in his voice belied his position in the gang.
Tears filled Ernest’s eyes. Okata’s mouth opened and closed wordlessly. As if pulled by an unseen string, all eyes turned to Linda. She walked up to Tomi and kissed him, crying openly.
Tomi held her off with one hand. This was no time to be soft. He turned to Jackson, right hand outstretched. Jackson hesitated, then handed over the Uzi.
‘‘Move. Now.’’
Okata paused.
‘‘Go, Okata. Protect Linda, please.’’
Okata nearly broke down. He opened his mouth, shut it and impulsively hugged his rival.
‘‘Two minutes!’’ snarled the bullhorn.
As the robbers trotted to the in-built underground door to the eastern wing of their den Tomi called: ‘‘Linda!’’
She turned, sobbing.
‘‘I love you. Pray for me.’’ he said calmly.
Linda could only sob as Okata led her out.
Immediately Tomi opened blistering fire, praying his guys would make it. He paid little heed to the swarming feet of the attackers. He was a good marksman and was fast in diving out of the way of the police guns. But he knew it was only a matter of time: the enemy had the advantage of numbers. All he could do was keep them pinned down till his comrades got away.
The fusillade that slammed into his body hurled him through the bullet-shattered door. He fell, knowing instinctively that the Universe had heard his prayer. Route B was unknown to the security agents.