403Webshell
Server IP : 14.225.204.176  /  Your IP : 216.73.216.252
Web Server : nginx/1.24.0
System : Linux nodejs-ybgk 6.8.0-40-generic #40-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 5 10:34:03 UTC 2024 x86_64
User : root ( 0)
PHP Version : 8.1.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/html/php/langngon.com/wp-content/themes/langngon/lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/php/langngon.com/wp-content/themes/langngon/lib/custom.php
<?php
/**
 * 
 * @copyright  ZiniMedia 2016
 * @version    Release: 1.0
 * @package    langngon
 * @author     Minh.Tran
 */ 

/*
 * Get object videos and custom html
 *
 * Descriptiom
 *
 * @param   array   $posts
 * @return  null
 */
if ( ! function_exists( 'get_object_videos' ) ) {
	function get_object_videos($posts) { ?>
	    <?php  if( $posts ) { ?>
	      <?php $max = count($posts) - 1; ?>
	      <?php foreach( $posts as $key => $p ) { // variable must NOT be called $post (IMPORTANT) ?>

	        <?php if ($key == 0) { ?>
				<div class="subtray larg-photo">
					<div class="item">
						<?php get_sub_object_large_video($p->ID); ?>
					</div>
				</div>
	        <?php } else { ?>
				<?php if ($key % 2 == 1) { ?>
					<?php if ( $key %4 == 1 ) { ?>
					<div class="subtray">
					<?php } ?>
						<div class="item">
						<?php get_sub_object_videos($p->ID); ?>
				<?php }else{ ?>
						<?php get_sub_object_videos($p->ID); ?>
						</div>
					<?php if ( $key %4 == 0 || $key == $max ) { ?>
					</div>
					<?php } ?>
				<?php } ?>
	        <?php } ?>

	        <?php if ( $key == $max && $key %2 != 0 ) { ?>
          				</div>
	         		 </div>
	        <?php } ?>
	      <?php } ?>
	    <?php } ?>
	<?php 
	}
}

/*
 * Get object videos and custom html
 *
 * Descriptiom
 *
 * @param   array   $posts
 * @return  null
 */
if ( ! function_exists( 'get_object_thumb_videos' ) ) {
	function get_object_thumb_videos($posts) { ?>
	    <?php  if( $posts ) { ?> 
	      <?php foreach( $posts as $key => $p ) { // variable must NOT be called $post (IMPORTANT) ?>
				<div class="subtray"> 
					<div class="item">
						<?php get_sub_object_videos($p->ID); ?> 
      				</div>
         		 </div> 
	      <?php }   
	  	}  
	}
}

/*
 * Get first object video and custom html with large photo
 *
 * Descriptiom
 *
 * @param   integer   $id
 * @return  null
 */
if ( ! function_exists( 'get_sub_object_large_video' ) ) {
	function get_sub_object_large_video($id){ ?>
	  <a href="<?php echo get_the_permalink( $id ); ?>" title="<?php echo get_the_title( $id ); ?>" class="">
	    <?php if (has_post_thumbnail($id, THUMB_ITEM_FIRST_VIDEO)) {
	      $imgThumb = wp_get_attachment_image_src(get_post_thumbnail_id( $id ), THUMB_ITEM_FIRST_VIDEO);
	    ?>
	    <img src="<?php echo $imgThumb[0]; ?>" alt="<?php echo get_the_title( $id ); ?>" />
	   <?php }else{ ?>
	      <img src="<?php echo PART_IMAGE_THEME; ?>/no-image-<?php echo THUMB_ITEM_FIRST_VIDEO; ?>.jpg" alt="<?php echo get_the_title($id); ?>">
	   <?php } ?>
	  </a>
	  <div class="description">
	    <h4><a href="<?php echo get_the_permalink( $id ); ?>" title="<?php echo get_the_title( $id ); ?>" class=""><?php echo wp_trim_words(get_the_title( $id ), 14); ?></a></h4>
	  	<?php echo wp_trim_words(get_the_excerpt($id), 35); ?>
	  </div>
	  <?php
	}
}
/*
 * Get sub object videos and custom html with thumb medium photo
 *
 * Descriptiom
 *
 * @param   integer   $id
 * @return  null
 */
if ( ! function_exists( 'get_sub_object_videos' ) ) {
	function get_sub_object_videos($id){ ?>
	  <div class="item-sub">
	    <a href="<?php echo get_the_permalink( $id ); ?>" title="<?php echo get_the_title( $id ); ?>" class="">
	      <?php 
	      	$thumb_size = ( is_single() ) ? THUMB_ITEM_VIDEO_V1 : THUMB_ITEM_VIDEO;
	        if (has_post_thumbnail($id, $thumb_size)) {
	          $imgThumb = wp_get_attachment_image_src(get_post_thumbnail_id( $id ), $thumb_size);
	          if(!empty($imgThumb)) { ?>
	            <img src="<?php echo $imgThumb[0]?>" alt="<?php echo get_the_title( $id ); ?>" />
	          <?php }
	        }else{ ?>
	          <img src="<?php echo PART_IMAGE_THEME; ?>/no-image-<?php echo $thumb_size; ?>.jpg" alt="<?php echo get_the_title($id); ?>">
	        <?php } ?>
	    </a>                
	    <div class="description">
	      <h4><a href="<?php echo get_the_permalink( $id ); ?>" title="<?php echo get_the_title( $id ); ?>" class=""><?php echo wp_trim_words(get_the_title( $id ),14); ?></a></h4>
	    </div>
	  </div> 
	  <?php
	}
}

/*
 * Builds custom HTML.
 *
 * With this function, I can alter WPP's HTML output from my theme's custom.php.
 * Custom output filter for Wordpress Popular Posts - templates/parts/home-exclusive-videos.php
 *
 * @param   array   $mostpopular
 * @param   array   $instance
 * @return  null
 */
if ( ! function_exists( 'wpp_custom_output' ) ) {
	function wpp_custom_output( $mostpopular, $instance ){
	 $max = count($mostpopular) - 1;
	 foreach ($mostpopular as $key => $mostpopular_post) {
	   global $post;
	   $post = get_post($mostpopular_post->id);
	   setup_postdata( $post );
		if ($key == 0) { ?>
			<div class="subtray larg-photo">
				<div class="item">
					<?php get_sub_object_large_video($post->ID); ?>
				</div>
			</div>
        <?php }else{ ?>
			<?php if ($key % 2 == 1) { ?>
				<?php if ( $key %4 == 1 ) { ?>
				<div class="subtray">
				<?php } ?>
					<div class="item">
					<?php get_sub_object_videos($post->ID); ?>
			<?php }else{ ?>
					<?php get_sub_object_videos($post->ID); ?>
					</div>
				<?php if ( $key %4 == 0 ) { ?>
				</div>
				<?php } ?>
			<?php } ?>
        <?php } ?>

        <?php if ( $key == $max && $key %2 != 0 ) { ?>
      				</div>
         		 </div>
        <?php }
	 }
	 wp_reset_postdata();
	 return null;
	}
	add_filter( 'wpp_custom_html', 'wpp_custom_output', 10, 2 );
}


// Custom.php
if ( ! function_exists( 'get_view_post' ) ) {
  function get_view_post($id){
  ?>
    <p class="views">
      <strong><?php
      if (function_exists('wpp_get_views')) {
        $value = wpp_get_views( $id ); // This will only work when used inside the loop!
        if (strlen($value) > 9 ) {
          echo $value;
        } else {
          $view = (int)$value + 3000;
          echo $view;
        }
      }
      ?></strong>&nbsp<?php echo _e('View','langngon'); ?>
    </p>
    <?php
  }
}

if ( ! function_exists( 'zinimedia_pagination' ) ) {  
  function zinimedia_pagination() {
    $paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
      global $wp_query;
      $big = 99999999;
      echo '<div class="zn-paginationi">';
      echo paginate_links( array(
          'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
          'format' => '?paged=%#%',
          'current' => max( $paged, get_query_var('paged') ),
          'next_text' => __('»'),
          'prev_text' => __('«'),
          'total' => $wp_query->max_num_pages
      ) );
      echo '</div>';
  }
}


/*
 * DUPLICATE POST 
 */
function rd_duplicate_post_as_draft(){
	global $wpdb;
	if (! ( isset( $_GET['post']) || isset( $_POST['post'])  || ( isset($_REQUEST['action']) && 'rd_duplicate_post_as_draft' == $_REQUEST['action'] ) ) ) {
		wp_die('No post to duplicate has been supplied!');
	}
 
	/*
	 * get the original post id
	 */
	$post_id = (isset($_GET['post']) ? absint( $_GET['post'] ) : absint( $_POST['post'] ) );
	/*
	 * and all the original post data then
	 */
	$post = get_post( $post_id );
 
	/*
	 * if you don't want current user to be the new post author,
	 * then change next couple of lines to this: $new_post_author = $post->post_author;
	 */
	$current_user = wp_get_current_user();
	$new_post_author = $current_user->ID;
 
	/*
	 * if post data exists, create the post duplicate
	 */
	if (isset( $post ) && $post != null) {
 
		/*
		 * new post data array
		 */
		$args = array(
			'comment_status' => $post->comment_status,
			'ping_status'    => $post->ping_status,
			'post_author'    => $new_post_author,
			'post_content'   => $post->post_content,
			'post_excerpt'   => $post->post_excerpt,
			'post_name'      => $post->post_name,
			'post_parent'    => $post->post_parent,
			'post_password'  => $post->post_password,
			'post_status'    => 'draft',
			'post_title'     => $post->post_title,
			'post_type'      => $post->post_type,
			'to_ping'        => $post->to_ping,
			'menu_order'     => $post->menu_order
		);
 
		/*
		 * insert the post by wp_insert_post() function
		 */
		$new_post_id = wp_insert_post( $args );
 
		/*
		 * get all current post terms ad set them to the new post draft
		 */
		$taxonomies = get_object_taxonomies($post->post_type); // returns array of taxonomy names for post type, ex array("category", "post_tag");
		foreach ($taxonomies as $taxonomy) {
			$post_terms = wp_get_object_terms($post_id, $taxonomy, array('fields' => 'slugs'));
			wp_set_object_terms($new_post_id, $post_terms, $taxonomy, false);
		}
 
		/*
		 * duplicate all post meta just in two SQL queries
		 */
		$post_meta_infos = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id");
		if (count($post_meta_infos)!=0) {
			$sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
			foreach ($post_meta_infos as $meta_info) {
				$meta_key = $meta_info->meta_key;
				$meta_value = addslashes($meta_info->meta_value);
				$sql_query_sel[]= "SELECT $new_post_id, '$meta_key', '$meta_value'";
			}
			$sql_query.= implode(" UNION ALL ", $sql_query_sel);
			$wpdb->query($sql_query);
		}
 
 
		/*
		 * finally, redirect to the edit post screen for the new draft
		 */
		wp_redirect( admin_url( 'post.php?action=edit&post=' . $new_post_id ) );
		exit;
	} else {
		wp_die('Post creation failed, could not find original post: ' . $post_id);
	}
}
// add_action( 'admin_action_rd_duplicate_post_as_draft', 'rd_duplicate_post_as_draft' );
 
/*
 * Add the duplicate link to action list for post_row_actions
 */
function rd_duplicate_post_link( $actions, $post ) {
	if (current_user_can('edit_posts')) {
		$actions['duplicate'] = '<a href="admin.php?action=rd_duplicate_post_as_draft&amp;post=' . $post->ID . '" title="Duplicate this item" rel="permalink">Duplicate</a>';
	}
	return $actions;
}
 
// add_filter( 'post_row_actions', 'rd_duplicate_post_link', 10, 2 );

/*
 * End develop by Minh.Tran
 */


// Wrap span.breadcrumb-sep around Yoast breadcrumb separator
add_filter( 'wpseo_breadcrumb_separator', 'breadcrumb_separator_wrap' );
function breadcrumb_separator_wrap($output) {
    return '<span class="breadcrumb-sep">'.$output.'</span>';
}

// add_action('admin_head', 'admin_styles');
// function admin_styles() {
//   echo '<link rel="stylesheet" href="../wp-content/themes/langngon/assets/css/admin.css" type="text/css" media="all" />';
// }

// remove breadcurmb
// Author: Dat Nguyen
remove_action( 'woocommerce_before_main_content','woocommerce_breadcrumb', 20, 0);
// Remove WooThemes Helper notice
remove_action( 'admin_notices', 'woothemes_updater_notice' );


// // Related Products Shortcode
// function related_products_shortcode() {
// 	$posts_slider_heading = __( 'Related Products', 'langngon' );
// 	$posts_slider_posts = get_field('related_products');
// 	$posts_slider_slug = 'related-products';
// 	ob_start();
// 	include(locate_template('templates/parts/posts-slider.php'));
// 	return ob_get_clean();
// }
// add_shortcode( 'related-products', 'related_products_shortcode' );


// YARPP Options
function yarpp_custom_options() {
	if ( function_exists('yarpp_set_option') ) {
		yarpp_set_option('auto_display', false);
		yarpp_set_option('use_template', true);
		yarpp_set_option('template_file', 'yarpp-template-posts-slider.php');
		yarpp_set_option('limit', '6');
	}
}
add_action( 'plugins_loaded', 'yarpp_custom_options');


// Remove unwanted assets
function deregister_assets_header() {
  wp_dequeue_style('yarppWidgetCss');
  wp_deregister_style('yarppRelatedCss');
}
add_action( 'wp_print_styles', 'deregister_assets_header' );


// function getImgServerUrl ( $url ) {
// 	return "/wp-content/themes/langngon/assets/img/share.jpg";
// }
// //link to image server

// add_filter( 'wpseo_opengraph_image', 'getImgServerUrl', 10, 1 );//for og:image

// add_filter('show_admin_bar', '__return_false');

add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 );
add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 );
// Genesis framework only
add_filter( 'genesis_get_image', 'remove_thumbnail_dimensions', 10 );
// Removes attached image sizes as well
add_filter( 'the_content', 'remove_thumbnail_dimensions', 10 );

function remove_thumbnail_dimensions( $html ) {
    $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
    return $html;
}



/*
 * Get first object video and custom html with large photo
 *
 * Descriptiom
 *
 * @param   integer   $id
 * @return  null
 */
if ( ! function_exists( 'get_sub_hot_large_video' ) ) {
	function get_sub_hot_large_video($video){
		$id 		= $video['ID'];
		$thumb_id 	= $video['thumb_id'];
		$title 		= $video['title'];
		$link 		= $video['link'];
		?>
	  <a href="<?php echo $link; ?>" title="<?php echo $title; ?>" class="">
	    <?php  
		    if ( $thumb_id && has_post_thumbnail($thumb_id, THUMB_ITEM_FIRST_VIDEO)) {
				$imgThumb = wp_get_attachment_image_src( $thumb_id , THUMB_ITEM_FIRST_VIDEO);
				if( !empty($imgThumb) ) { ?>
					<img src="<?php echo $imgThumb[0]?>" alt="<?php echo $title; ?>" />
				<?php 
				}
		    }elseif (has_post_thumbnail($id, THUMB_ITEM_FIRST_VIDEO)) {
			  	$imgThumb = wp_get_attachment_image_src(get_post_thumbnail_id( $id ), THUMB_ITEM_FIRST_VIDEO);
			?>
			<img src="<?php echo $imgThumb[0]; ?>" alt="<?php echo $title; ?>" />
			<?php 
			}else{ ?>
			  	<img src="<?php echo PART_IMAGE_THEME; ?>/no-image-<?php echo THUMB_ITEM_FIRST_VIDEO; ?>.jpg" alt="<?php echo $title?>">
			<?php } ?>
			</a>
			<div class="description">
				<h4><a href="<?php echo $link; ?>" title="<?php echo $title; ?>" class=""><?php echo wp_trim_words($title, 14); ?></a></h4>
				<?php echo wp_trim_words(get_the_excerpt($id), 35); ?>
			</div>
	  <?php
	}
}
/*
 * Get sub object videos and custom html with thumb medium photo
 *
 * Descriptiom
 *
 * @param   integer   $id
 * @return  null
 */
if ( ! function_exists( 'get_sub_hot_videos' ) ) {
	function get_sub_hot_videos($video){ 
		$id 		= $video['ID'];
		$thumb_id 	= $video['thumb_id'];
		$title 		= $video['title'];
		$link 		= $video['link'];
		?>
		<div class="item-sub">
			<a href="<?php echo $link ?>" title="<?php echo $title; ?>" class="">
			  <?php 
			  	$thumb_size = ( is_single() ) ? THUMB_ITEM_VIDEO_V1 : THUMB_ITEM_VIDEO;
			    if ( $thumb_id ) {
					$imgThumb = wp_get_attachment_image_src( $thumb_id , $thumb_size);
					if( !empty($imgThumb) ) { ?>
						<img src="<?php echo $imgThumb[0]?>" alt="<?php echo $title; ?>" />
					<?php 
					}
			    }elseif (has_post_thumbnail($id, $thumb_size)) {
			        $imgThumb = wp_get_attachment_image_src(get_post_thumbnail_id( $id ), $thumb_size);
			        if(!empty($imgThumb)) { ?>
			            <img src="<?php echo $imgThumb[0]?>" alt="<?php echo $title; ?>" />
			        <?php 
			  		}
			    }else{ ?>
			      	<img src="<?php echo PART_IMAGE_THEME; ?>/no-image-<?php echo $thumb_size; ?>.jpg" alt="<?php echo $title; ?>">
			    <?php } ?>
			</a>                
			<div class="description">
			  <h4><a href="<?php echo $link ?>" title="<?php echo $title; ?>" class=""><?php echo wp_trim_words($title, 14); ?></a></h4>
			</div>
		</div> 
  	<?php
	}
}

	/*
	* Sord function by datetime Y-m-d g:i:s
	*
	*/
	function sortFunction( $a, $b ) {
	    return strtotime($a["date"]) - strtotime($b["date"]);
	}



	/*
	* Get id oEmbed youtube from url
	*
	*/
	function get_youtube_id_from_url($url){
	    if (stristr($url,'youtu.be/'))
	        {preg_match('/(https:|http:|)(\/\/www\.|\/\/|)(.*?)\/(.{11})/i', $url, $final_ID); return $final_ID[4]; }
	    else 
	        {@preg_match('/(https:|http:|):(\/\/www\.|\/\/|)(.*?)\/(embed\/|\/v\/|watch.*?v=|)([a-z_A-Z0-9\-]{11})/i', $url, $IDD); return $IDD[5]; }
	}


	/*
	* Get repeater menu
	*
	*/
	if ( ! function_exists( 'get_menu_list_langngon' ) ) {
		function get_menu_list_langngon( $field ){

			if( have_rows( $field , get_the_ID() ) ){ ?>
                <?php 

                // loop through rows (parent repeater)
                while( have_rows( $field , get_the_ID() ) ): the_row(); ?>
                  <div>
                    <h3 class="food-parent"><?php the_sub_field('parent'); ?></h3>
                    <?php 

                    // check for rows (sub repeater)
                    if( have_rows( 'child', get_the_ID() ) ) { ?>
                      <ul>
                      <?php 

                      // loop through rows (sub repeater)
                      while( have_rows( 'child', get_the_ID() ) ): the_row();

                        // display each item as a list - with a class of completed ( if completed )
                        ?>
                        <li class="food-child">
                        	<h4><?php the_sub_field('title'); ?></h4>
                        	<div class="price">
                        		<p><?php the_sub_field('price'); ?><p>
                        	</div>
                        	<div class="desc">
	                        	<?php the_sub_field('description'); ?>
                        	</div>
                        </li>
                      <?php endwhile; ?>
                      </ul>
                    <?php } ?>
                  </div>  

                <?php endwhile; // while( has_sub_field('to-do_lists') ): ?>
            <?php }
		}
	}

Youez - 2016 - github.com/yon3zu
LinuXploit