This topic has 1 reply, 2 voices, and was last updated 9 years by Abe.

  • Author
  • #32171
     Ukia Sephiroth
    Participant

    Hello, i have chatcat plugin, and it works very good with your theme, but i noticed in the profile when you switch to basic or interest it changes to /#/interest and it should be /#interest, it only happends when i enable this plugin, here is the code of it, can you tell me what can i edit?

    COPY CODE
    <?php
    /*
    Plugin Name: Chatcat Messenger
    Plugin URI: http://chatcat.io/support
    Description: Add Chatcat instant messenger to your website
    Version: 1.0.1
    Author: Ben Smiley-Andrews
    Author URI: http://chatcat.io
    License: MIT
    */
    
    require_once "CCAuth.php";
    
    // Get the current user
    if ( !defined('__DIR__') ) define('__DIR__', dirname(__FILE__));
    $path = explode('wp-content',__DIR__);
    include_once($path[0].'wp-load.php');
    
    // Enable AJAX
    add_action("wp_ajax_cc_auth", "cc_auth");
    add_action("wp_ajax_nopriv_cc_auth", "cc_auth_logout");
    
    function cc_auth () {
    
        global $current_user;
    
        $doc = new DOMDocument();
        $doc->loadHTML(get_avatar($current_user->ID, 100));
        $xpath = new DOMXPath($doc);
        $src = $xpath->evaluate("string(//img/@src)");
        $exp = explode('&d=', $src);
        $src = urldecode($exp[1]);
    
        // Is the user logged in?
        if($current_user->ID > 0) {
            // Get the API key from the settings
            $api_key = get_option('cc_options');
    
            // Get the user's description
            $description = get_the_author_meta( 'description', $current_user->ID, $_SERVER['HTTP_HOST']);
    
            // Create a new Auth instance
            $auth = new CCAuth ($current_user->ID, $api_key['api_key'], '');
    
            // Authenticate the user
            $auth->authUser($current_user->display_name, $description, null, null, null, null, $src, array());
    
        }
        else {
            CCAuth::logout();
        }
    
        die();
    }
    
    function cc_auth_logout () {
        CCAuth::logout();
        die();
    }
    
    function cc_add_footer () {
    
        // Get the URL for the module this will let us set the
        $module_url = plugin_dir_url(__FILE__);
    
        // Get the URL of the API connector script
        //$api_url = $module_url . 'cc-auth-api.php';
        $api_url = admin_url('admin-ajax.php');;
    
        $options = get_option('cc_options');
    
        // If the API key isn't set disable the API URL
        $api_key = $options['api_key'];
        if(!isset($api_key) || strlen($api_key) != 40) {
            $api_url = '';
        }
    
        // Setup the login and register URLs
        $login_url = $options['login'];
        if(!isset($login_url) || strlen($login_url) == 0) {
            $login_url = wp_login_url();
        }
    
        // Setup the login and register URLs
        $register_url = $options['register'];
        if(!isset($register_url) || strlen($register_url) == 0) {
            $register_url = wp_registration_url();
        }
    
        $primary_url = $options['primary_url'];
    
        // Include the chat in the footer
        ?>
    
        <div ng-app="myApp" ><ng-include src=" baseURL + 'chatcat.html'" ng-controller="AppController"></ng-include></div>
        <script type="text/javascript">
    
            // Set options here
            var CC_OPTIONS = {
    
                <?php if(isset($primary_url) && strlen($primary_url) > 0): ?>
                primaryDomain: '<?php echo $primary_url  ?>',
                <?php endif ?>
    
                // Users can create public chat rooms?
                // If this is true users will be able to setup new
                // public rooms
                usersCanCreatePublicRooms: true,
    
                // Allow anonymous login?
                anonymousLoginEnabled: false,
    
                // Enable social login - please email us to get your domain whitelisted
                socialLoginEnabled: true,
    
                // The URL to contact for single sign on
                singleSignOnURL: '<?php echo $api_url ?>',
    
                // Optional - if this is set the login box will direct users
                // to log in
                loginURL: '<?php echo $login_url?>',
    
                // Optional - if this is set the login box will direct users
                // to register
                registerURL: '<?php echo $register_url?>'
    
            }
    
            var ccProtocol = (("https:" == document.location.protocol) ? "https://" : "http://");
    
        <?php if ($_SERVER['SERVER_NAME'] == 'ccwp') { ?>
    
            // TEST
            document.write(decodeURI("%3Clink rel='stylesheet' href='" + ccProtocol + "chatcat/dist/css/_/cc_styles.min.css' %3E%3C/link%3E"));
            document.write(decodeURI("%3Cscript src='" + ccProtocol + "chatcat/dist/js/all.js' type='text/javascript'%3E%3C/script%3E"));
    
        <?php } else { ?>
    
            // PRODUCTION
            document.write(decodeURI("%3Clink rel='stylesheet' href='" + ccProtocol + "chatcat.firebaseapp.com/css/_/cc_styles.min.css' %3E%3C/link%3E"));
            document.write(decodeURI("%3Cscript src='" + ccProtocol + "chatcat.firebaseapp.com/js/all.min.js' type='text/javascript'%3E%3C/script%3E"));
    
        <?php } ?>
    
        </script>
    
    <?php
    
    }
    
    add_action( 'wp_footer', 'cc_add_footer' );
    
    /**
     * Add the admin menu
     */
    
    add_action( 'admin_menu', 'cc_plugin_menu' );
    
    function cc_plugin_menu() {
        add_options_page( 'Chatcat', 'Chatcat', 'manage_options', 'cc_plugin', 'cc_plugin_options_page' );
    }
    
    // Print the options page
    function cc_plugin_options_page() {
        if ( !current_user_can( 'manage_options' ) )  {
            wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
        }
    
    ?>
        <div class="wrap">
            <form action="options.php" method="post">
                <?php settings_fields('cc_plugin_api_key'); ?>
                <?php do_settings_sections('cc_plugin'); ?>
                <input name="Submit" type="submit" value="<?php esc_attr_e('Save Changes'); ?>" />
            </form>
        </div>
    <?php
    }
    
    // Generate content for setting subtitle
    function cc_plugin_section_text() {
        echo '<p>Enter your API key here to enable single sign on. The key must be 40 characters long. If login or register URLs are not provided the WordPress default will be used.</p>';
    }
    
    // Generate text input box
    function cc_print_api_key_field() {
        $options = get_option('cc_options');
        $value = isset($options['api_key']) ? $options['api_key'] : '';
        echo "<input id='plugin_text_string_api_key' name='cc_options[api_key]' size='40' type='text' value='{$value}' />";
    }
    
    function cc_print_login_key_field() {
        $options = get_option('cc_options');
        $value = isset($options['login']) ? $options['login'] : '';
        echo "<input id='plugin_text_string_login' name='cc_options[login]' size='40' type='text' value='{$value}' />";
    }
    
    function cc_print_register_key_field() {
        $options = get_option('cc_options');
        $value = isset($options['register']) ? $options['register'] : '';
        echo "<input id='plugin_text_string_register' name='cc_options[register]' size='40' type='text' value='{$value}' />";
    }
    
    function cc_print_primary_url_key_field() {
        $options = get_option('cc_options');
        $value = isset($options['primary_url']) ? $options['primary_url'] : '';
        echo "<input id='plugin_text_string_primary_url' name='cc_options[primary_url]' size='40' type='text' value='{$value}' />";
    }
    
    // Validation
    function plugin_options_validate($input) {
    
        // Validate API Key
        $api_key = trim($input['api_key']);
        if(!preg_match('/^[a-zA-Z0-9]{40}$/i', $api_key)) {
            $api_key = '';
        }
        $input['api_key'] = $api_key;
    
        // Validate the login URL
        if(strlen($input['login']) != 0) {
            $input['login'] = esc_url($input['login']);
        }
    
        // Validate register URL
        if(strlen($input['register']) != 0) {
            $input['register'] = esc_url($input['register']);
        }
    
        if(strlen($input['primary_url']) != 0) {
            $url = $input['primary_url'];
            $url = str_replace('www.', '', $url);
            $parse = parse_url(esc_url($url));
            $input['primary_url'] = $parse['host'];
        }
    
        return $input;
    }
    
    add_action('admin_init', 'plugin_admin_init');
    
    function plugin_admin_init(){
        register_setting( 'cc_plugin_api_key', 'cc_options', 'plugin_options_validate' );
        add_settings_section('plugin_main', 'Chatcat Settings', 'cc_plugin_section_text', 'cc_plugin');
        add_settings_field('plugin_text_string_api_key', 'API Key', 'cc_print_api_key_field', 'cc_plugin', 'plugin_main');
    
        add_settings_field('plugin_text_string_login', 'Login Page URL (optional)', 'cc_print_login_key_field', 'cc_plugin', 'plugin_main');
        add_settings_field('plugin_text_string_register', 'Register Page URL (optional)', 'cc_print_register_key_field', 'cc_plugin', 'plugin_main');
        add_settings_field('plugin_text_string_primary_url', 'Primary URL (optional)', 'cc_print_primary_url_key_field', 'cc_plugin', 'plugin_main');
    }
    #32889
     Abe
    Keymaster

    hi, sorry you should contact plugin developers but there is something from their JavaScript that does that.

    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Log in with your credentials

Forgot your details?