generated from a8cteam51/team51-plugin-scaffold
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto-flickr-importer.php
93 lines (83 loc) · 3.45 KB
/
auto-flickr-importer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* The Auto Flickr Importer bootstrap file.
*
* @since 1.0.0
* @version 1.0.0
* @author WordPress.com Special Projects
* @license GPL-3.0-or-later
*
* @noinspection ALL
*
* @wordpress-plugin
* Plugin Name: Auto Flickr Importer
* Requires Plugins: action-scheduler
* Plugin URI: https://wpspecialprojects.wordpress.com
* Description: Automatically import photos from Flickr to your WordPress site.
* Version: 1.0.0
* Requires at least: 6.5
* Tested up to: 6.5
* Requires PHP: 8.2
* Author: WordPress.com Special Projects
* Author URI: https://wpspecialprojects.wordpress.com
* License: GPL v3 or later
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
* Text Domain: auto-flickr-importer
* Domain Path: /languages
* WC requires at least: 8.8
* WC tested up to: 8.8
**/
defined( 'ABSPATH' ) || exit;
// Define plugin constants.
function_exists( 'get_plugin_data' ) || require_once ABSPATH . 'wp-admin/includes/plugin.php';
define( 'AUTO_FLICKR_IMPORTER_METADATA', get_plugin_data( __FILE__, false, false ) );
define( 'AUTO_FLICKR_IMPORTER_BASENAME', plugin_basename( __FILE__ ) );
define( 'AUTO_FLICKR_IMPORTER_PATH', plugin_dir_path( __FILE__ ) );
define( 'AUTO_FLICKR_IMPORTER_URL', plugin_dir_url( __FILE__ ) );
// Get the uploads directory information
$auto_flickr_importer_uploads_dir = wp_upload_dir();
// Define the path to the uploads directory
define( 'AUTO_FLICKR_IMPORTER_UPLOADS_PATH', trailingslashit( $auto_flickr_importer_uploads_dir['basedir'] ) . 'auto-flickr-importer/' );
// Optionally create the directory if it doesn't exist
if ( ! file_exists( AUTO_FLICKR_IMPORTER_UPLOADS_PATH ) ) {
wp_mkdir_p( AUTO_FLICKR_IMPORTER_UPLOADS_PATH );
}
// Load plugin translations so they are available even for the error admin notices.
add_action(
'init',
static function () {
load_plugin_textdomain(
AUTO_FLICKR_IMPORTER_METADATA['TextDomain'],
false,
dirname( AUTO_FLICKR_IMPORTER_BASENAME ) . AUTO_FLICKR_IMPORTER_METADATA['DomainPath']
);
}
);
// Load the autoloader.
if ( ! is_file( AUTO_FLICKR_IMPORTER_PATH . '/vendor/autoload.php' ) ) {
add_action(
'admin_notices',
static function () {
$message = __( 'It seems like <strong>auto-flickr-importer</strong> is corrupted. Please reinstall!', 'auto-flickr-importer' );
$html_message = wp_sprintf( '<div class="error notice auto-flickr-importer-error">%s</div>', wpautop( $message ) );
echo wp_kses_post( $html_message );
}
);
return;
}
require_once AUTO_FLICKR_IMPORTER_PATH . '/vendor/autoload.php';
// Initialize the plugin if system requirements check out.
$auto_flickr_importer_requirements = validate_plugin_requirements( AUTO_FLICKR_IMPORTER_BASENAME );
define( 'AUTO_FLICKR_IMPORTER_REQUIREMENTS', $auto_flickr_importer_requirements );
if ( $auto_flickr_importer_requirements instanceof WP_Error ) {
add_action(
'admin_notices',
static function () use ( $auto_flickr_importer_requirements ) {
$html_message = wp_sprintf( '<div class="error notice auto-flickr-importer-error">%s</div>', $auto_flickr_importer_requirements->get_error_message() );
echo wp_kses_post( $html_message );
}
);
} else {
require_once AUTO_FLICKR_IMPORTER_PATH . 'functions.php';
add_action( 'plugins_loaded', array( auto_flickr_importer_get_plugin_instance(), 'initialize' ) );
}