Skip to content

Instantly share code, notes, and snippets.

@Pross
Created March 7, 2014 20:50
Show Gist options
  • Select an option

  • Save Pross/9419820 to your computer and use it in GitHub Desktop.

Select an option

Save Pross/9419820 to your computer and use it in GitHub Desktop.
<?php
class Section_Overide {
function __construct() {
add_filter( 'pagelines_render_section', array( $this, 'section_overide' ), 10, 2 );
}
function section_overide( $s, $class ) {
$to_overide = 'textbox'; // lets target textbox...and pretend there is a new option
if( $to_overide == $s->id ) {
$s->meta['set']['textbox_waist_size'] = '50';
ob_start();
$this->alternative_textbox_template( $s );
$output = ob_get_clean();
return $output;
}
// it isnt textbox so load section per normal.
ob_start();
$class->section_template_load( $s ); // this is the actual section output
$output = ob_get_clean();
return $output;
}
// so this is the regular textbox section template, with added waist size ;)
function alternative_textbox_template( $s ) {
global $pldraft;
$edit = false;
$extra = '';
if( is_object( $pldraft ) && 'draft' == $pldraft->mode )
$edit = true;
$title_wrap = ( '' != $s->opt( 'textbox_title_wrap' ) ) ? $s->opt( 'textbox_title_wrap' ) : 'strong';
$text = $s->opt('textbox_content');
$waistsize = $s->opt( 'textbox_waist_size' );
$title = $s->opt('textbox_title');
if( ! $text ){
$text = 'Textbox Section';
}
if( 'strong' == $title_wrap )
$extra = '<br />';
if( '' != $title ) {
if( 'none' != $title_wrap )
$title = sprintf( '<%s data-sync="textbox_title">%s</%s>%s', $title_wrap, $title, $title_wrap, $extra );
else
$title = sprintf( '<span data-sync="textbox_title">%s</span>', $title );
}
printf( '<h1>%s</h1>', $waistsize );
$text = sprintf('<div class="hentry" data-sync="textbox_content">%s</div>', do_shortcode( wpautop($text) ) );
$class = $s->opt('textbox_animation');
$align = $s->opt('textbox_align');
$pad = ($s->opt('textbox_pad')) ? sprintf('padding: %s;', $s->opt('textbox_pad')) : '';
$size = ($s->opt('textbox_font_size')) ? sprintf('font-size: %spx;', $s->opt('textbox_font_size')) : '';
printf('<div class="textbox-wrap pl-animation %s %s" style="%s%s">%s%s</div>', $align, $class, $pad, $size, $title, $text);
}
}
new Section_Overide;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment