Changeset 2296846
- Timestamp:
- 05/02/2020 09:32:57 PM (6 years ago)
- Location:
- devotionalium
- Files:
-
- 11 edited
-
tags/1.0.1/src/Devotionalium/Devotionalium.php (modified) (3 diffs)
-
tags/1.0.1/src/Model/Api/DevotionaliumApi.php (modified) (4 diffs)
-
trunk/devotionalium.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/Block/Devotionalium.php (modified) (3 diffs)
-
trunk/src/Block/Settings.php (modified) (1 diff)
-
trunk/src/Devotionalium/Devotionalium.php (modified) (3 diffs)
-
trunk/src/Model/Api/DevotionaliumApi.php (modified) (5 diffs)
-
trunk/src/Plugin.php (modified) (13 diffs)
-
trunk/src/View/devotionalium-widget.phtml (modified) (1 diff)
-
trunk/src/View/devotionalium.phtml (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
devotionalium/tags/1.0.1/src/Devotionalium/Devotionalium.php
r1823971 r2296846 45 45 /** 46 46 * @return Verse[] 47 * @throws \Exception 47 48 */ 48 49 public function getVerses() … … 56 57 /** 57 58 * @return \DateTime 59 * @throws \Exception 58 60 */ 59 61 public function getDate() … … 83 85 /** 84 86 * Lazily load content from api. 87 * @throws \Exception 85 88 */ 86 89 private function load() -
devotionalium/tags/1.0.1/src/Model/Api/DevotionaliumApi.php
r1823971 r2296846 5 5 use Devotionalium\Devotionalium\Devotionalium; 6 6 use Devotionalium\Model\Storage\Transient; 7 use Exception; 7 8 8 9 class DevotionaliumApi … … 20 21 private $transient; 21 22 22 /**23 * DevotionaliumApi constructor.24 */25 23 public function __construct() 26 24 { … … 34 32 * @param int $dayOffset 35 33 * @return Devotionalium 34 * @throws Exception 36 35 */ 37 36 public function loadDevotionalium( … … 84 83 * @param $language 85 84 * @return Version[] 85 * @throws Exception 86 86 */ 87 87 public function loadVersions($language = 'en') -
devotionalium/trunk/devotionalium.php
r2164856 r2296846 4 4 Plugin URI: https://devotionalium.com/wordpress/ 5 5 Description: Include today's verses from devotionalium.com, with rich support for original languages. 6 Version: 1.2. 06 Version: 1.2.1 7 7 Author: Max Melzer 8 8 Author URI: http://moehrenzahn.de/en/about -
devotionalium/trunk/readme.txt
r2164860 r2296846 3 3 Tags: bible, quran, torah, devotion, watchword, losung, theology 4 4 Requires at least: 4.9 5 Tested up to: 5. 1.16 Stable tag: 1.2. 05 Tested up to: 5.3.2 6 Stable tag: 1.2.1 7 7 Requires PHP: 5.6 8 8 Text Domain: devotionalium … … 45 45 46 46 == Changelog == 47 = 1.2.1 = 48 * Add error handling in case Devotionalium API is not available 49 * Fixed issue where Devotionalium Verses were not read from cache properly 47 50 = 1.2.0 = 48 51 * Add setting to toggle Quran display -
devotionalium/trunk/src/Block/Devotionalium.php
r1824100 r2296846 3 3 namespace Devotionalium\Block; 4 4 5 use DateTime; 6 use Devotionalium\Block; 5 7 use Devotionalium\ConfigAccessor; 6 8 use Devotionalium\Plugin; 9 use Exception; 7 10 8 /** 9 * Class Devotionalium 10 * 11 * @package Devotionalium\Block 12 */ 13 class Devotionalium extends \Devotionalium\Block 11 class Devotionalium extends Block 14 12 { 15 13 /** … … 24 22 25 23 /** 26 * Devotionalium constructor.27 *28 24 * @param ConfigAccessor $config 29 25 * @param string $templatePath … … 84 80 $parts[] = _x('for', 'for a date', Plugin::WP_TEXTDOMAIN); 85 81 82 try { 83 $date = $this->getDevotionalium()->getDate(); 84 } catch (Exception $exception) { 85 $date = new DateTime(); 86 } 87 86 88 $parts[] = date_i18n( 87 89 get_option('date_format'), 88 $ this->getDevotionalium()->getDate()->getTimestamp()90 $date->getTimestamp() 89 91 ); 90 92 -
devotionalium/trunk/src/Block/Settings.php
r1875729 r2296846 4 4 5 5 use Devotionalium\Block; 6 use Devotionalium\Config\Section;7 6 8 7 class Settings extends Block -
devotionalium/trunk/src/Devotionalium/Devotionalium.php
r2164856 r2296846 45 45 /** 46 46 * @return Verse[] 47 * @throws \Exception 47 48 */ 48 49 public function getVerses() … … 56 57 /** 57 58 * @return \DateTime 59 * @throws \Exception 58 60 */ 59 61 public function getDate() … … 83 85 /** 84 86 * Lazily load content from api. 87 * 88 * @throws \Exception 85 89 */ 86 90 private function load() -
devotionalium/trunk/src/Model/Api/DevotionaliumApi.php
r2164856 r2296846 5 5 use Devotionalium\Devotionalium\Devotionalium; 6 6 use Devotionalium\Model\Storage\Transient; 7 use Exception; 7 8 8 9 class DevotionaliumApi … … 21 22 22 23 /** 23 * DevotionaliumApi constructor.24 *25 24 * @param string $endpointUrl 26 25 */ … … 39 38 * @param bool $showQuran 40 39 * @return Devotionalium 40 * @throws Exception 41 41 */ 42 42 public function loadDevotionalium( … … 51 51 ); 52 52 if ($cached = $this->transient->load($index)) { 53 //return $cached;53 return $cached; 54 54 } 55 55 … … 103 103 * @param string $language 104 104 * @return Version[] 105 * @throws \Exception105 * @throws Exception 106 106 */ 107 107 public function loadVersions($language = 'en') 108 108 { 109 $index = Communicator::ACTION_VERSIONS .'-'.$language;109 $index = Communicator::ACTION_VERSIONS . '-' . $language; 110 110 111 111 if ($cached = $this->transient->load($index)) { -
devotionalium/trunk/src/Plugin.php
r2164856 r2296846 10 10 use Devotionalium\Model\ShortCode; 11 11 use Devotionalium\Model\Widget; 12 use Exception; 12 13 13 14 class Plugin … … 73 74 { 74 75 $communicator = new DevotionaliumApi($this->config->getEndpointUrl()); 75 $versions = $communicator->loadVersions();76 76 $versionsArray = []; 77 foreach ($versions as $version) { 78 $versionsArray[$version->getId()] = $version->getName(); 77 try { 78 $versions = $communicator->loadVersions(); 79 foreach ($versions as $version) { 80 $versionsArray[$version->getId()] = $version->getName(); 81 } 82 } catch (Exception $exception) { 83 global $pagenow; 84 if ($pagenow === 'options-general.php' && $_GET['page'] === 'devotionalium') { 85 $this->loader->addAction( 86 'admin_notices', 87 $this, 88 'getNoConnectionErrorNotice' 89 ); 90 } 79 91 } 80 92 $generalSettings = [ … … 83 95 __('Original languages', Plugin::WP_TEXTDOMAIN), 84 96 __('Display verses from the Torah, the New Testament, and the Quran in original languages greek, hebrew, and arabic as well.', Plugin::WP_TEXTDOMAIN), 85 new \Devotionalium\Block\Setting('/View/config/setting/boolean.phtml')97 new Block\Setting('/View/config/setting/boolean.phtml') 86 98 ), 87 99 new Setting( … … 89 101 __('Display Quran verse', Plugin::WP_TEXTDOMAIN), 90 102 __('Display verses from the Quran.', Plugin::WP_TEXTDOMAIN), 91 new \Devotionalium\Block\Setting('/View/config/setting/boolean.phtml')103 new Block\Setting('/View/config/setting/boolean.phtml') 92 104 ), 93 105 new Setting\Select( … … 96 108 __('Choose a bible version to display Torah and New Testament verses in.', Plugin::WP_TEXTDOMAIN), 97 109 $versionsArray, 98 new \Devotionalium\Block\Setting('/View/config/setting/select.phtml')110 new Block\Setting('/View/config/setting/select.phtml') 99 111 ), 100 112 new Setting( … … 105 117 Plugin::WP_TEXTDOMAIN 106 118 ), 107 new \Devotionalium\Block\Setting('/View/config/setting/boolean.phtml')119 new Block\Setting('/View/config/setting/boolean.phtml') 108 120 ), 109 121 ]; … … 116 128 Plugin::WP_TEXTDOMAIN 117 129 ), 118 new \Devotionalium\Block\Setting('/View/config/setting/text-wide.phtml')130 new Block\Setting('/View/config/setting/text-wide.phtml') 119 131 ), 120 132 new Setting\Select( … … 126 138 'de' => __('German', Plugin::WP_TEXTDOMAIN) 127 139 ], 128 new \Devotionalium\Block\Setting('/View/config/setting/select.phtml')140 new Block\Setting('/View/config/setting/select.phtml') 129 141 ), 130 142 new Setting( … … 132 144 __('Day Offset', Plugin::WP_TEXTDOMAIN), 133 145 __('Offset the displayed Devotionalium by the given amount of days (-7 to 7).', Plugin::WP_TEXTDOMAIN), 134 new \Devotionalium\Block\Setting('/View/config/setting/text.phtml')146 new Block\Setting('/View/config/setting/text.phtml') 135 147 ), 136 148 new Setting( … … 141 153 Plugin::WP_TEXTDOMAIN 142 154 ), 143 new \Devotionalium\Block\Setting('/View/config/setting/textarea.phtml')155 new Block\Setting('/View/config/setting/textarea.phtml') 144 156 ), 145 157 ]; … … 149 161 '', 150 162 $generalSettings, 151 new \Devotionalium\Block\Section('/View/config/section.phtml')163 new Block\Section('/View/config/section.phtml') 152 164 ), 153 165 new Section( … … 155 167 __('Experimental', Plugin::WP_TEXTDOMAIN), 156 168 $experimentalSettings, 157 new \Devotionalium\Block\Section('/View/config/section.phtml'),169 new Block\Section('/View/config/section.phtml'), 158 170 __("Don't touch this if you don't know what you are doing.", Plugin::WP_TEXTDOMAIN) 159 171 ) … … 200 212 'devotionalium/languages' 201 213 ); 214 } 215 216 public function getNoConnectionErrorNotice() { 217 echo '<div class="notice notice-error"><p>'; 218 echo __('The Devotionalium API could not be reached. Please try again later.' , Plugin::WP_TEXTDOMAIN); 219 echo '</p></div>'; 202 220 } 203 221 -
devotionalium/trunk/src/View/devotionalium-widget.phtml
r2164856 r2296846 1 <?php /** @var \Devotionalium\Block\DevotionaliumWidget $block */ ?> 2 <?php echo $block->getBeforeWidget(); ?> 1 <?php 2 use Devotionalium\Block\DevotionaliumWidget; 3 4 /** @var DevotionaliumWidget $block */ 5 6 echo $block->getBeforeWidget(); 7 ?> 8 3 9 <style> 4 10 <?php echo $block->getCustomCss(); ?> 5 11 </style> 6 <?php echo $block->getBeforeTitle(); ?> 7 <?php echo $block->getHeading(); ?> 8 <?php echo $block->getAfterTitle(); ?> 12 <?php 13 echo $block->getBeforeTitle(); 14 echo $block->getHeading(); 15 echo $block->getAfterTitle(); 16 ?> 9 17 <div class="devotionalium"> 10 <?php foreach ($block->getDevotionalium()->getVerses() as $verse) : ?> 18 <?php 19 try { 20 $verses = $block->getDevotionalium()->getVerses(); 21 }catch (Exception $e) { 22 $verses = []; 23 } 24 foreach ($verses as $verse) : ?> 11 25 <?php if ($verse->getCollection() === 0) { 12 26 $collection = 'ot'; -
devotionalium/trunk/src/View/devotionalium.phtml
r2164856 r2296846 1 <?php /** @var \Devotionalium\Block\Devotionalium $block */ ?> 1 <?php 2 use Devotionalium\Block\Devotionalium; 3 4 /** @var Devotionalium $block */ 5 ?> 6 2 7 <style> 3 8 <?php echo $block->getCustomCss(); ?> … … 7 12 <?php echo $block->getHeading(); ?> 8 13 </h2> 9 <?php foreach ($block->getDevotionalium()->getVerses() as $verse) : ?> 14 <?php 15 try { 16 $verses = $block->getDevotionalium()->getVerses(); 17 } catch (Exception $e) { 18 $verses = []; 19 } 20 foreach ($verses as $verse) : ?> 10 21 <?php if ($verse->getCollection() === 0) { 11 22 $collection = 'ot';
Note: See TracChangeset
for help on using the changeset viewer.