Changeset 3771999 for wpide/trunk/App/App.php
- Timestamp:
- 10/29/2026 03:41:15 AM (16 hours ago)
- File:
-
- 1 edited
-
wpide/trunk/App/App.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wpide/trunk/App/App.php
r3236183 r3771999 56 56 public function activate() { 57 57 $this->installDropIn(); 58 59 \WPIDE\App\Services\Snippets\Schema::maybeInstall(); 58 60 } 59 61 … … 114 116 } 115 117 118 /** 119 * Whether the installed fatal-error-handler.php drop-in belongs to WPIDE. 120 */ 121 public function isOwnDropIn(): bool 122 { 123 $file = CONTENT_DIR.'/'.FATAL_ERROR_DROPIN; 124 125 if(!is_readable($file)) { 126 return false; 127 } 128 129 $header = (string) file_get_contents($file, false, null, 0, 512); 130 131 return strpos($header, 'WPide - Fatal Error Handler - Drop-In') !== false; 132 } 133 116 134 public function installDropIn() { 117 135 … … 119 137 120 138 if($fs->fileExists(FATAL_ERROR_DROPIN)) { 139 140 // Never replace a drop-in installed by another recovery provider. 141 if(!$this->isOwnDropIn()) { 142 update_option(FATAL_ERROR_DROPIN_VERSION_OPT.'_conflict', true); 143 return; 144 } 145 121 146 $this->unInstallDropIn(); 122 147 } … … 125 150 126 151 update_option(FATAL_ERROR_DROPIN_VERSION_OPT, FATAL_ERROR_DROPIN_VERSION); 152 delete_option(FATAL_ERROR_DROPIN_VERSION_OPT.'_conflict'); 127 153 } 128 154 … … 131 157 $fs = LocalFileSystem::load(CONTENT_DIR); 132 158 133 if($fs->fileExists(FATAL_ERROR_DROPIN) ) {159 if($fs->fileExists(FATAL_ERROR_DROPIN) && $this->isOwnDropIn()) { 134 160 $fs->deleteFile(FATAL_ERROR_DROPIN); 135 161 } 162 } 163 164 public function dropInConflictNotice() { 165 166 if(!get_option(FATAL_ERROR_DROPIN_VERSION_OPT.'_conflict') || !current_user_can('manage_options')) { 167 return; 168 } 169 ?> 170 <div class="notice notice-warning wpide-notice" data-slug="<?php echo esc_attr(SLUG); ?>"> 171 <p><?php echo esc_html__('WPIDE did not install its file recovery drop-in because wp-content/fatal-error-handler.php belongs to another plugin. File recovery after a fatal error is unavailable until that file is removed.', 'wpide'); ?></p> 172 </div> 173 <?php 136 174 } 137 175 … … 149 187 $this->installDropIn(); 150 188 } 189 190 add_action('admin_notices', [$this, 'dropInConflictNotice']); 151 191 152 192 $this->loadTextDomain(); … … 286 326 ], 287 327 [ 328 'title' => __( 'Snippets', 'wpide' ), 329 'slug' => SLUG.'#/snippets', 330 'callback' => [$this, 'bootstrap'], 331 'position' => 30 332 ], 333 [ 288 334 'title' => __( 'Settings', 'wpide' ), 289 335 'slug' => SLUG.'#/settings', … … 515 561 * @since 1.0.0 516 562 */ 517 public function getExternalUrl( string $utm_content = null,string $url = null): string563 public function getExternalUrl(?string $utm_content = null, ?string $url = null): string 518 564 { 519 565
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)