| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPAdminify\Inc\Admin\Frames; |
| 4 |
|
| 5 |
use WPAdminify\Inc\Utils; |
| 6 |
|
| 7 |
// no direct access allowed |
| 8 |
if (!defined('ABSPATH')) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
/** |
| 12 |
* WP Adminify |
| 13 |
* Frames Class |
| 14 |
* |
| 15 |
* @author Jewel Theme <support@jeweltheme.com> |
| 16 |
*/ |
| 17 |
|
| 18 |
if (!class_exists('Frames')) { |
| 19 |
class Frames |
| 20 |
{ |
| 21 |
public function __construct() |
| 22 |
{ |
| 23 |
$this->init_hooks(); |
| 24 |
} |
| 25 |
|
| 26 |
private function init_hooks() |
| 27 |
{ |
| 28 |
add_filter("language_attributes", [$this, "page_attribute"]); |
| 29 |
add_action('admin_enqueue_scripts', [$this, 'load_scripts']); |
| 30 |
|
| 31 |
// Reload the page after plugin activation/deactivation |
| 32 |
if ( isset( $_GET['activate'] ) || isset( $_GET['activate-multi'] ) || isset( $_GET['deactivate'] ) || isset( $_GET['deactivate-multi'] ) ) { |
| 33 |
self::custom_plugin_change_reload(); |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
static function custom_plugin_change_reload($actual_link = null) { |
| 38 |
// if (shortcode_exists('ssa_booking')) { |
| 39 |
// return; |
| 40 |
// } Commented out to avoid issues with shortcode existence check as this plugin using iframe inside it. |
| 41 |
|
| 42 |
if (!is_null($actual_link)) { |
| 43 |
echo "<script type='text/javascript'> |
| 44 |
parent.location.replace('$actual_link'); |
| 45 |
</script>"; |
| 46 |
return; |
| 47 |
}else{ |
| 48 |
echo '<script type="text/javascript"> |
| 49 |
parent.location.reload(); |
| 50 |
</script>'; |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
public function load_scripts() |
| 55 |
{ |
| 56 |
wp_enqueue_style('frame-adminify--frame', WP_ADMINIFY_ASSETS . 'admin/css/frame' . Utils::assets_ext('.css'), [], WP_ADMINIFY_VER); |
| 57 |
} |
| 58 |
|
| 59 |
public function page_attribute($attr) |
| 60 |
{ |
| 61 |
$attrs = [$attr]; |
| 62 |
$attrs[] = 'frame-adminify-iframe="true"'; |
| 63 |
return implode(' ', $attrs); |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
} |
| 68 |
|