golden hour
/home/godaofbq/hardchambers.com/wp-content/plugins/create-members-pro/utils
⬆️ Go Up
Upload
File/Folder
Size
Actions
helper.php
7.33 KB
Del
OK
singleton.php
315 B
Del
OK
Edit: helper.php
<?php namespace MembershipPro\Utils; defined( 'ABSPATH' ) || exit; /** * Helper function */ class Helper { use Singleton; /** * Html markup validation */ public static function kses( $raw ) { $allowed_tags = [ 'svg' => array( 'class' => true, 'aria-hidden' => true, 'aria-labelledby' => true, 'role' => true, 'xmlns' => true, 'width' => true, 'height' => true, 'viewbox' => true // <= Must be lower case! ), 'g' => array( 'fill' => true ), 'title' => array( 'title' => true ), 'path' => array( 'd' => true, 'fill' => true ), 'a' => [ 'class' => [], 'href' => [], 'rel' => [], 'title' => [], 'target' => [], ], 'input' => [ 'value' => [], 'type' => [], 'size' => [], 'name' => [], 'checked' => [], 'placeholder' => [], 'id' => [], 'class' => [], 'data-label' => [] ], 'select' => [ 'value' => [], 'type' => [], 'size' => [], 'name' => [], 'placeholder' => [], 'id' => [], 'class' => [], 'multiple' => [], 'data-option' => [] ], 'option' => [ 'selected' => [], 'value' => [], 'disabled' => [] ], 'textarea' => [ 'value' => [], 'type' => [], 'size' => [], 'name' => [], 'rows' => [], 'cols' => [], 'placeholder' => [], 'id' => [], 'class' => [], ], 'abbr' => [ 'title' => [], ], 'b' => [], 'blockquote' => [ 'cite' => [], ], 'cite' => [ 'title' => [], ], 'code' => [], 'del' => [ 'datetime' => [], 'title' => [], ], 'dd' => [], 'div' => [ 'data' => [], 'class' => [], 'title' => [], 'style' => [], ], 'dl' => [], 'dt' => [], 'em' => [], 'h1' => [ 'class' => [], ], 'h2' => [ 'class' => [], ], 'h3' => [ 'class' => [], ], 'h4' => [ 'class' => [], ], 'h5' => [ 'class' => [], ], 'h6' => [ 'class' => [], ], 'i' => [ 'class' => [], ], 'img' => [ 'alt' => [], 'class' => [], 'height' => [], 'src' => [], 'width' => [], ], 'li' => [ 'class' => [], ], 'ol' => [ 'class' => [], ], 'p' => [ 'class' => [], ], 'q' => [ 'cite' => [], 'title' => [], ], 'span' => [ 'class' => [], 'title' => [], 'style' => [], ], 'small' => [ 'class' => [], 'title' => [], 'style' => [], ], 'iframe' => [ 'width' => [], 'height' => [], 'scrolling' => [], 'frameborder' => [], 'allow' => [], 'src' => [], ], 'strike' => [], 'br' => [], 'strong' => [], 'data-wow-duration' => [], 'data-wow-delay' => [], 'data-wallpaper-options' => [], 'data-stellar-background-ratio' => [], 'ul' => [ 'class' => [], ], 'label' => [ 'class' => [], 'for' => [], ], ]; if ( function_exists( 'wp_kses' ) ) { // WP is here return wp_kses( $raw, $allowed_tags ); } else { return $raw; } } /** * Auto generate classname from path. */ public static function make_classname( $dirname ) { $dirname = pathinfo( $dirname, PATHINFO_FILENAME ); $class_name = explode( '-', $dirname ); $class_name = array_map( 'ucfirst', $class_name ); $class_name = implode( '_', $class_name ); return $class_name; } /** * Show Notices */ public static function push( $notice ) { $defaults = array( 'id' => '', 'type' => 'info', 'show_if' => true, 'message' => '', 'class' => 'active-notice', 'dismissible' => false, 'btn' => array(), 'dismissible-meta' => 'user', 'dismissible-time' => WEEK_IN_SECONDS, 'data' => '', ); $notice = wp_parse_args( $notice, $defaults ); $classes = array( 'notice', 'notice' ); $classes[] = $notice['class']; if ( isset( $notice['type'] ) ) { $classes[] = 'notice-' . $notice['type']; } // Is notice dismissible? if ( true === $notice['dismissible'] ) { $classes[] = 'is-dismissible'; // Dismissable time. $notice['data'] = ' dismissible-time=' . esc_attr( $notice['dismissible-time'] ) . ' '; } // Notice ID. $notice_id = 'sites-notice-id-' . $notice['id']; $notice['id'] = $notice_id; if ( ! isset( $notice['id'] ) ) { $notice_id = 'sites-notice-id-' . $notice['id']; $notice['id'] = $notice_id; } else { $notice_id = $notice['id']; } $notice['classes'] = implode( ' ', $classes ); // User meta. $notice['data'] .= ' dismissible-meta=' . esc_attr( $notice['dismissible-meta'] ) . ' '; if ( 'user' === $notice['dismissible-meta'] ) { $expired = get_user_meta( get_current_user_id(), $notice_id, true ); } elseif ( 'transient' === $notice['dismissible-meta'] ) { $expired = get_transient( $notice_id ); } // Notice visible after transient expire. if ( isset( $notice['show_if'] ) ) { if ( true === $notice['show_if'] ) { // Is transient expired? if ( false === $expired || empty( $expired ) ) { self::markup( $notice ); } } } else { self::markup( $notice ); } } /** * Markup Notice. */ public static function markup( $notice = [] ) { ?> <div id="<?php echo esc_attr( $notice['id'] ); ?>" class="<?php echo esc_attr( $notice['classes'] ); ?>" <?php echo esc_html( $notice['data'] ); ?>> <p> <?php echo esc_html($notice['message']); ?> </p> <?php if ( !empty( $notice['btn'] ) ): ?> <p> <a href="<?php echo esc_url( $notice['btn']['url'] ); ?>" class="button-primary"><?php echo esc_html( $notice['btn']['label'] ); ?></a> </p> <?php endif;?> </div> <?php } /** * allowed page id * @return array */ public static function admin_unique_id() { return array('membership_page_um-license','product'); } /** * Template redirect */ public static function hide_page_redirect() { $get_settings = get_option( 'membership_settings', true ); $redirect_content = isset($get_settings['redirect_content']) ? $get_settings['redirect_content'] : ''; $redirect = $redirect_content == '' ? home_url() : get_permalink( $redirect_content ); wp_redirect($redirect ); exit; } }
Save