. */ /** * @package AllAccessible * @version 1.3.4 * @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.'); } // ============================================= // Define Global Constants // ============================================= aacb_define_constants(); function aacb_define_constants() { // $aacb_siteOptions = aacb_siteOptions(); define('AACB_NAME', isset($aacb_siteOptions->isWhitelabel) && $aacb_siteOptions->isWhitelabel ? _e( "Accessibility", 'allaccessible' ) : 'AllAccessible'); define('AACB_VERSION','1.3.4'); define('AACB_WP_MIN_VERSION','5.0'); define('AACB_TEXT','allaccessible'); define('AACB_DIR', dirname( plugin_basename( __FILE__ ) ) ); define('AACB_URL', plugin_dir_url( __FILE__ ) ); define('AACB_PATH', plugin_dir_path( __FILE__ ) ); define('AACB_JS', AACB_URL . trailingslashit('assets') ); define('AACB_CSS', AACB_URL . trailingslashit('assets') ); define('AACB_IMG', AACB_URL . trailingslashit('assets') ); define('AACB_INC', AACB_PATH . trailingslashit('inc') ); define('AACB_SUPPORT','https://support.allaccessible.org/'); } function aacb_load_textdomain() { load_plugin_textdomain( 'allaccessible', false, basename( dirname( __FILE__ ) ) . '/languages/' ); } add_action( 'init', 'aacb_load_textdomain' ); /** * 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() { // Removes all admin notices for this page remove_all_actions( 'admin_notices' ); //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 //========================= function AllAccessible_loadWidget() { if (!is_admin() && empty($_GET['et_fb'])) { $account_id = get_option('aacb_accountID') ? esc_attr(get_option('aacb_accountID')) : 'wp_vFtGhKjLm'; $script_src = "https://app.allaccessible.org/api/{$account_id}.js"; $aacbPreview = false; if(isset($_GET['aacb_preview']) && $_GET['aacb_preview']){ $aacbPreview = true; } ?> admin_url('admin-ajax.php') ); wp_localize_script('allaccessible-custom', 'ajax_object', $ajax_data); wp_enqueue_script('allaccessible-custom'); } add_action('admin_enqueue_scripts','AllAccessible_LoadScript'); function aacb_dismiss_notice() { update_option('aacb_hide_premium_notice', true); echo 'success'; wp_die(); } add_action('wp_ajax_aacb_dismiss_notice', 'aacb_dismiss_notice'); // =================================================== // Setup Core AllAccessible Admin Options and Settings // =================================================== /** * Admin dashboard menu bar */ add_action('admin_menu','AllAccessible_integration'); function AllAccessible_integration() { add_menu_page( AACB_NAME, AACB_NAME, 'manage_options', 'allaccessible', 'allaccessible_settings', 'data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgMzE3LjkgMzE3Ljg5Ij48ZGVmcz48bGluZWFyR3JhZGllbnQgaWQ9Im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40OCwzMC40OCwwLDAsMS03LDEwLjU0TDI3OC4yNiwxMDQuOGExMzEuMTEsMTMxLjExLDAsMCwxLTI1Ljc1LDE0NS44MmwtNDcuMzUtNDcuMzVjLTE3LjkzLTE3LjkzLTQ1LDkuMTgtMjcuMTEsMjcuMTFMMjIxLjY2LDI3NEExMzEuMjEsMTMxLjIxLDAsMCwxLDk2LDI3My44M2w0My42LTQzLjZjMTcuOTQtMTcuOTQtOS4xOS00NS0yNy4xMS0yNy4xMUw2NS4xNiwyNTAuNEExMzEsMTMxLDAsMCwxLDI0Mi4yOSw1Ny44OGw3LjE3LTcuMTZhMjkuMzMsMjkuMzMsMCwwLDEsMTcuMTktOC42N0ExNTguNDEsMTU4LjQxLDAsMCwwLDE1OSwwWiIgc3R5bGU9ImZpbGwtcnVsZTpldmVub2RkO2ZpbGw6dXJsKCNsaW5lYXItZ3JhZGllbnQtMikiLz48L3N2Zz4=', 25 ); } /** * AllAccessible Initial Activation */ function AllAccessible_activation() { global $wpdb; $options = get_option('aacb_options'); if ( ( $options['aacb_installed'] != 1 ) || ( ! is_array( $options ) ) ) { $opt = array( 'aacb_installed' => 1, ); update_option('aacb_options', $opt ); } } /** * AllAccessible Admin Notices */ function aacb_activated_notice() { $options = get_option('aacb_options'); $hide_notice = get_option('aacb_hide_premium_notice'); if ($options['aacb_installed'] && !get_option('aacb_accountID') && !$hide_notice) { $settings_url = admin_url('options-general.php?page=allaccessible'); ?>
AACB_TEXT, 'version' => AACB_VERSION, 'url' => get_bloginfo('wpurl') ); return $plugins; }); /** * 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) ); } } } /** * Hide all the unrelated notices from plugin page. * * @since 1.3 * @return void */ function hide_admin_notices() { // Bail if we're not on a AllAccessible screen. if ( empty( $_REQUEST['page'] ) || ! preg_match( '/allaccessible/', esc_html( wp_unslash( $_REQUEST['page'] ) ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized return; } global $wp_filter; $notices_type = array( 'user_admin_notices', 'admin_notices', 'all_admin_notices', ); foreach ( $notices_type as $type ) { if ( empty( $wp_filter[ $type ]->callbacks ) || ! is_array( $wp_filter[ $type ]->callbacks ) ) { continue; } foreach ( $wp_filter[ $type ]->callbacks as $priority => $hooks ) { foreach ( $hooks as $name => $arr ) { if ( is_object( $arr['function'] ) && $arr['function'] instanceof \Closure ) { unset( $wp_filter[ $type ]->callbacks[ $priority ][ $name ] ); continue; } $class = ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) ? strtolower( get_class( $arr['function'][0] ) ) : ''; if ( ! empty( $class ) && preg_match( '/^(?:aacb)/', $class ) ) { continue; } if ( ! empty( $name ) && ! preg_match( '/^(?:aacb)/', $name ) ) { unset( $wp_filter[ $type ]->callbacks[ $priority ][ $name ] ); } } } } } // Hide the unrelated admin notices. add_action( 'admin_print_scripts', 'hide_admin_notices');