views
6 days ago
FileList.php
5 years ago
Hooks.php
3 years ago
Package.php
1 year ago
PackageController.php
4 days ago
PackageLocks.php
4 days ago
PackageTemplate.php
5 years ago
RestAPI.php
3 years ago
Shortcodes.php
6 days ago
Hooks.php
75 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Actions and filters for package component |
| 4 | * @since 4.6.0 |
| 5 | * @version 1.0.0 |
| 6 | */ |
| 7 | |
| 8 | namespace WPDM\Package; |
| 9 | |
| 10 | |
| 11 | use PrivateMessage\__\__Template; |
| 12 | use WPDM\__\Crypt; |
| 13 | use WPDM\__\Messages; |
| 14 | use WPDM\__\Template; |
| 15 | use WPDM\__\TempStorage; |
| 16 | use WPDM\__\UI; |
| 17 | |
| 18 | class Hooks |
| 19 | { |
| 20 | function __construct() |
| 21 | { |
| 22 | add_action("wp", [$this, 'wp']); |
| 23 | add_filter("the_content", [$this, 'embedPackage']); |
| 24 | } |
| 25 | |
| 26 | function wp() |
| 27 | { |
| 28 | $this->wpdmIframe(); |
| 29 | $this->shortcodeIframe(); |
| 30 | } |
| 31 | |
| 32 | function wpdmIframe() |
| 33 | { |
| 34 | if (isset($_REQUEST['__wpdmlo'])) { |
| 35 | include Template::locate('lock-options-iframe.php', __DIR__.'/views'); |
| 36 | die(); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | function shortcodeIframe() |
| 41 | { |
| 42 | if (isset($_REQUEST['__wpdmxp'])) { |
| 43 | include Template::locate("shortcode-iframe.php", __DIR__.'/views'); |
| 44 | die(); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Package detail page |
| 50 | * @param $content |
| 51 | * @return mixed|string |
| 52 | */ |
| 53 | function embedPackage($content) |
| 54 | { |
| 55 | |
| 56 | $wpdm_single_main_query = apply_filters('wpdmpro_single_main_query', is_main_query()); |
| 57 | $wpdm_single_main_loop = apply_filters('wpdmpro_single_main_loop', in_the_loop()); |
| 58 | |
| 59 | if ( ( defined('WPDM_THEME_SUPPORT') && WPDM_THEME_SUPPORT == true ) |
| 60 | || current_theme_supports('wpdm') |
| 61 | || get_post_type(get_the_ID()) != 'wpdmpro' |
| 62 | || ! is_singular('wpdmpro') |
| 63 | || ! $wpdm_single_main_query |
| 64 | || ! $wpdm_single_main_loop |
| 65 | ) { |
| 66 | return $content; |
| 67 | } |
| 68 | |
| 69 | $template = get_post_meta(get_the_ID(), '__wpdm_page_template', true); |
| 70 | $data = WPDM()->package->fetchTemplate($template, get_the_ID(), 'page'); |
| 71 | |
| 72 | return UI::div($data, 'w3eden'); |
| 73 | } |
| 74 | } |
| 75 |