HEX
Server: Apache
System: Linux pdx1-shared-a1-28 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: dh_6nhrpv (6576398)
PHP: 8.2.26
Disabled: NONE
Upload Files
File: /home/dh_6nhrpv/callhare.com/wp-content/plugins/rank-assassin/includes/RankAssassinStyling.php
<?php
/**
 * @package RankAssassin
 */

defined( 'ABSPATH' ) or die( 'Looks like someone just took a headshot!' );

class RankAssassinStyling {
    private $styles_file = WP_CONTENT_DIR . '/uploads/rank-assassin/styling_settings.json';
    private $styles;
    private $default_styles = array(
        "general" => array (
            "section_gap" => 100,
            "font_family" => "Roboto/sans-serif/Roboto"
        ),
        "headings" => array(
            "font_color" => "#000000",
            "font_size" => 32,
            "font_weight" => 700,
            "alignment" => "center"
        ),
        "subheadings" => array(
            "font_color" => "#000000",
            "font_size" => 22,
            "font_weight" => 600,
            "alignment" => "center"
        ),
        "body_text" => array(
            "font_color" => "#727272",
            "font_size" => 16,
            "font_weight" => 400,
            "alignment" => "center"
        ),
        "cards" => array(
            "gap" => 20,
            "padding" => 40,
            "background_color" => "#F3F3F3",
            "border_radius" => 10,
            "border_width" => 1,
            "border_color" => "#E2E2E2"
        )
    );

    function __construct() {
        $this->load_styles();
    }

    /**
     * @Desc: Loads data from uploads/rank-local/styling_settings.json file to $this->styles
     */
    private function load_styles() {
        if (file_exists($this->styles_file)) {
            $this->styles = json_decode(file_get_contents($this->styles_file), true);
        } else {
            $this->styles = $this->default_styles;
        }
    }

    /**
     * @Desc: returns the default styles @ $this->default_styles
     */
    public function get_default_styles() {
        return $this->default_styles;
    }

    /**
     * @Desc: Returns $this->styles
     */
    public function get_styles() {
        return $this->styles;
    }

    /**
     * @Desc: update styles
     */
    public function update_styles($updates) {
        $update_data = json_decode(stripslashes($updates), true);

        // check for empty values in $updates and add $this->style values
        foreach ($update_data as $topkey => &$topvalue) {
            foreach ($topvalue as $key => $value) {
                if (!isset($value) || $value === "") {
                    $topvalue[$key] = $this->default_styles[$topkey][$key];
                }
            }
        }

        // convert to json string
        $update_data = json_encode($update_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);

        if (file_put_contents($this->styles_file, $update_data)) {
            $this->load_styles();
            return true;
        } else { return false; }
    }
}