| Server IP : 38.190.208.107 / Your IP : 216.73.217.1 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : 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,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/www.huomanshiye.com/wp-content/themes/astra/inc/core/ |
Upload File : |
<?php
/**
* Astra Attributes Class.
*
* @package Astra
* @link https://wpastra.com/
* @since Astra 1.6.2
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! class_exists( 'Astra_Attr' ) ) {
/**
* Class Astra_Attr
*/
class Astra_Attr {
/**
* Store Instance on Current Class.
*
* @var object instance
*/
private static $instance;
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Initialuze the Class.
*
* @since 1.6.2
*/
private function __construct() {
}
/**
* Build list of attributes into a string and apply contextual filter on string.
*
* The contextual filter is of the form `astra_attr_{context}_output`.
*
* @since 1.6.2
*
* @param string $context The context, to build filter name.
* @param array $attributes Optional. Extra attributes to merge with defaults.
* @param array $args Optional. Custom data to pass to filter.
* @return string String of HTML attributes and values.
*/
public function astra_attr( $context, $attributes = array(), $args = array() ) {
$attributes = $this->astra_parse_attr( $context, $attributes, $args );
$output = '';
// Cycle through attributes, build tag attribute string.
foreach ( $attributes as $key => $value ) {
if ( ! $value ) {
continue;
}
if ( true === $value ) {
$output .= esc_html( $key ) . ' ';
} else {
$output .= sprintf( '%s="%s" ', esc_html( $key ), esc_attr( $value ) );
}
}
$output = apply_filters( "astra_attr_{$context}_output", $output, $attributes, $context, $args );
return trim( $output );
}
/**
* Merge array of attributes with defaults, and apply contextual filter on array.
*
* The contextual filter is of the form `astra_attr_{context}`.
*
* @since 1.6.2
*
* @param string $context The context, to build filter name.
* @param array $attributes Optional. Extra attributes to merge with defaults.
* @param array $args Optional. Custom data to pass to filter.
* @return array Merged and filtered attributes.
*/
public function astra_parse_attr( $context, $attributes = array(), $args = array() ) {
$defaults = array(
'class' => sanitize_html_class( $context ),
);
$attributes = wp_parse_args( $attributes, $defaults );
// Contextual filter.
return apply_filters( "astra_attr_{$context}", $attributes, $context, $args );
}
}
}
/**
* Kicking this off by calling 'get_instance()' method
*/
Astra_Attr::get_instance();