PluginProbe
Substack Importer / 1.0.4
Substack Importer v1.0.4
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.0.4, at substack-importer.php

63 lines 1.9 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/Automattic/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.0.4
9 * requires PHP: 5.6
10 *
11 * @package SubstackImporter
12 */
13
14 use SubstackImporter\Importer_Admin;
15
16
17 defined( 'ABSPATH' ) || exit;
18
19 /** Before the plugin is activated, check if the wxr-generator and wordpress-import plugins are loaded. */
20 register_activation_hook( __FILE__, 'child_plugin_activate' );
21 function child_plugin_activate() {
22
23 $error_msg = __( 'Sorry but this plugin requires the %s plugin to be installed and active.', 'substack-importer' );
24 $plugins_link = '<a href="' . admin_url( 'plugins.php' ) . '">' . __( '&laquo; Return to plugins', 'substack-importer' ) . '</a>';
25
26 if ( ! is_plugin_active( 'wordpress-importer/wordpress-importer.php' ) && current_user_can( 'activate_plugins' ) ) {
27 wp_die( sprintf( $error_msg, 'WordPress Importer' ) . '<br>' . $plugins_link );
28 }
29 }
30
31 function substack_importer_init() {
32
33 require __DIR__ . '/vendor/autoload.php';
34
35 load_plugin_textdomain( 'substack-importer' );
36
37 $importer = new Importer_Admin();
38
39 // Register the Ajax action that handles fetching additional post data through the Substack API
40 add_action( 'wp_ajax_substack_progress', array( $importer, 'progress' ) );
41
42 if ( ! defined( 'WP_LOAD_IMPORTERS' ) ) {
43 return;
44 }
45
46 register_importer(
47 'substack',
48 'Substack',
49 __( 'Import content from a Substack newsletter', 'substack-importer' ),
50 array(
51 $importer,
52 'run',
53 )
54 );
55
56 if ( isset( $_GET['import'] ) && 'substack' === $_GET['import'] ) {
57 wp_enqueue_script( 'substack-index-js', plugins_url( '/js/index.js', __FILE__ ) );
58 wp_enqueue_style( 'substack-index-css', plugins_url( '/css/index.css', __FILE__ ) );
59 }
60
61 }
62 add_action( 'admin_init', 'substack_importer_init' );
63