Skip to content

Instantly share code, notes, and snippets.

View SlavaET's full-sized avatar

Slava SlavaET

  • elegantthemes.com
View GitHub Profile
@SlavaET
SlavaET / builder.js
Created February 19, 2016 12:33
builder.js with fixed autop issue
var ET_PageBuilder = ET_PageBuilder || {};
window.wp = window.wp || {};
( function($) {
// run et_pb_append_templates as many times as needed
for (var i = 0; i < Math.ceil( et_pb_options.et_builder_modules_count/et_pb_options.et_builder_templates_amount ); i++) {
et_pb_append_templates( i*et_pb_options.et_builder_templates_amount );
};
var et_pb_templates_interval,
et_pb_templates_count = 0;
// run et_pb_append_templates as many times as needed
et_pb_templates_interval = setInterval( function() {
if ( et_pb_templates_count === Math.ceil( et_pb_options.et_builder_modules_count/et_pb_options.et_builder_templates_amount ) ) {
clearInterval( et_pb_templates_interval );
return false;
}
<?php
add_action( 'et_pb_before_page_builder', array( 'ET_Builder_Element', 'output_templates' ) );
add_action( 'init', array( 'ET_Builder_Element', 'set_media_queries' ), 11 );
class ET_Builder_variables{
private $data;
public function __get($varName){
<?php
if ( 'video' == get_post_format( get_the_ID() ) && '' != $et_video_url ){
$video_embed = $wp_embed->shortcode( '', $et_video_url );
$video_embed = preg_replace('/<embed /','<embed wmode="transparent" ',$video_embed);
$video_embed = preg_replace('/<\/object>/','<param name="wmode" value="transparent" /></object>',$video_embed);
$video_embed = preg_replace("/height=\"[0-9]*\"/", "height=350", $video_embed);
$video_embed = preg_replace("/width=\"[0-9]*\"/", "width={$width}", $video_embed);
echo $video_embed;
foreach ( (array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author LIMIT 5") as $row )
foreach ( (array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author") as $row )
<ul class="slides">
<?php
$video_info = array();
$i = 0;
global $wp_embed;
?>
<?php while ( $video_posts_query->have_posts() ) : $video_posts_query->the_post(); ?>
<?php
$thumb = '';
$width = apply_filters('et_video_image_width',136);
function override_parent() {
remove_shortcode( 'et_pb_slide', 'et_pb_slide' );
add_shortcode( 'et_pb_slide', 'et_pb_slide_custom' );
}
add_action ('after_setup_theme','override_parent');
function et_pb_slide_custom( $atts, $content = '' ) {
extract( shortcode_atts( array(
'alignment' => 'center',
'heading' => '',
'button_text' => '',
function et_resize_image( $thumb, $new_width, $new_height, $crop ){
/*
* Fixes the issue with x symbol between width and height values in the filename.
* For instance, sports-400x400.jpg file results in 'image not found' in getimagesize() function.
*/
$thumb = str_replace( '%26%23215%3B', 'x', rawurlencode( $thumb ) );
$thumb = rawurldecode( $thumb );
if ( is_ssl() ) $thumb = preg_replace( '#^http://#', 'https://', $thumb );
$info = pathinfo($thumb);
$output = sprintf(
'<div%3$s class="et_pb_text%2$s%4$s">
%1$s
</div> <!-- .et_pb_text -->',
do_shortcode( et_pb_fix_shortcodes( preg_replace( '|http://www\.youtube\.com/watch\?.*\bv=([^<\, ]+)|','<iframe src=http://www.youtube.com/embed/$1 frameborder="0" allowfullscreen></iframe>',$content ) ) ),
esc_attr( $class ),
( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' )
);