Plugin Directory

Changeset 2649162


Ignore:
Timestamp:
12/26/2021 02:10:21 PM (4 years ago)
Author:
ole1986
Message:

Update to version 1.1.0 from GitHub

Location:
social-page-metadata
Files:
4 added
2 deleted
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • social-page-metadata/tags/1.1.0/lang/social-plugin-metadata-de_DE.po

    r2648243 r2649162  
    2828
    2929msgid "Please use the below Login & Sync button to synchronize the facebook pages"
    30 msgstr "Bitte verwende den unten dargestellten Knopf um mit der Synchronisierung deiner Facebook Seiten zu beginnen"
     30msgstr "Bitte verwende die unten dargestellte Schaltfläche um die  Facebook Seiten zu synchronisieren"
    3131
    3232msgid "Please register your domain first before using the Facebook App"
     
    9090msgstr "Mit Facebook verbinden"
    9191
    92 msgid "Setup your Facebook App (optional)"
    93 msgstr "Konfiguriere deine Facebook App (optional)"
     92msgid "Build your own %s and configure the APP ID as well as the APP KEY here"
     93msgstr "Erstelle eine eigene %s und konfiguriere die APP ID sowie den APP KEY hier"
    9494
    95 msgid "Quick Guide"
    96 msgstr "Kurzanleitung"
    97 
    98 msgid "To sychronize and outpout meta information (E.g. Business hours, About Us, last posts) from facebook pages"
    99 msgstr "Zur Syncronisierung und Ausgabe von Metadaten (Öffnungszeiten, Titel, Beschreibung, Letzte Beiträge) aus Facebook Seiten"
    100 
    101 msgid "Use the button Login and Sync (left side) to connect your facebook account with the Facebook App"
    102 msgstr "Verwenden Sie den Knopf Login and Sync (Links) um Ihr Facebook Konto mit der facebook App zu verbinden"
    103 
    104 msgid "Once successfully logged into your facebook account, choose the pages you wish to output metadata for"
    105 msgstr "Nach erfolgreicher Facebook Anmeldung wählen Sie die gewünschten Seiten aus für die Sie Metadaten ausgeben möchten"
    106 
    107 msgid "Is your account properly connected and the syncronization completed, you can switch to the Appearance -> Widget page"
    108 msgstr "Ist die Freigabe der Facebook Seiten und die Synchronisierung erfolgreich abgeschlossen, können Sie zum Abschnitt Design -> Widgets wechseln."
    109 
    110 msgid "To display the content on your front page, move the widget %s into a desired widget area"
    111 msgstr "Um den Inhalt des Widgets auf der Frontseite darzustellen, schieben Sie das widget %s in eine Bereich Ihrer Wahl"
    112 
    113 msgid "Finally save the widget settings and check the output on the front page"
    114 msgstr "Abschließend erfolgt das Speichern der gewünschten Widget Einstellung und die Sichtung der Frontseite"
    115 
    116 msgid "If you prefer to use %s, the below options are available"
    117 msgstr "Falls Sie den Einsatz von %s bevorzugen, stehen Ihnen nachfolgende Optionen zur Verfügung"
    118 
    119 msgid "Currently you are using our Facebook App to gather necessary page information"
    120 msgstr "Aktuell verwenden Sie unsere Facebook App um Seiteninformationen zu laden"
    121 
    122 msgid "Use my Facebook App"
    123 msgstr "Verwende meine Facebook App"
    124 
    125 msgid "Build your own %s or use our service gateway"
    126 msgstr "Erstelle Sie Ihre eigene %s oder verwenden Sie unseren externen Dienst"
    127 
    128 msgid "Dependent on details given in the '%s' you get asked to connect your Facebook Account with the following app"
    129 msgstr "Abhängig von den Angaben in '%s' werden Sie aufgefordert Ihr Facebook Konto mit nachstehender app zu verbinden"
     95msgid "Optionally you can also use shortcodes to displav the related information from Facebook (E.g. Business hours, About Us or the last posts)"
     96msgstr "Alternativ können auch Shortcodes verwendet werden um die erforderlichen Informationen aus Facebook darzustellen (z.B. Öffnungszeiten, Über uns oder die letzten Beiträge) "
    13097
    13198msgid "Some information has been updated on Facebook"
     
    134101msgid "Facebook page not found or no access"
    135102msgstr "Facebook Seite nicht gefunden oder kein Zugriff"
     103
     104msgid "Navigate to Appearance -> Widgets and configure the %s widget as desired"
     105msgstr "Navigiere zu Design -> Widgets und konfiguriere das %s Widget wie gewünscht"
  • social-page-metadata/tags/1.1.0/readme.txt

    r2648243 r2649162  
    33Tags: facebook, show, page info, meta data
    44Requires at least: 5.0
    5 Tested up to: 5.7
     5Tested up to: 5.8
    66Requires PHP: 7.0
    7 Stable tag: 1.0.8
     7Stable tag: 1.1.0
    88License: GPLv3
    99
     
    1212== Description ==
    1313
    14 Display meta information from the social network "Facebook" using either a widget or as shortcode.
     14Display meta information from the social network "Facebook" using either a widget or shortcode.
    1515Currently supported meta information which can be gathered are:
    1616
     
    2727**Quick Guide**
    2828
    29 To sychronize and output meta information (E.g. Business hours, About Us, last posts) from facebook pages.
     29To sychronize and output meta information (E.g. Business hours, About Us, last posts) from facebook pages, follow the below steps:
    3030
    31 1. Use the button Login and Sync (left side) to connect your facebook account with the Cloud 86 / Link Page application
    32 2. Once successfully logged into your facebook account, choose the pages you wish to output metadata for
    33 3. Is your account properly connected and the syncronization completed, you can switch to the Appearance -> Widget page
    34 4. To display the content on your front page, move the widget Facebook page info Widget into a desired widget area
    35 5. Finally save the widget settings and check the output on the front page
     311. Register as Facebook Developer and create a new [Facebook App](https://developers.facebook.com/apps/)
     322. Fill in the Facebook App ID and App secret from the app you just created into the Social Plugin (Menu "Tool" -> "Social Plugin - Metadata")
     333. Use the "Login and Sync" button to connect your facebook account with your Facebook App
     344. Switch to the Appearance -> Widget page once successfully logged in and pick the "Social Plugin - Metadata"
     355. Setup the widget for the page and content you want to display on frontend
    3636
    3737**Shortcodes**
     
    3939If you prefer to use Shortcodes, the below options are available
    4040
    41 [fb-pageinfo-businesshours page_id="..." empty_message=""]
    42 [fb-pageinfo-about page_id="..." empty_message=""]
    43 [fb-pageinfo-lastpost page_id="..." limit="..." max_age="..." empty_message=""]
     41[social-businesshours page_id="..." empty_message=""]
     42[social-about page_id="..." empty_message=""]
     43[social-lastpost page_id="..." limit="..." max_age="..." empty_message=""]
    4444
    4545== Screenshots ==
  • social-page-metadata/tags/1.1.0/scripts/init.js

    r2497278 r2649162  
    1717    };
    1818
    19     this.fbCheckAppDomain = function() {
    20         jQuery.post(social_plugin.gatewayurl, { action: 'fb_check_domain', domain: document.location.hostname})
    21             .done(function(response){
    22                 if (response) {
    23                     jQuery('#fb-gateway-register-container').hide();
    24                 } else {
    25                     jQuery('#fb-gateway-register-container').show();
    26                 }
    27             }).catch(function(e) {
    28                 AlertMessage('error', 'Unable to register the domain ' +  document.location.hostname);
    29             });
    30     }
     19    this.fbSaveAppdata = function(e) {
     20        e.preventDefault();
    3121
    32     this.fbRegisterAppDomain = function() {
    33         jQuery.post(social_plugin.gatewayurl, { action: 'fb_register_domain', domain: document.location.hostname})
    34             .done(function(response){
    35                 AlertMessage('updated', 'Domain ' + document.location.hostname + ' successfully registered');
    36                 jQuery('#fb-gateway-register-container').hide();
    37             }).catch(function(e) {
    38                 AlertMessage('error', 'Unable to register the domain ' +  document.location.hostname);
    39             });
    40     }
    41 
    42     this.fbSaveAppdata = function() {
    4322        AlertMessage('', 'Updating info...');
    4423
    45         var appId = jQuery('#fbAppId').val();
    46         var appSecret = jQuery('#fbAppSecret').val();
    47         var isPublic = jQuery('#fbIsPublic').is(':checked') ? 1 : 0;
     24        var formData = new FormData(e.target);
    4825
    49         jQuery.post(social_plugin.ajaxurl, { action: 'fb_save_appdata', appId, appSecret, isPublic})
    50         .done(function(response) {
     26        fetch(social_plugin.ajaxurl + '?action=fb_save_appdata', {
     27            method: 'POST',
     28            body: formData
     29        }).then(function() {
    5130            document.location.reload();
    5231        }).catch(function(e) {
    5332            AlertMessage('error', 'We encountered an error. Please try again later...');
    5433        });
     34
     35        return false;
    5536    }
    5637
    5738    this.fbSavePages = function(data) {
    58         AlertMessage('', 'Saving data received from ' + (social_plugin.use_gateway ? 'remote' : 'local') + ' gateway ...');
     39        AlertMessage('', 'Saving data...');
    5940   
    6041        jQuery.post(social_plugin.ajaxurl, { action: 'fb_save_pages', data })
     
    7657                response.authResponse.accessToken;
    7758   
    78                 jQuery.post(social_plugin.gatewayurl, { action: 'fb_get_pages', userID: response.authResponse.userID, token: response.authResponse.accessToken})
     59                jQuery.post(social_plugin.ajaxurl, { action: 'fb_get_pages', userID: response.authResponse.userID, token: response.authResponse.accessToken})
    7960                .done(function(response){
    8061                    self.fbSavePages(response.data);
    8162                }).catch(function(e) {
    82                     var url = new URL(social_plugin.gatewayurl);
    83                     AlertMessage('error', 'Something went wrong contacting ' + url.hostname + ': ' + e.responseJSON.error.message);
     63                    AlertMessage('error', 'Something went wrong: ' + e.responseJSON.error.message);
    8464                });
    8565            }
     
    11494        loadFB();
    11595        jQuery('#fb-gateway-login').click(self.fbLogin);
    116         jQuery('#fb-gateway-register').click(self.fbRegisterAppDomain);
    11796
    118         jQuery('#fb-appdata-save').click(self.fbSaveAppdata);
     97        document.getElementById('fb-configure-app').onsubmit = self.fbSaveAppdata;
    11998
    12099        jQuery('#fb-gateway-change').click(self.showCustomAppOptions);
     
    122101        var fbAppId = jQuery('#fbAppId').val();
    123102
    124         if (!fbAppId) {
    125             jQuery('#fb-gateway-custom').hide();
    126         } else {
    127             jQuery('#fb-gateway-custom').show();
    128             jQuery('#fb-gateway-our').hide();
     103        if (fbAppId) {
     104            jQuery('#fb-login-app').show();
    129105        }
    130 
    131         self.fbCheckAppDomain();
    132106    })();
    133107}
  • social-page-metadata/tags/1.1.0/social-plugin-metadata.php

    r2648243 r2649162  
    11<?php
     2namespace Cloud86\WP\Social;
     3
     4use Cloud86\WP\Social\Model\FacebookRestApi;
     5
    26/**
    37 * Plugin Name: Social Plugin - Metadata
    48 * Description: Used to display Facebook related page meta information as widget or shortcode (E.g. Business hours, About Us, Last Post)
    5  * Version: 1.0.8
    6  * Requires at least: 5.0
    7  * Requires PHP: 7.0
     9 * Version: 1.1.0
    810 * Author:      ole1986
    911 * License: MIT <https://raw.githubusercontent.com/Cloud-86/social-plugin-metadata/master/LICENSE>
     
    1618defined('ABSPATH') or die('No script kiddies please!');
    1719
    18 require_once 'gateway/interfaces/IFacebookGatewayHost.php';
    19 require_once 'gateway/gateway.php';
     20require_once 'model/facebook-rest-api.php';
    2021require_once 'widget.php';
    2122
    22 class Ole1986_FacebokPageInfo implements Ole1986_IFacebookGatewayHost
     23class SocialPlugin extends FacebookRestApi
    2324{
    2425    /**
     
    2627     */
    2728    static $CACHE_EXPIRATION = 60 * 5;
    28 
    29     static $DEFAULT_APP_ID = "475478070525107";
    30     static $SP_GATEWAY_URL = "https://www.cloud86.de/wp-admin/admin-ajax.php";
    3129
    3230    /**
     
    3735    static $WP_OPTION_APPID = 'social_plugin_fb_app_id';
    3836    static $WP_OPTION_APPSECRET = 'social_plugin_fb_app_secret';
    39     static $WP_OPTION_ISPUBLIC = 'social_plugin_api_public';
    4037
    4138    /**
    4239     * The unique instance of the plugin.
    4340     *
    44      * @var Ole1986_FacebokPageInfo
     41     * @var SocialPlugin
    4542     */
    4643    private static $instance;
     
    4946     * Gets an instance of our plugin.
    5047     *
    51      * @return Ole1986_FacebokPageInfo
     48     * @return SocialPlugin
    5249     */
    5350    public static function get_instance()
     
    6562    {
    6663        load_plugin_textdomain('social-plugin-metadata', false, dirname(plugin_basename(__FILE__)) . '/lang/');
     64
     65        parent::__construct();
    6766
    6867        // load scripts and styles for frontend
     
    7271
    7372        add_action('widgets_init', function () {
    74             register_widget('Ole1986_FacebokPageInfoWidget');
     73            register_widget('Cloud86\WP\Social\SocialPluginWidget');
    7574        });
    7675
     
    8281        add_action('wp_ajax_fb_save_appdata', [$this, 'fb_save_appdata']);
    8382
    84         // initialize the facebook for private use
    85         if (!empty($this->getAppSecret())) {
    86             new Ole1986_FacebookGateway($this, $this->isPublic());
    87         }
    88 
    8983        $this->registerShortcodes();
    9084    }
     
    10195            wp_localize_script('social_plugin', 'social_plugin', [
    10296                'ajaxurl' => admin_url('admin-ajax.php'),
    103                 'gatewayurl' => empty($this->getAppSecret()) ? self::$SP_GATEWAY_URL : admin_url('admin-ajax.php'),
    104                 "use_gateway" => $this->useGateway(),
    10597                'app_id' => $this->getAppID()
    10698            ]);   
     
    112104    public function getAppID()
    113105    {
    114         return get_option(self::$WP_OPTION_APPID, self::$DEFAULT_APP_ID);
     106        return get_option(self::$WP_OPTION_APPID);
    115107    }
    116108
     
    120112    }
    121113
    122     public function useGateway()
    123     {
    124         return empty($this->getAppSecret) ? 1 : 0;
    125     }
    126 
    127     public function isPublic()
    128     {
    129         return get_option(self::$WP_OPTION_ISPUBLIC, 0);
    130     }
    131 
    132114    private function registerShortcodes()
    133115    {
    134         // [fb-pageinfo-businesshours page_id="<page>"]
    135         add_shortcode('fb-pageinfo-businesshours', function ($atts, $content, $tag) {
     116        // [social-businesshours page_id="<page>"]
     117        add_shortcode('social-businesshours', function ($atts, $content, $tag) {
    136118            return $this->shortcodeCallback('BusinessHours', $atts, $content, $tag);
    137119        });
    138120
    139         // [fb-pageinfo-about page_id="<page>"]
    140         add_shortcode('fb-pageinfo-about', function ($atts, $content, $tag) {
     121        // [social-about page_id="<page>"]
     122        add_shortcode('social-about', function ($atts, $content, $tag) {
    141123            return $this->shortcodeCallback('About', $atts, $content, $tag);
    142124        });
    143125
    144         // [fb-pageinfo-lastpost page_id="<page>"]
    145         add_shortcode('fb-pageinfo-lastpost', function ($atts, $content, $tag) {
     126        // [social-lastpost page_id="<page>"]
     127        add_shortcode('social-lastpost', function ($atts, $content, $tag) {
    146128            return $this->shortcodeCallback('LastPost', $atts, $content, $tag);
    147129        });
     
    313295
    314296        if (isset($options['max_age'])) {
    315             $now = new DateTime();
     297            $now = new \DateTime();
    316298            $page['data'] = array_filter($page['data'] ?? [], function ($p) use ($now, $options) {
    317                 $d = new DateTime($p['created_time']);
     299                $d = new \DateTime($p['created_time']);
    318300                $diff = ($now->getTimestamp() - $d->getTimestamp()) / 60;
    319301
     
    337319
    338320        foreach ($page['data'] as $lastPost) {
    339             $created = new DateTime($lastPost['created_time']);
    340             $now = new DateTime();
     321            $created = new \DateTime($lastPost['created_time']);
     322            $now = new \DateTime();
    341323
    342324            if (!isset($lastPost['message'])) {
     
    390372    }
    391373
    392     public function fbGraphRequest($url, $doPost = false)
    393     {
    394         $path = 'https://graph.facebook.com/';
    395 
    396         if ($doPost) {
    397             $resp = wp_remote_post($path . $url);
    398         } else {
    399             $resp = wp_remote_get($path . $url);
    400         }
    401 
    402         if ($resp instanceof \WP_Error) {
    403             return [];
    404         }
    405        
    406         return json_decode($resp['body'], true);
    407     }
    408 
    409374    public function fb_get_page_options()
    410375    {
     
    416381
    417382        array_walk($result, function (&$v) {
    418             $v['access_token'] = '(hidden)';
     383            $v['access_token'] = '***' . substr($v['access_token'], -10);
    419384        });
    420385
     
    447412    public function fb_save_appdata()
    448413    {
    449         $appId = sanitize_key($_POST['appId']);
    450         $appSecret = sanitize_key($_POST['appSecret']);
    451         $isPublic = sanitize_key($_POST['isPublic']);
     414        $appId = sanitize_key($_POST['app_id']);
     415        $appSecret = sanitize_key($_POST['app_secret']);
    452416
    453417
     
    464428        }
    465429
    466         if (empty($isPublic)) {
    467             delete_option(self::$WP_OPTION_ISPUBLIC);
    468         } else {
    469             update_option(self::$WP_OPTION_ISPUBLIC, 1);
    470         }
    471 
    472430        header('Content-Type: application/json');
    473431        echo json_encode(true);
     
    511469    public function settings_page_content()
    512470    {
    513         $pages = get_option(self::$WP_OPTION_PAGES, []);
     471        $plugin_data = get_plugin_data(__FILE__);
     472        $plugin_version = $plugin_data['Version'];
     473
    514474        ?>
    515475        <h2><?php _e('Social Plugin - Metadata', 'social-plugin-metadata') ?></h2>
     
    519479        <div style="display: flex;  flex-wrap: wrap">
    520480            <div id="fb-gateway-frame" style="margin: 1em; flex-basis: 375px;">
    521                 <h3><?php _e('Connect with Facebook', 'social-plugin-metadata') ?></h3>
    522                 <div hidden id="fb-gateway-register-container">
    523                     <p>
    524                         <?php _e('Please register your domain first before using the Facebook App', 'social-plugin-metadata') ?>
    525                     </p>
    526                     <button id="fb-gateway-register" class="button button-primary hide-if-no-js">Register domain</button>
    527                 </div>
    528                 <div id="fb-gateway-container">
    529                     <p>
    530                         <?php _e('Please use the below Login & Sync button to synchronize the facebook pages', 'social-plugin-metadata') ?>
    531                     </p>
    532                     <button id="fb-gateway-login" class="button hide-if-no-js">Login and Sync</button>
    533                 </div>
    534                 <div style="margin-top: 1em"> 
    535                     <h3><?php _e('Setup your Facebook App (optional)', 'social-plugin-metadata') ?></h3>
    536                     <div id="fb-gateway-custom" hidden>
    537                         <p><?php printf(__('Build your own %s or use our service gateway', 'social-plugin-metadata'), '<a href="https://developers.facebook.com/apps/" target="_blank">Facebook App</a>') ?></p>
     481                <form method="POST" id="fb-configure-app" style="margin-top: 1em"> 
     482                    <h3><?php _e('Setup your Facebook App', 'social-plugin-metadata') ?></h3>
     483                    <div id="fb-gateway-custom">
     484                        <p><?php printf(__('Build your own %s and configure the APP ID as well as the APP KEY here', 'social-plugin-metadata'), '<a href="https://developers.facebook.com/apps/" target="_blank">Facebook App</a>') ?></p>
    538485                        <div>
    539                             <label>Facebook App ID (standalone / optional)</label><br />
    540                             <input class="widefat" type="text" autocomplete="off" id="fbAppId" value="<?php echo get_option(self::$WP_OPTION_APPID, '') ?>" />
     486                            <label>Facebook App ID</label><br />
     487                            <input class="widefat" type="text" name="app_id" autocomplete="off" id="fbAppId" value="<?php echo get_option(self::$WP_OPTION_APPID, '') ?>" />
    541488                        </div>
    542489                        <div style="margin-top: 0.5em">
    543                             <label>Facebook App Secret (standalone / optional)</label><br />
    544                             <input class="widefat" type="password" autocomplete="new-password" id="fbAppSecret" />
    545                         </div>
    546                         <div style="margin-top: 0.5em">
    547                             <label><input type="checkbox" id="fbIsPublic"  <?php echo $this->isPublic() ? 'checked' : '' ?> /> Make API publicly available</label>
     490                            <label>Facebook App Secret</label><br />
     491                            <input class="widefat" type="password" name="app_secret" autocomplete="new-password" id="fbAppSecret" />
    548492                        </div>
    549493                        <div style="margin-top: 1em">
    550                             <button id="fb-appdata-save" class="button hide-if-no-js">Save</button>
     494                            <button id="fb-appdata-save" type="submit" class="button hide-if-no-js">Save</button>
    551495                        </div>
    552496                    </div>
    553                     <div id="fb-gateway-our">
    554                         <div><?php _e('Currently you are using our Facebook App to gather necessary page information', 'social-plugin-metadata') ?></div>
    555                         <div style="margin-top: 1em">
    556                             <button id="fb-gateway-change" class="button hide-if-no-js"><?php _e('Use my Facebook App', 'social-plugin-metadata') ?></button>
    557                         </div>
     497                </form>
     498                <div id="fb-login-app" style="margin-top: 1em" hidden>
     499                    <h3><?php _e('Connect with Facebook', 'social-plugin-metadata') ?></h3>
     500                    <div id="fb-gateway-container">
     501                        <p>
     502                            <?php _e('Please use the below Login & Sync button to synchronize the facebook pages', 'social-plugin-metadata') ?>
     503                        </p>
     504                        <button id="fb-gateway-login" class="button hide-if-no-js">Login and Sync</button>
    558505                    </div>
    559506                </div>
    560507            </div>
    561508            <div style="margin: 1em; flex-basis: 375px; flex-grow: 1">
    562                 <h3><?php _e('Quick Guide', 'social-plugin-metadata') ?></h3>
    563                 <p><?php _e('To sychronize and outpout meta information (E.g. Business hours, About Us, last posts) from facebook pages', 'social-plugin-metadata') ?>.</p>
     509                <h3><?php _e('Widgets', 'social-plugin-metadata') ?></h3>
     510                <p><?php echo sprintf(__('Navigate to Appearance -> Widgets and configure the %s widget as desired', 'social-plugin-metadata'), __('Social Plugin - Metadata', 'social-plugin-metadata')) ?>.</p>
     511                <h3><?php _e('Shortcodes', 'social-plugin-metadata') ?></h3>
     512                <p><?php _e('Optionally you can also use shortcodes to displav the related information from Facebook (E.g. Business hours, About Us or the last posts)', 'social-plugin-metadata') ?>.</p>
    564513                <div style="font-family: monospace">
    565                     <ol>
    566                         <li>
    567                             <?php _e('Use the button Login and Sync (left side) to connect your facebook account with the Facebook App', 'social-plugin-metadata') ?><br />
    568                             <strong><?php printf(__("Dependent on details given in the '%s' you get asked to connect your Facebook Account with the following app", 'social-plugin-metadata'), __('Setup your Facebook App (optional)', 'social-plugin-metadata')) ?></strong>
    569                             <ul style="list-style: inside">
    570                                 <li>our Facebook App "Cloud 86 / Link Page"</li>
    571                                 <li>your own Facebook app</li>
    572                             </ul>
    573                         </li>
    574                         <li><?php _e('Once successfully logged into your facebook account, choose the pages you wish to output metadata for', 'social-plugin-metadata') ?></li>
    575                         <li><?php _e('Is your account properly connected and the syncronization completed, you can switch to the Appearance -> Widget page', 'social-plugin-metadata') ?></li>
    576                         <li><?php printf(__('To display the content on your front page, move the widget %s into a desired widget area', 'social-plugin-metadata'), __('Social plugin - Metadata Widget', 'social-plugin-metadata')) ?></li>
    577                         <li><?php _e('Finally save the widget settings and check the output on the front page', 'social-plugin-metadata') ?></li>
    578                     </ol>
    579                     <h4>Shortcodes</h4>
    580514                    <div>
    581                         <?php printf(__('If you prefer to use %s, the below options are available', 'social-plugin-metadata'), '<a href="https://wordpress.com/de/support/wordpress-editor/bloecke/shortcode-block/" target="_blank">Shortcodes</a>') ?>
    582515                        <ul>
    583                             <li>[fb-pageinfo-businesshours page_id="..." empty_message=""]</li>
    584                             <li>[fb-pageinfo-about page_id="..." empty_message=""]</li>
    585                             <li>[fb-pageinfo-lastpost page_id="..." limit="..." max_age="..." empty_message=""]</li>
     516                            <li>[social-businesshours page_id="..." empty_message=""]</li>
     517                            <li>[social-about page_id="..." empty_message=""]</li>
     518                            <li>[social-lastpost page_id="..." limit="..." max_age="..." empty_message=""]</li>
    586519                        </ul>
    587520                    </div>
    588521                </div>
    589                 <h2>Rechtliche Hinweise</h2>
     522                <h2>Legal Notices</h2>
    590523                <p>
    591                     <strong>Cloud 86 selbst speichert keine Facebook Daten. <br />Es werden ausschließlich technisch erforderliche Informationen zur Darstellung der Metadaten AUF DIESEM SERVER (<?php echo $_SERVER['HTTP_HOST'] ?>) abgelegt</strong>
     524                    <strong>This plugin does not save any facebook data. <br />All necessary information will be stored on this server (<?php echo $_SERVER['HTTP_HOST'] ?>)</strong>
    592525                </p>
    593526                <div id="rawdata" style="font-family: monospace; white-space: pre; background-color: white; padding: 1em;">
    594                     <a href="javascript:void(0)" onclick="SocialPlugin.fbRawPages()">DATEN ANZEIGEN</a>
     527<a href="javascript:void(0)" onclick="SocialPlugin.fbRawPages()">SHOW DATA</a>
    595528                </div>
    596                 <p>WEITER INFORMATIONEN ZUM DATENSCHUTZ FINDEN SIE <a href="https://www.cloud86.de/datenschutzerklaerung" target="_blank">HIER</a></p>
     529                <p>Futhermore the data protection policy from facebook applies for the given Facebook App</p>
    597530            </div>
    598531        </div>
     532        <div><small><?php _e('Social Plugin - Metadata', 'social-plugin-metadata') ?> Version: <?php echo $plugin_version ?></small></div>
    599533        <?php
    600534    }
    601535}
    602536
    603 Ole1986_FacebokPageInfo::get_instance();
    604 
     537SocialPlugin::get_instance();
    605538?>
  • social-page-metadata/tags/1.1.0/widget.php

    r2575935 r2649162  
    11<?php
     2namespace Cloud86\WP\Social;
     3
    24/**
    35 * The Facebook page info Widget used to display in sidebars or footer bars (dependent on the theme)
    46 */
    57
    6 class Ole1986_FacebokPageInfoWidget extends WP_Widget
     8class SocialPluginWidget extends \WP_Widget
    79{
    810    /**
     
    3638        $this->parseSettings($instance);
    3739
    38         $pages = get_option(Ole1986_FacebokPageInfo::$WP_OPTION_PAGES, []);
     40        $pages = get_option(SocialPlugin::$WP_OPTION_PAGES, []);
    3941
    4042        $filteredPages = array_filter(
     
    4749        $currentPage = array_pop($filteredPages);
    4850
    49         $result = Ole1986_FacebokPageInfo::get_instance()->processContentFromOption($currentPage, $this->option, $this->options);
     51        $result = SocialPlugin::get_instance()->processContentFromOption($currentPage, $this->option, $this->options);
    5052       
    5153        // before and after widget arguments are defined by themes
     
    6163                    <?php
    6264                    if (!empty($this->option)) {
    63                         Ole1986_FacebokPageInfo::get_instance()->{'show' . $this->option}($result, $this->options);
     65                        SocialPlugin::get_instance()->{'show' . $this->option}($result, $this->options);
    6466                    } else {
    6567                        echo "<div><small>No option given for ". __('Facebook page info Widget', 'social-plugin-metadata') ."<small></div>";
     
    9193    {
    9294        $this->parseSettings($instance);
    93         $pages = get_option(Ole1986_FacebokPageInfo::$WP_OPTION_PAGES, []);
     95        $pages = get_option(SocialPlugin::$WP_OPTION_PAGES, []);
    9496        ?>
    9597        <div class="social-widget-metadata-widget">
  • social-page-metadata/trunk/lang/social-plugin-metadata-de_DE.po

    r2648243 r2649162  
    2828
    2929msgid "Please use the below Login & Sync button to synchronize the facebook pages"
    30 msgstr "Bitte verwende den unten dargestellten Knopf um mit der Synchronisierung deiner Facebook Seiten zu beginnen"
     30msgstr "Bitte verwende die unten dargestellte Schaltfläche um die  Facebook Seiten zu synchronisieren"
    3131
    3232msgid "Please register your domain first before using the Facebook App"
     
    9090msgstr "Mit Facebook verbinden"
    9191
    92 msgid "Setup your Facebook App (optional)"
    93 msgstr "Konfiguriere deine Facebook App (optional)"
     92msgid "Build your own %s and configure the APP ID as well as the APP KEY here"
     93msgstr "Erstelle eine eigene %s und konfiguriere die APP ID sowie den APP KEY hier"
    9494
    95 msgid "Quick Guide"
    96 msgstr "Kurzanleitung"
    97 
    98 msgid "To sychronize and outpout meta information (E.g. Business hours, About Us, last posts) from facebook pages"
    99 msgstr "Zur Syncronisierung und Ausgabe von Metadaten (Öffnungszeiten, Titel, Beschreibung, Letzte Beiträge) aus Facebook Seiten"
    100 
    101 msgid "Use the button Login and Sync (left side) to connect your facebook account with the Facebook App"
    102 msgstr "Verwenden Sie den Knopf Login and Sync (Links) um Ihr Facebook Konto mit der facebook App zu verbinden"
    103 
    104 msgid "Once successfully logged into your facebook account, choose the pages you wish to output metadata for"
    105 msgstr "Nach erfolgreicher Facebook Anmeldung wählen Sie die gewünschten Seiten aus für die Sie Metadaten ausgeben möchten"
    106 
    107 msgid "Is your account properly connected and the syncronization completed, you can switch to the Appearance -> Widget page"
    108 msgstr "Ist die Freigabe der Facebook Seiten und die Synchronisierung erfolgreich abgeschlossen, können Sie zum Abschnitt Design -> Widgets wechseln."
    109 
    110 msgid "To display the content on your front page, move the widget %s into a desired widget area"
    111 msgstr "Um den Inhalt des Widgets auf der Frontseite darzustellen, schieben Sie das widget %s in eine Bereich Ihrer Wahl"
    112 
    113 msgid "Finally save the widget settings and check the output on the front page"
    114 msgstr "Abschließend erfolgt das Speichern der gewünschten Widget Einstellung und die Sichtung der Frontseite"
    115 
    116 msgid "If you prefer to use %s, the below options are available"
    117 msgstr "Falls Sie den Einsatz von %s bevorzugen, stehen Ihnen nachfolgende Optionen zur Verfügung"
    118 
    119 msgid "Currently you are using our Facebook App to gather necessary page information"
    120 msgstr "Aktuell verwenden Sie unsere Facebook App um Seiteninformationen zu laden"
    121 
    122 msgid "Use my Facebook App"
    123 msgstr "Verwende meine Facebook App"
    124 
    125 msgid "Build your own %s or use our service gateway"
    126 msgstr "Erstelle Sie Ihre eigene %s oder verwenden Sie unseren externen Dienst"
    127 
    128 msgid "Dependent on details given in the '%s' you get asked to connect your Facebook Account with the following app"
    129 msgstr "Abhängig von den Angaben in '%s' werden Sie aufgefordert Ihr Facebook Konto mit nachstehender app zu verbinden"
     95msgid "Optionally you can also use shortcodes to displav the related information from Facebook (E.g. Business hours, About Us or the last posts)"
     96msgstr "Alternativ können auch Shortcodes verwendet werden um die erforderlichen Informationen aus Facebook darzustellen (z.B. Öffnungszeiten, Über uns oder die letzten Beiträge) "
    13097
    13198msgid "Some information has been updated on Facebook"
     
    134101msgid "Facebook page not found or no access"
    135102msgstr "Facebook Seite nicht gefunden oder kein Zugriff"
     103
     104msgid "Navigate to Appearance -> Widgets and configure the %s widget as desired"
     105msgstr "Navigiere zu Design -> Widgets und konfiguriere das %s Widget wie gewünscht"
  • social-page-metadata/trunk/readme.txt

    r2648243 r2649162  
    33Tags: facebook, show, page info, meta data
    44Requires at least: 5.0
    5 Tested up to: 5.7
     5Tested up to: 5.8
    66Requires PHP: 7.0
    7 Stable tag: 1.0.8
     7Stable tag: 1.1.0
    88License: GPLv3
    99
     
    1212== Description ==
    1313
    14 Display meta information from the social network "Facebook" using either a widget or as shortcode.
     14Display meta information from the social network "Facebook" using either a widget or shortcode.
    1515Currently supported meta information which can be gathered are:
    1616
     
    2727**Quick Guide**
    2828
    29 To sychronize and output meta information (E.g. Business hours, About Us, last posts) from facebook pages.
     29To sychronize and output meta information (E.g. Business hours, About Us, last posts) from facebook pages, follow the below steps:
    3030
    31 1. Use the button Login and Sync (left side) to connect your facebook account with the Cloud 86 / Link Page application
    32 2. Once successfully logged into your facebook account, choose the pages you wish to output metadata for
    33 3. Is your account properly connected and the syncronization completed, you can switch to the Appearance -> Widget page
    34 4. To display the content on your front page, move the widget Facebook page info Widget into a desired widget area
    35 5. Finally save the widget settings and check the output on the front page
     311. Register as Facebook Developer and create a new [Facebook App](https://developers.facebook.com/apps/)
     322. Fill in the Facebook App ID and App secret from the app you just created into the Social Plugin (Menu "Tool" -> "Social Plugin - Metadata")
     333. Use the "Login and Sync" button to connect your facebook account with your Facebook App
     344. Switch to the Appearance -> Widget page once successfully logged in and pick the "Social Plugin - Metadata"
     355. Setup the widget for the page and content you want to display on frontend
    3636
    3737**Shortcodes**
     
    3939If you prefer to use Shortcodes, the below options are available
    4040
    41 [fb-pageinfo-businesshours page_id="..." empty_message=""]
    42 [fb-pageinfo-about page_id="..." empty_message=""]
    43 [fb-pageinfo-lastpost page_id="..." limit="..." max_age="..." empty_message=""]
     41[social-businesshours page_id="..." empty_message=""]
     42[social-about page_id="..." empty_message=""]
     43[social-lastpost page_id="..." limit="..." max_age="..." empty_message=""]
    4444
    4545== Screenshots ==
  • social-page-metadata/trunk/scripts/init.js

    r2497278 r2649162  
    1717    };
    1818
    19     this.fbCheckAppDomain = function() {
    20         jQuery.post(social_plugin.gatewayurl, { action: 'fb_check_domain', domain: document.location.hostname})
    21             .done(function(response){
    22                 if (response) {
    23                     jQuery('#fb-gateway-register-container').hide();
    24                 } else {
    25                     jQuery('#fb-gateway-register-container').show();
    26                 }
    27             }).catch(function(e) {
    28                 AlertMessage('error', 'Unable to register the domain ' +  document.location.hostname);
    29             });
    30     }
     19    this.fbSaveAppdata = function(e) {
     20        e.preventDefault();
    3121
    32     this.fbRegisterAppDomain = function() {
    33         jQuery.post(social_plugin.gatewayurl, { action: 'fb_register_domain', domain: document.location.hostname})
    34             .done(function(response){
    35                 AlertMessage('updated', 'Domain ' + document.location.hostname + ' successfully registered');
    36                 jQuery('#fb-gateway-register-container').hide();
    37             }).catch(function(e) {
    38                 AlertMessage('error', 'Unable to register the domain ' +  document.location.hostname);
    39             });
    40     }
    41 
    42     this.fbSaveAppdata = function() {
    4322        AlertMessage('', 'Updating info...');
    4423
    45         var appId = jQuery('#fbAppId').val();
    46         var appSecret = jQuery('#fbAppSecret').val();
    47         var isPublic = jQuery('#fbIsPublic').is(':checked') ? 1 : 0;
     24        var formData = new FormData(e.target);
    4825
    49         jQuery.post(social_plugin.ajaxurl, { action: 'fb_save_appdata', appId, appSecret, isPublic})
    50         .done(function(response) {
     26        fetch(social_plugin.ajaxurl + '?action=fb_save_appdata', {
     27            method: 'POST',
     28            body: formData
     29        }).then(function() {
    5130            document.location.reload();
    5231        }).catch(function(e) {
    5332            AlertMessage('error', 'We encountered an error. Please try again later...');
    5433        });
     34
     35        return false;
    5536    }
    5637
    5738    this.fbSavePages = function(data) {
    58         AlertMessage('', 'Saving data received from ' + (social_plugin.use_gateway ? 'remote' : 'local') + ' gateway ...');
     39        AlertMessage('', 'Saving data...');
    5940   
    6041        jQuery.post(social_plugin.ajaxurl, { action: 'fb_save_pages', data })
     
    7657                response.authResponse.accessToken;
    7758   
    78                 jQuery.post(social_plugin.gatewayurl, { action: 'fb_get_pages', userID: response.authResponse.userID, token: response.authResponse.accessToken})
     59                jQuery.post(social_plugin.ajaxurl, { action: 'fb_get_pages', userID: response.authResponse.userID, token: response.authResponse.accessToken})
    7960                .done(function(response){
    8061                    self.fbSavePages(response.data);
    8162                }).catch(function(e) {
    82                     var url = new URL(social_plugin.gatewayurl);
    83                     AlertMessage('error', 'Something went wrong contacting ' + url.hostname + ': ' + e.responseJSON.error.message);
     63                    AlertMessage('error', 'Something went wrong: ' + e.responseJSON.error.message);
    8464                });
    8565            }
     
    11494        loadFB();
    11595        jQuery('#fb-gateway-login').click(self.fbLogin);
    116         jQuery('#fb-gateway-register').click(self.fbRegisterAppDomain);
    11796
    118         jQuery('#fb-appdata-save').click(self.fbSaveAppdata);
     97        document.getElementById('fb-configure-app').onsubmit = self.fbSaveAppdata;
    11998
    12099        jQuery('#fb-gateway-change').click(self.showCustomAppOptions);
     
    122101        var fbAppId = jQuery('#fbAppId').val();
    123102
    124         if (!fbAppId) {
    125             jQuery('#fb-gateway-custom').hide();
    126         } else {
    127             jQuery('#fb-gateway-custom').show();
    128             jQuery('#fb-gateway-our').hide();
     103        if (fbAppId) {
     104            jQuery('#fb-login-app').show();
    129105        }
    130 
    131         self.fbCheckAppDomain();
    132106    })();
    133107}
  • social-page-metadata/trunk/social-plugin-metadata.php

    r2648243 r2649162  
    11<?php
     2namespace Cloud86\WP\Social;
     3
     4use Cloud86\WP\Social\Model\FacebookRestApi;
     5
    26/**
    37 * Plugin Name: Social Plugin - Metadata
    48 * Description: Used to display Facebook related page meta information as widget or shortcode (E.g. Business hours, About Us, Last Post)
    5  * Version: 1.0.8
    6  * Requires at least: 5.0
    7  * Requires PHP: 7.0
     9 * Version: 1.1.0
    810 * Author:      ole1986
    911 * License: MIT <https://raw.githubusercontent.com/Cloud-86/social-plugin-metadata/master/LICENSE>
     
    1618defined('ABSPATH') or die('No script kiddies please!');
    1719
    18 require_once 'gateway/interfaces/IFacebookGatewayHost.php';
    19 require_once 'gateway/gateway.php';
     20require_once 'model/facebook-rest-api.php';
    2021require_once 'widget.php';
    2122
    22 class Ole1986_FacebokPageInfo implements Ole1986_IFacebookGatewayHost
     23class SocialPlugin extends FacebookRestApi
    2324{
    2425    /**
     
    2627     */
    2728    static $CACHE_EXPIRATION = 60 * 5;
    28 
    29     static $DEFAULT_APP_ID = "475478070525107";
    30     static $SP_GATEWAY_URL = "https://www.cloud86.de/wp-admin/admin-ajax.php";
    3129
    3230    /**
     
    3735    static $WP_OPTION_APPID = 'social_plugin_fb_app_id';
    3836    static $WP_OPTION_APPSECRET = 'social_plugin_fb_app_secret';
    39     static $WP_OPTION_ISPUBLIC = 'social_plugin_api_public';
    4037
    4138    /**
    4239     * The unique instance of the plugin.
    4340     *
    44      * @var Ole1986_FacebokPageInfo
     41     * @var SocialPlugin
    4542     */
    4643    private static $instance;
     
    4946     * Gets an instance of our plugin.
    5047     *
    51      * @return Ole1986_FacebokPageInfo
     48     * @return SocialPlugin
    5249     */
    5350    public static function get_instance()
     
    6562    {
    6663        load_plugin_textdomain('social-plugin-metadata', false, dirname(plugin_basename(__FILE__)) . '/lang/');
     64
     65        parent::__construct();
    6766
    6867        // load scripts and styles for frontend
     
    7271
    7372        add_action('widgets_init', function () {
    74             register_widget('Ole1986_FacebokPageInfoWidget');
     73            register_widget('Cloud86\WP\Social\SocialPluginWidget');
    7574        });
    7675
     
    8281        add_action('wp_ajax_fb_save_appdata', [$this, 'fb_save_appdata']);
    8382
    84         // initialize the facebook for private use
    85         if (!empty($this->getAppSecret())) {
    86             new Ole1986_FacebookGateway($this, $this->isPublic());
    87         }
    88 
    8983        $this->registerShortcodes();
    9084    }
     
    10195            wp_localize_script('social_plugin', 'social_plugin', [
    10296                'ajaxurl' => admin_url('admin-ajax.php'),
    103                 'gatewayurl' => empty($this->getAppSecret()) ? self::$SP_GATEWAY_URL : admin_url('admin-ajax.php'),
    104                 "use_gateway" => $this->useGateway(),
    10597                'app_id' => $this->getAppID()
    10698            ]);   
     
    112104    public function getAppID()
    113105    {
    114         return get_option(self::$WP_OPTION_APPID, self::$DEFAULT_APP_ID);
     106        return get_option(self::$WP_OPTION_APPID);
    115107    }
    116108
     
    120112    }
    121113
    122     public function useGateway()
    123     {
    124         return empty($this->getAppSecret) ? 1 : 0;
    125     }
    126 
    127     public function isPublic()
    128     {
    129         return get_option(self::$WP_OPTION_ISPUBLIC, 0);
    130     }
    131 
    132114    private function registerShortcodes()
    133115    {
    134         // [fb-pageinfo-businesshours page_id="<page>"]
    135         add_shortcode('fb-pageinfo-businesshours', function ($atts, $content, $tag) {
     116        // [social-businesshours page_id="<page>"]
     117        add_shortcode('social-businesshours', function ($atts, $content, $tag) {
    136118            return $this->shortcodeCallback('BusinessHours', $atts, $content, $tag);
    137119        });
    138120
    139         // [fb-pageinfo-about page_id="<page>"]
    140         add_shortcode('fb-pageinfo-about', function ($atts, $content, $tag) {
     121        // [social-about page_id="<page>"]
     122        add_shortcode('social-about', function ($atts, $content, $tag) {
    141123            return $this->shortcodeCallback('About', $atts, $content, $tag);
    142124        });
    143125
    144         // [fb-pageinfo-lastpost page_id="<page>"]
    145         add_shortcode('fb-pageinfo-lastpost', function ($atts, $content, $tag) {
     126        // [social-lastpost page_id="<page>"]
     127        add_shortcode('social-lastpost', function ($atts, $content, $tag) {
    146128            return $this->shortcodeCallback('LastPost', $atts, $content, $tag);
    147129        });
     
    313295
    314296        if (isset($options['max_age'])) {
    315             $now = new DateTime();
     297            $now = new \DateTime();
    316298            $page['data'] = array_filter($page['data'] ?? [], function ($p) use ($now, $options) {
    317                 $d = new DateTime($p['created_time']);
     299                $d = new \DateTime($p['created_time']);
    318300                $diff = ($now->getTimestamp() - $d->getTimestamp()) / 60;
    319301
     
    337319
    338320        foreach ($page['data'] as $lastPost) {
    339             $created = new DateTime($lastPost['created_time']);
    340             $now = new DateTime();
     321            $created = new \DateTime($lastPost['created_time']);
     322            $now = new \DateTime();
    341323
    342324            if (!isset($lastPost['message'])) {
     
    390372    }
    391373
    392     public function fbGraphRequest($url, $doPost = false)
    393     {
    394         $path = 'https://graph.facebook.com/';
    395 
    396         if ($doPost) {
    397             $resp = wp_remote_post($path . $url);
    398         } else {
    399             $resp = wp_remote_get($path . $url);
    400         }
    401 
    402         if ($resp instanceof \WP_Error) {
    403             return [];
    404         }
    405        
    406         return json_decode($resp['body'], true);
    407     }
    408 
    409374    public function fb_get_page_options()
    410375    {
     
    416381
    417382        array_walk($result, function (&$v) {
    418             $v['access_token'] = '(hidden)';
     383            $v['access_token'] = '***' . substr($v['access_token'], -10);
    419384        });
    420385
     
    447412    public function fb_save_appdata()
    448413    {
    449         $appId = sanitize_key($_POST['appId']);
    450         $appSecret = sanitize_key($_POST['appSecret']);
    451         $isPublic = sanitize_key($_POST['isPublic']);
     414        $appId = sanitize_key($_POST['app_id']);
     415        $appSecret = sanitize_key($_POST['app_secret']);
    452416
    453417
     
    464428        }
    465429
    466         if (empty($isPublic)) {
    467             delete_option(self::$WP_OPTION_ISPUBLIC);
    468         } else {
    469             update_option(self::$WP_OPTION_ISPUBLIC, 1);
    470         }
    471 
    472430        header('Content-Type: application/json');
    473431        echo json_encode(true);
     
    511469    public function settings_page_content()
    512470    {
    513         $pages = get_option(self::$WP_OPTION_PAGES, []);
     471        $plugin_data = get_plugin_data(__FILE__);
     472        $plugin_version = $plugin_data['Version'];
     473
    514474        ?>
    515475        <h2><?php _e('Social Plugin - Metadata', 'social-plugin-metadata') ?></h2>
     
    519479        <div style="display: flex;  flex-wrap: wrap">
    520480            <div id="fb-gateway-frame" style="margin: 1em; flex-basis: 375px;">
    521                 <h3><?php _e('Connect with Facebook', 'social-plugin-metadata') ?></h3>
    522                 <div hidden id="fb-gateway-register-container">
    523                     <p>
    524                         <?php _e('Please register your domain first before using the Facebook App', 'social-plugin-metadata') ?>
    525                     </p>
    526                     <button id="fb-gateway-register" class="button button-primary hide-if-no-js">Register domain</button>
    527                 </div>
    528                 <div id="fb-gateway-container">
    529                     <p>
    530                         <?php _e('Please use the below Login & Sync button to synchronize the facebook pages', 'social-plugin-metadata') ?>
    531                     </p>
    532                     <button id="fb-gateway-login" class="button hide-if-no-js">Login and Sync</button>
    533                 </div>
    534                 <div style="margin-top: 1em"> 
    535                     <h3><?php _e('Setup your Facebook App (optional)', 'social-plugin-metadata') ?></h3>
    536                     <div id="fb-gateway-custom" hidden>
    537                         <p><?php printf(__('Build your own %s or use our service gateway', 'social-plugin-metadata'), '<a href="https://developers.facebook.com/apps/" target="_blank">Facebook App</a>') ?></p>
     481                <form method="POST" id="fb-configure-app" style="margin-top: 1em"> 
     482                    <h3><?php _e('Setup your Facebook App', 'social-plugin-metadata') ?></h3>
     483                    <div id="fb-gateway-custom">
     484                        <p><?php printf(__('Build your own %s and configure the APP ID as well as the APP KEY here', 'social-plugin-metadata'), '<a href="https://developers.facebook.com/apps/" target="_blank">Facebook App</a>') ?></p>
    538485                        <div>
    539                             <label>Facebook App ID (standalone / optional)</label><br />
    540                             <input class="widefat" type="text" autocomplete="off" id="fbAppId" value="<?php echo get_option(self::$WP_OPTION_APPID, '') ?>" />
     486                            <label>Facebook App ID</label><br />
     487                            <input class="widefat" type="text" name="app_id" autocomplete="off" id="fbAppId" value="<?php echo get_option(self::$WP_OPTION_APPID, '') ?>" />
    541488                        </div>
    542489                        <div style="margin-top: 0.5em">
    543                             <label>Facebook App Secret (standalone / optional)</label><br />
    544                             <input class="widefat" type="password" autocomplete="new-password" id="fbAppSecret" />
    545                         </div>
    546                         <div style="margin-top: 0.5em">
    547                             <label><input type="checkbox" id="fbIsPublic"  <?php echo $this->isPublic() ? 'checked' : '' ?> /> Make API publicly available</label>
     490                            <label>Facebook App Secret</label><br />
     491                            <input class="widefat" type="password" name="app_secret" autocomplete="new-password" id="fbAppSecret" />
    548492                        </div>
    549493                        <div style="margin-top: 1em">
    550                             <button id="fb-appdata-save" class="button hide-if-no-js">Save</button>
     494                            <button id="fb-appdata-save" type="submit" class="button hide-if-no-js">Save</button>
    551495                        </div>
    552496                    </div>
    553                     <div id="fb-gateway-our">
    554                         <div><?php _e('Currently you are using our Facebook App to gather necessary page information', 'social-plugin-metadata') ?></div>
    555                         <div style="margin-top: 1em">
    556                             <button id="fb-gateway-change" class="button hide-if-no-js"><?php _e('Use my Facebook App', 'social-plugin-metadata') ?></button>
    557                         </div>
     497                </form>
     498                <div id="fb-login-app" style="margin-top: 1em" hidden>
     499                    <h3><?php _e('Connect with Facebook', 'social-plugin-metadata') ?></h3>
     500                    <div id="fb-gateway-container">
     501                        <p>
     502                            <?php _e('Please use the below Login & Sync button to synchronize the facebook pages', 'social-plugin-metadata') ?>
     503                        </p>
     504                        <button id="fb-gateway-login" class="button hide-if-no-js">Login and Sync</button>
    558505                    </div>
    559506                </div>
    560507            </div>
    561508            <div style="margin: 1em; flex-basis: 375px; flex-grow: 1">
    562                 <h3><?php _e('Quick Guide', 'social-plugin-metadata') ?></h3>
    563                 <p><?php _e('To sychronize and outpout meta information (E.g. Business hours, About Us, last posts) from facebook pages', 'social-plugin-metadata') ?>.</p>
     509                <h3><?php _e('Widgets', 'social-plugin-metadata') ?></h3>
     510                <p><?php echo sprintf(__('Navigate to Appearance -> Widgets and configure the %s widget as desired', 'social-plugin-metadata'), __('Social Plugin - Metadata', 'social-plugin-metadata')) ?>.</p>
     511                <h3><?php _e('Shortcodes', 'social-plugin-metadata') ?></h3>
     512                <p><?php _e('Optionally you can also use shortcodes to displav the related information from Facebook (E.g. Business hours, About Us or the last posts)', 'social-plugin-metadata') ?>.</p>
    564513                <div style="font-family: monospace">
    565                     <ol>
    566                         <li>
    567                             <?php _e('Use the button Login and Sync (left side) to connect your facebook account with the Facebook App', 'social-plugin-metadata') ?><br />
    568                             <strong><?php printf(__("Dependent on details given in the '%s' you get asked to connect your Facebook Account with the following app", 'social-plugin-metadata'), __('Setup your Facebook App (optional)', 'social-plugin-metadata')) ?></strong>
    569                             <ul style="list-style: inside">
    570                                 <li>our Facebook App "Cloud 86 / Link Page"</li>
    571                                 <li>your own Facebook app</li>
    572                             </ul>
    573                         </li>
    574                         <li><?php _e('Once successfully logged into your facebook account, choose the pages you wish to output metadata for', 'social-plugin-metadata') ?></li>
    575                         <li><?php _e('Is your account properly connected and the syncronization completed, you can switch to the Appearance -> Widget page', 'social-plugin-metadata') ?></li>
    576                         <li><?php printf(__('To display the content on your front page, move the widget %s into a desired widget area', 'social-plugin-metadata'), __('Social plugin - Metadata Widget', 'social-plugin-metadata')) ?></li>
    577                         <li><?php _e('Finally save the widget settings and check the output on the front page', 'social-plugin-metadata') ?></li>
    578                     </ol>
    579                     <h4>Shortcodes</h4>
    580514                    <div>
    581                         <?php printf(__('If you prefer to use %s, the below options are available', 'social-plugin-metadata'), '<a href="https://wordpress.com/de/support/wordpress-editor/bloecke/shortcode-block/" target="_blank">Shortcodes</a>') ?>
    582515                        <ul>
    583                             <li>[fb-pageinfo-businesshours page_id="..." empty_message=""]</li>
    584                             <li>[fb-pageinfo-about page_id="..." empty_message=""]</li>
    585                             <li>[fb-pageinfo-lastpost page_id="..." limit="..." max_age="..." empty_message=""]</li>
     516                            <li>[social-businesshours page_id="..." empty_message=""]</li>
     517                            <li>[social-about page_id="..." empty_message=""]</li>
     518                            <li>[social-lastpost page_id="..." limit="..." max_age="..." empty_message=""]</li>
    586519                        </ul>
    587520                    </div>
    588521                </div>
    589                 <h2>Rechtliche Hinweise</h2>
     522                <h2>Legal Notices</h2>
    590523                <p>
    591                     <strong>Cloud 86 selbst speichert keine Facebook Daten. <br />Es werden ausschließlich technisch erforderliche Informationen zur Darstellung der Metadaten AUF DIESEM SERVER (<?php echo $_SERVER['HTTP_HOST'] ?>) abgelegt</strong>
     524                    <strong>This plugin does not save any facebook data. <br />All necessary information will be stored on this server (<?php echo $_SERVER['HTTP_HOST'] ?>)</strong>
    592525                </p>
    593526                <div id="rawdata" style="font-family: monospace; white-space: pre; background-color: white; padding: 1em;">
    594                     <a href="javascript:void(0)" onclick="SocialPlugin.fbRawPages()">DATEN ANZEIGEN</a>
     527<a href="javascript:void(0)" onclick="SocialPlugin.fbRawPages()">SHOW DATA</a>
    595528                </div>
    596                 <p>WEITER INFORMATIONEN ZUM DATENSCHUTZ FINDEN SIE <a href="https://www.cloud86.de/datenschutzerklaerung" target="_blank">HIER</a></p>
     529                <p>Futhermore the data protection policy from facebook applies for the given Facebook App</p>
    597530            </div>
    598531        </div>
     532        <div><small><?php _e('Social Plugin - Metadata', 'social-plugin-metadata') ?> Version: <?php echo $plugin_version ?></small></div>
    599533        <?php
    600534    }
    601535}
    602536
    603 Ole1986_FacebokPageInfo::get_instance();
    604 
     537SocialPlugin::get_instance();
    605538?>
  • social-page-metadata/trunk/widget.php

    r2575935 r2649162  
    11<?php
     2namespace Cloud86\WP\Social;
     3
    24/**
    35 * The Facebook page info Widget used to display in sidebars or footer bars (dependent on the theme)
    46 */
    57
    6 class Ole1986_FacebokPageInfoWidget extends WP_Widget
     8class SocialPluginWidget extends \WP_Widget
    79{
    810    /**
     
    3638        $this->parseSettings($instance);
    3739
    38         $pages = get_option(Ole1986_FacebokPageInfo::$WP_OPTION_PAGES, []);
     40        $pages = get_option(SocialPlugin::$WP_OPTION_PAGES, []);
    3941
    4042        $filteredPages = array_filter(
     
    4749        $currentPage = array_pop($filteredPages);
    4850
    49         $result = Ole1986_FacebokPageInfo::get_instance()->processContentFromOption($currentPage, $this->option, $this->options);
     51        $result = SocialPlugin::get_instance()->processContentFromOption($currentPage, $this->option, $this->options);
    5052       
    5153        // before and after widget arguments are defined by themes
     
    6163                    <?php
    6264                    if (!empty($this->option)) {
    63                         Ole1986_FacebokPageInfo::get_instance()->{'show' . $this->option}($result, $this->options);
     65                        SocialPlugin::get_instance()->{'show' . $this->option}($result, $this->options);
    6466                    } else {
    6567                        echo "<div><small>No option given for ". __('Facebook page info Widget', 'social-plugin-metadata') ."<small></div>";
     
    9193    {
    9294        $this->parseSettings($instance);
    93         $pages = get_option(Ole1986_FacebokPageInfo::$WP_OPTION_PAGES, []);
     95        $pages = get_option(SocialPlugin::$WP_OPTION_PAGES, []);
    9496        ?>
    9597        <div class="social-widget-metadata-widget">
Note: See TracChangeset for help on using the changeset viewer.