Changeset 2649162
- Timestamp:
- 12/26/2021 02:10:21 PM (4 years ago)
- Location:
- social-page-metadata
- Files:
-
- 4 added
- 2 deleted
- 12 edited
- 1 copied
-
tags/1.1.0 (copied) (copied from social-page-metadata/trunk)
-
tags/1.1.0/gateway (deleted)
-
tags/1.1.0/lang/social-plugin-metadata-de_DE.mo (modified) (previous)
-
tags/1.1.0/lang/social-plugin-metadata-de_DE.po (modified) (3 diffs)
-
tags/1.1.0/model (added)
-
tags/1.1.0/model/facebook-rest-api.php (added)
-
tags/1.1.0/readme.txt (modified) (4 diffs)
-
tags/1.1.0/scripts/init.js (modified) (4 diffs)
-
tags/1.1.0/social-plugin-metadata.php (modified) (19 diffs)
-
tags/1.1.0/widget.php (modified) (5 diffs)
-
trunk/gateway (deleted)
-
trunk/lang/social-plugin-metadata-de_DE.mo (modified) (previous)
-
trunk/lang/social-plugin-metadata-de_DE.po (modified) (3 diffs)
-
trunk/model (added)
-
trunk/model/facebook-rest-api.php (added)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/scripts/init.js (modified) (4 diffs)
-
trunk/social-plugin-metadata.php (modified) (19 diffs)
-
trunk/widget.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
social-page-metadata/tags/1.1.0/lang/social-plugin-metadata-de_DE.po
r2648243 r2649162 28 28 29 29 msgid "Please use the below Login & Sync button to synchronize the facebook pages" 30 msgstr "Bitte verwende d en unten dargestellten Knopf um mit der Synchronisierung deiner Facebook Seiten zu beginnen"30 msgstr "Bitte verwende die unten dargestellte Schaltfläche um die Facebook Seiten zu synchronisieren" 31 31 32 32 msgid "Please register your domain first before using the Facebook App" … … 90 90 msgstr "Mit Facebook verbinden" 91 91 92 msgid " Setup your Facebook App (optional)"93 msgstr " Konfiguriere deine Facebook App (optional)"92 msgid "Build your own %s and configure the APP ID as well as the APP KEY here" 93 msgstr "Erstelle eine eigene %s und konfiguriere die APP ID sowie den APP KEY hier" 94 94 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" 95 msgid "Optionally you can also use shortcodes to displav the related information from Facebook (E.g. Business hours, About Us or the last posts)" 96 msgstr "Alternativ können auch Shortcodes verwendet werden um die erforderlichen Informationen aus Facebook darzustellen (z.B. Öffnungszeiten, Über uns oder die letzten Beiträge) " 130 97 131 98 msgid "Some information has been updated on Facebook" … … 134 101 msgid "Facebook page not found or no access" 135 102 msgstr "Facebook Seite nicht gefunden oder kein Zugriff" 103 104 msgid "Navigate to Appearance -> Widgets and configure the %s widget as desired" 105 msgstr "Navigiere zu Design -> Widgets und konfiguriere das %s Widget wie gewünscht" -
social-page-metadata/tags/1.1.0/readme.txt
r2648243 r2649162 3 3 Tags: facebook, show, page info, meta data 4 4 Requires at least: 5.0 5 Tested up to: 5. 75 Tested up to: 5.8 6 6 Requires PHP: 7.0 7 Stable tag: 1. 0.87 Stable tag: 1.1.0 8 8 License: GPLv3 9 9 … … 12 12 == Description == 13 13 14 Display meta information from the social network "Facebook" using either a widget or asshortcode.14 Display meta information from the social network "Facebook" using either a widget or shortcode. 15 15 Currently supported meta information which can be gathered are: 16 16 … … 27 27 **Quick Guide** 28 28 29 To sychronize and output meta information (E.g. Business hours, About Us, last posts) from facebook pages .29 To sychronize and output meta information (E.g. Business hours, About Us, last posts) from facebook pages, follow the below steps: 30 30 31 1. Use the button Login and Sync (left side) to connect your facebook account with the Cloud 86 / Link Page application32 2. Once successfully logged into your facebook account, choose the pages you wish to output metadata for33 3. Is your account properly connected and the syncronization completed, you can switch to the Appearance -> Widget page34 4. To display the content on your front page, move the widget Facebook page info Widget into a desired widget area35 5. Finally save the widget settings and check the output on the front page31 1. Register as Facebook Developer and create a new [Facebook App](https://developers.facebook.com/apps/) 32 2. Fill in the Facebook App ID and App secret from the app you just created into the Social Plugin (Menu "Tool" -> "Social Plugin - Metadata") 33 3. Use the "Login and Sync" button to connect your facebook account with your Facebook App 34 4. Switch to the Appearance -> Widget page once successfully logged in and pick the "Social Plugin - Metadata" 35 5. Setup the widget for the page and content you want to display on frontend 36 36 37 37 **Shortcodes** … … 39 39 If you prefer to use Shortcodes, the below options are available 40 40 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=""] 44 44 45 45 == Screenshots == -
social-page-metadata/tags/1.1.0/scripts/init.js
r2497278 r2649162 17 17 }; 18 18 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(); 31 21 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() {43 22 AlertMessage('', 'Updating info...'); 44 23 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); 48 25 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() { 51 30 document.location.reload(); 52 31 }).catch(function(e) { 53 32 AlertMessage('error', 'We encountered an error. Please try again later...'); 54 33 }); 34 35 return false; 55 36 } 56 37 57 38 this.fbSavePages = function(data) { 58 AlertMessage('', 'Saving data received from ' + (social_plugin.use_gateway ? 'remote' : 'local') + ' gateway...');39 AlertMessage('', 'Saving data...'); 59 40 60 41 jQuery.post(social_plugin.ajaxurl, { action: 'fb_save_pages', data }) … … 76 57 response.authResponse.accessToken; 77 58 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}) 79 60 .done(function(response){ 80 61 self.fbSavePages(response.data); 81 62 }).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); 84 64 }); 85 65 } … … 114 94 loadFB(); 115 95 jQuery('#fb-gateway-login').click(self.fbLogin); 116 jQuery('#fb-gateway-register').click(self.fbRegisterAppDomain);117 96 118 jQuery('#fb-appdata-save').click(self.fbSaveAppdata);97 document.getElementById('fb-configure-app').onsubmit = self.fbSaveAppdata; 119 98 120 99 jQuery('#fb-gateway-change').click(self.showCustomAppOptions); … … 122 101 var fbAppId = jQuery('#fbAppId').val(); 123 102 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(); 129 105 } 130 131 self.fbCheckAppDomain();132 106 })(); 133 107 } -
social-page-metadata/tags/1.1.0/social-plugin-metadata.php
r2648243 r2649162 1 1 <?php 2 namespace Cloud86\WP\Social; 3 4 use Cloud86\WP\Social\Model\FacebookRestApi; 5 2 6 /** 3 7 * Plugin Name: Social Plugin - Metadata 4 8 * 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 8 10 * Author: ole1986 9 11 * License: MIT <https://raw.githubusercontent.com/Cloud-86/social-plugin-metadata/master/LICENSE> … … 16 18 defined('ABSPATH') or die('No script kiddies please!'); 17 19 18 require_once 'gateway/interfaces/IFacebookGatewayHost.php'; 19 require_once 'gateway/gateway.php'; 20 require_once 'model/facebook-rest-api.php'; 20 21 require_once 'widget.php'; 21 22 22 class Ole1986_FacebokPageInfo implements Ole1986_IFacebookGatewayHost23 class SocialPlugin extends FacebookRestApi 23 24 { 24 25 /** … … 26 27 */ 27 28 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";31 29 32 30 /** … … 37 35 static $WP_OPTION_APPID = 'social_plugin_fb_app_id'; 38 36 static $WP_OPTION_APPSECRET = 'social_plugin_fb_app_secret'; 39 static $WP_OPTION_ISPUBLIC = 'social_plugin_api_public';40 37 41 38 /** 42 39 * The unique instance of the plugin. 43 40 * 44 * @var Ole1986_FacebokPageInfo41 * @var SocialPlugin 45 42 */ 46 43 private static $instance; … … 49 46 * Gets an instance of our plugin. 50 47 * 51 * @return Ole1986_FacebokPageInfo48 * @return SocialPlugin 52 49 */ 53 50 public static function get_instance() … … 65 62 { 66 63 load_plugin_textdomain('social-plugin-metadata', false, dirname(plugin_basename(__FILE__)) . '/lang/'); 64 65 parent::__construct(); 67 66 68 67 // load scripts and styles for frontend … … 72 71 73 72 add_action('widgets_init', function () { 74 register_widget(' Ole1986_FacebokPageInfoWidget');73 register_widget('Cloud86\WP\Social\SocialPluginWidget'); 75 74 }); 76 75 … … 82 81 add_action('wp_ajax_fb_save_appdata', [$this, 'fb_save_appdata']); 83 82 84 // initialize the facebook for private use85 if (!empty($this->getAppSecret())) {86 new Ole1986_FacebookGateway($this, $this->isPublic());87 }88 89 83 $this->registerShortcodes(); 90 84 } … … 101 95 wp_localize_script('social_plugin', 'social_plugin', [ 102 96 '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(),105 97 'app_id' => $this->getAppID() 106 98 ]); … … 112 104 public function getAppID() 113 105 { 114 return get_option(self::$WP_OPTION_APPID , self::$DEFAULT_APP_ID);106 return get_option(self::$WP_OPTION_APPID); 115 107 } 116 108 … … 120 112 } 121 113 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 132 114 private function registerShortcodes() 133 115 { 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) { 136 118 return $this->shortcodeCallback('BusinessHours', $atts, $content, $tag); 137 119 }); 138 120 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) { 141 123 return $this->shortcodeCallback('About', $atts, $content, $tag); 142 124 }); 143 125 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) { 146 128 return $this->shortcodeCallback('LastPost', $atts, $content, $tag); 147 129 }); … … 313 295 314 296 if (isset($options['max_age'])) { 315 $now = new DateTime();297 $now = new \DateTime(); 316 298 $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']); 318 300 $diff = ($now->getTimestamp() - $d->getTimestamp()) / 60; 319 301 … … 337 319 338 320 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(); 341 323 342 324 if (!isset($lastPost['message'])) { … … 390 372 } 391 373 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 409 374 public function fb_get_page_options() 410 375 { … … 416 381 417 382 array_walk($result, function (&$v) { 418 $v['access_token'] = ' (hidden)';383 $v['access_token'] = '***' . substr($v['access_token'], -10); 419 384 }); 420 385 … … 447 412 public function fb_save_appdata() 448 413 { 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']); 452 416 453 417 … … 464 428 } 465 429 466 if (empty($isPublic)) {467 delete_option(self::$WP_OPTION_ISPUBLIC);468 } else {469 update_option(self::$WP_OPTION_ISPUBLIC, 1);470 }471 472 430 header('Content-Type: application/json'); 473 431 echo json_encode(true); … … 511 469 public function settings_page_content() 512 470 { 513 $pages = get_option(self::$WP_OPTION_PAGES, []); 471 $plugin_data = get_plugin_data(__FILE__); 472 $plugin_version = $plugin_data['Version']; 473 514 474 ?> 515 475 <h2><?php _e('Social Plugin - Metadata', 'social-plugin-metadata') ?></h2> … … 519 479 <div style="display: flex; flex-wrap: wrap"> 520 480 <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> 538 485 <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, '') ?>" /> 541 488 </div> 542 489 <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" /> 548 492 </div> 549 493 <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> 551 495 </div> 552 496 </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> 558 505 </div> 559 506 </div> 560 507 </div> 561 508 <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> 564 513 <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>580 514 <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>') ?>582 515 <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> 586 519 </ul> 587 520 </div> 588 521 </div> 589 <h2> Rechtliche Hinweise</h2>522 <h2>Legal Notices</h2> 590 523 <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> 592 525 </p> 593 526 <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> 595 528 </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> 597 530 </div> 598 531 </div> 532 <div><small><?php _e('Social Plugin - Metadata', 'social-plugin-metadata') ?> Version: <?php echo $plugin_version ?></small></div> 599 533 <?php 600 534 } 601 535 } 602 536 603 Ole1986_FacebokPageInfo::get_instance(); 604 537 SocialPlugin::get_instance(); 605 538 ?> -
social-page-metadata/tags/1.1.0/widget.php
r2575935 r2649162 1 1 <?php 2 namespace Cloud86\WP\Social; 3 2 4 /** 3 5 * The Facebook page info Widget used to display in sidebars or footer bars (dependent on the theme) 4 6 */ 5 7 6 class Ole1986_FacebokPageInfoWidget extendsWP_Widget8 class SocialPluginWidget extends \WP_Widget 7 9 { 8 10 /** … … 36 38 $this->parseSettings($instance); 37 39 38 $pages = get_option( Ole1986_FacebokPageInfo::$WP_OPTION_PAGES, []);40 $pages = get_option(SocialPlugin::$WP_OPTION_PAGES, []); 39 41 40 42 $filteredPages = array_filter( … … 47 49 $currentPage = array_pop($filteredPages); 48 50 49 $result = Ole1986_FacebokPageInfo::get_instance()->processContentFromOption($currentPage, $this->option, $this->options);51 $result = SocialPlugin::get_instance()->processContentFromOption($currentPage, $this->option, $this->options); 50 52 51 53 // before and after widget arguments are defined by themes … … 61 63 <?php 62 64 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); 64 66 } else { 65 67 echo "<div><small>No option given for ". __('Facebook page info Widget', 'social-plugin-metadata') ."<small></div>"; … … 91 93 { 92 94 $this->parseSettings($instance); 93 $pages = get_option( Ole1986_FacebokPageInfo::$WP_OPTION_PAGES, []);95 $pages = get_option(SocialPlugin::$WP_OPTION_PAGES, []); 94 96 ?> 95 97 <div class="social-widget-metadata-widget"> -
social-page-metadata/trunk/lang/social-plugin-metadata-de_DE.po
r2648243 r2649162 28 28 29 29 msgid "Please use the below Login & Sync button to synchronize the facebook pages" 30 msgstr "Bitte verwende d en unten dargestellten Knopf um mit der Synchronisierung deiner Facebook Seiten zu beginnen"30 msgstr "Bitte verwende die unten dargestellte Schaltfläche um die Facebook Seiten zu synchronisieren" 31 31 32 32 msgid "Please register your domain first before using the Facebook App" … … 90 90 msgstr "Mit Facebook verbinden" 91 91 92 msgid " Setup your Facebook App (optional)"93 msgstr " Konfiguriere deine Facebook App (optional)"92 msgid "Build your own %s and configure the APP ID as well as the APP KEY here" 93 msgstr "Erstelle eine eigene %s und konfiguriere die APP ID sowie den APP KEY hier" 94 94 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" 95 msgid "Optionally you can also use shortcodes to displav the related information from Facebook (E.g. Business hours, About Us or the last posts)" 96 msgstr "Alternativ können auch Shortcodes verwendet werden um die erforderlichen Informationen aus Facebook darzustellen (z.B. Öffnungszeiten, Über uns oder die letzten Beiträge) " 130 97 131 98 msgid "Some information has been updated on Facebook" … … 134 101 msgid "Facebook page not found or no access" 135 102 msgstr "Facebook Seite nicht gefunden oder kein Zugriff" 103 104 msgid "Navigate to Appearance -> Widgets and configure the %s widget as desired" 105 msgstr "Navigiere zu Design -> Widgets und konfiguriere das %s Widget wie gewünscht" -
social-page-metadata/trunk/readme.txt
r2648243 r2649162 3 3 Tags: facebook, show, page info, meta data 4 4 Requires at least: 5.0 5 Tested up to: 5. 75 Tested up to: 5.8 6 6 Requires PHP: 7.0 7 Stable tag: 1. 0.87 Stable tag: 1.1.0 8 8 License: GPLv3 9 9 … … 12 12 == Description == 13 13 14 Display meta information from the social network "Facebook" using either a widget or asshortcode.14 Display meta information from the social network "Facebook" using either a widget or shortcode. 15 15 Currently supported meta information which can be gathered are: 16 16 … … 27 27 **Quick Guide** 28 28 29 To sychronize and output meta information (E.g. Business hours, About Us, last posts) from facebook pages .29 To sychronize and output meta information (E.g. Business hours, About Us, last posts) from facebook pages, follow the below steps: 30 30 31 1. Use the button Login and Sync (left side) to connect your facebook account with the Cloud 86 / Link Page application32 2. Once successfully logged into your facebook account, choose the pages you wish to output metadata for33 3. Is your account properly connected and the syncronization completed, you can switch to the Appearance -> Widget page34 4. To display the content on your front page, move the widget Facebook page info Widget into a desired widget area35 5. Finally save the widget settings and check the output on the front page31 1. Register as Facebook Developer and create a new [Facebook App](https://developers.facebook.com/apps/) 32 2. Fill in the Facebook App ID and App secret from the app you just created into the Social Plugin (Menu "Tool" -> "Social Plugin - Metadata") 33 3. Use the "Login and Sync" button to connect your facebook account with your Facebook App 34 4. Switch to the Appearance -> Widget page once successfully logged in and pick the "Social Plugin - Metadata" 35 5. Setup the widget for the page and content you want to display on frontend 36 36 37 37 **Shortcodes** … … 39 39 If you prefer to use Shortcodes, the below options are available 40 40 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=""] 44 44 45 45 == Screenshots == -
social-page-metadata/trunk/scripts/init.js
r2497278 r2649162 17 17 }; 18 18 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(); 31 21 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() {43 22 AlertMessage('', 'Updating info...'); 44 23 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); 48 25 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() { 51 30 document.location.reload(); 52 31 }).catch(function(e) { 53 32 AlertMessage('error', 'We encountered an error. Please try again later...'); 54 33 }); 34 35 return false; 55 36 } 56 37 57 38 this.fbSavePages = function(data) { 58 AlertMessage('', 'Saving data received from ' + (social_plugin.use_gateway ? 'remote' : 'local') + ' gateway...');39 AlertMessage('', 'Saving data...'); 59 40 60 41 jQuery.post(social_plugin.ajaxurl, { action: 'fb_save_pages', data }) … … 76 57 response.authResponse.accessToken; 77 58 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}) 79 60 .done(function(response){ 80 61 self.fbSavePages(response.data); 81 62 }).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); 84 64 }); 85 65 } … … 114 94 loadFB(); 115 95 jQuery('#fb-gateway-login').click(self.fbLogin); 116 jQuery('#fb-gateway-register').click(self.fbRegisterAppDomain);117 96 118 jQuery('#fb-appdata-save').click(self.fbSaveAppdata);97 document.getElementById('fb-configure-app').onsubmit = self.fbSaveAppdata; 119 98 120 99 jQuery('#fb-gateway-change').click(self.showCustomAppOptions); … … 122 101 var fbAppId = jQuery('#fbAppId').val(); 123 102 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(); 129 105 } 130 131 self.fbCheckAppDomain();132 106 })(); 133 107 } -
social-page-metadata/trunk/social-plugin-metadata.php
r2648243 r2649162 1 1 <?php 2 namespace Cloud86\WP\Social; 3 4 use Cloud86\WP\Social\Model\FacebookRestApi; 5 2 6 /** 3 7 * Plugin Name: Social Plugin - Metadata 4 8 * 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 8 10 * Author: ole1986 9 11 * License: MIT <https://raw.githubusercontent.com/Cloud-86/social-plugin-metadata/master/LICENSE> … … 16 18 defined('ABSPATH') or die('No script kiddies please!'); 17 19 18 require_once 'gateway/interfaces/IFacebookGatewayHost.php'; 19 require_once 'gateway/gateway.php'; 20 require_once 'model/facebook-rest-api.php'; 20 21 require_once 'widget.php'; 21 22 22 class Ole1986_FacebokPageInfo implements Ole1986_IFacebookGatewayHost23 class SocialPlugin extends FacebookRestApi 23 24 { 24 25 /** … … 26 27 */ 27 28 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";31 29 32 30 /** … … 37 35 static $WP_OPTION_APPID = 'social_plugin_fb_app_id'; 38 36 static $WP_OPTION_APPSECRET = 'social_plugin_fb_app_secret'; 39 static $WP_OPTION_ISPUBLIC = 'social_plugin_api_public';40 37 41 38 /** 42 39 * The unique instance of the plugin. 43 40 * 44 * @var Ole1986_FacebokPageInfo41 * @var SocialPlugin 45 42 */ 46 43 private static $instance; … … 49 46 * Gets an instance of our plugin. 50 47 * 51 * @return Ole1986_FacebokPageInfo48 * @return SocialPlugin 52 49 */ 53 50 public static function get_instance() … … 65 62 { 66 63 load_plugin_textdomain('social-plugin-metadata', false, dirname(plugin_basename(__FILE__)) . '/lang/'); 64 65 parent::__construct(); 67 66 68 67 // load scripts and styles for frontend … … 72 71 73 72 add_action('widgets_init', function () { 74 register_widget(' Ole1986_FacebokPageInfoWidget');73 register_widget('Cloud86\WP\Social\SocialPluginWidget'); 75 74 }); 76 75 … … 82 81 add_action('wp_ajax_fb_save_appdata', [$this, 'fb_save_appdata']); 83 82 84 // initialize the facebook for private use85 if (!empty($this->getAppSecret())) {86 new Ole1986_FacebookGateway($this, $this->isPublic());87 }88 89 83 $this->registerShortcodes(); 90 84 } … … 101 95 wp_localize_script('social_plugin', 'social_plugin', [ 102 96 '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(),105 97 'app_id' => $this->getAppID() 106 98 ]); … … 112 104 public function getAppID() 113 105 { 114 return get_option(self::$WP_OPTION_APPID , self::$DEFAULT_APP_ID);106 return get_option(self::$WP_OPTION_APPID); 115 107 } 116 108 … … 120 112 } 121 113 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 132 114 private function registerShortcodes() 133 115 { 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) { 136 118 return $this->shortcodeCallback('BusinessHours', $atts, $content, $tag); 137 119 }); 138 120 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) { 141 123 return $this->shortcodeCallback('About', $atts, $content, $tag); 142 124 }); 143 125 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) { 146 128 return $this->shortcodeCallback('LastPost', $atts, $content, $tag); 147 129 }); … … 313 295 314 296 if (isset($options['max_age'])) { 315 $now = new DateTime();297 $now = new \DateTime(); 316 298 $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']); 318 300 $diff = ($now->getTimestamp() - $d->getTimestamp()) / 60; 319 301 … … 337 319 338 320 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(); 341 323 342 324 if (!isset($lastPost['message'])) { … … 390 372 } 391 373 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 409 374 public function fb_get_page_options() 410 375 { … … 416 381 417 382 array_walk($result, function (&$v) { 418 $v['access_token'] = ' (hidden)';383 $v['access_token'] = '***' . substr($v['access_token'], -10); 419 384 }); 420 385 … … 447 412 public function fb_save_appdata() 448 413 { 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']); 452 416 453 417 … … 464 428 } 465 429 466 if (empty($isPublic)) {467 delete_option(self::$WP_OPTION_ISPUBLIC);468 } else {469 update_option(self::$WP_OPTION_ISPUBLIC, 1);470 }471 472 430 header('Content-Type: application/json'); 473 431 echo json_encode(true); … … 511 469 public function settings_page_content() 512 470 { 513 $pages = get_option(self::$WP_OPTION_PAGES, []); 471 $plugin_data = get_plugin_data(__FILE__); 472 $plugin_version = $plugin_data['Version']; 473 514 474 ?> 515 475 <h2><?php _e('Social Plugin - Metadata', 'social-plugin-metadata') ?></h2> … … 519 479 <div style="display: flex; flex-wrap: wrap"> 520 480 <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> 538 485 <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, '') ?>" /> 541 488 </div> 542 489 <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" /> 548 492 </div> 549 493 <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> 551 495 </div> 552 496 </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> 558 505 </div> 559 506 </div> 560 507 </div> 561 508 <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> 564 513 <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>580 514 <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>') ?>582 515 <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> 586 519 </ul> 587 520 </div> 588 521 </div> 589 <h2> Rechtliche Hinweise</h2>522 <h2>Legal Notices</h2> 590 523 <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> 592 525 </p> 593 526 <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> 595 528 </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> 597 530 </div> 598 531 </div> 532 <div><small><?php _e('Social Plugin - Metadata', 'social-plugin-metadata') ?> Version: <?php echo $plugin_version ?></small></div> 599 533 <?php 600 534 } 601 535 } 602 536 603 Ole1986_FacebokPageInfo::get_instance(); 604 537 SocialPlugin::get_instance(); 605 538 ?> -
social-page-metadata/trunk/widget.php
r2575935 r2649162 1 1 <?php 2 namespace Cloud86\WP\Social; 3 2 4 /** 3 5 * The Facebook page info Widget used to display in sidebars or footer bars (dependent on the theme) 4 6 */ 5 7 6 class Ole1986_FacebokPageInfoWidget extendsWP_Widget8 class SocialPluginWidget extends \WP_Widget 7 9 { 8 10 /** … … 36 38 $this->parseSettings($instance); 37 39 38 $pages = get_option( Ole1986_FacebokPageInfo::$WP_OPTION_PAGES, []);40 $pages = get_option(SocialPlugin::$WP_OPTION_PAGES, []); 39 41 40 42 $filteredPages = array_filter( … … 47 49 $currentPage = array_pop($filteredPages); 48 50 49 $result = Ole1986_FacebokPageInfo::get_instance()->processContentFromOption($currentPage, $this->option, $this->options);51 $result = SocialPlugin::get_instance()->processContentFromOption($currentPage, $this->option, $this->options); 50 52 51 53 // before and after widget arguments are defined by themes … … 61 63 <?php 62 64 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); 64 66 } else { 65 67 echo "<div><small>No option given for ". __('Facebook page info Widget', 'social-plugin-metadata') ."<small></div>"; … … 91 93 { 92 94 $this->parseSettings($instance); 93 $pages = get_option( Ole1986_FacebokPageInfo::$WP_OPTION_PAGES, []);95 $pages = get_option(SocialPlugin::$WP_OPTION_PAGES, []); 94 96 ?> 95 97 <div class="social-widget-metadata-widget">
Note: See TracChangeset
for help on using the changeset viewer.