File: /home/dwauav0tm6jp/hosted/joshcross_me/wp-content/themes/photographer-wp/admin/shortcodes.php
<?php
add_filter( 'the_excerpt', 'do_shortcode' );
add_filter( 'widget_text', 'do_shortcode' );
/* ============================================================================================================================================= */
function row( $atts, $content = "" )
{
$row = '<div class="row">' . do_shortcode( $content ) . '</div>';
return $row;
}
add_shortcode( 'row', 'row' );
/* ============================================================================================================================================= */
function column( $atts, $content = "" )
{
extract( shortcode_atts( array( 'width' => "",
'width_xs' => "",
'width_md' => "",
'width_lg' => "" ), $atts ) );
if ( $width != "" )
{
$width = 'col-sm-' . $width;
}
if ( $width_xs != "" )
{
$width_xs = 'col-xs-' . $width_xs;
}
if ( $width_md != "" )
{
$width_md = 'col-md-' . $width_md;
}
if ( $width_lg != "" )
{
$width_lg = 'col-lg-' . $width_lg;
}
$column = '<div class="' . $width . ' ' . $width_xs . ' ' . $width_md . ' ' . $width_lg . '">' . do_shortcode( $content ) . '</div>';
return $column;
}
add_shortcode( 'column', 'column' );
/* ============================================================================================================================================= */
function alert( $atts, $content = "" )
{
extract( shortcode_atts( array( 'type' => "" ), $atts ) );
$alert = '<div class="alert ' . $type . '">' . do_shortcode( $content ) . '</div>';
return $alert;
}
add_shortcode( 'alert', 'alert' );
/* ============================================================================================================================================= */
function button( $atts, $content = "" )
{
extract( shortcode_atts( array( 'text' => "",
'url' => "",
'target' => "",
'color' => "",
'size' => "",
'icon' => "" ), $atts ) );
if ( $target != "" )
{
$target = ' target="' . $target . '"';
}
if ( $icon != "" )
{
$icon = '<i class="pw-icon-' . $icon . '"></i>';
}
$output = '<a' . $target . ' href="' . $url . '" class="button ' . $color . ' ' . $size . '">' . $icon . $text . '</a>';
return $output;
}
add_shortcode( 'button', 'button' );
/* ============================================================================================================================================= */
function social_icon_wrap( $atts, $content = "" )
{
$social_icon_wrap = '<ul class="social">' . do_shortcode( $content ) . '</ul>';
return $social_icon_wrap;
}
add_shortcode( 'social_icon_wrap', 'social_icon_wrap' );
/* ============================================================================================================================================= */
function social_icon( $atts, $content = "" )
{
extract( shortcode_atts( array( 'type' => "",
'url' => "" ), $atts ) );
$social_icon = '<li><a target="_blank" class="' . $type . '" href="' . $url . '"></a></li>';
return $social_icon;
}
add_shortcode( 'social_icon', 'social_icon' );
/* ============================================================================================================================================= */
function toggle_wrap( $atts, $content = "" )
{
$toggle_wrap = '<div class="toggle-group">' . do_shortcode( $content ) . '</div>';
return $toggle_wrap;
}
add_shortcode( 'toggle_wrap', 'toggle_wrap' );
/* ============================================================================================================================================= */
function toggle( $atts, $content = "" )
{
extract( shortcode_atts( array( 'title' => "" ), $atts ) );
$toggle = '<div class="toggle"><h4>' . $title . '</h4><div class="toggle-content">' . do_shortcode( $content ) . '</div></div>';
return $toggle;
}
add_shortcode( 'toggle', 'toggle' );
/* ============================================================================================================================================= */
function accordion_wrap( $atts, $content = "" )
{
$accordion_wrap = '<div class="toggle-group accordion">' . do_shortcode( $content ) . '</div>';
return $accordion_wrap;
}
add_shortcode( 'accordion_wrap', 'accordion_wrap' );
/* ============================================================================================================================================= */
function accordion( $atts, $content = "" )
{
extract( shortcode_atts( array( 'title' => "" ), $atts ) );
$accordion = '<div class="toggle"><h4>' . $title . '</h4><div class="toggle-content">' . do_shortcode( $content ) . '</div></div>';
return $accordion;
}
add_shortcode( 'accordion', 'accordion' );
/* ============================================================================================================================================= */
function tab_wrap( $atts, $content = "" )
{
extract( shortcode_atts( array( 'titles' => "",
'active' => "" ), $atts ) );
$titles_with_commas = $titles;
$titles_with_markup = "";
if ( $titles_with_commas != "" )
{
$titles_array = preg_split("/[\s]*[,][\s]*/", $titles_with_commas);
foreach ( $titles_array as $title_name )
{
if ( $active == $title_name )
{
$titles_with_markup .= '<li><a class="active">' . $title_name . '</a></li>';
}
else
{
$titles_with_markup .= '<li><a>' . $title_name . '</a></li>';
}
}
}
$tab_wrap = '<div class="tabs"><ul class="tab-titles">' . $titles_with_markup . '</ul><div class="tab-content">' . do_shortcode( $content ) . '</div></div>';
return $tab_wrap;
}
add_shortcode( 'tab_wrap', 'tab_wrap' );
/* ============================================================================================================================================= */
function tab( $atts, $content = "" )
{
$tab = '<div>' . do_shortcode( $content ) . '</div>';
return $tab;
}
add_shortcode( 'tab', 'tab' );
/* ============================================================================================================================================= */
function contact_form( $atts, $content = "" )
{
extract( shortcode_atts( array( 'to' => "",
'subject' => "",
'captcha' => "" ), $atts ) );
if ( $to != "" )
{
update_option( 'contact_form_to', $to );
}
else
{
$admin_email = get_bloginfo( 'admin_email' );
update_option( 'contact_form_to', $admin_email );
}
if ( $captcha == "yes" )
{
$random1 = rand( 1, 5 );
$random2 = rand( 1, 5 );
$sum_random = $random1 + $random2;
$captcha_out = '<p>';
$captcha_out .= '<input type="hidden" id="captcha" name="captcha" value="yes">';
$captcha_out .= '<label for="sum_user">' . $random1 . ' + ' . $random2 . ' = ?</label>';
$captcha_out .= '<input type="text" id="sum_user" name="sum_user" class="required" placeholder="' . __( 'What is the sum?', 'read' ) . '">';
$captcha_out .= '<input type="hidden" id="sum_random" name="sum_random" value="' . $sum_random . '">';
$captcha_out .= '</p>';
}
else
{
$captcha_out = '<p style="padding: 0px; margin: 0px;"><input type="hidden" id="captcha" name="captcha" value="no"></p>';
}
// Get the site domain and get rid of www.
$site_url = strtolower( $_SERVER['SERVER_NAME'] );
if ( substr( $site_url, 0, 4 ) == 'www.' )
{
$site_url = substr( $site_url, 4 );
}
$sender_domain = 'server@' . $site_url;
$contact_form = '<div class="contact-form"><form id="contact-form" class="validate-form" method="post" action="' . get_template_directory_uri() . '/send-mail.php">';
$contact_form .= '<input type="hidden" id="sender_domain" name="sender_domain" value="' . $sender_domain . '">';
$contact_form .= '<input type="hidden" id="subject" name="subject" value="' . $subject . '">';
$contact_form .= '<p><label for="name">' . __( 'NAME', 'read' ) . '</label><input type="text" id="name" name="name" class="required"></p>';
$contact_form .= '<p><label for="email">' . __( 'EMAIL', 'read' ) . '</label><input type="text" id="email" name="email" class="required email"></p>';
$contact_form .= '<p><label for="message">' . __( 'MESSAGE', 'read' ) . '</label><textarea id="message" name="message" class="required"></textarea></p>';
$contact_form .= $captcha_out;
$contact_form .= '<p><button class="submit button"><span class="submit-label">' . __( 'Submit', 'read' ) . '</span><span class="submit-status"></span></button></p>';
$contact_form .= '</form></div>';
return $contact_form;
}
add_shortcode( 'contact_form', 'contact_form' );
/* ============================================================================================================================================= */
function section_title( $atts, $content = "" )
{
extract( shortcode_atts( array( 'text' => "",
'align' => "" ), $atts ) );
$section_title = '<h2 class="section-title ' . $align . '">' . $text . '</h2>';
return $section_title;
}
add_shortcode( 'section_title', 'section_title' );
/* ============================================================================================================================================= */
function fun_fact( $atts, $content = "" )
{
extract( shortcode_atts( array( 'icon' => "",
'text' => "" ), $atts ) );
$fun_fact = '<div class="fun-fact"><i class="pw-icon-' . $icon . '"></i><h4>' . $text . '</h4></div>';
return $fun_fact;
}
add_shortcode( 'fun_fact', 'fun_fact' );
/* ============================================================================================================================================= */
function intro( $atts, $content = "" )
{
$intro = '<div class="intro"><h2>' . do_shortcode( $content ) . '</h2></div>';
return $intro;
}
add_shortcode( 'intro', 'intro' );
/* ============================================================================================================================================= */
function rotate_words( $atts, $content = "" )
{
extract( shortcode_atts( array( 'titles' => "",
'interval' => "3000" ), $atts ) );
$titles_with_commas = $titles;
$titles_with_markup = "";
if ( $titles_with_commas != "" )
{
$titles_array = preg_split("/[\s]*[,][\s]*/", $titles_with_commas);
foreach ( $titles_array as $title_name )
{
$titles_with_markup .= '<span>' . $title_name . '</span>';
}
}
$rotate_words = '<span class="rotate-words" data-interval="' . $interval . '">' . $titles_with_markup . '</span>';
return $rotate_words;
}
add_shortcode( 'rotate_words', 'rotate_words' );
/* ============================================================================================================================================= */
function testimonial_wrap( $atts, $content = "" )
{
$testimonial_wrap = '<div class="testo-group">' . do_shortcode( $content ) . '</div>';
return $testimonial_wrap;
}
add_shortcode( 'testimonial_wrap', 'testimonial_wrap' );
/* ============================================================================================================================================= */
function testimonial( $atts, $content = "" )
{
extract( shortcode_atts( array( 'image' => "",
'title' => "",
'sub_title' => "" ), $atts ) );
$testimonial = '<div class="testo"><img alt="" src="' . $image . '"><h4>' . $title . '<span>' . $sub_title . '</span></h4><p>' . do_shortcode( $content ) . '</p></div>';
return $testimonial;
}
add_shortcode( 'testimonial', 'testimonial' );
/* ============================================================================================================================================= */
function slider($atts, $content = "")
{
extract(shortcode_atts(array('items' => '1',
'loop' => 'true',
'center' => 'false',
'mouse_drag' => 'true',
'nav' => 'true',
'dots' => 'true',
'autoplay' => 'false',
'speed' => '600',
'timeout' => '2000'), $atts));
$output = '<div class="owl-carousel owl-loading" data-items="' . $items . '" data-loop="' . $loop . '" data-center="' . $center . '" data-mouse-drag="' . $mouse_drag . '" data-nav="' . $nav . '" data-dots="' . $dots . '" data-autoplay="' . $autoplay . '" data-autoplay-speed="' . $speed . '" data-autoplay-timeout="' . $timeout . '" data-nav-text-prev="' . __('Prev', 'read') . '" data-nav-text-next="' . __('Next', 'read') . '">' . do_shortcode($content) . '</div>';
return $output;
}
add_shortcode('slider', 'slider');
/* ============================================================================================================================================= */
function slide($atts, $content = "")
{
extract(shortcode_atts(array('title' => "",
'image' => ""), $atts));
if ($title != "")
{
$title = '<p class="owl-title">' . $title . '</p>';
}
$output = '<div>';
$output .= '<p><img alt="" src="' . $image . '"></p>';
$output .= $title;
$output .= '</div>';
return $output;
}
add_shortcode('slide', 'slide');
/* ============================================================================================================================================= */
function quote( $atts, $content = "" )
{
extract( shortcode_atts( array( 'name' => "",
'align' => "" ), $atts ) );
$quote = '<blockquote class="' . $align . '">' . do_shortcode( $content ) . '<cite>' . $name . '</cite></blockquote>';
return $quote;
}
add_shortcode( 'quote', 'quote' );
/* ============================================================================================================================================= */
function media_wrap( $atts, $content = "" )
{
$media_wrap = '<div class="media-wrap">' . do_shortcode( $content ) . '</div>';
return $media_wrap;
}
add_shortcode( 'media_wrap', 'media_wrap' );
/* ============================================================================================================================================= */
function theme_audio( $atts, $content = "" )
{
extract( shortcode_atts( array( 'url' => "",
'poster' => "" ), $atts ) );
if ( $poster != "" )
{
$poster = '<img alt="" src="' . $poster . '">';
}
$theme_audio = $poster . '<audio src="' . $url . '" preload="none" style="width: 100%;"></audio>';
return $theme_audio;
}
add_shortcode( 'theme_audio', 'theme_audio' );
/* ============================================================================================================================================= */
function theme_video( $atts, $content = "" )
{
extract( shortcode_atts( array( 'url' => "",
'poster' => "" ), $atts ) );
$theme_video = '<video src="' . $url . '" poster="' . $poster . '" preload="none" style="width: 100%; height: 100%;"></video>';
return $theme_video;
}
add_shortcode( 'theme_video', 'theme_video' );
/* ============================================================================================================================================= */
function drop_cap( $atts, $content = "" )
{
$drop_cap = '<p class="drop-cap">' . do_shortcode( $content ) . '</p>';
return $drop_cap;
}
add_shortcode( 'drop_cap', 'drop_cap' );
/* ============================================================================================================================================= */
function full_width_image( $atts, $content = "" )
{
$full_width_image = '<div class="full-width-image">' . do_shortcode( $content ) . '</div>';
return $full_width_image;
}
add_shortcode( 'full_width_image', 'full_width_image' );
/* ============================================================================================================================================= */
function pricing_table( $atts, $content = "" )
{
$pricing_table = '<div class="pricing-table">' . do_shortcode( $content ) . '</div>';
return $pricing_table;
}
add_shortcode( 'pricing_table', 'pricing_table' );
/* ============================================================================================================================================= */
function photo_wall( $atts, $content = "" )
{
extract( shortcode_atts( array( 'animation' => "random",
'interval' => "1600",
'max_step' => "3" ), $atts ) );
$output = "";
$images = "";
$items_count = 1;
$args = array( 'post_type' => 'portfolio',
'orderby' => 'rand',
'posts_per_page' => -1 );
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) :
while ( $loop->have_posts() ) : $loop->the_post();
$post_content = get_the_content();
if ( preg_match( '/\[gallery.*ids=.(.*).\]/', $post_content, $ids ) )
{
$ids_in_array = explode( ',', $ids[1] );
foreach ( $ids_in_array as $item )
{
$image = wp_get_attachment_image_src( $item, 'pixelwars_theme_image_size_2' );
$image_alt = get_post_meta( $item, '_wp_attachment_image_alt', true );
if ( $image[0] != "" )
{
if ( $items_count <= 100 )
{
$images .= '<li>';
$images .= '<a href="#">';
$images .= '<img alt="' . esc_attr( $image_alt ) . '" src="' . esc_url( $image[0] ) . '">';
$images .= '</a>';
$images .= '</li>';
$items_count++;
}
}
}
}
endwhile;
if ( $images != "" )
{
$output .= '<div class="ri-grid ri-grid-loading" data-animation="' . esc_attr( $animation ) . '" data-interval="' . esc_attr( $interval ) . '" data-max-step="' . esc_attr( $max_step ) . '">';
$output .= '<ul>' . $images . '</ul>';
$output .= '</div>';
}
endif;
wp_reset_query();
return $output;
}
add_shortcode( 'photo_wall', 'photo_wall' );
/* ============================================================================================================================================= */
function ken_slider_wrap( $atts, $content = "" )
{
extract( shortcode_atts( array( 'speed' => '5000',
'animation' => 'kenburns' ), $atts ) );
$ken_slider_wrap = '<ul class="ken-slider" data-speed="' . $speed . '" data-animation="' . $animation . '">' . do_shortcode( $content ) . '</ul>';
return $ken_slider_wrap;
}
add_shortcode( 'ken_slider_wrap', 'ken_slider_wrap' );
/* ============================================================================================================================================= */
function ken_slide( $atts, $content = "" )
{
extract( shortcode_atts( array( 'image' => "" ), $atts ) );
$ken_slide = '<li><img alt="" src="' . $image . '"></li>';
return $ken_slide;
}
add_shortcode( 'ken_slide', 'ken_slide' );
/* ============================================================================================================================================= */
function pixelwars_theme_run_shortcode( $content )
{
global $shortcode_tags;
// Backup current registered shortcodes and clear them all out
$orig_shortcode_tags = $shortcode_tags;
remove_all_shortcodes();
add_shortcode( 'row', 'row' );
add_shortcode( 'column', 'column' );
add_shortcode( 'alert', 'alert' );
add_shortcode( 'contact_form', 'contact_form' );
add_shortcode( 'section_title', 'section_title' );
add_shortcode( 'fun_fact', 'fun_fact' );
add_shortcode( 'button', 'button' );
add_shortcode( 'intro', 'intro' );
add_shortcode( 'rotate_words', 'rotate_words' );
add_shortcode( 'social_icon_wrap', 'social_icon_wrap' );
add_shortcode( 'social_icon', 'social_icon' );
add_shortcode( 'toggle_wrap', 'toggle_wrap' );
add_shortcode( 'toggle', 'toggle' );
add_shortcode( 'accordion_wrap', 'accordion_wrap' );
add_shortcode( 'accordion', 'accordion' );
add_shortcode( 'tab_wrap', 'tab_wrap' );
add_shortcode( 'tab', 'tab' );
add_shortcode( 'testimonial_wrap', 'testimonial_wrap' );
add_shortcode( 'testimonial', 'testimonial' );
add_shortcode( 'slider', 'slider' );
add_shortcode( 'slide', 'slide' );
add_shortcode( 'quote', 'quote' );
add_shortcode( 'media_wrap', 'media_wrap' );
add_shortcode( 'theme_video', 'theme_video' );
add_shortcode( 'theme_audio', 'theme_audio' );
add_shortcode( 'drop_cap', 'drop_cap' );
add_shortcode( 'full_width_image', 'full_width_image' );
add_shortcode( 'pricing_table', 'pricing_table' );
add_shortcode( 'photo_wall', 'photo_wall' );
add_shortcode( 'ken_slider_wrap', 'ken_slider_wrap' );
add_shortcode( 'ken_slide', 'ken_slide' );
// Do the shortcode ( only the one above is registered )
$content = do_shortcode( $content );
// Put the original shortcodes back
$shortcode_tags = $orig_shortcode_tags;
return $content;
}
add_filter( 'the_content', 'pixelwars_theme_run_shortcode', 7 );
?>