Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////////////
- //JNews Custom Drawer Code | START |
- ////////////////////////////////////////////////////////////
- add_action('init', function (){
- remove_action( 'jnews_mobile_menu_cotent', 'jnews_render_mobile_menu_content' );
- add_action( 'jnews_mobile_menu_cotent', 'drawer_builder' );
- function drawer_builder() {
- $post_id = 94425;
- get_template_part('fragment/header/element/mobile/logo');
- ?>
- <div class="jeg_header">
- <div class="container">
- <div id="icon-x">
- <svg>
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 308.3 308.3">
- <path d="M188.8 154.1l119.1-119L273.2.4 154.1 119.5 35.3.6.2 34.9l119.3 119.2L.4 273.2l34.7 34.7 119.2-119.2 118.9 119.2 34.9-34.5z"></path>
- </svg>
- </svg>
- </div>
- </div>
- </div>
- <hr>
- <style>
- .jeg_mobile_wrapper .jeg_header {
- display:block;
- }
- #icon-x {
- position: relative;
- }
- #icon-x>svg {
- width: 25px;
- height: 25px;
- position: absolute;
- top: -43px;
- left: 0;
- cursor: pointer;
- }
- div.jeg_header + hr {
- margin-top:15px !important;
- }
- .jeg_mobile_wrapper {
- width: 100vw;
- }
- .item_main {
- max-width: 500px;
- margin: auto;
- }
- .jeg_mobile_wrapper .jeg_mobile_logo img {
- margin: auto;
- margin-top: 25px;
- }
- @media (max-width: 1024px) {
- #icon-x>svg {
- top: -28px;
- }
- }
- </style>
- <script>
- (function (){
- document.getElementById('icon-x').addEventListener('click', function (e) {
- document.querySelector('.jeg_menu_close').click();
- });
- })();
- </script>
- <?php
- $document = \Elementor\Plugin::$instance->documents->get_doc_for_frontend( $post_id );
- $data = $document->get_elements_data();
- $css_file = \Elementor\Core\Files\CSS\Post::create( $post_id );
- ob_start();
- $css_file->print_css();
- $document->print_elements_with_wrapper( $data );
- echo ob_get_clean();
- }
- });
- ////////////////////////////////////////////////////////////
- //JNews Custom Drawer Code | END |
- ////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////
- //JNews Author Tooltip | START |
- ////////////////////////////////////////////////////////////
- add_action( 'wp_head', function () {
- ?>
- <style>
- .jeg_mobile_wrapper {
- transition: none;
- }
- .jeg_mobile_wrapper img.jeg_logo_img {
- margin-top: 15px !important;
- height: 60px;
- max-height: unset;
- }
- .jeg_header_wrapper .jeg_bottombar .jeg_nav_row {
- display: grid;
- grid-auto-flow: column;
- grid-template-columns: 1fr 1fr 1fr;
- }
- .jeg_navbar_mobile_wrapper .jeg_mobile_midbar.jeg_mobile_bottombar .jeg_nav_row {
- display: grid;
- grid-auto-flow: column;
- grid-template-columns: 1fr 3fr 1fr;
- }
- .author-tooltip-container {
- position: relative;
- }
- .author-tooltip-container strong {
- font-weight: 700;
- }
- .author-tooltip-container .fa::before {
- /* display: none; */
- }
- .author-tooltip {
- color: #212121;
- position: absolute;
- top: calc(100% + 10px);
- left: 0;
- z-index: 99;
- background: white;
- border: solid #D3D3D3 1px;
- display: grid;
- grid-template-areas:
- "a b"
- "a c"
- "d d"
- "e e";
- grid-template-columns: 80px max(200px);
- grid-template-rows: min-content min-content auto;
- grid-gap: 10px;
- padding: 10px;
- visibility: hidden;
- }
- .author-tooltip.right {
- left: unset;
- right: 0;
- }
- .author-tooltip-container:hover>.author-tooltip {
- visibility: visible;
- }
- .author-tooltip-container.show>.author-tooltip {
- visibility: visible;
- }
- .author-tooltip a {
- color: #0d57cf;
- text-decoration: underline;
- }
- .author-tooltip>img {
- width: unset !important;
- border-radius: unset !important;
- grid-area: a;
- }
- .author-tooltip>.jeg_author_name {
- grid-area: b;
- align-self: end;
- }
- .author-tooltip>.jeg_author_socials a {
- margin: 11px 10px 6px 0;
- }
- .author-tooltip>.jeg_author_socials {
- grid-area: c;
- }
- .author-tooltip>.jeg_author_description {
- grid-area: d;
- }
- .author-tooltip>.jeg_author_footer {
- grid-area: e;
- padding-top: 10px;
- border-top: 1px solid #EEE;
- }
- .author-tooltip::before {
- content: "";
- position:absolute;
- width: 10px;
- height: 10px;
- background: white;
- transform: translate(10px,-6px) rotate(45deg);
- border: #D3D3D3 solid 1px;
- border-bottom: unset;
- border-right: unset;
- }
- .author-tooltip.right::before {
- transform: translate(-10px,-6px) rotate(45deg);
- right: 0;
- }
- .author-tooltip .jeg_author_socials>a {
- text-decoration:none;
- }
- .author-tooltip-container .fa {
- background:black;
- color: white !important;
- display:flex;
- align-items: center;
- justify-content: center;
- border-radius: 50%
- }
- .author-tooltip-container .jeg_author_socials>a {
- margin: 0 .3125rem 0 0;
- }
- @media (max-width: 768px) {
- .author-tooltip, .author-tooltip.right {
- position: absolute;
- top: 25px;
- transform: translate(-50%, 0%);
- right: unset;
- }
- .author-tooltip::before {
- display: none;
- }
- }
- @media (max-width: 1024px) {
- .jeg_mobile_wrapper .jeg_mobile_logo .jeg_logo_img {
- height: 30px;
- }
- }
- </style>
- <?php
- }, 99999);
- add_action( 'wp_footer', function () {
- ?>
- <script>
- (function(){
- document.querySelectorAll(".author-tooltip-container").forEach(function (value) {
- let timeout;
- ["mouseover", "mouseleave"].forEach(function(event) {
- value.addEventListener(event, function() {
- this.classList.add("show");
- clearTimeout(timeout) || (timeout = setTimeout(function() {
- this.classList.remove("show");
- }.bind(this),1000));
- });
- });
- })
- })();
- (function() {
- let authors = document.querySelectorAll('.author-tooltip '),
- resonsive = function() {
- let width = window.outerWidth;
- if(width > 768) {
- authors.forEach(function(author) {
- author.style.left = '';
- });
- } else {
- authors.forEach(function(author) {
- author.style.left = `${(width / 2 - author.parentElement.getBoundingClientRect().left)}px`;
- });
- }
- };
- window.addEventListener('resize', resonsive);
- resonsive();
- })();
- </script>
- <?php
- } );
- // if ( ! function_exists( 'jnews_the_author_link' ) && false ) {
- if ( ! function_exists( 'jnews_the_author_link' ) ) {function jnews_the_author_link( $author = null, $print = true, $review = false ) {
- ob_start();
- get_template_part( 'fragment/post/author-social' );
- $social = ob_get_clean();
- $footer = 'Learn about our <a href="#">editorial process</a>.';
- $prefix = '';
- $suffix = '';
- $right = '';
- if ( $review ) {
- $right = 'right';
- $post_id = get_the_ID();
- if ( $review_footer = vp_metabox( 'jnews_custom_review.footer', false, $post_id ) ) $footer = $review_footer;
- if ( $review_prefix = vp_metabox( 'jnews_custom_review.prefix', false, $post_id ) ) $prefix = $review_prefix;
- if ( $review_suffix = vp_metabox( 'jnews_custom_review.suffix', false, $post_id ) ) $suffix = $review_suffix;
- }
- $ret = sprintf(
- '
- <span class="author-tooltip-container">
- <a href="%1$s">%2$s</a>
- <div class="author-tooltip %7$s">
- ' . get_avatar( get_the_author_meta( 'ID', $author ), 80, null, get_the_author_meta( 'display_name', $author ) ) . '
- <div class="jeg_author_name">
- <strong>%5$s</strong> <a href="%1$s">%2$s</a> <span>%6$s</span>
- </div>
- <div class="jeg_author_socials">
- %3$s
- </div>
- <div class="jeg_author_description">' . get_the_author_meta( 'description', $author ) . '</div>
- <div class="jeg_author_footer">
- <span>%4$s</span>
- </div>
- </div>
- </span>
- ',
- esc_url( get_author_posts_url( get_the_author_meta( 'ID', $author ) ) ),
- '<strong>' . get_the_author_meta( 'display_name', $author ) . '</strong>',
- $social,
- $footer,
- $prefix,
- $suffix,
- $right
- );
- if ( ! $print ) return $ret;
- echo $ret;
- }
- }
- ////////////////////////////////////////////////////////////
- //JNews Author Tooltip | END |
- ////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////
- //JNews Reviewer | START |
- ////////////////////////////////////////////////////////////
- add_action('after_setup_theme', 'review_check_metabox');
- function review_check_metabox () {
- if( class_exists('VP_Metabox') ) {
- new VP_Metabox( [
- 'id' => 'jnews_custom_review',
- 'types' => [ 'post' ],
- 'title' => 'JNews : Fact Checker',
- 'priority' => 'high',
- 'template' => [
- [
- 'type' => 'toggle',
- 'name' => 'reviewed',
- 'label' => esc_html__( 'Reviewed?', 'jnews-custom' ),
- 'description' => esc_html__( 'enable this option if this article has been reviewed', 'jnews-custom' ),
- 'default' => false,
- ],
- [
- 'type' => 'textbox',
- 'name' => 'prefix',
- 'label' => esc_html__( 'Prefix', 'jnews-custom' ),
- 'description' => esc_html__( 'please insert the review prefix', 'jnews-custom' ),
- 'default' => 'reviewed by',
- 'active_callback' => [
- [
- 'field' => 'reviewed',
- 'operator' => '==',
- 'value' => true,
- ]
- ]
- ],
- [
- 'type' => 'select',
- 'name' => 'reviewer',
- 'label' => esc_html__( 'The Reviewer', 'jnews-custom' ),
- 'description' => esc_html__( 'Assign user that has reviewd this article', 'jnews-custom' ),
- 'default' => '',
- 'items' => call_user_func( function () {
- $users = [];
- foreach ( get_users() as $user ) {
- $users[] = [
- 'value' => $user->ID,
- 'label' => $user->display_name,
- ];
- }
- return $users;
- } ),
- 'active_callback' => [
- [
- 'field' => 'reviewed',
- 'operator' => '==',
- 'value' => true,
- ]
- ]
- ],
- [
- 'type' => 'textbox',
- 'name' => 'suffix',
- 'label' => esc_html__( 'Suffix', 'jnews-custom' ),
- 'description' => esc_html__( 'please insert the review suffix', 'jnews-custom' ),
- 'default' => '',
- 'active_callback' => [
- [
- 'field' => 'reviewed',
- 'operator' => '==',
- 'value' => true,
- ]
- ]
- ],
- [
- 'type' => 'textbox',
- 'name' => 'footer',
- 'label' => esc_html__( 'Footer', 'jnews-custom' ),
- 'description' => esc_html__( 'please insert the review footer', 'jnews-custom' ),
- 'default' => '',
- 'active_callback' => [
- [
- 'field' => 'reviewed',
- 'operator' => '==',
- 'value' => true,
- ]
- ]
- ],
- ],
- ] );
- }
- }
- add_action( 'jnews_render_after_meta_left', function () {
- global $post;
- if ( vp_metabox( 'jnews_custom_review.reviewed', false, $post->ID ) ) {
- if ( ! is_numeric( $author = vp_metabox( 'jnews_custom_review.reviewer', '', $post->ID ) ) ) return;
- ?>
- <div class="jeg_meta_reviewed">
- <svg class="reviewer-icon" width="14px" height="14px">
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
- <path fill="#FF3300" fill-rule="evenodd" d="M9.15254 3.72881c-3.93152 0-7.11864 3.18713-7.11864 7.11869 0 3.9315 3.18712 7.1186 7.11864 7.1186 3.93156 0 7.11866-3.1871 7.11866-7.1186 0-1.22169-.3069-2.36863-.847-3.37101l1.3082-1.85999.4824.89528c.6958 1.29151 1.0903 2.76904 1.0903 4.33572 0 5.0548-4.0977 9.1525-9.15256 9.1525C4.09773 20 0 15.9023 0 10.8475c0-5.05485 4.09773-9.15258 9.15254-9.15258.96176 0 1.89076.14869 2.76416.42508l.9696.30683-1.5833 1.63229c-.6772-.21431-1.39931-.33031-2.15046-.33031z" clip-rule="evenodd"></path>
- <path fill="#00040B" d="M8.61503 10.6461c.27188-.4746.52111-.96029.81564-1.41285.58743-.94516 1.22653-1.85894 1.91443-2.73741.891-1.0994 1.844-2.14963 2.8548-3.14581.9773-.96997 2.0642-1.82904 3.2399-2.560805.5756-.347472 1.202-.607978 1.8578-.7726565.1426-.02209132.2879-.02209132.4305 0h.2718l-.0113.2538725-.1359.154531c-.0886.100988-.1831.196816-.2832.286987C17.2471 2.73398 15.2093 5.04622 13.5088 7.5886c-1.4535 2.26724-2.6355 4.6893-3.52305 7.2188-.65703 1.7992-1.88049 1.9537-3.06996.3863-1.12443-1.5455-2.03121-3.2309-2.69613-5.0112-.22375-.51301-.38349-1.05036-.47578-1.60049-.14727-1.24728.8043-1.76607 1.85783-1.99786 1.05353-.2318 1.2801.51878 1.59729 1.30247.12461.30907.98556 3.00228 1.28009 2.85888.04602-.0324.08461-.0738.11329-.1215l.02265.0221z"></path>
- </svg>
- </svg>
- <span><?php echo vp_metabox( 'jnews_custom_review.prefix', '', $post->ID ) ?></span>
- <?php jnews_the_author_link( $author, true, true ) ?>
- </div>
- <?php
- }
- }, 999 );
- ////////////////////////////////////////////////////////////
- //JNews Reviewer | END |
- ////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment