init_shortcodes(); if( file_exists( dirname(__FILE__) . '/options.php' ) ) { $this->conf = dirname(__FILE__) . '/options.php'; //$this->formate_shortcode(); add_action( 'init',array($this,'formate_shortcode'),20) ; } $this->magee_shortcodes = $magee_shortcodes; $this->magee_sliders = $this->sliders_meta(); } public static function init() { load_plugin_textdomain( 'magee-shortcodes', false, dirname( plugin_basename( MAGEE_SHORTCODES_PATH ) ). '/languages/' ); } function admin_scripts() { wp_enqueue_script('thickbox'); wp_enqueue_style('thickbox'); wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_style('font-awesome', plugins_url( 'assets/font-awesome/css/font-awesome.css',MAGEE_SHORTCODES_PATH ), '', '4.4.0', false ); wp_enqueue_style('magee-shortcode', plugins_url( 'assets/css/shortcode.css',MAGEE_SHORTCODES_PATH ), '', MAGEE_SHORTCODES_VER, false ); wp_enqueue_style('magee-admin', plugins_url( 'assets/css/admin.css',MAGEE_SHORTCODES_PATH ), '', MAGEE_SHORTCODES_VER, false ); wp_enqueue_style('prettyPhoto', plugins_url( 'assets/css/prettyPhoto.css',MAGEE_SHORTCODES_PATH ), '', MAGEE_SHORTCODES_VER, false ); wp_enqueue_script( 'magee-twentytwenty', plugins_url( 'assets/js/jquery.twentytwenty.js',MAGEE_SHORTCODES_PATH ), array( 'jquery','wp-color-picker' ),MAGEE_SHORTCODES_VER, true ); wp_enqueue_script( 'magee-admin-js', plugins_url( 'assets/js/admin.js',MAGEE_SHORTCODES_PATH ), array( 'jquery','wp-color-picker' ),MAGEE_SHORTCODES_VER, true ); wp_enqueue_script( 'combodate-js', plugins_url( 'assets/js/combodate.js',MAGEE_SHORTCODES_PATH ), array( 'jquery'),'', true ); wp_enqueue_script( 'moment-js', plugins_url( 'assets/js/moment.js',MAGEE_SHORTCODES_PATH ), array( 'jquery'),'', true ); } function frontend_scripts() { wp_enqueue_style('font-awesome', plugins_url( 'assets/font-awesome/css/font-awesome.css',MAGEE_SHORTCODES_PATH ), '', '4.4.0', false ); wp_enqueue_style('bootstrap', plugins_url( 'assets/bootstrap/css/bootstrap.min.css',MAGEE_SHORTCODES_PATH ), '', '3.3.4', false ); wp_enqueue_style('prettyPhoto', plugins_url( 'assets/css/prettyPhoto.css',MAGEE_SHORTCODES_PATH ), '', '', false ); wp_enqueue_style('classycountdown', plugins_url( 'assets/jquery-countdown/jquery.classycountdown.css',MAGEE_SHORTCODES_PATH ), '', '1.1.0', false ); wp_enqueue_style('twentytwenty', plugins_url( 'assets/css/twentytwenty.css',MAGEE_SHORTCODES_PATH ), '', '', false ); wp_enqueue_style('audioplayer', plugins_url( 'assets/css/audioplayer.css',MAGEE_SHORTCODES_PATH ), '', '', false ); wp_enqueue_style('weather-icons', plugins_url( 'assets/weathericons/css/weather-icons.min.css',MAGEE_SHORTCODES_PATH ), '', '', false ); wp_enqueue_style('animate', plugins_url( 'assets/css/animate.css',MAGEE_SHORTCODES_PATH ), '', '', false ); wp_enqueue_style('magee-shortcode', plugins_url( 'assets/css/shortcode.css',MAGEE_SHORTCODES_PATH ), '', MAGEE_SHORTCODES_VER, false ); wp_enqueue_script( 'bootstrap', plugins_url( 'assets/bootstrap/js/bootstrap.min.js',MAGEE_SHORTCODES_PATH ), array( 'jquery'), '3.3.4', false ); wp_enqueue_script( 'waypoints', plugins_url( 'assets/js/jquery.waypoints.js',MAGEE_SHORTCODES_PATH ), array( 'jquery'), '2.0.5', false ); wp_enqueue_script( 'countdown', plugins_url( 'assets/jquery-countdown/jquery.countdown.min.js',MAGEE_SHORTCODES_PATH ), array( 'jquery'), '2.0.4', false ); wp_enqueue_script( 'easy-pie-chart', plugins_url( 'assets/jquery-easy-pie-chart/jquery.easypiechart.min.js',MAGEE_SHORTCODES_PATH ), array( 'jquery'), '2.1.7', false ); wp_enqueue_script( 'jquery.prettyPhoto', plugins_url( 'assets/js/jquery.prettyPhoto.js',MAGEE_SHORTCODES_PATH ), array( 'jquery'), '3.1.6', false ); wp_enqueue_script( 'jquery.knob', plugins_url( 'assets/jquery-countdown/jquery.knob.js',MAGEE_SHORTCODES_PATH ), array( 'jquery'), '1.2.11', false ); wp_enqueue_script( 'jquery.throttle', plugins_url( 'assets/jquery-countdown/jquery.throttle.js',MAGEE_SHORTCODES_PATH ), array( 'jquery'), '', false ); wp_enqueue_script( 'jquery.classycountdown', plugins_url( 'assets/jquery-countdown/jquery.classycountdown.min.js',MAGEE_SHORTCODES_PATH ), array( 'jquery'), '1.1.0', false ); wp_enqueue_script( 'jquery.event.move', plugins_url( 'assets/js/jquery.event.move.js',MAGEE_SHORTCODES_PATH ), array( 'jquery'), '1.3.6', false ); wp_enqueue_script( 'jquery.twentytwenty', plugins_url( 'assets/js/jquery.twentytwenty.js',MAGEE_SHORTCODES_PATH ), array( 'jquery'), '', false ); wp_enqueue_script( 'jquery-audioplayer', plugins_url( 'assets/js/audioplayer.js',MAGEE_SHORTCODES_PATH ), array( 'jquery'), '', false ); wp_enqueue_script( 'chart.min', plugins_url( 'assets/js/chart.min.js',MAGEE_SHORTCODES_PATH ), array( 'jquery'), '2.1.4', false ); wp_enqueue_script( 'moment', plugins_url( 'assets/js/moment.js',MAGEE_SHORTCODES_PATH ), array( 'jquery'),'2.12.0', false ); wp_enqueue_script( 'magee-main', plugins_url( 'assets/js/magee-shortcodes.js',MAGEE_SHORTCODES_PATH ), array( 'jquery'),MAGEE_SHORTCODES_VER, true ); wp_enqueue_script( 'magee-modal', plugins_url( 'assets/js/magee-modal.js',MAGEE_SHORTCODES_PATH ),array( 'jquery'),MAGEE_SHORTCODES_VER, true ); //wp_enqueue_script( 'magee-main', plugins_url( 'assets/js/main.js',MAGEE_SHORTCODES_PATH ), array( 'jquery'),MAGEE_SHORTCODES_VER, true ); } //action to add a custom button to the content editor function add_shortcodes_button($context) { //path to shortcode icon $img = plugins_url( 'assets/images/shortcode.png',MAGEE_SHORTCODES_PATH ); //our popup's title $title = __('Magee Shortcodes','magee-shortcodes'); //append the icon $context .= "".__("Magee Shortcodes",'magee-shortcodes').""; return $context; } /** * Popup function which will show shortcode options in thickbox. */ function popup() { require_once( MAGEE_SHORTCODES_DIR_PATH . '/inc/popup.php' ); die(); } function shortcode_form(){ $magee_shortcodes = $this->magee_shortcodes; if( isset($_POST['shortcode']) && isset($magee_shortcodes[$_POST['shortcode']]) ){ if( isset($magee_shortcodes[$_POST['shortcode']]['child_shortcode'])){ echo '

'.$magee_shortcodes[$_POST['shortcode']]['popup_title'].'

'; if(isset($magee_shortcodes[$_POST['shortcode']]['name'])){ echo '
Want to know more about this shortcode? Check Examples of use.
'; } $this->popup = $_POST['shortcode']; echo self::formate_shortcode(); echo '
Values for the following section can be added multiple times with ADD button
'; echo '
'.self::formate_children_shortcode().'
'; echo '
add
' ; }else{ echo '

'.$magee_shortcodes[$_POST['shortcode']]['popup_title'].'

'; if(isset($magee_shortcodes[$_POST['shortcode']]['name'])){ echo '
Want to know more about this shortcode? Check Examples of use.
'; } $this->popup = $_POST['shortcode']; echo self::formate_shortcode(); } } exit(0); } function init_shortcodes() { foreach( glob( MAGEE_SHORTCODES_DIR_PATH . 'shortcodes/*.php' ) as $filename ) { require_once $filename; } } /** * Function to get the default shortcode param values applied. */ public static function set_shortcode_defaults( $defaults, $args ) { if( ! $args ) { $$args = array(); } $args = shortcode_atts( $defaults, $args ); foreach( $args as $key => $value ) { if( $value == '' || $value == '|' ) { $args[$key] = $defaults[$key]; } } return $args; } // fix shortcodes public static function fix_shortcodes($content){ $replace_tags_from_to = array ( '

[' => '[', ']

' => ']', ']
' => ']', ']
' => ']', ']\r\n' => ']', ']\n' => ']', ']\r' => ']', '\r\n[' => '[', ); return strtr( $content, $replace_tags_from_to ); } /** * Convert Hex Code to RGB * @param string $hex Color Hex Code * @return array RGB values */ function hex2rgb( $hex ) { if ( strpos( $hex,'rgb' ) !== FALSE ) { $rgb_part = strstr( $hex, '(' ); $rgb_part = trim($rgb_part, '(' ); $rgb_part = rtrim($rgb_part, ')' ); $rgb_part = explode( ',', $rgb_part ); $rgb = array($rgb_part[0], $rgb_part[1], $rgb_part[2], $rgb_part[3]); } elseif( $hex == 'transparent' ) { $rgb = array( '255', '255', '255', '0' ); } else { $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 = array( $r, $g, $b ); } return $rgb; // returns an array with the rgb values } public static function unrecognize_shortcodes($content){ $pre = "/(.*?)<\/pre>/"; preg_match_all($pre,$content,$result); $count = count($result); foreach( $result as $val){ foreach( $val as $cval){ $ck = str_replace('[',"[",strval($cval)); $content = str_replace($val,$ck,$content); } } return $content; } public static function colourBrightness($hex, $percent) { // Work out if hash given $hash = ''; if (stristr($hex,'#')) { $hex = str_replace('#','',$hex); $hash = '#'; } /// HEX TO RGB $rgb = array(hexdec(substr($hex,0,2)), hexdec(substr($hex,2,2)), hexdec(substr($hex,4,2))); //// CALCULATE for ($i=0; $i<3; $i++) { // See if brighter or darker if ($percent > 0) { // Lighter $rgb[$i] = round($rgb[$i] * $percent) + round(255 * (1-$percent)); } else { // Darker $positivePercent = $percent - ($percent*2); $rgb[$i] = round($rgb[$i] * $positivePercent) + round(0 * (1-$positivePercent)); } // In case rounding up causes us to go to 256 if ($rgb[$i] > 255) { $rgb[$i] = 255; } } //// RBG to Hex $hex = ''; for($i=0; $i < 3; $i++) { // Convert the decimal digit to hex $hexDigit = dechex($rgb[$i]); // Add a leading zero if necessary if(strlen($hexDigit) == 1) { $hexDigit = "0" . $hexDigit; } // Append to the hex string $hex .= $hexDigit; } return $hash.$hex; } /** * Function to apply attributes to HTML tags. */ public static function attributes( $slug, $attributes = array() ) { $out = ''; $attr = apply_filters( "magee_attr_{$slug}", $attributes ); if ( empty( $attr ) ) { $attr['class'] = $slug; } foreach ( $attr as $name => $value ) { $out .= !empty( $value ) ? sprintf( ' %s="%s"', esc_html( $name ), esc_attr( $value ) ) : esc_html( " {$name}" ); } return trim( $out ); } //widget load function get_sidebars() { global $wp_registered_sidebars; $sidebars = array(); $sidebars[''] = 'Default'; foreach( $wp_registered_sidebars as $sidebar_id => $sidebar ) { $sidebars[$sidebar_id] = $sidebar['name']; } return $sidebars; } function get_control_button(){ //path to preview icon $preview = plugins_url( 'assets/images/preview.png',MAGEE_SHORTCODES_PATH ); //path to list icon $list = plugins_url( 'assets/images/list.png',MAGEE_SHORTCODES_PATH ); //path to insert shortcode icon $insert = plugins_url( 'assets/images/insert_shortcode.png',MAGEE_SHORTCODES_PATH ); echo ''; exit(0); } function create_shortcode(){ $magee_shortcodes = $this->magee_shortcodes; $shortcode = ''; if( isset( $magee_shortcodes ) && is_array( $magee_shortcodes ) && isset($_POST['shortcode']) ) { $popup = $_POST['shortcode']; $params = $magee_shortcodes[$popup]['params']; $shortcode = $magee_shortcodes[$popup]['shortcode']; $attrs = array(); if( isset( $_POST['attr'] ) ): foreach( $_POST['attr'] as $attr){ $attrs[str_replace('magee_','',$attr['name'])] = $attr['value']; } foreach( $params as $pkey => $param ) { if( isset($attrs[$pkey] )){ $shortcode = str_replace('{{'.$pkey.'}}',$attrs[$pkey],$shortcode); }else{ $shortcode = str_replace('{{'.$pkey.'}}','',$shortcode); } } endif; if( isset($magee_shortcodes[$popup]['child_shortcode'])): $common = array_slice($_POST['attr'],count($_POST['attr'])-2,2) ; array_splice($_POST['attr'],count($_POST['attr'])-2,2); $number = count($magee_shortcodes[$popup]['child_shortcode']['params']); $expcet = count($magee_shortcodes[$popup]['params']); array_splice($_POST['attr'],0,$expcet); $loop = array_chunk($_POST['attr'],$number); $i = ''; $copyshortcode = ''; for( $i=0;$i $cparam ) { if( isset($attrs[$cpkey] )){ $cshortcode = str_replace('{{'.$cpkey.'}}',$attrs[$cpkey],$cshortcode); }else{ $cshortcode = str_replace('{{'.$cpkey.'}}','',$cshortcode); } } $copyshortcode .= $cshortcode; } $shortcode = str_replace('{{child_shortcode}}',$copyshortcode,$shortcode); endif; } $shortcode = str_replace('\\\'','\'',$shortcode); $shortcode = str_replace('\\"','"',$shortcode); $shortcode = str_replace('\\\\','\\',$shortcode); echo $shortcode; exit(); } function formate_shortcode() { global $magee_shortcodes,$magee_widget; $magee_widget = self::get_sidebars(); // get config file include_once( $this->conf ); $this->magee_shortcodes = $magee_shortcodes; $output = ''; unset($magee_shortcodes['shortcode-generator']['params']['select_shortcode']); if( isset( $magee_shortcodes ) && is_array( $magee_shortcodes ) && isset( $magee_shortcodes[$this->popup]['params'])) { // get shortcode config stuff $this->params = $magee_shortcodes[$this->popup]['params']; $this->shortcode = $magee_shortcodes[$this->popup]['shortcode']; $this->popup_title = $magee_shortcodes[$this->popup]['popup_title']; // adds stuff for js use $this->append_output( "\n" . '' ); $this->append_output( "\n" . '' ); // filters and excutes params if( $this->params ): foreach( $this->params as $pkey => $param ) { // prefix the fields names and ids with magee_ $pkey = 'magee_' . $pkey; if(!isset($param['std'])) { $param['std'] = ''; } if(!isset($param['desc'])) { $param['desc'] = ''; } // popup form row start $row_start = '
' . "\n"; $row_start .= '
' . "\n"; if($param['type'] != 'info') { $row_start .= '
'; $row_start .= '' . $param['label'] . '' . "\n"; $row_start .= '' . $param['desc'] . '' . "\n"; $row_start .= '
' . "\n"; } $row_start .= '
' . "\n"; // popup form row end $row_end = '
' . "\n"; $row_end .= '
' . "\n"; $row_end .= '
' . "\n"; switch( $param['type'] ) { case 'text' : // prepare $output .= $row_start; $output .= '' . "\n"; $output .= $row_end; // append $this->append_output( $output ); break; case 'textarea' : // prepare $output .= $row_start;; // Turn on the output buffer ob_start(); // Echo the editor to the buffer wp_editor( $param['std'], $pkey, array( 'editor_class' => 'magee_tinymce', 'media_buttons' => true ) ); // Store the contents of the buffer in a variable $editor_contents = ob_get_clean(); //$output .= $editor_contents; $output .= '' . "\n"; $output .= $row_end; // append $this->append_output( $output ); break; case 'select' : // prepare $output .= $row_start; $output .= '
'; $output .= '' . "\n"; $output .= '
'; $output .= $row_end; // append $this->append_output( $output ); break; case 'more_select' : // prepare $output .= $row_start; $output .= '
'; $output .= '' . "\n"; $output .= '
'; $output .= $row_end; // append $this->append_output( $output ); break; case 'multiple_select' : // prepare $output .= $row_start;; $output .= '' . "\n"; $output .= $row_end; // append $this->append_output( $output ); break; case 'checkbox' : // prepare $output .= $row_start;; $output .= '' . "\n"; $output .= $row_end; // append $this->append_output( $output ); break; case 'uploader' : // prepare $output .= $row_start;; $output .= '
'; $output .= 'Image'; $output .= '' . "\n"; $output .= ''.__('Upload','magee-shortcodes').''; $output .= '
'; $output .= $row_end; // append $this->append_output( $output ); break; case 'gallery' : if(!isset($cpkey)) { $cpkey = ''; } // prepare $output .= $row_start;; $output .= ''.__('Attach Images to Gallery','magee-shortcodes').''; $output .= $row_end; // append $this->append_output( $output ); break; case 'iconpicker' : // prepare $output .= $row_start; $output .= '
'; $output .= ''. "\n"; $output .= '' . "\n"; $output .= "
\n"; $output .= '
'; foreach( $param['options'] as $value => $option ) { $output .= ''; } $output .= '
'; if(!isset($param['std'])) { $param['std'] = ''; } $output .= $row_end; // append $this->append_output( $output ); break; case 'icon' : // prepare $output .= $row_start; $output .= '
'; $output .= ''. "\n"; $output .= "
\n"; $output .= '
'; foreach( $param['options'] as $value => $option ) { $output .= ''; } $output .= '
'; if(!isset($param['std'])) { $param['std'] = ''; } $output .= $row_end; // append $this->append_output( $output ); break; case 'colorpicker' : if(!isset($param['std'])) { $param['std'] = ''; } // prepare $output .= $row_start;; $output .= '' . "\n"; $output .= $row_end; // append $this->append_output( $output ); break; case 'info' : // prepare $output .= $row_start;; $output .= '

' . $param['std'] . "

\n"; $output .= $row_end; // append $this->append_output( $output ); break; case 'size' : // prepare $output .= $row_start;; $output .= '
' . "\n"; $output .= '' . "\n"; $output .= '' . "\n"; $output .= '
' . "\n"; $output .= '
' . "\n"; $output .= '' . "\n"; $output .= '' . "\n"; $output .= '
' . "\n"; $output .= $row_end; // append $this->append_output( $output ); break; case 'number': // prepare $output .= $row_start;; $output .= '
'. "\n";; $output .= ''. "\n"; $output .= $row_end; // append $this->append_output( $output ); break; case 'choose' : // prepare $output .= $row_start;; $output .= '
' . "\n"; if( $param['options'] && is_array($param['options']) ) { foreach( $param['options'] as $value => $option ) { $selected = (isset($param['std']) && $param['std'] == $value) ? 'style="display:block"' : ''; $output .= '' .$option. '' . "\n"; } } $output .= '
' . "\n"; $output .= ''. "\n"; $output .= $row_end; // append $this->append_output( $output ); break; case 'datepicker' : // prepare $output .= $row_start;; $output .= ''; $output .= ''. "\n"; $output .= $row_end; // append $this->append_output( $output ); break; case 'link' : // prepare $output .= $row_start;; $output .= '
'; $output .= '' . "\n"; $output .= '
' . "\n"; $output .= $row_end; // append $this->append_output( $output ); break; } } endif; } return $output; } //children format shortcode function formate_children_shortcode() { $magee_shortcodes = $this->magee_shortcodes; // get config file require_once( $this->conf ); $output = ''; unset($magee_shortcodes['shortcode-generator']['params']['select_shortcode']); if( isset( $magee_shortcodes ) && is_array( $magee_shortcodes ) ) { // checks if has a child shortcode if( isset( $magee_shortcodes[$this->popup]['child_shortcode']) ){ // set child shortcode $this->cparams = $magee_shortcodes[$this->popup]['child_shortcode']['params']; $this->cshortcode = $magee_shortcodes[$this->popup]['child_shortcode']['shortcode']; // for js use $output_child = "\n" . '' ; $output .= $output_child; $this->append_output($output); //$this->append_output( "\n" . '' ); // add $prow_start to output //$this->append_output( $prow_start ); foreach( $this->cparams as $cpkey => $cparam ) { // prefix the fields names and ids with magee_ $cpkey = 'magee_' . $cpkey; if(!isset($cparam['std'])) { $cparam['std'] = ''; } if(!isset($cparam['desc'])) { $cparam['desc'] = ''; } // popup form row start $row_start = '
' . "\n"; $row_start .= '
' . "\n"; if($cparam['type'] != 'info') { $row_start .= '
'; $row_start .= '' . $cparam['label'] . '' . "\n"; $row_start .= '' . $cparam['desc'] . '' . "\n"; $row_start .= '
' . "\n"; } $row_start .= '
' . "\n"; // popup form row end $row_end = '
' . "\n"; $row_end .= '
' . "\n"; $row_end .= '
' . "\n"; switch( $cparam['type'] ) { case 'text' : // prepare $output_child = $row_start; $output_child .= '' . "\n"; $output_child .= $row_end; // append $output .= $output_child; $this->append_output($output); break; case 'textarea' : // prepare $output_child = $row_start; $output_child .= '' . "\n"; $output_child .= $row_end; // append $output .= $output_child; $this->append_output($output); break; case 'select' : // prepare $output_child = $row_start; $output_child .= '
'; $output_child .= '' . "\n"; $output_child .= '
'; $output_child .= $row_end; // append $output .= $output_child; $this->append_output($output); break; case 'number': // prepare $output .= $row_start;; $output .= '
'. "\n";; $output .= ''. "\n"; $output .= $row_end; // append $this->append_output( $output ); break; case 'checkbox' : // prepare $output_child = $row_start; $output_child .= '' . "\n"; $output_child .= $row_end; // append $output .= $output_child; $this->append_output($output); break; case 'uploader' : if(!isset($cparam['std'])) { $cparam['std'] = ''; } // prepare $output_child = $row_start; $output_child .= '
'; $output_child .= 'Image'; $output_child .= '' . "\n"; $output_child .= 'Upload'; $output_child .= '
'; $output_child .= $row_end; // append $output .= $output_child; $this->append_output($output); break; case 'colorpicker' : // prepare $output_child = $row_start; $output_child .= '' . "\n"; $output_child .= $row_end; // append $output .= $output_child; $this->append_output($output); break; case 'choose' : // prepare $output_child = $row_start;; $output_child .= '
' . "\n"; if( $cparam['options'] && is_array($cparam['options']) ) { foreach( $cparam['options'] as $value => $option ) { $selected = (isset($cparam['std']) && $cparam['std'] == $value) ? 'style="display:block"' : ''; $output_child .= '' .$option. '' . "\n"; } } $output_child .= '
' . "\n"; $output_child .= ''. "\n"; $output_child .= $row_end; // append $output .= $output_child; $this->append_output( $output ); break; case 'iconpicker' : // prepare $output_child = $row_start; $output_child .= '
'; $output_child .= ''. "\n"; $output_child .= '' . "\n"; $output_child .= "
\n"; $output_child .= '
'; foreach( $cparam['options'] as $value => $option ) { $output_child .= ''; } $output_child .= '
'; if(!isset($cparam['std'])) { $cparam['std'] = ''; } $output_child .= $row_end; // append $output .= $output_child; $this->append_output( $output ); break; case 'size' : // prepare $output_child = $crow_start; $output_child .= '
' . "\n"; $output_child .= '' . "\n"; $output_child .= '' . "\n"; $output_child .= '
' . "\n"; $output_child .= '
' . "\n"; $output_child .= '' . "\n"; $output_child .= '' . "\n"; $output_child .= '
' . "\n"; $output_child .= $crow_end; // append $output .= $output_child; $this->append_output($output); break; } } } } return $output; } function append_output( $output ) { $this->output = $this->output . "\n" . $output; } // -------------------------------------------------------------------------- function reset_output( $output ) { $this->output = ''; } // -------------------------------------------------------------------------- function append_error( $error ) { $this->errors = $this->errors . "\n" . $error; } public static function sliders_meta(){ $magee_sliders[''] = __( 'Select a slider', 'magee-shortcodes' ); $args = array( 'post_type' => 'magee_slider', 'post_status'=>'publish', 'posts_per_page' => -1 ); $sliders = get_posts( $args ); foreach( $sliders as $post ) : $magee_sliders[$post->ID] = $post->post_title; endforeach; wp_reset_postdata(); return $magee_sliders; } /* * live preview * --------------------------------------------------------------------- */ function say($all){ // echo do_shortcode(str_replace( '\"', '"', $_POST['preview'] ) ); $magee_shortcodes = $this->magee_shortcodes ; $shortcode = ''; if( isset( $magee_shortcodes ) && is_array( $magee_shortcodes ) && isset($_POST['name']) ) { $popup = $_POST['name']; $params = $magee_shortcodes[$popup]['params']; $shortcode = $magee_shortcodes[$popup]['shortcode']; $attrs = array(); if( isset( $_POST['preview'] ) ): foreach( $_POST['preview'] as $attr){ $attrs[str_replace('magee_','',$attr['name'])] = $attr['value']; } foreach( $params as $pkey => $param ) { if( isset($attrs[$pkey] )){ $shortcode = str_replace('{{'.$pkey.'}}',$attrs[$pkey],$shortcode); }else{ $shortcode = str_replace('{{'.$pkey.'}}','',$shortcode); } } endif; if( isset($magee_shortcodes[$popup]['child_shortcode'])): $common = array_slice($_POST['preview'],count($_POST['attr'])-2,2) ; array_splice($_POST['preview'],count($_POST['preview'])-2,2); $number = count($magee_shortcodes[$popup]['child_shortcode']['params']); $expcet = count($magee_shortcodes[$popup]['params']); array_splice($_POST['preview'],0,$expcet); $loop = array_chunk($_POST['preview'],$number); $i = ''; $copyshortcode = ''; for( $i=0;$i $cparam ) { if( isset($attrs[$cpkey] )){ $cshortcode = str_replace('{{'.$cpkey.'}}',$attrs[$cpkey],$cshortcode); }else{ $cshortcode = str_replace('{{'.$cpkey.'}}','',$cshortcode); } } $copyshortcode .= $cshortcode; } $shortcode = str_replace('{{child_shortcode}}',$copyshortcode,$shortcode); endif; } $shortcode = str_replace('\\\'','\'',$shortcode); $shortcode = str_replace('\\"','"',$shortcode); $shortcode = str_replace('\\\\','\\',$shortcode); $shortcode = str_replace('\"','"',$shortcode); echo do_shortcode($shortcode); die(); } function js(){ $script = ""; $script .= ""; $script .= ""; $script .= ""; $script .= ""; $script .= ""; $script .= ""; $script .= ""; $script .= ""; $script .= ""; $script .= ""; $script .= ""; $script .= ""; $script .= ""; $script .= ""; $script .= ""; $script .= ""; $script .= ""; $script .= ""; $script .= ""; $script .= ""; $script .= ""; $script .= ""; $script .= ""; $script .= ""; echo $script; die(); } /** * Prints HTML with meta information for the current post-date/time and author. */ function posted_on( $echo = false ) { $return = ''; $display_meta_author = 'yes'; $display_meta_date = 'yes'; $display_meta_categories = 'yes'; $display_meta_comments = 'yes'; $display_meta_readmore = 'yes'; $display_meta_tags = 'yes'; $display_post_meta = 'yes'; if( function_exists('alchem_option')) $display_post_meta = alchem_option('display_post_meta'); if( function_exists('onetone_option')) $display_post_meta = onetone_option('display_post_meta'); if( $display_post_meta == 'yes' ){ if( function_exists('alchem_option')){ $display_meta_author = alchem_option('display_meta_author'); $display_meta_date = alchem_option('display_meta_date'); $display_meta_categories = alchem_option('display_meta_categories'); $display_meta_comments = alchem_option('display_meta_comments'); $display_meta_readmore = alchem_option('display_meta_readmore'); $display_meta_tags = alchem_option('display_meta_tags'); $date_format = alchem_option('date_format'); } if( function_exists('onetone_option')){ $display_meta_author = onetone_option('display_meta_author','yes'); $display_meta_date = onetone_option('display_meta_date','yes'); $display_meta_categories = onetone_option('display_meta_categories','yes'); $display_meta_comments = onetone_option('display_meta_comments','yes'); $display_meta_readmore = onetone_option('display_meta_readmore','yes'); $display_meta_tags = onetone_option('display_meta_tags','yes'); $date_format = onetone_option('date_format',''); } $return .= ''; } if( $echo == true ) echo $return; else return $return; } /** * Returns a select list of Google fonts * Feel free to edit this, update the fallbacks, etc. */ function magee_countdowns_get_google_fonts() { // Google Font Defaults global $google_fonts_json; $googleFontArray = array(); $fontArray = json_decode($google_fonts_json, true); foreach($fontArray['items'] as $index => $value){ $_family = strtolower( str_replace(' ','_',$value['family']) ); $googleFontArray[$_family]['family'] = $value['family']; $googleFontArray[$_family]['variants'] = $value['variants']; $googleFontArray[$_family]['subsets'] = $value['subsets']; $category = ''; if( isset($value['category']) ) $category = ', '.$value['category']; $googleFontArray['magee_of_family'][$value['family'].$category] = $value['family']; } return $googleFontArray; } }