| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: WP-Appbox |
| 4 |
Version: 4.5.13 |
| 5 |
Plugin URI: https://tchgdns.de/wp-appbox-app-badge-fuer-google-play-mac-app-store-windows-store-windows-phone-store-co/ |
| 6 |
Description: With WP-Appbox you can add beautiful mobile app badges to your WordPress posts and pages simply by adding a shortcode. |
| 7 |
Author: Marcel Schmilgeit |
| 8 |
Author URI: https://tchgdns.de |
| 9 |
Text Domain: wp-appbox |
| 10 |
Domain Path: /lang |
| 11 |
*/ |
| 12 |
|
| 13 |
|
| 14 |
/* |
| 15 |
Copyright (C) 2012-2025 Marcel Schmilgeit |
| 16 |
|
| 17 |
This program is free software; you can redistribute it and/or modify |
| 18 |
it under the terms of the GNU General Public License as published by |
| 19 |
the Free Software Foundation; either version 2 of the License, or |
| 20 |
(at your option) any later version. |
| 21 |
|
| 22 |
This program is distributed in the hope that it will be useful, |
| 23 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 24 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 25 |
GNU General Public License for more details. |
| 26 |
|
| 27 |
You should have received a copy of the GNU General Public License along |
| 28 |
with this program; if not, write to the Free Software Foundation, Inc., |
| 29 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 30 |
*/ |
| 31 |
|
| 32 |
/* PHP-Fehlerausgabe deaktivieren */ |
| 33 |
//error_reporting( E_ALL ); |
| 34 |
// |
| 35 |
|
| 36 |
defined( 'ABSPATH' ) or exit( 'Nothing to see here' ); // Exit if accessed directly |
| 37 |
|
| 38 |
|
| 39 |
/** |
| 40 |
* Ein paar Definitionen #YOLO |
| 41 |
*/ |
| 42 |
|
| 43 |
global $wpdb; |
| 44 |
define( 'WPAPPBOX_MIN_PHPVERSION', '7.4' ); |
| 45 |
define( 'WPAPPBOX_PLUGIN_NAME', 'WP-Appbox' ); |
| 46 |
define( 'WPAPPBOX_PLUGIN_VERSION', '4.5.13' ); |
| 47 |
define( 'WPAPPBOX_DB_VERSION', '1.0.4' ); |
| 48 |
define( 'WPAPPBOX_PREFIX', 'wpAppbox_' ); |
| 49 |
define( 'WPAPPBOX_TABLE_NAME', 'appbox' ); |
| 50 |
$wpAppboxFirstShortcode = true; |
| 51 |
|
| 52 |
|
| 53 |
/** |
| 54 |
* Includierung benötigter Scripte und Dateien |
| 55 |
* |
| 56 |
* @since 4.5.9 |
| 57 |
*/ |
| 58 |
function wpAppbox_includeFiles() { |
| 59 |
include_once( "inc/definitions.php" ); |
| 60 |
include_once( "inc/appboxdb.php" ); |
| 61 |
include_once( "inc/imagecache.class.php" ); |
| 62 |
include_once( "inc/getstoreurls.class.php" ); |
| 63 |
if ( is_admin() ) { |
| 64 |
include_once( 'admin/tinymce.php' ); |
| 65 |
include_once( "admin/settings.php" ); |
| 66 |
if ( isset( $_GET['page'] ) && 'wp-appbox' == $_GET['page'] ) { |
| 67 |
switch ( isset( $_GET['tab'] ) ) { |
| 68 |
case 'storeurls': |
| 69 |
case 'advanced': |
| 70 |
include_once( "inc/getstoreurls.class.php" ); |
| 71 |
break; |
| 72 |
case 'cache-list': |
| 73 |
include_once( "inc/getappinfo.class.php" ); |
| 74 |
include_once( "inc/createoutput.class.php" ); |
| 75 |
break; |
| 76 |
} |
| 77 |
} |
| 78 |
} |
| 79 |
if ( !is_admin() ) { |
| 80 |
include_once( "inc/getappinfo.class.php" ); |
| 81 |
include_once( "inc/createattributs.class.php" ); |
| 82 |
include_once( "inc/createoutput.class.php" ); |
| 83 |
} |
| 84 |
} |
| 85 |
add_action( 'init', 'wpAppbox_includeFiles' ); |
| 86 |
add_action( 'admin_init', 'wpAppbox_includeFiles' ); |
| 87 |
|
| 88 |
|
| 89 |
/** |
| 90 |
* Laden der Sprachpakete |
| 91 |
* |
| 92 |
* @since 1.0.0 |
| 93 |
* @change 4.5.6 |
| 94 |
*/ |
| 95 |
function wpAppbox_loadTextdomain() { |
| 96 |
load_textdomain( 'wp-appbox', plugin_dir_path( __FILE__ ) . 'languages/wp-appbox-' . determine_locale() . '.mo' ); |
| 97 |
} |
| 98 |
add_action( 'init', 'wpAppbox_loadTextdomain' ); |
| 99 |
|
| 100 |
|
| 101 |
/** |
| 102 |
* Cron Schedules für den Cache-Cronjob festlegen und Cron registrieren |
| 103 |
* |
| 104 |
* @since 4.0.0 |
| 105 |
* @change 4.4.0 |
| 106 |
* |
| 107 |
* @param ka $schedules ka |
| 108 |
* @return ka $schedules ka |
| 109 |
*/ |
| 110 |
|
| 111 |
function wpAppbox_cronSchedules( $schedules ) { |
| 112 |
global $wpAppbox_optionsDefault; |
| 113 |
$cronIntervall = intval( get_option( 'wpAppbox_cronIntervall' ) ); |
| 114 |
if ( !is_int( $cronIntervall ) || 0 == $cronIntervall ) |
| 115 |
$cronIntervall = $wpAppbox_optionsDefault['cronIntervall']; |
| 116 |
$schedules["wp_appbox_cache"] = array( |
| 117 |
'interval' => $cronIntervall * 60, |
| 118 |
'display' => sprintf( __( 'Every %1$s minutes', 'wp-appbox' ), esc_attr( $cronIntervall ) ) |
| 119 |
); |
| 120 |
return( $schedules ); |
| 121 |
} |
| 122 |
|
| 123 |
function wpAppbox_setupCronCache() { |
| 124 |
if ( wp_get_schedule('wpAppbox_cacheCron' ) ) |
| 125 |
wp_clear_scheduled_hook( 'wpAppbox_cacheCron' ); |
| 126 |
if ( 'cronjob' == get_option( 'wpAppbox_cacheMode' ) ) |
| 127 |
wp_schedule_event( time(), 'wp_appbox_cache', 'wpAppbox_cacheCron' ); |
| 128 |
} |
| 129 |
|
| 130 |
if ( 'cronjob' == get_option( 'wpAppbox_cacheMode' ) ) { |
| 131 |
add_filter( 'cron_schedules', 'wpAppbox_cronSchedules' ); |
| 132 |
add_action( 'wpAppbox_cacheCron', 'wpAppbox_cacheCron' ); |
| 133 |
} |
| 134 |
|
| 135 |
|
| 136 |
/** |
| 137 |
* Prüfen ob der Nutzer Autor (min. User-Level 2) ist |
| 138 |
* |
| 139 |
* @since 2.0.0 |
| 140 |
* @change 4.0.9 |
| 141 |
* |
| 142 |
* @return boolean true/false TRUE when author |
| 143 |
*/ |
| 144 |
|
| 145 |
function wpAppbox_isUserAuthor() { |
| 146 |
if ( current_user_can( 'editor' ) || current_user_can( 'author' ) || current_user_can( 'administrator' ) ) |
| 147 |
return( true ); |
| 148 |
else |
| 149 |
return( false ); |
| 150 |
} |
| 151 |
|
| 152 |
|
| 153 |
/** |
| 154 |
* Prüfen ob der Nutzer Admin (min. User-Level 9) ist |
| 155 |
* |
| 156 |
* @since 2.0.0 |
| 157 |
* @change 4.0.9 |
| 158 |
* |
| 159 |
* @return boolean true/false TRUE when admin |
| 160 |
*/ |
| 161 |
|
| 162 |
function wpAppbox_isUserAdmin() { |
| 163 |
if ( current_user_can( 'administrator' ) ) |
| 164 |
return( true ); |
| 165 |
else |
| 166 |
return( false ); |
| 167 |
} |
| 168 |
|
| 169 |
|
| 170 |
/** |
| 171 |
* Ausgabe der Fehlermeldungen |
| 172 |
* |
| 173 |
* @since 2.0.0 |
| 174 |
* @change 4.0.9 |
| 175 |
* |
| 176 |
* @param string $output Fehlermeldung [optional] |
| 177 |
* @print error message |
| 178 |
*/ |
| 179 |
|
| 180 |
function wpAppbox_errorOutput( $output = "" ) { |
| 181 |
if ( !wpAppbox_isUserAdmin() ) return; |
| 182 |
switch( get_option( "wpAppbox_eOutput" ) ): |
| 183 |
case 'output': |
| 184 |
print_r( "<pre>$output</pre>" ); |
| 185 |
break; |
| 186 |
case 'errorlog': |
| 187 |
error_log( $output ); |
| 188 |
break; |
| 189 |
case 'output+errorlog': |
| 190 |
print_r( "<pre>$output</pre>" ); |
| 191 |
error_log( $output ); |
| 192 |
break; |
| 193 |
endswitch; |
| 194 |
} |
| 195 |
|
| 196 |
|
| 197 |
/** |
| 198 |
* Prüfen ob "?wpappbox_reload_cache" angehangen |
| 199 |
* |
| 200 |
* @since 2.0.0 |
| 201 |
* @change 4.0.7 |
| 202 |
* |
| 203 |
* @return boolean true/false TRUE when $_GET[] |
| 204 |
*/ |
| 205 |
|
| 206 |
function wpAppbox_forceNewCache( $cacheID ) { |
| 207 |
if ( !wpAppbox_isUserAuthor() ) return( false ); |
| 208 |
if ( ( isset( $_GET["wpappbox_reload_cache"] ) ) || ( isset( $_GET["action"] ) && $_GET["action"] === 'wpappbox_reload_cache' ) ): |
| 209 |
if ( !isset( $_GET["app_cache_id"] ) ): |
| 210 |
return( false ); |
| 211 |
elseif ( $_GET["app_cache_id"] === $cacheID ): |
| 212 |
return( true ); |
| 213 |
endif; |
| 214 |
endif; |
| 215 |
} |
| 216 |
|
| 217 |
|
| 218 |
/** |
| 219 |
* Einlesen des Templates |
| 220 |
* |
| 221 |
* @since 2.0.0 |
| 222 |
* @change 4.0.5 |
| 223 |
* |
| 224 |
* @param string $styleName Verwendeter Stil |
| 225 |
* @param boolean $themeTemplate Deprecated [optional] |
| 226 |
* @return string $tpl Ausgabe des Banners |
| 227 |
*/ |
| 228 |
|
| 229 |
function wpAppbox_loadTemplate( $styleName, $themeTemplate = false ) { |
| 230 |
ob_start(); |
| 231 |
if ( file_exists( get_stylesheet_directory() . "/wpappbox-$styleName.php" ) ): |
| 232 |
include( get_stylesheet_directory()."/wpappbox-$styleName.php" ); |
| 233 |
elseif ( file_exists( get_stylesheet_directory() . "/wpappbox/$styleName.php" ) ): |
| 234 |
include( get_stylesheet_directory()."/wpappbox/$styleName.php" ); |
| 235 |
elseif ( file_exists( plugin_dir_path( __FILE__ ) . "tpl/$styleName.php" ) ): |
| 236 |
include( "tpl/$styleName.php" ); |
| 237 |
else: |
| 238 |
return( false ); |
| 239 |
endif; |
| 240 |
$tpl = ob_get_contents(); |
| 241 |
ob_end_clean(); |
| 242 |
return( $tpl ); |
| 243 |
} |
| 244 |
|
| 245 |
|
| 246 |
/** |
| 247 |
* Löscht den Seiten-Cache eines Cache-Plugins |
| 248 |
* |
| 249 |
* @since 4.0.0 |
| 250 |
* @change 4.2.0 |
| 251 |
* |
| 252 |
* @param string $postID ID des Posts |
| 253 |
*/ |
| 254 |
|
| 255 |
function wpAppbox_clearCachePlugin( $postID = '') { |
| 256 |
global $post; |
| 257 |
if ( !isset( $post ) ) return( false ); |
| 258 |
$postID = $post->ID; |
| 259 |
if ( false == get_option( 'wpappbox_cachePlugin' ) || !is_single() || !isset( $postID ) || '' == $postID ) return; |
| 260 |
switch ( get_option( 'wpappbox_cachePlugin' ) ): |
| 261 |
case 'cachify': |
| 262 |
if ( has_action( 'cachify_remove_post_cache' ) ): |
| 263 |
do_action( 'cachify_remove_post_cache', $postID ); |
| 264 |
endif; |
| 265 |
break; |
| 266 |
case 'w3-total-cache': |
| 267 |
if ( function_exists( 'w3tc_pgcache_flush_post' ) ): |
| 268 |
w3tc_pgcache_flush_post( $postID ); |
| 269 |
endif; |
| 270 |
case 'wp-super-cache': |
| 271 |
if ( function_exists( 'wp_cache_post_change' ) ): |
| 272 |
$GLOBALS["super_cache_enabled"] = 1; |
| 273 |
wp_cache_post_change( $postID ); |
| 274 |
endif; |
| 275 |
break; |
| 276 |
case 'wp-rocket': |
| 277 |
if ( function_exists( 'rocket_clean_post' ) ): |
| 278 |
rocket_clean_post( $postID ); |
| 279 |
endif; |
| 280 |
break; |
| 281 |
case 'wp-fastest-cache': |
| 282 |
if ( isset( $GLOBALS['wp_fastest_cache'] ) && method_exists( $GLOBALS['wp_fastest_cache'], 'singleDeleteCache' ) ): |
| 283 |
$GLOBALS['wp_fastest_cache']->singleDeleteCache( false, $postID ); |
| 284 |
endif; |
| 285 |
break; |
| 286 |
case 'zencache': |
| 287 |
if ( isset( $GLOBALS['zencache'] ) && method_exists( $GLOBALS['zencache'], 'auto_clear_post_cache' ) ): |
| 288 |
$GLOBALS['zencache']->auto_clear_post_cache( $postID ); |
| 289 |
endif; |
| 290 |
break; |
| 291 |
case 'cache-enabler': |
| 292 |
if ( has_action( 'ce_clear_post_cache' ) ): |
| 293 |
do_action( 'ce_clear_post_cache', $postID ); |
| 294 |
endif; |
| 295 |
break; |
| 296 |
endswitch; |
| 297 |
} |
| 298 |
|
| 299 |
|
| 300 |
/** |
| 301 |
* Prüfen ob Versionsnummer älter oder neuer |
| 302 |
* |
| 303 |
* @since 3.1.6 |
| 304 |
* @change 4.1.13 |
| 305 |
* |
| 306 |
* @param string $this_ver Zu prüfende Versionsnummer |
| 307 |
* @param string $com_ver Versionsnummer in der Datenbank |
| 308 |
* @return boolean true/false TRUE when $this_ver neuer |
| 309 |
*/ |
| 310 |
|
| 311 |
function wpAppbox_checkOlderVersion( $this_ver = '', $comp_ver = '' ) { |
| 312 |
if ( $this_ver == '' ) $this_ver = WPAPPBOX_PLUGIN_VERSION; |
| 313 |
if ( $comp_ver == '' ) $comp_ver = get_option( 'wpAppbox_pluginVersion' ); |
| 314 |
if ( $comp_ver == '' ) $comp_ver = $this_ver; |
| 315 |
if ( version_compare( $this_ver, $comp_ver ) == 1 ) |
| 316 |
return( true ); |
| 317 |
} |
| 318 |
|
| 319 |
|
| 320 |
/** |
| 321 |
* Appbox-Banner erstellen und ausgeben |
| 322 |
* |
| 323 |
* @since 2.0.0 |
| 324 |
* @change 4.5.5 |
| 325 |
* |
| 326 |
* @param string $appboxAttributs Attribute des Shortcodes |
| 327 |
* @param string $content Inhalte des Shortcodes [deprecated] |
| 328 |
* @return string $output Ausgabe des Banners |
| 329 |
*/ |
| 330 |
|
| 331 |
function wpAppbox_createAppbox( $appboxAttributs, $content = null ) { |
| 332 |
if ( is_admin() ) return( false ); |
| 333 |
$appboxAttributs = array_map( 'esc_attr', $appboxAttributs ); |
| 334 |
global $wpAppboxFirstShortcode; |
| 335 |
$runtimeStart = microtime( true ); |
| 336 |
wpAppbox_errorOutput( "//=================================================" ); |
| 337 |
$attr = new wpAppbox_CreateAttributs; |
| 338 |
$attr = $attr->devideAttributs( $appboxAttributs ); |
| 339 |
wpAppbox_errorOutput( "APP-ID: ".$attr['appid'] ); |
| 340 |
$output = new wpAppbox_CreateOutput; |
| 341 |
$output = $output->theOutput( $attr ); |
| 342 |
if ( $wpAppboxFirstShortcode ): |
| 343 |
if ( !get_option('wpAppbox_disableDefer') ): |
| 344 |
wpAppbox_registerStyle(); |
| 345 |
wpAppbox_loadFonts(); |
| 346 |
endif; |
| 347 |
$wpAppboxFirstShortcode = false; |
| 348 |
endif; |
| 349 |
$runtimeEnd = microtime( true ); |
| 350 |
$runetimeResult = $runtimeEnd - $runtimeStart; |
| 351 |
wpAppbox_errorOutput( "function: wpAppbox_createAppbox() ---> Runtime: $runetimeResult seconds\n" ); |
| 352 |
wpAppbox_errorOutput( "//=================================================\n\n" ); |
| 353 |
return( $output ); |
| 354 |
} |
| 355 |
|
| 356 |
|
| 357 |
/** |
| 358 |
* Store-URLs automatisch erkennen und umwandeln |
| 359 |
* |
| 360 |
* @since 3.3.0 |
| 361 |
* @change 4.4.6 |
| 362 |
* |
| 363 |
* @param string $appboxAttributs Attribute des Shortcodes |
| 364 |
*/ |
| 365 |
|
| 366 |
function wpAppbox_autoDetectLinks( $content ) { |
| 367 |
|
| 368 |
//Links zum App Store |
| 369 |
$pattern = array( '/^(?:<p>)?http.?:\/\/.*?apps.apple.com\/(?:.*?\/)?app\/(?:.*?\/)?id([0-9]{1,45}).*?(?:<\/p>)?$/m', |
| 370 |
'/^(?:<p>)?http.?:\/\/.*?apps.apple.com\/WebObjects\/MZStore\.woa\/wa\/viewSoftware\?id=([0-9]{1,45}).*?(?:<\/p>)?$/m', |
| 371 |
'/^(?:<p>)?http.?:\/\/.*?itunes.apple.com\/(?:.*?\/)?app\/(?:.*?\/)?id([0-9]{1,45}).*?(?:<\/p>)?$/m', |
| 372 |
'/^(?:<p>)?http.?:\/\/.*?itunes.apple.com\/WebObjects\/MZStore\.woa\/wa\/viewSoftware\?id=([0-9]{1,45}).*?(?:<\/p>)?$/m' |
| 373 |
); |
| 374 |
$content = preg_replace_callback( $pattern, function ( $matches ) { |
| 375 |
$appID = Trim( $matches[1] ); |
| 376 |
return( '[appbox appstore ' . $appID . ']' ); |
| 377 |
}, $content ); |
| 378 |
|
| 379 |
|
| 380 |
//Links zum Play Store |
| 381 |
$pattern = '/^(?:<p>)?http.?:\/\/play\.google\.com\/store\/apps\/details(?:\/)?\?id=(.*?)(?:\&.*?)?(?:<\/p>)?$/m'; |
| 382 |
$content = preg_replace_callback( $pattern, function ( $matches ) { |
| 383 |
$appID = Trim( $matches[1] ); |
| 384 |
return( '[appbox googleplay ' . $appID . ']' ); |
| 385 |
}, $content ); |
| 386 |
|
| 387 |
//Links zum Microsoft Store |
| 388 |
$pattern = array( '/^(?:<p>)?http.?:\/\/(?:www\.)?microsoft\.com\/.*?\/(?:apps|p)\/.*?\/(.*?)(?:\?.*?)?(?:<\/p>)?$/m', |
| 389 |
'/^(?:<p>)?http.?:\/\/apps\.microsoft\.com\/store\/detail\/.*?\/(.*?)(?:\?.*?)?(?:<\/p>)?$/m' |
| 390 |
); |
| 391 |
$content = preg_replace_callback( $pattern, function ( $matches ) { |
| 392 |
$appID = Trim( $matches[1] ); |
| 393 |
return( '[appbox microsoftstore ' . $appID . ']' ); |
| 394 |
}, $content ); |
| 395 |
|
| 396 |
//Links zu Edge-Add-Ons |
| 397 |
$pattern = '/^(?:<p>)?http.?:\/\/microsoftedge\.microsoft\.com\/addons\/detail\/.*?\/(.*?)(?:\?.*?)?(?:\&.*?)?(?:<\/p>)?$/m'; |
| 398 |
$content = preg_replace_callback( $pattern, function ( $matches ) { |
| 399 |
$appID = Trim( $matches[1] ); |
| 400 |
return( '[appbox edgeaddons ' . $appID . ']' ); |
| 401 |
}, $content ); |
| 402 |
|
| 403 |
//Links zu Amazon-Apps |
| 404 |
$pattern = array( '/^(?:<p>)?http.?:\/\/www\.amazon\.*(?:.*?)\/gp\/product\/([A-Za-z0-9]*)(?:.*)(?:<\/p>)?$/m', |
| 405 |
'/^(?:<p>)?http.?:\/\/www\.amazon\.*(?:.*?)\/dp\/([A-Za-z0-9]*)(?:.*)(?:<\/p>)?$/m', |
| 406 |
'/^(?:<p>)?http.?:\/\/www\.amazon\.*(?:.*?)\/exec\/obidos\/ASIN\/([A-Za-z0-9]*)(?:.*)(?:<\/p>)?$/m' |
| 407 |
); |
| 408 |
$content = preg_replace_callback( $pattern, function ( $matches ) { |
| 409 |
$appID = Trim( $matches[1] ); |
| 410 |
return( '[appbox amazonapps ' . $appID . ']' ); |
| 411 |
}, $content ); |
| 412 |
|
| 413 |
//Links zu F-Droid |
| 414 |
$pattern = '/^(?:<p>)?http.?:\/\/f\-droid\.org\/(?:.*\/)packages\/(.*?)\/?(?:<\/p>)?$/m'; |
| 415 |
$content = preg_replace_callback( $pattern, function ( $matches ) { |
| 416 |
$appID = Trim( $matches[1] ); |
| 417 |
return( '[appbox fdroid ' . $appID . ']' ); |
| 418 |
}, $content ); |
| 419 |
|
| 420 |
//Links zu Firefox-Addons |
| 421 |
$pattern = '/^(?:<p>)?http.?:\/\/addons\.mozilla\.org\/.*?\/firefox\/addon\/(.*?)(?:\/)?(?:<\/p>)?$/m'; |
| 422 |
$content = preg_replace_callback( $pattern, function ( $matches ) { |
| 423 |
$appID = Trim( $matches[1] ); |
| 424 |
return( '[appbox firefoxaddon ' . $appID . ']' ); |
| 425 |
}, $content ); |
| 426 |
|
| 427 |
//Links zum Chrome Web Store |
| 428 |
$pattern = '/^(?:<p>)?http.?:\/\/chrome\.google\.com\/webstore\/detail\/.*?\/(.*?)(?:\?.*?)?(?:\&.*?)?(?:<\/p>)?$/m'; |
| 429 |
$content = preg_replace_callback( $pattern, function ( $matches ) { |
| 430 |
$appID = Trim( $matches[1] ); |
| 431 |
return( '[appbox chromewebstore ' . $appID . ']' ); |
| 432 |
}, $content ); |
| 433 |
|
| 434 |
//Links zu WordPress Plugins |
| 435 |
$pattern = '/^(?:<p>)?http.?:\/\/(?:www\.)?wordpress\.org\/plugins\/([A-Za-z0-9-]*)(?:.*)?(?:<\/p>)?$/m'; |
| 436 |
$content = preg_replace_callback( $pattern, function ( $matches ) { |
| 437 |
$appID = Trim( $matches[1] ); |
| 438 |
return( '[appbox wordpress ' . $appID . ']' ); |
| 439 |
}, $content ); |
| 440 |
|
| 441 |
//Links zu Snapcraft |
| 442 |
$pattern = '/^(?:<p>)?http.?:\/\/snapcraft\.io\/([A-Za-z0-9-_]*)(?:.*)?(?:<\/p>)?$/m'; |
| 443 |
$content = preg_replace_callback( $pattern, function ( $matches ) { |
| 444 |
$appID = Trim( $matches[1] ); |
| 445 |
return( '[appbox snapcraft ' . $appID . ']' ); |
| 446 |
}, $content ); |
| 447 |
|
| 448 |
//Links zu Opera Addons |
| 449 |
$pattern = '/^(?:<p>)?http.?:\/\/addons\.opera\.com\/(?:.*\/)?extensions\/details\/([A-Za-z0-9-_]*)(?:.*)?(?:<\/p>)?$/m'; |
| 450 |
$content = preg_replace_callback( $pattern, function ( $matches ) { |
| 451 |
$appID = Trim( $matches[1] ); |
| 452 |
return( '[appbox operaaddons ' . $appID . ']' ); |
| 453 |
}, $content ); |
| 454 |
|
| 455 |
//Post-Content zurückgegen |
| 456 |
return( $content ); |
| 457 |
} |
| 458 |
if ( get_option('wpAppbox_autoLinks') ) add_filter( 'the_content', 'wpAppbox_autoDetectLinks', 0 ); |
| 459 |
|
| 460 |
|
| 461 |
/** |
| 462 |
* Benötigte Update-Funktionen durchführen |
| 463 |
* |
| 464 |
* @since 3.1.6 |
| 465 |
* @change 4.5.8 |
| 466 |
*/ |
| 467 |
|
| 468 |
wpAppbox_UpdateAction(); |
| 469 |
|
| 470 |
function wpAppbox_UpdateAction() { |
| 471 |
if ( get_option('wpAppbox_pluginVersion') == WPAPPBOX_PLUGIN_VERSION ) return; |
| 472 |
if ( wpAppbox_checkOlderVersion( '4.5.9' ) ) { |
| 473 |
global $wpdb; |
| 474 |
$sql = "DELETE FROM $wpdb->options WHERE option_name LIKE ('%wpAppbox_%steam%') OR option_name LIKE ('%wpAppbox_%gog%') OR option_name LIKE ('%wpAppbox_%appgallery%')"; |
| 475 |
$wpdb->query( $sql ); |
| 476 |
$sql = "DELETE FROM wp_appbox WHERE store_name_css LIKE ('%steam%') OR store_name_css LIKE ('%gog%') OR store_name_css LIKE ('%appgallery%')"; |
| 477 |
$wpdb->query( $sql ); |
| 478 |
$sql = " UPDATE wp_appbox SET store_name_css = REPLACE( store_name_css, 'macappstore', 'appstore' ) WHERE store_name_css LIKE '%macappstore%'"; |
| 479 |
$wpdb->query( $sql ); |
| 480 |
} |
| 481 |
if ( wpAppbox_checkOlderVersion( '4.5.2' ) ) { |
| 482 |
delete_option( 'wpAppbox_userAffiliate' ); |
| 483 |
delete_option( 'wpAppbox_affiliateMicrosoftDev' ); |
| 484 |
delete_option( 'wpAppbox_affiliateMicrosoftProgram' ); |
| 485 |
delete_option( 'wpAppbox_affiliateMicrosoftID' ); |
| 486 |
} |
| 487 |
if ( wpAppbox_checkOlderVersion( '4.5.0' ) ) { |
| 488 |
delete_option( 'wpAppbox_amaAPIregion' ); |
| 489 |
delete_option( 'wpAppbox_storeURL_amazon' ); |
| 490 |
delete_option( 'wpAppbox_affiliateAmazonID' ); |
| 491 |
delete_option( 'wpAppbox_affiliateAmazonDev' ); |
| 492 |
update_option( 'wpAppbox_affiliateMicrosoftDev', true, 'no' ); |
| 493 |
} |
| 494 |
if ( wpAppbox_checkOlderVersion( '4.4.0' ) ) { |
| 495 |
wpAppbox_setOptions(); |
| 496 |
} |
| 497 |
if ( wpAppbox_checkOlderVersion( '4.3.6' ) ) { |
| 498 |
global $wpdb; |
| 499 |
$sql = "DELETE FROM $wpdb->options WHERE option_name LIKE ('%wpAppbox_%xda%')"; |
| 500 |
$wpdb->query( $sql ); |
| 501 |
$sql = "DELETE FROM wp_appbox WHERE store_name_css LIKE ('%xda%')"; |
| 502 |
$wpdb->query( $sql ); |
| 503 |
} |
| 504 |
if ( wpAppbox_checkOlderVersion( '4.2.0' ) ) { |
| 505 |
global $wpdb; |
| 506 |
wpAppbox_setOptions(); |
| 507 |
wpAppbox_changeStoreName( 'windowsstore', 'microsoftstore', 'Microsoft Store' ); |
| 508 |
} |
| 509 |
if ( wpAppbox_checkOlderVersion( '4.1.26' ) ) { |
| 510 |
wpAppbox_setOptions(); |
| 511 |
delete_option( 'wpAppbox_amaAPIuse' ); |
| 512 |
delete_option( 'wpAppbox_amaAPIsecretKey' ); |
| 513 |
delete_option( 'wpAppbox_amaAPIpublicKey' ); |
| 514 |
delete_option( 'wpAppbox_affiliateAmazonID' ); |
| 515 |
delete_option( 'wpAppbox_amaAPIregion' ); |
| 516 |
} |
| 517 |
if ( wpAppbox_checkOlderVersion( '4.0.63' ) ) { |
| 518 |
global $wpdb; |
| 519 |
$sql = "DELETE FROM $wpdb->options WHERE option_name LIKE ('%wpAppbox_%affiliateApple%')"; |
| 520 |
$wpdb->query( $sql ); |
| 521 |
$sql = "DELETE FROM $wpdb->options WHERE option_name LIKE ('%wpAppbox_%firefoxmarketplace%')"; |
| 522 |
$wpdb->query( $sql ); |
| 523 |
} |
| 524 |
if ( wpAppbox_checkOlderVersion( '4.0.54' ) ) { |
| 525 |
global $wpdb; |
| 526 |
$sql = "DELETE FROM $wpdb->options WHERE option_name LIKE ('%wpAppbox_%firefoxmarketplace%')"; |
| 527 |
$wpdb->query( $sql ); |
| 528 |
$sql = "DELETE FROM wp_appbox WHERE store_name_css LIKE ('%firefoxmarketplace%')"; |
| 529 |
$wpdb->query( $sql ); |
| 530 |
} |
| 531 |
if ( wpAppbox_checkOlderVersion( '4.0.47' ) ) { |
| 532 |
switch ( get_option('wpAppbox_imgCacheMode') ): |
| 533 |
case 'appicon': |
| 534 |
update_option( 'wpAppbox_imgCacheMode', array( 'appicon' ), 'no' ); |
| 535 |
break; |
| 536 |
case 'screenshots': |
| 537 |
update_option( 'wpAppbox_imgCacheMode', array( 'screenshots' ), 'no' ); |
| 538 |
break; |
| 539 |
case 'appicon+screenshots': |
| 540 |
update_option( 'wpAppbox_imgCacheMode', array( 'appicon', 'screenshots' ), 'no' ); |
| 541 |
break; |
| 542 |
endswitch; |
| 543 |
} |
| 544 |
if ( wpAppbox_checkOlderVersion( '4.0.45' ) ) { |
| 545 |
delete_option( 'wpAppbox_cacheCronjob' ); |
| 546 |
} |
| 547 |
if ( wpAppbox_checkOlderVersion( '4.0.42' ) ) { |
| 548 |
if ( get_option( 'wpAppbox_disableCSS' ) ) |
| 549 |
update_option( 'wpAppbox_includeCSS', 1, 'no' ); |
| 550 |
else |
| 551 |
update_option( 'wpAppbox_includeCSS', 0, 'no' ); |
| 552 |
delete_option( 'wpAppbox_disableCSS' ); |
| 553 |
} |
| 554 |
if ( wpAppbox_checkOlderVersion( '4.0.30' ) ) { |
| 555 |
global $wpdb; |
| 556 |
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE ('%wpAppbox_blockQuery_%')" ); |
| 557 |
} |
| 558 |
if ( wpAppbox_checkOlderVersion( '4.0.18' ) ) { |
| 559 |
if ( !get_option('wpAppbox_affiliateApple') ) |
| 560 |
update_option( 'wpAppbox_affiliateAppleDev', true, 'no' ); |
| 561 |
if ( !get_option('wpAppbox_affiliateAmazon') ) |
| 562 |
update_option( 'wpAppbox_affiliateAmazonDev', true, 'no' ); |
| 563 |
if ( !get_option('wpAppbox_affiliateMicrosoft') ) |
| 564 |
update_option( 'wpAppbox_affiliateMicrosoftDev', true, 'no' ); |
| 565 |
} |
| 566 |
if ( wpAppbox_checkOlderVersion( '4.0.15' ) ) |
| 567 |
wpAppbox_setOptions(); |
| 568 |
if ( wpAppbox_checkOlderVersion( '4.0.10' ) ) |
| 569 |
delete_option( 'wpAppbox_iTunesGeo' ); |
| 570 |
if ( wpAppbox_checkOlderVersion( '4.0.9' ) ) |
| 571 |
wpAppbox_autoLanguageStoreURLs(); |
| 572 |
if ( wpAppbox_checkOlderVersion( '4.0.7' ) ) { |
| 573 |
if ( get_option('wpAppbox_sslAppleImages') ) |
| 574 |
update_option( 'wpAppbox_forceSSL', true, 'no' ); |
| 575 |
else |
| 576 |
update_option( 'wpAppbox_forceSSL', false, 'no' ); |
| 577 |
delete_option( 'wpAppbox_sslAppleImages' ); |
| 578 |
delete_option( 'wpAppbox_eImageApple' ); |
| 579 |
} |
| 580 |
if ( wpAppbox_checkOlderVersion( '4.0.0' ) ) { |
| 581 |
global $wpdb; |
| 582 |
$whereQuery = "option_name = 'wpAppbox_pluginVersion'"; |
| 583 |
$whereQuery .= " OR option_name = 'wpAppbox_cacheTime'"; |
| 584 |
$whereQuery .= " OR option_name = 'wpAppbox_disableDefer'"; |
| 585 |
$whereQuery .= " OR option_name = 'wpAppbox_dbVersion'"; |
| 586 |
$whereQuery .= " OR option_name = 'wpAppbox_pluginVersion'"; |
| 587 |
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->options SET autoload = 'yes' WHERE $whereQuery" ) ); |
| 588 |
delete_option( 'wpAppbox_disableAutoCache' ); |
| 589 |
delete_option( 'wpAppbox_disableCache' ); |
| 590 |
delete_option( 'wpAppbox_showReload' ); |
| 591 |
delete_option( 'wpAppbox_imageCache' ); |
| 592 |
delete_option( 'wpAppbox_imageCacheMode' ); |
| 593 |
if ( true == get_option('wpAppbox_eOutput') ) |
| 594 |
update_option( 'wpAppbox_eOutput', 'output', 'no' ); |
| 595 |
wpAppbox_setOptions(); |
| 596 |
wpAppbox_createTable(); |
| 597 |
} |
| 598 |
/* Grundsätzlich nach Update zu prüfen */ |
| 599 |
if ( get_option('wpAppbox_dbVersion') != WPAPPBOX_DB_VERSION ): |
| 600 |
include_once( "inc/appboxdb.php" ); |
| 601 |
wpAppbox_createTable(); |
| 602 |
endif; |
| 603 |
/* Neue Versionsnummer in die Datenbank schreiben */ |
| 604 |
update_option( "wpAppbox_pluginVersion", WPAPPBOX_PLUGIN_VERSION ); |
| 605 |
} |
| 606 |
|
| 607 |
|
| 608 |
/** |
| 609 |
* Neue Optionen in wp_options ($wpdb->options) einfügen |
| 610 |
* |
| 611 |
* @since 3.1.6 |
| 612 |
* @change 4.0.9 |
| 613 |
*/ |
| 614 |
|
| 615 |
function wpAppbox_setOptions() { |
| 616 |
global $wpAppbox_optionsDefault, $wpAppbox_storeNames; |
| 617 |
foreach ( $wpAppbox_optionsDefault as $key => $value ): |
| 618 |
$key = 'wpAppbox_'.$key; |
| 619 |
if ( false === get_option( $key ) ) update_option( $key, $value, 'no' ); |
| 620 |
endforeach; |
| 621 |
foreach ( $wpAppbox_storeNames as $storeID => $storeName ): |
| 622 |
$key_buttonAppbox = "wpAppbox_buttonAppbox_$storeID"; |
| 623 |
$key_buttonWYSIWYG = "wpAppbox_buttonWYSIWYG_$storeID"; |
| 624 |
$key_buttonHTML = "wpAppbox_buttonHTML_$storeID"; |
| 625 |
$key_buttonHidden = "wpAppbox_buttonHidden_$storeID"; |
| 626 |
$key_storeURL = "wpAppbox_storeURL_$storeID"; |
| 627 |
$key_storeURL_URL = "wpAppbox_storeURL_URL_$storeID"; |
| 628 |
if ( false === get_option( $key_buttonWYSIWYG ) ) update_option( $key_buttonWYSIWYG, true, 'no' ); |
| 629 |
if ( false === get_option( $key_buttonHTML ) ) update_option( $key_buttonHTML, true, 'no' ); |
| 630 |
if ( false === get_option( $key_storeURL ) ) update_option( $key_storeURL, intval( "1" ), 'no' ); |
| 631 |
if ( false === get_option( $key_storeURL_URL ) ) update_option( $key_storeURL_URL, "", 'no' ); |
| 632 |
endforeach; |
| 633 |
update_option( "wpAppbox_pluginVersion", WPAPPBOX_PLUGIN_VERSION ); |
| 634 |
} |
| 635 |
|
| 636 |
|
| 637 |
/** |
| 638 |
* Automatische Erkennung der Sprache bei Neuinstallation |
| 639 |
* |
| 640 |
* @since 4.0.9 |
| 641 |
*/ |
| 642 |
|
| 643 |
function wpAppbox_autoLanguageStoreURLs() { |
| 644 |
if ( false !== get_option( 'wpAppbox_pluginVersion' ) ) return; |
| 645 |
global $wpAppbox_storeNames, $wpAppbox_storeURL_languages, $wpAppbox_storeURL_noLanguages, $wpAppbox_storeURL; |
| 646 |
foreach ( $wpAppbox_storeNames as $storeID => $storeName ): |
| 647 |
if ( in_array( $storeID, $wpAppbox_storeURL_noLanguages ) ) continue; |
| 648 |
if ( false !== get_option( $key_storeURL ) ) continue; |
| 649 |
$key_storeURL = "wpAppbox_storeURL_$storeID"; |
| 650 |
$blogLanguage = get_bloginfo( 'language' ); |
| 651 |
foreach( $wpAppbox_storeURL_languages as $languageID => $languageNameCode ): |
| 652 |
if ( strtolower( $languageNameCode['code'] ) == strtolower( $blogLanguage ) ) $languageCode = $languageID; |
| 653 |
endforeach; |
| 654 |
if ( !empty( $wpAppbox_storeURL[$storeID][$languageCode] ) ) update_option( $key_storeURL, intval( $languageCode ), 'no' ); |
| 655 |
endforeach; |
| 656 |
} |
| 657 |
|
| 658 |
|
| 659 |
/** |
| 660 |
* Registrierung des Gutenberg-Blocks |
| 661 |
* |
| 662 |
* @since 4.1.0 |
| 663 |
* @change 4.4.12 |
| 664 |
*/ |
| 665 |
|
| 666 |
function wpAppbox_registerGutenbergBlock() { |
| 667 |
if ( !function_exists( 'register_block_type' ) ) { return; } |
| 668 |
wp_register_script( |
| 669 |
'wp-appbox-block', |
| 670 |
plugins_url( 'editor/gutenberg/block.js?ver=' . WPAPPBOX_PLUGIN_VERSION, __FILE__ ), |
| 671 |
array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-plugins', 'wp-components', 'wp-edit-post', 'wp-api', 'wp-editor', 'wp-hooks' ) |
| 672 |
); |
| 673 |
if ( function_exists( 'wp_set_script_translations' ) ) |
| 674 |
wp_set_script_translations( 'wp-appbox-block', 'wp-appbox', plugin_dir_path( __FILE__ ) . 'lang' ); |
| 675 |
if ( get_option('wpAppbox_renderGutenberg') ): |
| 676 |
wp_register_style( |
| 677 |
'wp-appbox-block-style', |
| 678 |
plugins_url( 'css/styles.min.css', __FILE__ ), |
| 679 |
array( 'wp-edit-blocks' ), |
| 680 |
WPAPPBOX_PLUGIN_VERSION |
| 681 |
); |
| 682 |
endif; |
| 683 |
register_block_type( 'wp-appbox/appbox', array( |
| 684 |
'attributes' => array( |
| 685 |
'appID' => array( 'type' => 'string' ), |
| 686 |
'storeID' => array( 'type' => 'string' ), |
| 687 |
'style' => array( 'type' => 'string' ) |
| 688 |
), |
| 689 |
'editor_script' => 'wp-appbox-block', |
| 690 |
'editor_style' => 'wp-appbox-block-style', |
| 691 |
'render_callback' => 'wpAppbox_renderGutenberg' |
| 692 |
) ); |
| 693 |
} |
| 694 |
add_action( 'init', 'wpAppbox_registerGutenbergBlock' ); |
| 695 |
|
| 696 |
|
| 697 |
/** |
| 698 |
* Gutenberg-Vorschau direkt im Editor rendern (oder auch nicht) |
| 699 |
* |
| 700 |
* @since 4.1.0 |
| 701 |
* @change n/a |
| 702 |
*/ |
| 703 |
|
| 704 |
function wpAppbox_renderGutenberg( $attributes ) { |
| 705 |
if ( !get_option('wpAppbox_renderGutenberg') && !is_preview() ) { |
| 706 |
$theShortcode = ''; |
| 707 |
if ( $attributes[ 'style' ] != '' ) $theShortcode .= ' ' . $attributes[ 'style' ]; |
| 708 |
if ( $attributes[ 'storeID' ] != '' ) $theShortcode .= ' ' . $attributes[ 'storeID' ]; |
| 709 |
if ( $attributes[ 'appID' ] != '' ) $theShortcode .= ' ' . $attributes[ 'appID' ]; |
| 710 |
return( '<div class="wp-block-shortcode wp-block-appbox"><label><img src="' . plugins_url( 'editor/tinymce/appbox.btn.png', __FILE__ ) . '" class="dashicon dashicons-shortcode" aria-hidden="true" width="20" height="20" />WP-Appbox</label><textarea class="editor-plain-text input-control" id="blocks-shortcode-input-1" rows="1" style="overflow: hidden; word-wrap: break-word; resize: none; height: 37px;" disabled>[appbox' . $theShortcode . ']</textarea></div>' ); |
| 711 |
} |
| 712 |
else { |
| 713 |
return( wpAppbox_createAppbox( $attributes ) ); |
| 714 |
} |
| 715 |
} |
| 716 |
|
| 717 |
|
| 718 |
/** |
| 719 |
* "Einstellungen"-Link zur Plugin-Liste hinzufügen |
| 720 |
* |
| 721 |
* @since 2.0.0 |
| 722 |
* @change 4.0.9 |
| 723 |
* |
| 724 |
* @param array $links Array der eingetragenen Links [WordPress] |
| 725 |
* @param string $file Aufgerufene Datei [WordPress] |
| 726 |
* @return array $links Rückgabe der überarbeiteten Links [WordPress] |
| 727 |
*/ |
| 728 |
|
| 729 |
function wpAppbox_addSettings( $links, $file ) { |
| 730 |
static $this_plugin; |
| 731 |
if ( !$this_plugin ) $this_plugin = plugin_basename( __FILE__ ); |
| 732 |
if ( $file == $this_plugin ): |
| 733 |
$settings_link = '<a href="options-general.php?page=wp-appbox">' . esc_html__('Settings', 'wp-appbox') . '</a>'; |
| 734 |
$links = array_merge( array( $settings_link ), $links ); |
| 735 |
endif; |
| 736 |
return( $links ); |
| 737 |
} |
| 738 |
|
| 739 |
|
| 740 |
function wpAppbox_addMenuAdminbar() { |
| 741 |
global $wp_admin_bar; |
| 742 |
$menu_id = 'wp-appbox'; |
| 743 |
$wp_admin_bar->add_menu( array( 'id' => $menu_id, 'title' => __( 'WP-Appbox' ), 'href' => '/options-general.php?page=wp-appbox' ) ); |
| 744 |
$wp_admin_bar->add_menu( array( 'parent' => $menu_id, 'title' => __( 'Homepage' ), 'id' => 'dwb-home', 'href' => '/options-general.php?page=wp-appbox' ) ); |
| 745 |
} |
| 746 |
|
| 747 |
//add_action('admin_bar_menu', 'wpAppbox_addMenuAdminbar', 2000); |
| 748 |
|
| 749 |
|
| 750 |
function wpAppbox_addMenuSidebar() { |
| 751 |
add_menu_page( 'Über', 'WP-Appbox', 'manage_options', 'wp-appbox', 'sd_display_top_level_menu_page', '', 6 ); |
| 752 |
add_submenu_page( 'wp-appbox', 'Editor Buttons', 'Editor Buttons', 'manage_options', 'wp-appbox&tab=buttons', 'sd_display_sub_menu_page' ); |
| 753 |
} |
| 754 |
|
| 755 |
//add_action( 'admin_menu', 'wpAppbox_addMenuSidebar' ); |
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
/** |
| 763 |
* Weitere Links zur Plugin-Beschreibung in der Liste hinzufügen |
| 764 |
* |
| 765 |
* @since 2.0.0 |
| 766 |
* @change 4.4.0 |
| 767 |
* |
| 768 |
* @param array $links Array der eingetragenen Links [WordPress] |
| 769 |
* @param string $file Aufgerufene Datei [WordPress] |
| 770 |
* @return array $links Rückgabe der überarbeiteten Links [WordPress] |
| 771 |
*/ |
| 772 |
|
| 773 |
function wpAppbox_addLinks( $links, $file ) { |
| 774 |
static $this_plugin; |
| 775 |
if ( !$this_plugin ) { |
| 776 |
$this_plugin = plugin_basename( __FILE__ ); |
| 777 |
} |
| 778 |
if ( $file == $this_plugin ) { |
| 779 |
$links = array(); |
| 780 |
$links[] = 'Version '.WPAPPBOX_PLUGIN_VERSION; |
| 781 |
$links[] = '<a target="_blank" href="https://mastodon.social/@marcelismus">' . esc_html__('Follow me on Mastodon', 'wp-appbox') . '</a>'; |
| 782 |
$links[] = '<a target="_blank" href="' . ( ( get_locale() == 'de_DE' ) ? 'https://tchgdns.de/wp-appbox-app-badge-fuer-google-play-mac-app-store-windows-store-windows-phone-store-co/' : 'https://translate.google.de/translate?hl=de&sl=de&tl=en&u=https%3A%2F%2Ftchgdns.de%2Fwp-appbox-app-badge-fuer-google-play-mac-app-store-windows-store-windows-phone-store-co%2F' ) . '">' . esc_html__('Plugin page', 'wp-appbox') . '</a>'; |
| 783 |
$links[] = '<a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/wp-appbox">' . esc_html__('Rate the plugin', 'wp-appbox') . '</a>'; |
| 784 |
$links[] = '<a target="_blank" href="http://www.amazon.de/gp/registry/wishlist/1FC2DA2J8SZW7">' . esc_html__('My Amazon Wishlist', 'wp-appbox') . '</a>'; |
| 785 |
$links[] = '<a target="_blank" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SH9AAS276RAS6">' . esc_html__('PayPal-Donation', 'wp-appbox') . '</a>'; |
| 786 |
} |
| 787 |
return( $links ); |
| 788 |
} |
| 789 |
|
| 790 |
|
| 791 |
/** |
| 792 |
* Ausgabe von Fehlermeldungen |
| 793 |
* |
| 794 |
* @since 2.0.0 |
| 795 |
* @change 3.2.0 |
| 796 |
* |
| 797 |
* @param string $message Fehlermeldung |
| 798 |
*/ |
| 799 |
|
| 800 |
function br_trigger_error( $message ) { |
| 801 |
if ( isset( $_GET['action'] ) && $_GET['action'] == 'error_scrape' ) { |
| 802 |
echo( "<strong>" . esc_html( $message ) . "</strong>" ); |
| 803 |
exit; |
| 804 |
} else { |
| 805 |
trigger_error( $message, E_USER_ERROR ); |
| 806 |
} |
| 807 |
} |
| 808 |
|
| 809 |
|
| 810 |
/** |
| 811 |
* Aktivierung des Plugins |
| 812 |
* |
| 813 |
* @since 2.0.0 |
| 814 |
* @change 4.0.15 |
| 815 |
*/ |
| 816 |
|
| 817 |
function wpAppbox_activatePlugin( $network_wide ) { |
| 818 |
if ( version_compare( phpversion(), WPAPPBOX_MIN_PHPVERSION ) == -1 ) br_trigger_error( esc_html__( 'To use this plugin requires at least PHP version ' . WPAPPBOX_MIN_PHPVERSION . ' is required.', 'wp-appbox' ) ); |
| 819 |
if ( !function_exists('curl_init') ) br_trigger_error( esc_html__( '"cURL" is disabled on this server, but is required. Please enable this feature (or contact your hoster).', 'wp-appbox' ) ); |
| 820 |
if ( !function_exists('curl_exec') ) br_trigger_error( esc_html__( '"curl_exec" is disabled on this server, but is required. Please enable this feature (or contact your hoster).', 'wp-appbox' ) ); |
| 821 |
if ( !function_exists('json_decode') ) br_trigger_error( esc_html__( '"json_decode" is disabled on this server, but is required. Please enable this feature (or contact your hoster).', 'wp-appbox' ) ); |
| 822 |
if ( function_exists( 'is_multisite' ) && is_multisite() && $network_wide ) { |
| 823 |
global $wpdb; |
| 824 |
$current_blog = $wpdb->blogid; |
| 825 |
$blogs = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
| 826 |
foreach ( $blogs as $blog ): |
| 827 |
switch_to_blog( $blog ); |
| 828 |
wpAppbox_activateActions(); |
| 829 |
endforeach; |
| 830 |
switch_to_blog( $current_blog ); |
| 831 |
} else wpAppbox_activateActions(); |
| 832 |
} |
| 833 |
|
| 834 |
|
| 835 |
/** |
| 836 |
* Aktivierung-Actions des Plugins |
| 837 |
* |
| 838 |
* @since 3.2.7 |
| 839 |
* @change 4.5.9 |
| 840 |
*/ |
| 841 |
|
| 842 |
function wpAppbox_activateActions() { |
| 843 |
wpAppbox_includeFiles(); |
| 844 |
wpAppbox_autoLanguageStoreURLs(); /* Standard-URLs für die Stores festlegen */ |
| 845 |
wpAppbox_setOptions(); /* Standard-Einstellungen in wp_options schreiben */ |
| 846 |
wpAppbox_createTable(); /* Tabelle für "WP-Appbox" erstellen */ |
| 847 |
wpAppbox_setupCronCache(); |
| 848 |
} |
| 849 |
|
| 850 |
|
| 851 |
/** |
| 852 |
* Deinstallation des Plugins |
| 853 |
* |
| 854 |
* @since 2.0.0 |
| 855 |
* @change 4.0.9 |
| 856 |
*/ |
| 857 |
|
| 858 |
function wpAppbox_uninstallPlugin() { |
| 859 |
if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
| 860 |
global $wpdb; |
| 861 |
$current_blog = $wpdb->blogid; |
| 862 |
$blogs = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
| 863 |
foreach ( $blogs as $blog ): |
| 864 |
switch_to_blog( $blog ); |
| 865 |
wpAppbox_uninstallActions(); |
| 866 |
endforeach; |
| 867 |
switch_to_blog( $current_blog ); |
| 868 |
} else wpAppbox_uninstallActions(); |
| 869 |
} |
| 870 |
|
| 871 |
|
| 872 |
/** |
| 873 |
* Deinstallation-Actions des Plugins |
| 874 |
* |
| 875 |
* @since 3.2.2 |
| 876 |
* @change 4.5.9 |
| 877 |
*/ |
| 878 |
|
| 879 |
function wpAppbox_uninstallActions() { |
| 880 |
global $wpdb; |
| 881 |
wpAppbox_includeFiles(); |
| 882 |
$wpdb->query( "DELETE FROM " . $wpdb->prefix . "options WHERE option_name LIKE 'wpAppbox_%';" ); |
| 883 |
delete_option( "wpAppbox" ); //Für ältere Versionen ==> bis 3.1.6 |
| 884 |
wp_clear_scheduled_hook( 'wpAppbox_cacheCron' ); |
| 885 |
wpAppbox_deleteTable(); |
| 886 |
$delete = wpAppbox_imageCache::deleteImageCache( true ); |
| 887 |
} |
| 888 |
|
| 889 |
|
| 890 |
/** |
| 891 |
* Deaktivierung des Plugins |
| 892 |
* |
| 893 |
* @since 4.0.0 |
| 894 |
*/ |
| 895 |
|
| 896 |
function wpAppbox_deactivatePlugin() { |
| 897 |
if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
| 898 |
global $wpdb; |
| 899 |
$current_blog = $wpdb->blogid; |
| 900 |
$blogs = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
| 901 |
foreach ( $blogs as $blog ) { |
| 902 |
switch_to_blog( $blog ); |
| 903 |
wpAppbox_deactivateActions(); |
| 904 |
} |
| 905 |
switch_to_blog( $current_blog ); |
| 906 |
} else wpAppbox_deactivateActions(); |
| 907 |
} |
| 908 |
|
| 909 |
|
| 910 |
/** |
| 911 |
* Deaktivierungs-Actions des Plugins |
| 912 |
* |
| 913 |
* @since 4.0.0 |
| 914 |
*/ |
| 915 |
|
| 916 |
function wpAppbox_deactivateActions() { |
| 917 |
wpAppbox_includeFiles(); |
| 918 |
wp_clear_scheduled_hook( 'wpAppbox_cacheCron' ); |
| 919 |
} |
| 920 |
|
| 921 |
|
| 922 |
/** |
| 923 |
* Aktivierung für neue Multisite-Blogs nach Plugin-Aktivierung |
| 924 |
* |
| 925 |
* @since 3.2.7 |
| 926 |
*/ |
| 927 |
|
| 928 |
function wpAppbox_activateBlogMultisite( $blogID ) { |
| 929 |
global $wpdb; |
| 930 |
if ( is_plugin_active_for_network('wp-appbox/wp-appbox.php') ) { |
| 931 |
switch_to_blog( $blogID ); |
| 932 |
my_plugin_activate(); |
| 933 |
restore_current_blog(); |
| 934 |
} |
| 935 |
} |
| 936 |
add_action( 'wpmu_new_blog', 'wpAppbox_activateBlogMultisite' ); |
| 937 |
|
| 938 |
|
| 939 |
/** |
| 940 |
* Stylesheet des Plugins registrieren |
| 941 |
* |
| 942 |
* @since 2.0.0 |
| 943 |
* @change 4.0.42 |
| 944 |
*/ |
| 945 |
|
| 946 |
function wpAppbox_registerStyle() { |
| 947 |
wp_register_style( 'wpappbox', plugins_url( 'css/styles.min.css', __FILE__ ), array(), WPAPPBOX_PLUGIN_VERSION, 'screen' ); |
| 948 |
switch ( get_option('wpAppbox_includeCSS') ): |
| 949 |
case 1: //Disable CSS |
| 950 |
break; |
| 951 |
case 2: //Only on posts and pages |
| 952 |
if ( is_singular() ) wp_enqueue_style( 'wpappbox' ); |
| 953 |
break; |
| 954 |
default: //Default |
| 955 |
wp_enqueue_style( 'wpappbox' ); |
| 956 |
break; |
| 957 |
endswitch; |
| 958 |
} |
| 959 |
|
| 960 |
|
| 961 |
/** |
| 962 |
* Google Fonts für das Plugin registrieren |
| 963 |
* |
| 964 |
* @since 2.0.0 |
| 965 |
* @change 4.0.42 |
| 966 |
*/ |
| 967 |
|
| 968 |
function wpAppbox_loadFonts() { |
| 969 |
if ( get_option('wpAppbox_disableFonts') == false ) { |
| 970 |
wp_register_style( 'open-sans', '//fonts.googleapis.com/css?family=Open+Sans:400,600' ); |
| 971 |
switch ( get_option('wpAppbox_includeCSS') ): |
| 972 |
case 1: //Disable CSS |
| 973 |
break; |
| 974 |
case 2: //Only on posts and pages |
| 975 |
if ( is_singular() ) wp_enqueue_style( 'open-sans' ); |
| 976 |
break; |
| 977 |
default: //Default |
| 978 |
wp_enqueue_style( 'open-sans' ); |
| 979 |
break; |
| 980 |
endswitch; |
| 981 |
} |
| 982 |
} |
| 983 |
|
| 984 |
|
| 985 |
/* Diverse Filter, Aktionen und Hooks registrieren */ |
| 986 |
add_filter( 'plugin_action_links', 'wpAppbox_addSettings', 10, 2 ); |
| 987 |
add_filter( 'plugin_row_meta', 'wpAppbox_addLinks', 10, 2 ); |
| 988 |
add_action( 'plugins_loaded', 'wpAppbox_UpdateAction' ); |
| 989 |
add_action( 'admin_menu', 'wpAppbox_pageInit' ); |
| 990 |
register_activation_hook( __FILE__, 'wpAppbox_activatePlugin' ); |
| 991 |
register_deactivation_hook( __FILE__, 'wpAppbox_deactivatePlugin' ); |
| 992 |
register_uninstall_hook( __FILE__, 'wpAppbox_uninstallPlugin' ); |
| 993 |
|
| 994 |
|
| 995 |
/* Stylesheet und Font auf den normalen Weg laden */ |
| 996 |
if ( get_option('wpAppbox_disableDefer') ) { |
| 997 |
add_action( 'wp_enqueue_scripts', 'wpAppbox_registerStyle' ); |
| 998 |
add_action( 'wp_print_styles', 'wpAppbox_loadFonts' ); |
| 999 |
} |
| 1000 |
|
| 1001 |
|
| 1002 |
/* DER Shortcode */ |
| 1003 |
add_shortcode( 'appbox', 'wpAppbox_createAppbox' ); |
| 1004 |
|
| 1005 |
|
| 1006 |
?> |