. */ use Psr\Container\ContainerInterface; use RebelCode\Wpra\Core\Container\ModuleContainer; use RebelCode\Wpra\Core\Container\WpFilterContainer; use RebelCode\Wpra\Core\Modules\AddonsModule; use RebelCode\Wpra\Core\Modules\CoreModule; use RebelCode\Wpra\Core\Modules\CustomFeedModule; use RebelCode\Wpra\Core\Modules\FeedBlacklistModule; use RebelCode\Wpra\Core\Modules\FeedDisplayModule; use RebelCode\Wpra\Core\Modules\FeedItemsModule; use RebelCode\Wpra\Core\Modules\FeedShortcodeModule; use RebelCode\Wpra\Core\Modules\FeedSourcesModule; use RebelCode\Wpra\Core\Modules\FeedTemplatesModule; use RebelCode\Wpra\Core\Modules\GutenbergBlockModule; use RebelCode\Wpra\Core\Modules\I18nModule; use RebelCode\Wpra\Core\Modules\ImporterModule; use RebelCode\Wpra\Core\Modules\LoggerModule; use RebelCode\Wpra\Core\Modules\ModuleInterface; use RebelCode\Wpra\Core\Modules\ParsedownModule; use RebelCode\Wpra\Core\Modules\RestApiModule; use RebelCode\Wpra\Core\Modules\SettingsModule; use RebelCode\Wpra\Core\Modules\TwigModule; use RebelCode\Wpra\Core\Modules\WpModule; use RebelCode\Wpra\Core\Plugin; /** * Define constants used by the plugin. */ // Set the version number of the plugin. if( !defined( 'WPRSS_VERSION' ) ) define( 'WPRSS_VERSION', '4.13.1' ); if( !defined( 'WPRSS_WP_MIN_VERSION' ) ) define( 'WPRSS_WP_MIN_VERSION', '4.0' ); if( !defined( 'WPRSS_MIN_PHP_VERSION' ) ) define( 'WPRSS_MIN_PHP_VERSION', '5.4' ); // Set the database version number of the plugin. if( !defined( 'WPRSS_DB_VERSION' ) ) define( 'WPRSS_DB_VERSION', 15 ); // Set the plugin prefix if( !defined( 'WPRSS_PREFIX' ) ) define( 'WPRSS_PREFIX', 'wprss' ); // Set the plugin prefix if( !defined( 'WPRSS_FILE_CONSTANT' ) ) define( 'WPRSS_FILE_CONSTANT', __FILE__ ); // Set constant path to the plugin directory. if( !defined( 'WPRSS_DIR' ) ) define( 'WPRSS_DIR', plugin_dir_path( __FILE__ ) ); // Set constant URI to the plugin URL. if( !defined( 'WPRSS_URI' ) ) define( 'WPRSS_URI', plugin_dir_url( __FILE__ ) ); // Set the constant path to the plugin's javascript directory. if( !defined( 'WPRSS_JS' ) ) define( 'WPRSS_JS', WPRSS_URI . trailingslashit( 'js' ) ); // Set the constant path to the plugin's CSS directory. if( !defined( 'WPRSS_CSS' ) ) define( 'WPRSS_CSS', WPRSS_URI . trailingslashit( 'css' ) ); // Set the constant path to the plugin's javascript build directory. if( !defined( 'WPRSS_APP_JS' ) ) define( 'WPRSS_APP_JS', WPRSS_URI . trailingslashit( 'js/build' ) ); // Set the constant path to the plugin's CSS build directory. if( !defined( 'WPRSS_APP_CSS' ) ) define( 'WPRSS_APP_CSS', WPRSS_URI . trailingslashit( 'css/build' ) ); // Set the constant path to the plugin's images directory. if( !defined( 'WPRSS_IMG' ) ) define( 'WPRSS_IMG', WPRSS_URI . trailingslashit( 'images' ) ); // Set the constant path to the plugin's includes directory. if( !defined( 'WPRSS_INC' ) ) define( 'WPRSS_INC', WPRSS_DIR . trailingslashit( 'includes' ) ); if( !defined( 'WPRSS_LANG' ) ) define( 'WPRSS_LANG', WPRSS_DIR . trailingslashit( 'languages' ) ); if( !defined( 'WPRSS_TEMPLATES' ) ) define( 'WPRSS_TEMPLATES', WPRSS_DIR . trailingslashit( 'templates' ) ); // Set the constant path to the plugin's log file. if( !defined( 'WPRSS_LOG_FILE' ) ) define( 'WPRSS_LOG_FILE', WP_CONTENT_DIR . '/log/wprss/log' ); if( !defined( 'WPRSS_LOG_FILE_EXT' ) ) define( 'WPRSS_LOG_FILE_EXT', '.txt' ); if ( !defined('WPRSS_SL_STORE_URL') ) { define( 'WPRSS_SL_STORE_URL', 'https://www.wprssaggregator.com' ); } if ( !defined( 'WPRSS_TEXT_DOMAIN' ) ) { define( 'WPRSS_TEXT_DOMAIN', 'wprss' ); } // Maximum time for the feed source to be fetched if ( !defined( 'WPRSS_FEED_FETCH_TIME_LIMIT' ) ) { define( 'WPRSS_FEED_FETCH_TIME_LIMIT', 30 ); } // Maximum time for a single feed item to import if ( !defined( 'WPRSS_ITEM_IMPORT_TIME_LIMIT' ) ) { define( 'WPRSS_ITEM_IMPORT_TIME_LIMIT', 15 ); } // Where to take the diagnostic tests from if ( !defined( 'WPRACORE_DIAG_TESTS_DIR' ) ) { define( 'WPRACORE_DIAG_TESTS_DIR', WPRSS_DIR . 'test/diag' ); } define('WPRSS_CORE_PLUGIN_NAME', 'WP RSS Aggregator'); /** * Code of the Core plugin. * * @since 4.11 */ define('WPRSS_PLUGIN_CODE', 'wprss'); /** * Prefix for events used by this plugin. * * @since 4.11 */ define('WPRSS_EVENT_PREFIX', \WPRSS_PLUGIN_CODE . '_'); /** * Whether this plugin is in debug mode. * * @since 4.11 */ define('WPRSS_DEBUG', \WP_DEBUG); /** * Load required files. */ /* Autoloader for this plugin */ require_once ( WPRSS_INC . 'autoload.php' ); // Adding autoload paths wprss_autoloader()->add('Aventura\\Wprss\\Core', WPRSS_INC); wprss_autoloader()->add('Aventura\\Wprss\\Core\\DiagTest', WPRACORE_DIAG_TESTS_DIR); /* Only function definitions, no effect! */ require_once(WPRSS_INC . 'functions.php'); /* Deprecated functions */ require_once(WPRSS_INC . 'deprecated.php'); /* SimplePie */ require_once ( ABSPATH . WPINC . '/class-simplepie.php' ); /* Twig */ require_once ( WPRSS_INC . '/twig.php' ); /* Dependency injection */ require_once ( WPRSS_INC . 'di.php' ); /* Load install, upgrade and migration code. */ require_once ( WPRSS_INC . 'update.php' ); /* Load the file for setting capabilities of our post types */ require_once ( WPRSS_INC . 'roles-capabilities.php' ); /* Load the feed processing functions file */ require_once ( WPRSS_INC . 'feed-processing.php' ); /* Load the blacklist functions file */ require_once ( WPRSS_INC . 'feed-blacklist.php' ); /* Load the feed importing functions file */ require_once ( WPRSS_INC . 'feed-importing.php' ); /* Load the feed states functions file */ require_once ( WPRSS_INC . 'feed-states.php' ); /* Load the feed display functions file */ require_once ( WPRSS_INC . 'legacy-feed-display.php' ); /* Load the custom post type feeds file */ require_once ( WPRSS_INC . 'cpt-feeds.php' ); /* Load the cron job scheduling functions. */ require_once ( WPRSS_INC . 'cron-jobs.php' ); /* Load the admin functions file. */ require_once ( WPRSS_INC . 'admin.php' ); /* Load the admin options functions file. */ require_once ( WPRSS_INC . 'admin-options.php' ); /* Load the legacy admin options functions file. */ require_once ( WPRSS_INC . 'admin-options-legacy.php' ); /* Load the settings import/export file */ require_once ( WPRSS_INC . 'admin-import-export.php' ); /* Load the debugging file */ require_once ( WPRSS_INC . 'system-info.php' ); /* Load the miscellaneous functions file */ require_once ( WPRSS_INC . 'misc-functions.php' ); /* Load the OPML Class file */ require_once ( WPRSS_INC . 'OPML.php' ); /* Load the OPML Importer file */ require_once ( WPRSS_INC . 'opml-importer.php' ); /* Load the admin debugging page file */ require_once ( WPRSS_INC . 'admin-debugging.php' ); /* Load the addons page file */ require_once ( WPRSS_INC . 'admin-addons.php' ); /* Load the admin display-related functions */ require_once ( WPRSS_INC . 'admin-display.php' ); /* Load the admin metaboxes functions */ require_once ( WPRSS_INC . 'admin-metaboxes.php' ); /* Load the scripts loading functions file */ require_once ( WPRSS_INC . 'scripts.php' ); /* Load the Ajax notification file */ require_once ( WPRSS_INC . 'admin-ajax-notice.php' ); /* Load the dashboard welcome screen file */ require_once ( WPRSS_INC . 'admin-dashboard.php' ); /* Load the logging class */ require_once ( WPRSS_INC . 'roles-capabilities.php' ); /* Load the security reset file */ require_once ( WPRSS_INC . 'secure-reset.php' ); /* Load the licensing file */ require_once ( WPRSS_INC . 'licensing.php' ); /* Load the admin editor file */ require_once ( WPRSS_INC . 'admin-editor.php' ); /* Load the admin heartbeat functions */ require_once ( WPRSS_INC . 'admin-heartbeat.php' ); // Load the logging functions file require_once ( WPRSS_INC . 'admin-log.php' ); if ( !defined( 'WPRSS_LOG_LEVEL' ) ) define( 'WPRSS_LOG_LEVEL', WPRSS_LOG_LEVEL_ERROR ); /* Load the admin help file */ require_once ( WPRSS_INC . 'admin-help.php' ); /* Load the admin metaboxes help file */ require_once ( WPRSS_INC . 'admin-help-metaboxes.php' ); /* Load the admin settings help file */ require_once ( WPRSS_INC . 'admin-help-settings.php' ); /* Admin plugin activation events */ require_once ( WPRSS_INC . 'admin-activate.php' ); /* Add components to the plugins page */ require_once(WPRSS_INC . 'admin-plugins.php'); /* Access to feed */ require_once ( WPRSS_INC . 'feed-access.php' ); /* Load the fallbacks for mbstring */ require_once ( WPRSS_INC . 'fallback-mbstring.php' ); /* The "Leave a Review" notification module */ require_once ( WPRSS_INC . 'leave-review-notification.php' ); // Initializes licensing add_action( 'plugins_loaded', 'wprss_licensing' ); do_action('wprss_pre_init'); register_activation_hook(__FILE__, 'wprss_activate'); register_deactivation_hook(__FILE__, 'wprss_deactivate'); // Run WPRA add_action('plugins_loaded', 'wpra_run', 100); /** * Runs WP RSS Aggregator. * * @since 4.13 */ function wpra_run() { try { $plugin = wpra(); $container = wpra_container(); $plugin->run($container); } catch (Exception $exception) { if (WP_DEBUG && WP_DEBUG_DISPLAY) { trigger_error($exception->getMessage()); } wp_die($exception->getMessage()); } } /** * Retrieves the WP RSS Aggregator instance. * * @since 4.13 * * @return Plugin */ function wpra() { static $instance = null; if ($instance === null) { $modules = wpra_modules(); $plugin = new Plugin($modules); $instance = apply_filters('wpra_plugin_instance', $plugin); } return $instance; } /** * Retrieves the WP RSS Aggregator plugin modules. * * @since 4.13 * * @return ModuleInterface[] The modules. */ function wpra_modules() { return apply_filters('wpra_plugin_modules', [ 'core' => new CoreModule(__FILE__), 'addons' => new AddonsModule(), 'wordpress' => new WpModule(), 'importer' => new ImporterModule(), 'feed_sources' => new FeedSourcesModule(), 'feed_items' => new FeedItemsModule(), 'feed_blacklist' => new FeedBlacklistModule(), 'feed_display' => new FeedDisplayModule(), 'feed_shortcode' => new FeedShortcodeModule(), 'feed_templates' => new FeedTemplatesModule(), 'gutenberg_block' => new GutenbergBlockModule(), 'custom_feed' => new CustomFeedModule(), 'rest_api' => new RestApiModule(), 'settings' => new SettingsModule(), 'logging' => new LoggerModule(), 'i18n' => new I18nModule(), 'twig' => new TwigModule(), 'parsedown' => new ParsedownModule(), ]); } /** * Retrieves the WP RSS Aggregator DI container. * * @since 4.13 * * @return ContainerInterface The container instance. */ function wpra_container() { static $instance = null; if ($instance === null) { $plugin = wpra(); // Create the container for the plugin module $moduleCntr = new ModuleContainer($plugin); // Create a WP filter container that wraps around it $filterCntr = new WpFilterContainer($moduleCntr); // Set the module container to pass the WP filter container to service definitions $moduleCntr->useProxy($filterCntr); // Use the WP filter container as the main container $instance = apply_filters('wpra_plugin_container', $filterCntr); } return $instance; } /** * Retrieves a WP RSS Aggregator service from the container. * * @since 4.13 * * @param string $key The service key, without the 'wpra/' prefix. * * @return mixed The service instance or value. */ function wpra_get($key) { return wpra_container()->get('wpra/' . $key); } /** * Loads a WP RSS Aggregator module. * * @since 4.13 * * @param string $key The module key. * @param ModuleInterface $module The module instance. */ function wpra_load_module($key, $module) { if (!($module instanceof ModuleInterface)) { throw new RuntimeException(__('Attempted to load an invalid WP RSS Aggregator module', 'wprss')); } add_filter('wpra_plugin_modules', function ($modules) use ($key, $module) { $modules[$key] = $module; return $modules; }); } /** * Returns the Core plugin singleton instance. * * Using DI container since 4.11. * * @since 4.8.1 * @return Aventura\Wprss\Core\Plugin */ function wprss() { return wprss_wp_container()->get(sprintf('%1$splugin', \WPRSS_SERVICE_ID_PREFIX)); } try { $instance = wprss(); } catch (Exception $e) { if (WP_DEBUG && WP_DEBUG_DISPLAY) { trigger_error($e->getMessage()); } wp_die( $e->getMessage() ); } add_action( 'init', 'wprss_init' ); /** * Initialise the plugin * * @since 1.0 * @return void */ function wprss_init() { do_action( 'wprss_init' ); } /** * Informs users that have not updated to 4.13 that 4.13 will stop supporting PHP 5.3, if their PHP version is * less than 5.4. * * @since 4.13 */ add_action('after_plugin_row', function($plugin_file) { if ($plugin_file !== plugin_basename(__FILE__) || version_compare(WPRSS_VERSION, '4.13', '>=') || version_compare(PHP_VERSION, '5.4', '>=') ) { return; } $message = __( 'As of version 4.13, WP RSS Aggregator will stop supporting PHP 5.3 and will require PHP 5.4 or later. Kindly contact your site\'s hosting provider for PHP version update options.', WPRSS_TEXT_DOMAIN ); $notice = sprintf('
%s
%2$s requires WordPress to be of version %1$s or higher.' . 'Older versions of WordPress are no longer supported by %2$s. Please upgrade your WordPress core to continue benefiting from %2$s support services.
', WPRSS_TEXT_DOMAIN ), WPRSS_WP_MIN_VERSION, WPRSS_CORE_PLUGIN_NAME ), 'notice_type' => 'error' )); } add_action( 'init', 'wprss_add_php_version_warning' ); function wprss_add_php_version_warning() { if (version_compare(PHP_VERSION, WPRSS_MIN_PHP_VERSION, '>=')) { return; } if (!function_exists('deactivate_plugins')) { require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); } deactivate_plugins(plugin_basename(__FILE__)); $firstLine = get_transient('_wprss_activation_redirect') ? __('WP RSS Aggregator cannot be activated.', WPRSS_TEXT_DOMAIN) : __('WP RSS Aggregator has been deactivated.', WPRSS_TEXT_DOMAIN); $supportLink = sprintf( '%1$s', _x( 'contact support', 'Used like "Kindly contact your hosting provider or contact support for more information."', WPRSS_TEXT_DOMAIN ), 'https://wordpress.org/support/plugin/wp-rss-aggregator' ); $secondLine = sprintf( __("The plugin requires version %s or later and your site's PHP version is %s.", WPRSS_TEXT_DOMAIN), '' . WPRSS_MIN_PHP_VERSION . '', '' . PHP_VERSION . '' ); $thirdLine = sprintf( _x( 'Kindly contact your hosting provider to upgrade your PHP version or %s for more information.', 'the "%s" part is a link with text = "contact support"', WPRSS_TEXT_DOMAIN ), $supportLink ); wp_die( implode('%s