'theme', // theme | light | dark | glass. 'accent' => '', // Button color, '' = theme. 'accent_text' => '#ffffff', 'radius' => 10, 'width' => 560, 'icon' => 'yes', ) ); } public static function get() { $saved = get_option( self::OPTION, array() ); return wp_parse_args( is_array( $saved ) ? $saved : array(), self::defaults() ); } public static function hex( $v, $fallback ) { $v = sanitize_hex_color( is_string( $v ) ? $v : '' ); return $v ? $v : $fallback; } public static function sanitize( $in ) { $d = self::defaults(); $clean = array( 'style' => isset( $in['style'] ) && in_array( $in['style'], array( 'theme', 'light', 'dark', 'glass' ), true ) ? $in['style'] : 'theme', 'accent' => isset( $in['accent'] ) && '' !== $in['accent'] ? self::hex( $in['accent'], '' ) : '', 'accent_text' => self::hex( isset( $in['accent_text'] ) ? $in['accent_text'] : '', $d['accent_text'] ), 'radius' => isset( $in['radius'] ) ? max( 0, min( 40, absint( $in['radius'] ) ) ) : $d['radius'], 'width' => isset( $in['width'] ) ? max( 380, min( 900, absint( $in['width'] ) ) ) : $d['width'], 'icon' => empty( $in['icon'] ) ? 'no' : 'yes', ); return (array) apply_filters( 'hyperdrop_design_sanitize', $clean, $in ); } public static function save() { if ( ! current_user_can( 'manage_woocommerce' ) ) { wp_die( esc_html__( 'Not allowed.', 'hyperdrop' ) ); } check_admin_referer( 'hyperdrop_design' ); if ( isset( $_POST['reset'] ) ) { delete_option( self::OPTION ); $msg = __( 'Design reset to defaults.', 'hyperdrop' ); } else { $in = isset( $_POST['design'] ) && is_array( $_POST['design'] ) ? map_deep( wp_unslash( $_POST['design'] ), 'sanitize_text_field' ) : array(); update_option( self::OPTION, self::sanitize( $in ), false ); $msg = __( 'Design saved.', 'hyperdrop' ); } HyperDrop_Admin::flash( $msg ); wp_safe_redirect( HyperDrop_Admin::url( array( 'tab' => 'design' ) ) ); exit; } /** * CSS custom properties for the current design (shared by front end and admin preview). */ public static function vars( $d = null ) { $d = $d ? $d : self::get(); $vars = array( '--hd-radius' => $d['radius'] . 'px', '--hd-width' => $d['width'] . 'px', ); if ( $d['accent'] ) { $vars['--hd-accent'] = $d['accent']; $vars['--hd-accent-text'] = $d['accent_text']; } $vars = (array) apply_filters( 'hyperdrop_design_vars', $vars, $d ); $css = ''; foreach ( $vars as $k => $v ) { $css .= $k . ':' . $v . ';'; } return $css; } public static function inline_css() { wp_add_inline_style( 'hyperdrop', '.hyperdrop-gate-main,.hyperdrop-gate,.hyperdrop-box{' . self::vars() . '}' ); } /** * Classes + inline style for a card (and its wrapper). * * @param string $scope t:ID | p:ID | ''. * @param bool $full_page Whether the card is the main content of the page. * @return array{ box_class:string, box_style:string, wrap_class:string, wrap_style:string } */ public static function attrs( $scope, $full_page = false ) { $d = self::get(); $box = array( 'hd-skin-' . $d['style'] ); if ( $d['accent'] ) { $box[] = 'hd-accent'; } if ( 'no' === $d['icon'] ) { $box[] = 'hd-no-icon'; } $a = array( 'box_class' => implode( ' ', $box ), 'box_style' => '', 'wrap_class' => '', 'wrap_style' => '', ); return (array) apply_filters( 'hyperdrop_card_attrs', $a, $scope, $full_page, $d ); } /* ------------------------------------------------------------------ * Admin * ------------------------------------------------------------------ */ public static function admin_assets() { if ( 'hyperdrop-design' !== HyperDrop_Admin::current_page() ) { return; } wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_script( 'hyperdrop-design', HYPERDROP_URL . 'assets/design.js', array( 'jquery', 'wp-color-picker' ), hyperdrop_asset_ver( 'assets/design.js' ), true ); wp_enqueue_style( 'hyperdrop', HYPERDROP_URL . 'assets/hyperdrop.css', array(), hyperdrop_asset_ver( 'assets/hyperdrop.css' ) ); } public static function tab() { $d = self::get(); $a = self::attrs( '', true ); ?>

__( 'Theme', 'hyperdrop' ), 'light' => __( 'Light', 'hyperdrop' ), 'dark' => __( 'Dark', 'hyperdrop' ), 'glass' => __( 'Glass', 'hyperdrop' ), ); foreach ( $styles as $k => $label ) : ?>