. */ /** * @package AllAccessible * @version 1.2.7 * @since 1.0 * @author AllAccessible Team * @copyright Copyright (c) 2022 AllAccessible * @link https://www.allaccessible.org/ * @license http://www.gnu.org/licenses/gpl.html */ if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); } function aacb_load_textdomain() { load_plugin_textdomain( 'allaccessible', false, basename( dirname( __FILE__ ) ) . '/languages/' ); } add_action( 'init', 'aacb_load_textdomain' ); // ============================================= // Define Global Constants // ============================================= if ( !defined('AACB_NAME') ) { if (isset($GLOBALS['aacb_siteOptions']->isWhitelabel) && $GLOBALS['aacb_siteOptions']->isWhitelabel) { define('AACB_NAME', _e( "Accessibility", 'allaccessible' )); } else { define('AACB_NAME', 'AllAccessible'); } } //Set Current Plugin Version if ( !defined('AACB_VERSION') ) { define('AACB_VERSION','1.2.7'); } //Set Minimum WordPress version for compatibility if( !defined('AACB_WP_MIN_VERSION') ){ define('AACB_WP_MIN_VERSION','5.0'); } if ( !defined('AACB_TEXT') ) { define('AACB_TEXT','allaccessible'); } if ( !defined('AACB_DIR') ) { define('AACB_DIR', dirname( plugin_basename( __FILE__ ) ) ); } // Set constant URI to the plugin URL. if ( !defined('AACB_URL') ) { define('AACB_URL', plugin_dir_url( __FILE__ ) ); } // Set constant path to the plugin directory. if ( !defined('AACB_PATH') ) { define('AACB_PATH', plugin_dir_path( __FILE__ ) ); } // Set the constant path to the plugin's javascript directory. if( !defined('AACB_JS') ) { define('AACB_JS', AACB_URL . trailingslashit('assets') ); } // Set the constant path to the plugin's CSS directory. if( !defined('AACB_CSS') ) { define('AACB_CSS', AACB_URL . trailingslashit('assets') ); } // Set the constant path to the plugin's images directory. if( !defined('AACB_IMG') ) { define('AACB_IMG', AACB_URL . trailingslashit('assets') ); } // Set the constant path to the plugin's includes directory. if( !defined('AACB_INC') ) { define('AACB_INC', AACB_PATH . trailingslashit('inc') ); } // Set the constant path to the plugin's includes directory. if( !defined('AACB_SUPPORT') ) { define('AACB_SUPPORT','https://support.allaccessible.org/'); } /** * Load AllAccessible options */ function AllAccessible_getSiteOptions() { $apiUrl ='https://app.allaccessible.org/api/get-site-options/'; $apiResponse = wp_remote_post( $apiUrl, [ 'method' =>'POST', 'sslverify'=> false, 'headers' => [ 'content-type'=>'application/json', ], 'body' => json_encode(array('siteId'=> get_option('aacb_siteID'))) ] ); return json_decode( wp_remote_retrieve_body( $apiResponse ) ); } /** * Load AllAccessible Settings Page */ function AllAccessible_settings() { //TODO - improve $GLOBALS['aacb_accountID'] = get_option('aacb_accountID'); if(!get_option('aacb_siteID') && get_option('aacb_accountID')){ $apiUrl ='https://app.allaccessible.org/api/get-site-id/'; $apiResponse = wp_remote_post( $apiUrl, [ 'method' =>'POST', 'sslverify'=> false, 'headers' => [ 'content-type'=>'application/json', ], 'body' => json_encode(array('pageUrl'=> get_bloginfo('wpurl'),'accountID'=> get_option('aacb_accountID'))) ] ); $apiBody = json_decode( wp_remote_retrieve_body( $apiResponse ) ); update_option('aacb_siteID', $apiBody ); } $GLOBALS['aacb_accountID'] = get_option('aacb_siteID'); if(get_option('aacb_siteID')){ $GLOBALS['aacb_siteOptions'] = AllAccessible_getSiteOptions(); } include AACB_INC .'AllAccessibleSettings.php'; } //========================= // Add Script to Header //========================= if(get_option('aacb_accountID')){ function AllAccessible_loadWidget() { if(!is_admin() && empty($_GET['et_fb'])){ ?> 1, ); update_option('aacb_options', $opt ); } // wp_redirect(admin_url('options-general.php?page=allaccessible')); // exit; } /** * AllAccessible Setting Saver */ function AllAccessible_save_settings() { $opt_name = isset($_POST['opt_name']) ? sanitize_text_field($_POST['opt_name']) : null; $opt_value = isset($_POST['opt_value']) ? sanitize_text_field($_POST['opt_value']) : null; $update = update_option($opt_name, $opt_value); } add_action('wp_ajax_AllAccessible_save_settings','AllAccessible_save_settings'); /** * AllAccessible Deactivation */ function AllAccessible_Deactivation() { delete_option( 'aacb_options' ); delete_option( 'aacb_installed' ); delete_option( 'aacb_siteID' ); delete_option( 'aacb_accountID'); } /** * Logs a debug statement to /wp-content/debug.log * * @param string */ function AllAccessible_log_debug( $message ) { if ( WP_DEBUG === true ) { if ( is_array( $message ) || is_object( $message ) ) { error_log( print_r( $message, true ) ); } else { error_log( esc_attr($message) ); } } }