'', /* ============================ Advanced Post Meta Settings ============================*/ // META ITEM ENABLE 'authorShow' => true, 'dateShow' => true, 'cmtCountShow' => true, 'viewCountShow' => false, 'readTimeShow' => false, 'catShow' => false, 'tagShow' => false, 'metaSeparator' => 'dot', 'metaItemSort' => array( 'author', 'date', 'cmtCount', 'viewCount', 'readTime', 'cat', 'tag' ), /* ============================ Post Author Style ============================*/ // Avatar 'authImgShow' => false, // Author Label 'authLabelShow' => true, 'authLabel' => 'Author', // Auth Icon 'authIconShow' => false, 'authIconStyle' => 'author1', 'authAlign' => false, /* ============================ Post Publish Time Style ============================*/ 'dateFormat' => 'updated', 'metaDateFormat' => 'M j, Y', 'dateColor' => '#a4a4a4', // Prefix 'enablePrefix' => true, 'datePubText' => 'Publish Update', 'dateText' => 'Latest Update', // Icon 'DateIconShow' => false, 'dateIconStyle' => 'date1', 'dateAlign' => false, /* ============================ Comment Style ============================*/ // Prefix 'cmtLabelShow' => true, 'cmtLabel' => 'Comment', // Icon 'cmtIconShow' => false, 'cmntIconStyle' => 'commentCount1', 'cmntAlign' => false, // Prefix Style 'viewLabelShow' => true, 'viewLabel' => 'View', // Icon 'viewIconShow' => false, 'viewIconStyle' => 'viewCount1', 'viewAlign' => false, /* ============================ Reading Time Style ============================*/ // Prefix 'readTimePrefix' => true, 'readTimeText' => 'Minute Read', 'readPrefixAlign' => 'after', // Icon 'readTimeIcon' => false, 'readIconStyle' => 'readingTime2', 'readAlign' => false, /* ============================ Categories Style ============================*/ 'catLabelShow' => true, 'catLabel' => 'Category', 'catIconShow' => false, 'catIconStyle' => 'cat2', 'catAlign' => false, /* ============================ Tag Style ============================*/ 'tagColor' => '#545454', 'tagHovColor' => '#ddd', 'tagTypo' => (object) array( 'openTypography' => 1, 'decoration' => 'none', 'size' => (object) array( 'lg' => 15, 'unit' => 'px', ), 'height' => (object) array( 'lg' => 20, 'unit' => 'px', ), ), 'tagSpace' => (object) array( 'lg' => '7', 'unit' => 'px', ), 'tagLabelShow' => true, 'tagLabel' => 'Tag - ', 'tagIconShow' => false, 'tagIconStyle' => 'tag2', 'tagAlign' => false, /* ============================ Advance Setting ============================*/ 'advanceId' => '', 'advanceZindex' => '', 'hideExtraLarge' => false, 'hideDesktop' => false, 'hideTablet' => false, 'hideMobile' => false, 'advanceCss' => '', ); } public function register() { register_block_type( 'ultimate-post/advance-post-meta', array( 'editor_script' => 'ultp-blocks-editor-script', 'editor_style' => 'ultp-blocks-editor-css', 'render_callback' => array( $this, 'content' ), ) ); } public function content( $attr, $noAjax ) { $attr = wp_parse_args( $attr, $this->get_attributes() ); $block_name = 'post_meta'; $wrapper_before = $wrapper_after = $wrapper_content = $authContent = $updateLabel = $dateLabel = ''; $post_id = get_the_ID(); $contentAlign = ( $attr['catAlign'] || $attr['tagAlign'] || $attr['cmntAlign'] || $attr['viewAlign'] || $attr['readAlign'] || $attr['authAlign'] || $attr['dateAlign'] ) ? 'ultp-contentMeta-align' : 'ultp-contentMeta'; $attr['className'] = isset( $attr['className'] ) && $attr['className'] ? preg_replace( '/[^A-Za-z0-9_ -]/', '', $attr['className'] ) : ''; $attr['align'] = isset( $attr['align'] ) && $attr['align'] ? preg_replace( '/[^A-Za-z0-9_ -]/', '', $attr['align'] ) : ''; $attr['advanceId'] = isset( $attr['advanceId'] ) ? sanitize_html_class( $attr['advanceId'] ) : ''; $attr['blockId'] = isset( $attr['blockId'] ) ? sanitize_html_class( $attr['blockId'] ) : ''; $attr['metaSeparator'] = sanitize_html_class( $attr['metaSeparator'] ); $allowed_html_tags = ultimate_post()->ultp_allowed_html_tags(); $attr['authLabel'] = wp_kses( $attr['authLabel'], $allowed_html_tags ); $attr['dateText'] = wp_kses( $attr['dateText'], $allowed_html_tags ); $attr['datePubText'] = wp_kses( $attr['datePubText'], $allowed_html_tags ); $attr['cmtLabel'] = wp_kses( $attr['cmtLabel'], $allowed_html_tags ); $attr['viewLabel'] = wp_kses( $attr['viewLabel'], $allowed_html_tags ); $attr['readTimeText'] = wp_kses( $attr['readTimeText'], $allowed_html_tags ); $attr['catLabel'] = wp_kses( $attr['catLabel'], $allowed_html_tags ); $attr['tagLabel'] = wp_kses( $attr['tagLabel'], $allowed_html_tags ); // Author Content if ( $attr['authorShow'] ) { $author_id = get_post_field( 'post_author', $post_id ); $authContent .= ''; $authContent .= ''; if ( $attr['authIconShow'] ) { $authContent .= ultimate_post()->get_svg_icon( '' . $attr['authIconStyle'] . '' ); } if ( $attr['authImgShow'] ) { $authContent .= get_avatar( $author_id, 32 ); } if ( $attr['authLabelShow'] ) { $authContent .= '' . $attr['authLabel'] . ''; } $authContent .= ' '; $authContent .= ''; $authContent .= get_the_author_meta( 'display_name', $author_id ); $authContent .= ''; $authContent .= ''; } // Date Content if ( $attr['enablePrefix'] ) { $dateLabel .= '' . $attr['dateText'] . ''; } if ( $attr['enablePrefix'] ) { $updateLabel .= '' . $attr['datePubText'] . ''; } $dateContent = ''; if ( $attr['dateShow'] ) { $dateContent .= ''; if ( $attr['DateIconShow'] ) { $dateContent .= '' . ultimate_post()->get_svg_icon( '' . $attr['dateIconStyle'] . '' ) . ''; } if ( $attr['dateFormat'] == 'updated' ) { $dateContent .= '' . $dateLabel . ''; } if ( $attr['dateFormat'] == 'publish' ) { $dateContent .= '' . $updateLabel . ' '; } $dateContent .= ''; } // Main Content $wrapper_before .= '
'; $wrapper_before .= '
'; $wrapper_content .= ''; $wrapper_after .= '
'; $wrapper_after .= '
'; return $wrapper_before . $wrapper_content . $wrapper_after; } public function renderPostCount( $title, $data, $labelEnable, $labelText, $iconEnable, $icon, $post_id = null ) { $content = ''; $content .= ''; if ( ( $title == 'tag' || $title == 'cat' ) && $iconEnable ) { $content .= '' . $icon . ''; } if ( ( $title == 'tag' || $title == 'cat' ) && ( $labelEnable ) ) { $content .= '' . $labelText . ''; } if ( $title == 'tag' || $title == 'cat' ) { $content .= ''; if ( is_array( $data ) && count( $data ) > 0 ) { if ( is_array( $data ) ) { foreach ( $data as $dt ) { $content .= '' . $dt->name . ''; } } } else { $content .= 'No Taxonomy Found.'; } $content .= ''; } elseif ( ( $title != 'tag' && $title != 'cat' && $title != 'readTime' ) ) { $content .= ''; if ( $iconEnable ) { $content .= $icon; } $content .= $data ? $data : 0; $content .= ''; } if ( ( $title != 'tag' && $title != 'cat' && $title != 'readTime' ) && $labelEnable ) { $content .= '' . $labelText . ''; } if ( $title == 'readTime' ) { if ( $iconEnable ) { $content .= $icon; } $content .= '
' . ceil( mb_strlen( wp_strip_all_tags( get_the_content( null, false, $post_id ) ) ) / 1200 ) . '
'; $content .= $labelEnable ? '' . $labelText . '' : ''; $content .= '
'; } $content .= ''; return $content; } }