PluginProbe
Substack Importer / 1.2.0
Substack Importer v1.2.0
trunk 0.1.0 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0
substack-importer / substack-importer.php

substack-importer.php in Substack Importer 1.2.0, at substack-importer.php

63 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Substack Importer
4 * Plugin URI: https://github.com/wordpress/substack-importer
5 * Description: A plugin that lets you import content from Substack to your WordPress site
6 * Author: wordpressdotorg
7 * Text Domain: substack-importer
8 * Version: 1.2.0
9 * Requires PHP: 7.4
10 * Tested up to: 6.9
11 *
12 * @package SubstackImporter
13 */
14
15 use SubstackImporter\Importer_Admin;
16
17
18 defined( 'ABSPATH' ) || exit;
19
20 /** Before the plugin is activated, check if the wxr-generator and wordpress-import plugins are loaded. */
21 register_activation_hook( __FILE__, 'child_plugin_activate' );
22 function child_plugin_activate() {
23
24 $error_msg = __( 'Sorry but this plugin requires the %s plugin to be installed and active.', 'substack-importer' );
25 $plugins_link = '<a href="' . admin_url( 'plugins.php' ) . '">' . __( '&laquo; Return to plugins', 'substack-importer' ) . '</a>';
26
27 if ( ! is_plugin_active( 'wordpress-importer/wordpress-importer.php' ) && current_user_can( 'activate_plugins' ) ) {
28 wp_die( sprintf( $error_msg, 'WordPress Importer' ) . '<br>' . $plugins_link );
29 }
30 }
31
32 function substack_importer_init() {
33
34 require __DIR__ . '/vendor/autoload.php';
35
36 load_plugin_textdomain( 'substack-importer' );
37
38 $importer = new Importer_Admin();
39
40 // Register the Ajax action that handles fetching additional post data through the Substack API
41 add_action( 'wp_ajax_substack_progress', array( $importer, 'progress' ) );
42
43 if ( ! defined( 'WP_LOAD_IMPORTERS' ) ) {
44 return;
45 }
46
47 register_importer(
48 'substack',
49 'Substack',
50 __( 'Import content from a Substack newsletter', 'substack-importer' ),
51 array(
52 $importer,
53 'run',
54 )
55 );
56
57 if ( isset( $_GET['import'] ) && 'substack' === $_GET['import'] ) {
58 wp_enqueue_script( 'substack-index-js', plugins_url( '/js/index.js', __FILE__ ) );
59 wp_enqueue_style( 'substack-index-css', plugins_url( '/css/index.css', __FILE__ ) );
60 }
61 }
62 add_action( 'admin_init', 'substack_importer_init' );
63