Plugin Directory

Changeset 3346640


Ignore:
Timestamp:
08/18/2025 08:15:45 PM (8 months ago)
Author:
themifyme
Message:

update

Location:
themify-audio-dock
Files:
22 added
3 edited

Legend:

Unmodified
Added
Removed
  • themify-audio-dock/trunk/includes/admin.php

    r2941443 r3346640  
    4646     */
    4747    public function admin_init() {       
    48         register_setting( 'themify_audio_dock_option_group', 'themify_audio_dock_playlist' );
    49         register_setting( 'themify_audio_dock_option_group', 'themify_audio_dock_collapsed' );
    50         register_setting( 'themify_audio_dock_option_group', 'themify_audio_dock_bar_color' );
    51         register_setting( 'themify_audio_dock_option_group', 'themify_audio_dock_track_color' );
     48        register_setting(
     49            'themify_audio_dock_option_group',
     50            'themify_audio_dock_playlist',
     51            array(
     52                'sanitize_callback' => array( $this, 'sanitize_playlist' )
     53            )
     54        );
     55        register_setting(
     56            'themify_audio_dock_option_group',
     57            'themify_audio_dock_collapsed',
     58            array(
     59                'sanitize_callback' => array( $this, 'sanitize_collapsed' )
     60            )
     61        );
     62        register_setting(
     63            'themify_audio_dock_option_group',
     64            'themify_audio_dock_bar_color',
     65            array(
     66                'sanitize_callback' => array( $this, 'sanitize_color' )
     67            )
     68        );
     69        register_setting(
     70            'themify_audio_dock_option_group',
     71            'themify_audio_dock_track_color',
     72            array(
     73                'sanitize_callback' => array( $this, 'sanitize_color' )
     74            )
     75        );
    5276
    5377        add_settings_section(
     
    121145        foreach( $playlist as $key => $track ) {
    122146            echo '<div class="themify-track">';
    123             printf( '<label>%s <input class="widefat" type="text" name="themify_audio_dock_playlist[%s][name]" value="%s"></label>', __( 'Name', 'themify-audio-dock' ), $key, $track['name'] );
    124             printf( '<label>%s <input class="widefat song-file-field" type="text" name="themify_audio_dock_playlist[%s][file]" value="%s"></label>', __( 'Song File', 'themify-audio-dock' ), $key, $track['file'] );
     147            printf( '<label>%s <input class="widefat" type="text" name="themify_audio_dock_playlist[%s][name]" value="%s"></label>', __( 'Name', 'themify-audio-dock' ), $key, esc_attr($track['name']) );
     148            printf( '<label>%s <input class="widefat song-file-field" type="text" name="themify_audio_dock_playlist[%s][file]" value="%s"></label>', __( 'Song File', 'themify-audio-dock' ), $key, esc_attr($track['file']) );
    125149            echo '<a href="#" class="themify-audio-dock-media-browse" data-uploader-title="' . __( 'Browse Audio', 'themify-audio-dock' ) . '" data-uploader-button-text="' . __( 'Insert Audio', 'themify-audio-dock' ) . '" data-type="audio">' . __( 'Browse Library', 'themify-audio-dock' ) . '</a>';
    126150            echo '<a href="#" class="themify-audio-dock-delete-track">X</a>';
     
    150174        wp_enqueue_script( 'themify-player-admin', $url . 'assets/admin.js', array( 'jquery', 'audiodock-colorpicker' ),$v,true );
    151175    }
     176
     177    public function sanitize_playlist( $playlist ) {
     178        if ( ! is_array( $playlist ) ) {
     179            return array();
     180        }
     181        foreach ( $playlist as $key => $track ) {
     182            $playlist[$key]['name'] = sanitize_text_field( $track['name'] );
     183            $playlist[$key]['file'] = esc_url_raw( $track['file'] );
     184        }
     185        return $playlist;
     186    }
     187
     188    public function sanitize_collapsed( $value ) {
     189        return in_array( $value, array( 'yes', 'no' ), true ) ? $value : 'no';
     190    }
     191
     192    public function sanitize_color($color)
     193    {
     194        // Accept valid hex (#fff, #ffffff) or rgba(r,g,b,a) format
     195        $color = trim($color);
     196        if (preg_match('/^#([A-Fa-f0-9]{3}){1,2}$/', $color)) {
     197            return $color;
     198        }
     199        if (preg_match('/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0?\.\d+)\s*\)$/', $color)) {
     200            // Validate each channel
     201            $parts = [];
     202            preg_match('/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0?\.\d+)\s*\)$/', $color, $parts);
     203            $r = (int)$parts[1];
     204            $g = (int)$parts[2];
     205            $b = (int)$parts[3];
     206            $a = (float)$parts[4];
     207            if ($r >= 0 && $r <= 255 && $g >= 0 && $g <= 255 && $b >= 0 && $b <= 255 && $a >= 0 && $a <= 1) {
     208                return "rgba($r,$g,$b,$a)";
     209            }
     210        }
     211        return '';
     212    }
    152213}
    153214new Themify_Player_Admin;
  • themify-audio-dock/trunk/init.php

    r3184692 r3346640  
    33Plugin Name:  Themify Audio Dock
    44Plugin URI:   https://themify.me/
    5 Version:      2.0.5
     5Version:      2.0.6
    66Author:       Themify
    77Author URI:   https://themify.me
     
    4444   
    4545    public static function get_version(){
    46         return '2.0.5';
     46        return '2.0.6';
    4747    }
    4848
  • themify-audio-dock/trunk/readme.txt

    r3184692 r3346640  
    44Tags: audio, audio-player, playlist
    55Requires at least: 4.3
    6 Tested up to: 6.6.0
    7 Stable tag: 2.0.5
     6Tested up to: 6.8.2
     7Stable tag: 2.0.6
    88License: GPL v2
    99License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
Note: See TracChangeset for help on using the changeset viewer.