Ejemplo n.º 1
0
/**
 * Get app loader html
 */
function wpce_get_loader($atts = array())
{
    $loader_url = wpce_config('loader_url');
    if (empty($loader_url)) {
        $app_name = wpce_config('name');
        if (empty($app_name)) {
            $message = 'GovRight embedded app is not selected. Select an application in the plugin settings.';
        } else {
            $message = 'Can\'t load the ' . $app_name . ' application, missing loader url.';
        }
        return '<script>console.warn("' . $message . '");</script>';
    }
    $law_slug = get_option('wpce_law_slug');
    if (!is_array($atts)) {
        $atts = array();
    }
    if (!isset($atts['data-law-slug'])) {
        $atts['data-law-slug'] = $law_slug;
    }
    return '<script src="' . $loader_url . '" ' . wpce_atts_string($atts) . '></script>';
}
Ejemplo n.º 2
0
<?php

add_action('plugins_loaded', function () {
    if ($_SERVER['REQUEST_URI'] === '/auth/success') {
        $post_url = wpce_config('auth_post_url');
        if (empty($post_url)) {
            return;
        }
        $response = wp_remote_post($post_url, array('body' => $_POST));
        if (is_wp_error($response)) {
            echo $response->get_error_message();
        } else {
            echo $response['body'];
        }
        die;
    }
});
Ejemplo n.º 3
0
 $white_list = apply_filters('wpce_social_urls_white_list', '*') ?: '*';
 if ($white_list !== '*') {
     $white_list = wpce_normalize_urls($white_list);
 }
 $current_path = wpce_normalize_urls($_SERVER['REQUEST_URI'], true);
 if ($white_list === '*' || in_array($current_path, $white_list)) {
     $social_url = wpce_config('social_url');
     $law_slug = trim(get_option('wpce_law_slug'));
     if (empty($social_url)) {
         return;
     }
     // _escaped_fragment_ usually goes first
     $fragment = urldecode(str_replace('_escaped_fragment_=', '', $_SERVER['QUERY_STRING']));
     $locale = defined('ICL_LANGUAGE_CODE') && ICL_LANGUAGE_CODE ? ICL_LANGUAGE_CODE : 'en';
     if (!empty($law_slug)) {
         $law_route = '/' . $locale . '/' . trim(wpce_config('law_route'), '/') . '/';
         if ($fragment[1] === '?' || $fragment === '/') {
             $fragment = ltrim($fragment, '/');
         }
         $path = $law_route . $law_slug . $fragment;
     } else {
         $path = $fragment;
     }
     $url = $social_url . '?path=' . $path;
     $port = parse_url($social_url, PHP_URL_PORT);
     if ($port) {
         $url .= '&port=' . $port;
     }
     $response = wp_remote_get($url, array('timeout' => 10));
     // In case of error or something just show a Wordpress page
     // At least something will be displayed