HEX
Server: nginx/1.28.1
System: Linux iZgw8b5bpgd4jyptfmmmxgZ 6.6.102-5.2.alnx4.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Nov 27 23:11:10 CST 2025 x86_64
User: www (1000)
PHP: 8.2.28
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/www.scdc-marine.com/wp-content/themes/scdc-marine/functions.php
<?php
/**
 * Version: 1.01
 * 内置调用 到  Heku\HekuClass\Common\ActionHook.php 中调用了
 */

// /* ------------------------  定义常量    ------------------------------ */
	define( 'HK_DS' , DIRECTORY_SEPARATOR );  // PHP 定义中的 分隔符
	define( 'HEKU_HOME_URI' , home_url() );
	define( 'HEKU_THEME_DIR' , get_template_directory() );
	define( 'HEKU_INCLUDES_PATH' , get_template_directory() . '/includes/' );
	define( 'HEKU_THEME_URI' , get_template_directory_uri() );
	define( 'HEKU_VERSION' , '1.1.3' );
	//add_menu_page( '河枯主题,后台插件界面设置', '界 面 设 置2',  'administrator', 'heku-menu-pages222', "" );
	require HEKU_THEME_DIR. HK_DS . 'loader.php';
// /* ------------------------  定义常量    ------------------------------ */

// /* ------------------------ heku_get_option 自定义参数的 快捷调用方式  ------------------------------ */

	function heku_get_option( $where , $key , $circle_id = 0 ){
		if(defined('HEKU_OPT_'.strtoupper($where))){
			$settings = constant('HEKU_OPT_'.strtoupper($where));
		}else{
			$settings = get_option('heku_'.$where);
		}
		if(isset($settings[$key])){
			return $settings[$key];
		}else{
			return '';
		}
		return '';
	}
	//菜单设置项
	function heku_get_menu_option( $menu_item_id , $key = '' , $default = null){
		$opts = get_option('cmb2_nav_menus', null);
		if ($opts) {
			$key .= '-' . $menu_item_id;
			return (isset($opts[$key])) ? $opts[$key] : $default;
		}
		return $default;
	}

// /* ------------------------ heku_get_option 自定义参数的 快捷调用方式  ------------------------------ */

// /* ------------------------  定义、注册列表    ------------------------------ */

	register_nav_menu( 'header-menu', '顶部导航菜单列表' );
	register_nav_menu( 'sidebar-product', '侧边产品分类列表' );
	register_nav_menu( 'sidebar-appproduct', '侧边产品应用列表' );

// /* ------------------------  定义、注册列表    ------------------------------ */

// /* ------------------------ 自己仿照分页函数设涉及的  非主分页的正确分页函数  ------------------------------ */

	function heku_mypage( $range = 5 ) {
		global $paged, $wp_query;
		$max_page = $wp_query->max_num_pages;

		if ( $max_page > 1 ) {
			echo '';
			if ( !$paged ) {
				$paged = 1;
			}
			echo '<div class="col-sm-3 col-md-4 col-lg-3 col-xl-3 page_arr_left">';
			if ( $paged != 1 ) {
				echo "<a href='" . get_pagenum_link( 1 ) . "' class='extend icon iconfont icon-start_left' title='Home Page'></a>";
			}else{
				echo "<a href='" . get_pagenum_link( 1 ) . "' class='pointernone extend icon iconfont icon-start_left' title='Home Page'></a>";
				echo "<a href='" . get_pagenum_link( 1 ) . "' class='pointernone' ><i class='pointernone icon iconfont icon-left'></i><b class='transition'></b></a>";
			}
			previous_posts_link( '<i class="icon iconfont icon-left"></i><b class="transition"></b>' );
			echo '</div>';
			echo '<div class="col-sm-6 col-md-4 col-lg-6 col-xl-6 page_arr_center">';
			if ( $max_page > $range ) {
				if ( $paged <= ceil( ( $range / 2 ) ) ) {
					for ( $i = 1; $i <= ( $range ); $i++ ) {
						echo "<a href='" . get_pagenum_link( $i ) . "'";
						if ( $i == $paged )echo " class='current'";
						echo ">$i</a>";
					}
					echo "<a href='" . get_pagenum_link( $max_page ) . "' class='extend ' title='Last Page'>...</a>";
				} elseif ( $paged > ceil( ( $range / 2 ) ) && $paged <= ( $max_page - ceil( ( $range / 2 ) ) ) ) {
					for ( $i = ( $paged - ceil( $range / 2 )); $i < ( $paged + ceil( ( $range / 2 ) ) ); $i++ ) {
						echo "<a href='" . get_pagenum_link( $i ) . "'";
						if ( $i == $paged )echo " class='current'";
						echo ">$i</a>";
					}
					echo "<a href='" . get_pagenum_link( $max_page ) . "' class='extend ' title='Last Page'>...</a>";
				} elseif ( $paged > ( $max_page - ceil( ( $range / 2 ) ) ) ) {
					for ( $i = $max_page - $range; $i <= $max_page; $i++ ) {
						echo "<a href='" . get_pagenum_link( $i ) . "'";
						if ( $i == $paged )echo " class='current'";
						echo ">$i</a>";
					}
				}
			} else {
				for ( $i = 1; $i <= $max_page; $i++ ) {
					echo "<a href='" . get_pagenum_link( $i ) . "'";
					if ( $i == $paged )echo " class='current'";
					echo ">$i</a>";
				}
			}
			echo '</div>';
			echo '<div class="col-sm-3 col-md-4 col-lg-3 col-xl-3  page_arr_right">';
			next_posts_link( '<b class="transition"></b><i class="icon iconfont icon-right"></i>' );
			if ( $paged != $max_page ) {
				echo "<a href='" . get_pagenum_link( $max_page ) . "' class='extend icon iconfont icon-end_right' title='Last Page'></a>";
			}else{
				echo "<a href='" . get_pagenum_link( $max_page ) . "' class='pointernone' > <b class='transition'></b><i class='pointernone icon iconfont icon-right'></i></a>";
				echo "<a href='" . get_pagenum_link( $max_page ) . "' class='pointernone extend icon iconfont icon-end_right' title='Last Page'></a>";
			}
			echo '</div>';
		}
	}

// /* ------------------------ 自己仿照分页函数设涉及的  非主分页的正确分页函数  ------------------------------ */

// /* ------------------------ 分割 导航路径 路径生成函数  ------------------------------ */

	function heku_breadcrumbs() {
		$delimiter = '<span class="icon iconfont icon-right"></span>'; // 分隔符
		$before = '<a href="#">'; // 在当前链接前插入
		$after = '</a>'; // 在当前链接后插入
		if ( !is_home() && !is_front_page() || is_paged() ) {
			$breadcrumb = '';
			global $post;
			$homeLink = home_url();
			$breadcrumb .= ' <a class="home-bar" href="' . $homeLink . '"><span class="icon iconfont icon-chunbo-shouye"></span>' . __( 'Home', 'heku' ) . '</a>' . $delimiter . ' ';
			if ( is_category() ) { // 分类 存档
				global $wp_query;
				$cat_obj = $wp_query->get_queried_object();
				$thisCat = $cat_obj->term_id;
				$thisCat = get_category( $thisCat );
				$parentCat = get_category( $thisCat->parent );
				if ( $thisCat->parent != 0 ) {
					$cat_code = get_category_parents( $parentCat, TRUE, ' ' . $delimiter . ' ' );
					$cat_code = str_replace( '<a', '<a ', $cat_code );
					$breadcrumb .= $cat_code;
				}
				$breadcrumb .= $before . '' . single_cat_title( '', false ) . '' . $after;
			} elseif(is_tax()){
				global $wp_query;
				$cat_obj = $wp_query->get_queried_object();
				$breadcrumb .= '<a href="' . $homeLink . '/' . $cat_obj->taxonomy .'/' . $cat_obj->slug . '/">' . $cat_obj->name . '</a> ';

			} elseif ( is_single() && !is_attachment() ) { // 文章
				if ( get_post_type() != 'post' ) { // 自定义文章类型
					$post_type = get_post_type_object( get_post_type() );
					$slug = $post_type->rewrite;
					$breadcrumb .=  '<a href="' . $homeLink . '/' . $slug[ 'slug' ] . '/">' . $post_type->labels->singular_name . '</a> ' ;
					/* echo $before . get_the_title() . $after; */
				} else { // 文章 post
					$cat = get_the_category();
					$cat = $cat[ 0 ];
					$cat_code = get_category_parents( $cat, TRUE, ' ' . $delimiter . ' '  );
					$breadcrumb .= $cat_code = str_replace( '<a', '<a ', str_replace( $delimiter . ' ' . 'end', ' ', $cat_code .'end' ) );
					/* echo $before . get_the_title() . $after; */
				}
			} elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_tag() && !is_search() ) {
				$post_type = get_post_type_object( get_post_type() );
				$breadcrumb .= $before  . $post_type->labels->singular_name . $after;
			} elseif ( is_attachment() ) { // 附件
				$parent = get_post( $post->post_parent );
				$cat = get_the_category( $parent->ID );
				$cat = $cat[ 0 ];
				$breadcrumb .= '<a  href="' . get_permalink( $parent ) . '">' . $parent->post_title . '</a> ' . $delimiter . ' ';
				$breadcrumb .= $before . get_the_title() . $after;
			} elseif ( is_page() && !$post->post_parent ) { // 页面
				$breadcrumb .= $before . get_the_title() . $after;
			} elseif ( is_page() && $post->post_parent ) { // 父级页面
				$parent_id = $post->post_parent;
				$breadcrumbs = array();
				while ( $parent_id ) {
					$page = get_page( $parent_id );
					$breadcrumbs[] = '<a href="' . get_permalink( $page->ID ) . '">' . get_the_title( $page->ID ) . '</a>';
					$parent_id = $page->post_parent;
				}
				$breadcrumbs = array_reverse( $breadcrumbs );
				foreach ( $breadcrumbs as $crumb )echo $crumb . ' ' . $delimiter . ' ';
				$breadcrumb .= $before . get_the_title() . $after;
			} elseif ( is_search() ) { // 搜索结果
				$breadcrumb .=  $before;
				$breadcrumb .= 'Tag : ' . '<font color=#ff0505>'.get_search_query().'</font>';
				//printf( __( '搜索词为: %s 的搜索结果:', 'cmp' ), get_search_query() );
				$breadcrumb .=  $after;
			} elseif ( is_tag() ) { //标签 存档
				$breadcrumb .= $before ;
				$breadcrumb .= single_tag_title('TAG : ', false);
				//$breadcrumb .= single_tag_title('TAG : ');
				$breadcrumb .= $after;
			} elseif ( is_author() ) { // 作者存档
				global $author;
				$userdata = get_userdata( $author );
				$breadcrumb .= $before;
				//printf( __( 'Author Archives: %s', 'cmp' ), $userdata->display_name );
				$breadcrumb .= $after;
			} elseif ( is_404() ) { // 404 页面
				$breadcrumb .= $before;
				_e( '404页面:', 'cmp' );
				$breadcrumb .= $after;
			}
		/* 			if ( get_query_var( 'paged' ) ) { // 分页
				if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() )
				$breadcrumb .= sprintf( __( ' Page %s ', 'cmp' ), get_query_var( 'paged' ) );
			} */
			return  $breadcrumb ;
		}

	}

// /* ------------------------ 分割 导航路径 路径生成函数  ------------------------------ */