getPrefixedFilterHook( 'template_name' ), $name, $template );
$template = apply_filters( ace()->getPrefixedFilterHook( 'template' ), array( 'template', $template ) );
get_template_part( implode( '/', $template ), $name );
}
/**
* Forms
**/
/**
*
**/
public static function renderCustomSearchForm( $post_types, $custom_search_fields )
{
$form = '
';
return $form;
}
#
# General Tags
#
/**
* Render defined SVG
* @param string $svg_class
* @param string $xlink_id
**/
public static function renderDefinedSVG( $svg_class, $xlink_id, $size = array( 24, 24 ), $view_box = '0 0 24 24' )
{
echo self::getDefinedSVG( $svg_class, $xlink_id );
}
public static function getDefinedSVG( $svg_class, $xlink_id )
{
return '';
}
/**
* Print General Element Tag
*
* @static
*
* @param string $element
* @param string $atts
* @param string $text
* @param string $wrap
*
* @see self::getGeneratedTag( $element, $atts, $text, $wrap )
**/
public static function generatedTag( $element, $atts = array(), $text = '', $wrap = false ) {
echo self::getGeneratedTag( $element, $atts, $text, $wrap );
}
/**
* Get General Element Tag
*
* @static
*
* @param string $element
* @param string $atts
* @param string $text
* @param string $wrap
*
* @return string
**/
public static function getGeneratedTag( $element, $atts = array(), $text = '', $wrap = false ) {
$return = '<' . $element;
foreach( $atts as $key => $val ) { $return .= ' ' . esc_attr( $key ) . '="' . esc_attr( $val ) . '"'; }
if ( $wrap ) {
$return .= '>' . esc_html( $text ) . '' . $element . '>';
} else {
if ( $text != '' ) { $return .= ' data-' . ACE_THEME_PREFIX . 'text="' . esc_attr( $text ) . '"'; }
$return .= '/>';
}
return $return;
}
#
# Icons
#
/**
* Icon
* @param string $icon_name
* @return string
**/
public static function getMdITag( $icon_name )
{
if ( ! is_string( $icon_name ) || '' === $icon_name ) return '';
return sprintf( '', $icon_name );
}
#
# Images
#
/**
* Get Image Tag with Alternative Noscript Tag
*
* @static
*
* @param string $src
* @param string $type
* @param [] $atts
*
* @return string
**/
public static function getImageTagWithNoScript( $src, $type = 'img', $atts = array() ) {
$no_img = self::getNoImageSrc();
if ( 'img' === $type ) {
$img_format = '
';
}
elseif ( 'svg' === $type ) {
$img_format = '';
}
$atts = wp_parse_args( $atts, array(
'src' => esc_url( $src ),
'class' => '',
'alt' => '',
'width' => 80,
'height' => 80,
'desc' => '',
));
$html = sprintf( $img_format, esc_attr( $atts['class'] ), esc_attr( $atts['alt'] ), esc_url( $atts['src'] ), absint( $atts['width'] ), absint( $atts['height'] ), esc_url( $no_img ), $atts['desc'] );
return $html;
}
/**
* Print Default Post Thumbnail URL
*
* @static
*
* @param WP_Post $post
*
* @see self::getGeneratedTag( $element, $atts, $text, $wrap )
**/
public static function theDefaultThumbnailUrl( $post ) {
echo esc_url( self::getTheDefaultThumbnailUrl( $post ) );
}
/**
* Get Default Post Thumbnail URL
*
* @static
*
* @param WP_Post $post
*
* @return string $url
**/
public static function getTheDefaultThumbnailUrl( $post ) {
$cat = get_the_category( $post->ID );
if ( isset( $cat[ 0 ] ) ) {
$default_cat_thumbnail = get_term_meta( $cat[ 0 ]->term_id, 'ace_term_default_thumbnail', true );
} else {
$default_cat_thumbnail = '';
}
$default_cat_thumbnail = esc_url( apply_filters( ace()->getPrefixedFilterHook( 'defualt_thumbnail_url_before_set_theme_mod_value' ), $default_cat_thumbnail, $post ) );
return esc_url(
$default_cat_thumbnail != ''
? $default_cat_thumbnail
: get_theme_mod( 'default_thumbnail_image', ACE_DIR_URL . 'img/no-img.png' )
);
}
/**
* Print Default Post Thumbnail in Div Tag
*
* @static
*
* @param string $class
* @param array $size
* 'width' => "{$int}px",
* 'height' => "{$int}px",
*
* @see self::getDivTagDefaultThumbnail( $class, $size )
**/
public static function divTagDefaultThumbnail( $class = 'default-post-thumbnail', $size = array( 'width' => '80px', 'height' => '80px' ) ) {
echo self::getDivTagDefaultThumbnail( $class, $size );
}
/**
* Get Default Post Thumbnail in Div Tag
*
* @static
*
* @param string $class : Default "default-post-thumbnail"
* @param array $size : Default
* 'width' => "{$int}px",
* 'height' => "{$int}px",
* @param string $optional_def_image_url : Default ""
*
* @see self::getGeneratedTag( $element, $atts = array(), $text = '', $wrap = false )
*
* @return string
**/
public static function getDivTagDefaultThumbnail( $class = 'default-post-thumbnail', $size = array( 'width' => '80px', 'height' => '80px' ), $optional_def_image_url = '' ) {
// カスタマイザーでデフォルトを設定している場合
$default_thumbnail_url = esc_url(
$optional_def_image_url
? $optional_def_image_url
: getThemeMod( 'default_thumbnail_image', '' )
);
$atts = array(
'class' => esc_attr( $class ? $class . ' default-thumbnail' : 'default-thumbnail' ),
'style' => esc_attr( 'width: ' . $size[ 'width' ] . '; height: ' . $size[ 'height' ] . '; background-image: url(' . $default_thumbnail_url . '); background-size: ' . $size[ 'width' ] . ' ' . $size[ 'height' ] . '; background-position: center center; background-repeat: no-repeat;' )
);
$return = self::getGeneratedTag( 'div', $atts, '', true );
return apply_filters( ace()->getPrefixedFilterHook( 'default_thumbnail_div_tag' ), $return, $class, $size, $optional_def_image_url );
}
/**
* Print Default Thumbnail IMG Tag
*
* @static
*
* @param string $class
* @param array $size
* 'width' => "{$int}px",
* 'height' => "{$int}px",
*
* @see self::getImgTagDefaultThumbnail( $class, $size, $alt )
**/
public static function imgTagDefaultThumbnail( $class = 'default-post-thumbnail', $size = array( 'width' => 80, 'height' => 80 ), $alt = '' ) {
echo self::getImgTagDefaultThumbnail( $class, $size, $alt );
}
/**
* Get Default Thumbnail IMG Tag
*
* @static
*
* @param string $class
* @param array $size
* 'width' => "{$int}px",
* 'height' => "{$int}px",
*
* @see self::getGeneratedTag( $element, $atts = array(), $text = '', $wrap = false )
*
* @return string
**/
public static function getImgTagDefaultThumbnail( $class = 'default-post-thumbnail', $size = array( 'width' => 80, 'height' => 80 ), $alt = '', $optional_def_image_url = '' ) {
$default_thumbnail_url = esc_url(
$optional_def_image_url
? $optional_def_image_url
: get_theme_mod( 'default_thumbnail_image', ACE_DIR_URL . 'img/no-img.png' )
);
$atts = array(
'class' => esc_attr( $class ? $class . ' default-thumbnail' : 'default-thumbnail' ),
'src' => esc_url( $default_thumbnail_url ),
'width' => absint( $size[ 'width' ] ),
'height' => absint( $size[ 'height' ] ),
'alt' => esc_attr( $alt )
);
$return = self::getGeneratedTag( 'img', $atts, '', true );
return apply_filters( ace()->getPrefixedFilterHook( 'default_thumbnail_img_tag' ), $return, $class, $size, $alt, $optional_def_image_url );
}
/**
* Print Image in Div
*
* @static
*
* @param int $post_id
* @param string $class
* @param array $size
* 'width' => "{$int}px",
* 'height' => "{$int}px",
*
* @see self::getDivTagPostThumbnail( $post_id, $class, $size )
**/
public static function divTagPostThumbnail( $post_id, $div_class = 'post-thumbnail', $size = array( 'width' => '80px', 'height' => '80px' ) ) {
echo self::getDivTagPostThumbnail( $post_id, $div_class, $size );
}
/**
* Get Default Thumbnail IMG Tag
*
* @static
*
* @param int $post_id
* @param string $class
* @param array $size
* 'width' => "{$int}px",
* 'height' => "{$int}px",
*
* @see self::getGeneratedTag( $element, $atts = array(), $text = '', $wrap = false )
*
* @return string
**/
public static function getDivTagPostThumbnail( $post_id, $div_class = 'post-thumbnail', $size = array( 'width' => '80px', 'height' => '80px' ) ) {
$post_thumbnail_url = esc_url( get_the_post_thumbnail( $post_id ) );
if ( ! $post_thumbnail_url )
return;
$atts = array(
'class' => esc_attr( $div_class ),
'style' => 'background-image: url(' . $post_thumbnail_url . '); background-size: ' . esc_attr( $size[ 'width' ] ) . ' ' . esc_attr( $size[ 'height' ] ) . '; background-position: center center; background-repeat: no-repeat;'
);
$return = self::getGeneratedTag( 'div', $atts );
return apply_filters( ace()->getPrefixedFilterHook( 'post_thumbnail_div_tag' ), $return, $post_id, $div_class, $size );
}
/**
* Breadcrumb
**/
/**
* Item
* @param string $label
* @param string $type
* @param string $url
**/
public static function renderBreadcrumbItem( $label, $type, $url = '' )
{
echo '';
if ( is_string( $url ) && '' !== $url ) echo '';
echo '';
echo esc_html( $label );
echo '';
if ( is_string( $url ) && '' !== $url ) echo '';
echo '';
}
/**
* Theme Customizer
**/
/**
* Edit Shortcut for Theme Customizer
*
* @param string $setting_id
* @param string $label
*
* @return string
**/
public static function editorShortcutForThemeCustomizer( $setting_id, $label = '' ) {
echo self::getEditorShortcutForThemeCustomizer( $setting_id, $label );
}
/**
* Edit Shortcut for Theme Customizer
*
* @param string $setting_id
* @param string $label
*
* @return string
**/
public static function getEditorShortcutForThemeCustomizer( $setting_id, $label = '' ) {
if( empty( $label ) )
$label = esc_html__( 'Click to edit this.', 'ace' );
$return = '';
$return .= '';
$return .= '';
$return .= '';
return apply_filters( ace()->getPrefixedFilterHook( 'edit_shortcut_icon_for_theme_customizer' ), $return, $setting_id, $label );
}
}