PluginProbe
Nooz / trunk
Nooz vtrunk
1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.6.0 1.7.0 1.7.2 trunk 0.1.0 0.10.0 0.11.0 0.12.0 0.12.1 0.13.0 0.14.0 0.14.1 0.2.0 0.3.0 0.4.0 0.4.1 0.4.2 0.5.0 All 46 releases
nooz / nooz.php

nooz.php in Nooz trunk, at nooz.php

109 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 Plugin Name: Nooz
5 Plugin URI: https://www.mightydev.com/noozroom/
6 Description: Simplified press release and media coverage management for websites.
7 Version: 1.13.0
8 Author: Mighty Digital
9 Author URI: https://www.mightydev.com
10 Text Domain: mdnooz
11 */
12
13 // exit if accessed directly.
14 defined( 'ABSPATH' ) || exit;
15
16 function mdnooz_uninstall() {
17 require_once( __DIR__ . '/inc/autoload.php');
18 \MightyDev\Nooz\Admin::get_instance()->uninstall();
19 }
20
21 $exit_styles = '<style> html, body { font-family: sans-serif; font-size: 14px; margin: 0; padding: 0; } </style>';
22 if ( defined( 'MDNOOZ_PLUGIN_FILE' ) ) {
23 exit( __( 'Only a single version of the Nooz plugin can be active. You must deactivate the current version.', 'mdnooz' ) . $exit_styles );
24 }
25 /* translators: 1: Required PHP version 2: Current PHP version */
26 if ( version_compare( PHP_VERSION, '7.4', '<' ) ) {
27 exit( sprintf( __( 'The Nooz plugin requires PHP version %1$s, the current PHP version is %2$s', 'mdnooz' ), '7.4+', PHP_VERSION ) . $exit_styles );
28 }
29 unset( $exit_styles );
30
31 // @since 1.0.0
32 define( 'MDNOOZ_PLUGIN_FILE', __FILE__ );
33 define( 'MDNOOZ_PLUGIN_VERSION', '1.13.0' );
34
35 use \MightyDev\Nooz;
36 use \MightyDev\WordPress;
37
38 // register_activation_hook must be setup in the main plugin file
39 // see: https://codex.wordpress.org/Function_Reference/register_activation_hook
40 register_activation_hook( MDNOOZ_PLUGIN_FILE, 'mdnooz_core_activation' );
41 function mdnooz_core_activation() {
42 delete_option( 'mdnooz_flush_rewrite_rules' );
43 }
44
45 add_action( 'plugins_loaded', 'mdnooz_load' );
46 function mdnooz_load() {
47 require_once( dirname( __FILE__ ) . '/inc/autoload.php' );
48 $upgrades = new Nooz\Upgrade();
49 $upgrades->setup();
50 $form_fields = new WordPress\FormFields();
51 $form_fields->setup();
52 // manage plugin specific themes
53 $themes_manager = new WordPress\ThemesManager();
54 $themes_manager->register_themes_directory( dirname( __FILE__ ) . '/themes' );
55 $nooz_admin = Nooz\Admin::get_instance();
56 $nooz_admin->plugin_file( MDNOOZ_PLUGIN_FILE );
57 $nooz_admin->name( 'Nooz' );
58 $nooz_admin->version( '1.13.0' );
59 $nooz_admin->use_form_fields( $form_fields );
60 $nooz_admin->register_themes_manager( $themes_manager );
61 $nooz_admin->register();
62 $nooz_help = new Nooz\ContextualHelp();
63 $nooz_help->plugin_file( MDNOOZ_PLUGIN_FILE );
64 $nooz_help->register();
65 $nooz_release_type = new Nooz\Release();
66 $nooz_release_type->plugin_file( MDNOOZ_PLUGIN_FILE );
67 $nooz_release_type->use_form_fields( $form_fields );
68 $nooz_release_type->register();
69 $nooz_coverage_type = new Nooz\Coverage();
70 $nooz_coverage_type->plugin_file( MDNOOZ_PLUGIN_FILE );
71 $nooz_coverage_type->use_form_fields( $form_fields );
72 $nooz_coverage_type->register();
73
74 do_action( 'nooz_init', $nooz_admin );
75 }
76
77 /**
78 * Get an instance of core.
79 *
80 * @since 0.8
81 */
82 function mdnooz() {
83 return Nooz\Admin::get_instance();
84 }
85
86 /**
87 * Get and process a template content. Using this function allows Nooz and
88 * other extensions to filter the content. At minimum, "post" template name is
89 * required. Additionally the following template names/parts are recommended
90 * "post-preview", "post-title", "post-date", "post-excerpt" and "post-action".
91 *
92 * @var string $template_name A template identifier.
93 * @var string $template_file The template file to use, a theme relative or full file path.
94 * @var array $data Data made available in the template file.
95 *
96 * @return string Processed template cotent.
97 */
98 function nooz_get_template( $template_name, $template_file = NULL, $data = NULL ) {
99 if ( is_array( $template_file ) ) {
100 $data = $template_file;
101 $template_file = NULL;
102 }
103 if ( NULL === $template_file ) {
104 $template_file = $template_name . '.php';
105 }
106 $content = mdnooz()->get_themes_manager()->get_template( $template_file, $data );
107 return apply_filters( 'nooz_template_' . $template_name, $content, $data );
108 }
109