array( 'name' => esc_html__( 'Content', 'mega' ), 'description' => esc_html__( 'Content block', 'mega' )),
'before' => '
',
'after' => '
'
);
parent::__construct( __CLASS__, $args );
$this->hookOnce();
add_filter( 'wp_video_shortcode', array( $this, 'getVideoAudioFormat' ), 10, 5 );
add_filter( 'wp_audio_shortcode', array( $this, 'getVideoAudioFormat' ), 10, 5 );
}
public function settings( $form )
{
$form->add_control( 'Mega_Control_onOff', array( 'label' => esc_html__( 'Generate Excerpts', 'mega' ), 'pro' => 1, 'value' => 0, 'name' => 'excerpts', 'desc' => esc_html__( 'Excluding single posts & pages', 'mega' )));
$form->add_sub_control( 'Mega_Control_Number', array( 'control' => 'excerpts', 'control_value' => 'true', 'label' => esc_html__( 'Excerpt Length (chars)', 'mega' ), 'value' => 500, 'name' => 'excerpt_length' ));
$form->add_control( 'Mega_Control_onOff', array( 'label' => esc_html__( 'Show comment & ping status', 'mega' ), 'value' => 1, 'name' => 'show_rules', 'desc' => esc_html__( 'Show a notice on single posts, whether comments and pings are opened or closed', 'mega' )));
}
public function hookOnce()
{
add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue' ));
}
public function enqueue()
{
wp_enqueue_script( 'jquery.jplayer.min', MEGA_DIR_URI . '/assets/js/jquery.jplayer.min.js', array( 'jquery' ), false, true );
wp_enqueue_script( 'mega.jquery.jplayer.init', MEGA_DIR_URI . '/assets/js/mega.jquery.jplayer.init.js', array( 'jquery', 'jquery.jplayer.min' ), false, true );
wp_enqueue_style( 'mega.jquery.jplayer.style', MEGA_DIR_URI . '/assets/css/Blocks/player.css' );
}
public function block()
{
extract( $this->mega['settings'] );
switch( get_post_format() )
{
case 'quote' :
$this->getQuoteFormat();
break;
case 'status' :
$this->getStatusFormat();
break;
case 'link' :
$this->getLinkFormat();
break;
case 'video' : case 'audio' :
$obj = hybrid_media_grabber(array( 'split_media' => false, 'type' => get_post_format() ));
//if ( $obj->spit )
echo $obj->media;
//else
//echo $this->getVideoAudioFormat( $obj->media );
break;
default :
if ( !is_singular() && $excerpts )
echo mega_clean_words( $excerpt_length, get_the_excerpt() );
else
the_content();
edit_post_link( null, '', '
' );
}
wp_link_pages( array(
'before' => '' . esc_html__( 'Pages:', 'mega' ),
'after' => '
'
));
if ( is_single() && $show_rules )
mega_html( $this->getRule(), '', '
' );
}
public function getRule()
{
if ( post_password_required())
return false;
elseif ( !comments_open() && pings_open())
return sprintf( wp_kses( __( 'Responses are currently closed, but you can trackback from your own site.', 'mega' ), array( 'a' => array( 'href' => true, 'rel' => true ))), get_trackback_url());
elseif ( comments_open() && !pings_open())
return esc_html__( 'You can skip to the end and leave a response. Pinging is currently not allowed.', 'mega' );
elseif ( !comments_open() && !pings_open())
return esc_html__( 'Both comments and pings are currently closed.', 'mega' );
return false;
}
public function getQuoteFormat()
{
$quote = get_post_meta( get_the_ID(), 'post_quote', true );
$author = get_post_meta( get_the_ID(), 'post_quote_author', true );
echo
'',
'',
$quote ? $quote : esc_html__( 'Please enter a quote using the metaboxes', 'mega' ),
'
';//remove -use content
if ( $author )
echo '' . $author . '';
}
public function getStatusFormat()
{
echo '';
the_content();
echo '
';
}
public function getLinkFormat()
{
echo
'';
}
public function getVideoAudioFormat( $html, $atts = array(), $audio = '', $post_id = '', $library = '' )// $atts, $content = '', $name
{
$post_format = '';
$supplied = array();
if ( !isset( $atts['src'] ))
$atts['src'] = '';
$ext = pathinfo( $atts['src'], PATHINFO_EXTENSION );
$fname = pathinfo( $atts['src'], PATHINFO_FILENAME );
$title = get_the_title();
if ( isset( $fname ))
$title = $fname;
switch ( $ext )
{
case 'mp3' : case 'ogg' : case 'm4a' :
$post_format = 'audio';
$poster = '';
$supplied[$ext] = $atts['src'];
break;
case 'm4v' : case 'ogv' : case 'webmv' :
$post_format = 'video';
$poster = $atts['poster'];
$supplied[$ext] = $atts['src'];
break;
}
$data = array();
foreach( $supplied as $ext => $file )
{
if ( !empty( $file ))
{
$data[] = 'data-' . $ext . '="' . $file . '"';
}
}
//$title = $this->jpTitle( $supplied, $title );
$poster = !empty( $poster ) ? 'data-poster="' . $poster . '"' : '';
$r =
''.
'
'.
'
'.
'
'.
'
';
$r .= $this->jpProgress();
$r .= $this->jpControls();
$r .= $this->jpVolume();
$r .= $this->jpTime();
$r .= $this->jpDetails();
$r .=
'
'.
'
'.
'
'.
'
';
return $r;
}
public function jpProgress()
{
return
'';
}
public function jpControls()
{
return
'';
}
public function jpVolume()
{
return
'';
}
public function jpTime()
{
return
'';
}
public function jpDetails()
{
return
''.
''.
'
';
}
public function jpTitle( $supplied, $title )
{
if ( empty( $title ))
{
foreach( $supplied as $ext => $file )
if ( !empty( $file ))
return basename( $file );
}
return $title;
}
}