| @@ -8,14 +8,50 @@ | ||
| 8 | 8 | class Admin { |
| 9 | 9 | public static function init() { |
| 10 | 10 | $self = new self(); |
| 11 | 11 | $self->dispatch_hooks(); |
| 12 | + | |
| 13 | + add_filter( 'upload_mimes', [ $self, 'allow_lottie_json_uploads' ] ); | |
| 14 | + add_filter( 'upload_mimes', [ $self, 'allow_svg_uploads' ] ); | |
| 15 | + add_filter( 'wp_check_filetype_and_ext', function ( $data, $file, $filename ) { | |
| 16 | + $ext = pathinfo( $filename, PATHINFO_EXTENSION ); | |
| 17 | + | |
| 18 | + if ( 'json' === $ext ) { | |
| 19 | + $data['ext'] = 'json'; | |
| 20 | + $data['type'] = 'application/json'; | |
| 21 | + } elseif ( 'svg' === strtolower( $ext ) && current_user_can( 'unfiltered_html' ) ) { | |
| 22 | + $data['ext'] = 'svg'; | |
| 23 | + $data['type'] = 'image/svg+xml'; | |
| 24 | + } | |
| 25 | + | |
| 26 | + return $data; | |
| 27 | + }, 10, 3 ); | |
| 12 | 28 | } |
| 13 | 29 | |
| 30 | + function allow_lottie_json_uploads( $mimes ) { | |
| 31 | + $mimes['json'] = 'application/json'; | |
| 32 | + $mimes['lottie'] = 'application/json'; | |
| 33 | + return $mimes; | |
| 34 | + } | |
| 35 | + | |
| 36 | + // Gated to unfiltered_html (administrators, by default) rather than opened | |
| 37 | + // for every role: an SVG file can carry a <script>, and unlike the Atomic | |
| 38 | + // SVG block's own read path (which strips scripts/handlers before inlining | |
| 39 | + // markup — see atomic-svg/edit.js `cleanSvg`), the raw file the media | |
| 40 | + // library stores is unsanitised and can execute if it is ever opened | |
| 41 | + // directly as a top-level document. | |
| 42 | + function allow_svg_uploads( $mimes ) { | |
| 43 | + if ( current_user_can( 'unfiltered_html' ) ) { | |
| 44 | + $mimes['svg'] = 'image/svg+xml'; | |
| 45 | + } | |
| 46 | + return $mimes; | |
| 47 | + } | |
| 48 | + | |
| 14 | 49 | public function dispatch_hooks() { |
| 15 | 50 | Admin\Menu::init(); |
| 16 | 51 | \ABlocks\CreatePage\page\ShowPageState::init(); |
| 17 | 52 | Admin\Export::init(); |
| 53 | + Admin\Notice::init(); | |
| 18 | 54 | add_filter( 'allowed_redirect_hosts', array( $this, 'add_white_listed_redirect_hosts' ) ); |
| 19 | 55 | add_action( 'current_screen', array( $this, 'conditional_loaded' ) ); |
| 20 | 56 | add_filter( 'plugin_action_links_' . ABLOCKS_PLUGIN_BASENAME, array( $this, 'plugin_action_links' ) ); |
| 21 | 57 | add_filter( 'plugin_row_meta', array( $this, 'add_plugin_links' ), 10, 2 ); |
| @@ -24,21 +60,30 @@ | ||
| 24 | 60 | public function add_white_listed_redirect_hosts( $hosts ) { |
| 25 | 61 | $hosts[] = 'ablocks.pro'; |
| 26 | 62 | return $hosts; |
| 27 | 63 | } |
| 64 | + | |
| 28 | 65 | public function conditional_loaded() { |
| 29 | 66 | $screen = get_current_screen(); |
| 30 | 67 | |
| 31 | - if ( ! $screen ) { | |
| 32 | - return; | |
| 33 | - } | |
| 68 | + if ( $screen && $screen->id == 'ablocks_page_ablocks-get-pro' ) { | |
| 69 | + $link = add_query_arg( | |
| 70 | + [ | |
| 71 | + 'utm_source' => 'ablocks-plugin', | |
| 72 | + 'utm_medium' => 'admin-dashboard', | |
| 73 | + 'utm_campaign' => 'upgrade-to-pro', | |
| 74 | + 'utm_content' => 'get-pro-button', | |
| 75 | + 'utm_term' => 'free-user', | |
| 76 | + 'locale' => get_locale(), | |
| 77 | + ], | |
| 78 | + 'https://ablocks.pro/pricing/' | |
| 79 | + ); | |
| 34 | 80 | |
| 35 | - switch ( $screen->id ) { | |
| 36 | - case 'ablocks_page_ablocks-get-pro': | |
| 37 | - wp_safe_redirect( 'https://ablocks.pro/pricing/' ); | |
| 38 | - exit; | |
| 81 | + wp_safe_redirect( $link ); | |
| 82 | + exit; | |
| 39 | 83 | } |
| 40 | 84 | } |
| 85 | + | |
| 41 | 86 | public function add_plugin_links( $links, $file ) { |
| 42 | 87 | if ( ABLOCKS_PLUGIN_BASENAME !== $file ) { |
| 43 | 88 | return $links; |
| 44 | 89 | } |
| @@ -46,9 +91,9 @@ | ||
| 46 | 91 | $map_block_links = array( |
| 47 | 92 | 'docs' => array( |
| 48 | 93 | 'url' => 'https://ablocks.pro/docs/', |
| 49 | 94 | 'label' => __( 'Docs', 'ablocks' ), |
| 50 | - 'aria-label' => __( 'View Academy documentation', 'ablocks' ), | |
| 95 | + 'aria-label' => __( 'View aBlocks documentation', 'ablocks' ), | |
| 51 | 96 | ), |
| 52 | 97 | 'video' => array( |
| 53 | 98 | 'url' => 'https://www.youtube.com/@ablocksteam', |
| 54 | 99 | 'label' => __( 'Video Tutorials', 'ablocks' ), |