get_settings(); if ( isset( $settings['color']['palette']['theme'] ) ) { $color_palette = $settings['color']['palette']['theme']; } // If empty color palette, try to get from theme supports. if ( empty( $color_palette ) ) { $color_palette = get_theme_support( 'editor-color-palette' ); if ( ! empty( $color_palette ) ) { $color_palette = $color_palette[0]; } } /** * Filter the color palette used by the plugin. * * @param array $color_palette { * @type string $name The color name. * @type string $slug The color slug. * @type string $color The color hex value. * } */ $color_palette = apply_filters( 'alerts_dlx_color_palette', $color_palette ); return $color_palette; } /** * Take a _ separated field and convert to camelcase. * * @param string $field Field to convert to camelcase. * * @return string camelCased field. */ public static function to_camelcase( string $field ) { return str_replace( '_', '', lcfirst( ucwords( $field, '_' ) ) ); } /** * Return the plugin slug. * * @return string plugin slug. */ public static function get_plugin_slug() { return dirname( plugin_basename( ALERTS_DLX_FILE ) ); } /** * Return the basefile for the plugin. * * @return string base file for the plugin. */ public static function get_plugin_file() { return plugin_basename( ALERTS_DLX_FILE ); } /** * Return the version for the plugin. * * @return float version for the plugin. */ public static function get_plugin_version() { return ALERTS_DLX_VERSION; } /** * Get the plugin author name. */ public static function get_plugin_author() { /** * Filer the output of the plugin Author. * * Potentially change branding of the plugin. * * @since 1.0.0 * * @param string Plugin Author name. */ $plugin_author = apply_filters( 'alerts_dlx_plugin_author', 'MediaRon LLC' ); return $plugin_author; } /** * Return the Plugin author URI. */ public static function get_plugin_author_uri() { /** * Filer the output of the plugin Author URI. * * Potentially change branding of the plugin. * * @since 1.0.0 * * @param string Plugin Author URI. */ $plugin_author = apply_filters( 'alerts_dlx_plugin_author_uri', 'https://mediaron.com' ); return $plugin_author; } /** * Return the plugin name for the plugin. * * @return string Plugin name. */ public static function get_plugin_name() { /** * Filer the output of the plugin name. * * Potentially change branding of the plugin. * * @since 1.0.0 * * @param string Plugin name. */ return apply_filters( 'alerts_dlx_plugin_name', __( 'AlertsDLX', 'alerts-dlx' ) ); } /** * Return the plugin description for the plugin. * * @return string plugin description. */ public static function get_plugin_description() { /** * Filer the output of the plugin name. * * Potentially change branding of the plugin. * * @since 1.0.0 * * @param string Plugin description. */ return apply_filters( 'alerts_dlx_plugin_description', __( 'An alert and notification block inspired by Bootstrap, Material UI, and Chakra UI.', 'alerts-dlx' ) ); } /** * Retrieve the plugin URI. */ public static function get_plugin_uri() { /** * Filer the output of the plugin URI. * * Potentially change branding of the plugin. * * @since 1.0.0 * * @param string Plugin URI. */ return apply_filters( 'alerts_dlx_plugin_uri', 'https://dlxplugins.com/plugins/alertsdlx' ); } /** * Retrieve the plugin support URI. */ public static function get_plugin_support_uri() { /** * Filer the output of the plugin support URI. * * Potentially change branding of the plugin. * * @since 1.0.0 * * @param string Plugin Support URI. */ return apply_filters( 'alerts_dlx_plugin_support_uri', 'https://dlxplugins.com/support/' ); } /** * Retrieve the plugin documentation URI. */ public static function get_plugin_docs_uri() { /** * Filer the output of the plugin docs URI. * * Potentially change branding of the plugin. * * @since 1.0.0 * * @param string Plugin Docs URI. */ return apply_filters( 'alerts_dlx_plugin_docs_uri', 'https://alertsdlx.dlxplugins.com/' ); } /** * Retrieve the plugin documentation URI. */ public static function get_plugin_ratings_uri() { /** * Filer the output of the plugin ratings URI. * * Potentially change branding of the plugin. * * @since 1.0.0 * * @param string Plugin ratings URI. */ return apply_filters( 'alerts_dlx_plugin_docs_uri', 'https://dlxplugins.com/support/' ); } /** * Retrieve the plugin title. */ public static function get_plugin_title() { /** * Filer the output of the plugin title. * * Potentially change branding of the plugin. * * @since 1.0.0 * * @param string Plugin Menu Name. */ return apply_filters( 'alerts_dlx_plugin_menu_title', self::get_plugin_name() ); } /** * Returns appropriate html for KSES. * * @param bool $svg Whether to add SVG data to KSES. */ public static function get_kses_allowed_html( $svg = true ) { $allowed_tags = wp_kses_allowed_html(); $allowed_tags['nav'] = array( 'class' => array(), ); $allowed_tags['a']['class'] = array(); if ( ! $svg ) { return $allowed_tags; } $allowed_tags['svg'] = array( 'xmlns' => array(), 'fill' => array(), 'viewbox' => array(), 'role' => array(), 'aria-hidden' => array(), 'focusable' => array(), 'class' => array(), ); $allowed_tags['path'] = array( 'd' => array(), 'fill' => array(), 'opacity' => array(), ); $allowed_tags['g'] = array(); $allowed_tags['use'] = array( 'xlink:href' => array(), ); $allowed_tags['symbol'] = array( 'aria-hidden' => array(), 'viewBox' => array(), 'id' => array(), 'xmls' => array(), ); return $allowed_tags; } /** * Array data that must be sanitized. * * @param array $data Data to be sanitized. * * @return array Sanitized data. */ public static function sanitize_array_recursive( array $data ) { $sanitized_data = array(); foreach ( $data as $key => $value ) { if ( '0' === $value ) { $value = 0; } if ( 'true' === $value ) { $value = true; } elseif ( 'false' === $value ) { $value = false; } if ( is_array( $value ) ) { $value = self::sanitize_array_recursive( $value ); $sanitized_data[ $key ] = $value; continue; } if ( is_bool( $value ) ) { $sanitized_data[ $key ] = (bool) $value; continue; } if ( is_int( $value ) ) { $sanitized_data[ $key ] = (int) $value; continue; } if ( is_string( $value ) ) { $sanitized_data[ $key ] = sanitize_text_field( $value ); continue; } } return $sanitized_data; } /** * Get the plugin directory for a path. * * @param string $path The path to the file. * * @return string The new path. */ public static function get_plugin_dir( $path = '' ) { $dir = rtrim( plugin_dir_path( ALERTS_DLX_FILE ), '/' ); if ( ! empty( $path ) && is_string( $path ) ) { $dir .= '/' . ltrim( $path, '/' ); } return $dir; } /** * Return a plugin URL path. * * @param string $path Path to the file. * * @return string URL to to the file. */ public static function get_plugin_url( $path = '' ) { $dir = rtrim( plugin_dir_url( ALERTS_DLX_FILE ), '/' ); if ( ! empty( $path ) && is_string( $path ) ) { $dir .= '/' . ltrim( $path, '/' ); } return $dir; } /** * Gets the highest priority for a filter. * * @param int $subtract The amount to subtract from the high priority. * * @return int priority. */ public static function get_highest_priority( $subtract = 0 ) { $highest_priority = PHP_INT_MAX; $subtract = absint( $subtract ); if ( 0 === $subtract ) { --$highest_priority; } else { $highest_priority = absint( $highest_priority - $subtract ); } return $highest_priority; } }