PluginProbe
Easy Quotes / trunk
Easy Quotes vtrunk
trunk 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.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 All 28 releases
easy-quotes / easy-quotes.php

easy-quotes.php in Easy Quotes trunk, at easy-quotes.php

110 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Easy Quotes
4 * Description: Adds a new Post Type 'Quotes' and a customizable Gutenberg Block 'Easy Quotes' to your wordpress site. Collect and show your favorite Quotes (random, daily or specific).
5 * Requires at least: 6.8
6 * Requires PHP: 7.4
7 * Version: 1.3.7
8 * Author: Jürgen Müller
9 * Author URI: https://www.layart.org
10 * License: GPL-2.0-or-later
11 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
12 * Text Domain: easy-quotes
13 *
14 * @package LayArt
15 */
16
17 // Exit if accessed directly.
18 if ( ! defined( 'ABSPATH' ) ) {
19 exit;
20 }
21
22 define('EASY_QUOTES_VERSION', '1.3.7');
23 define('EASY_QUOTES_PLUGIN_URL', plugin_dir_url(__FILE__));
24 define('EASY_QUOTES_PLUGIN_DIR', plugin_dir_path(__FILE__));
25
26 class Easy_Quotes
27 {
28 function __construct() {
29 add_action( 'init', [$this, 'register_blocks'] );
30 add_action( 'wp_enqueue_scripts', [$this, 'enqueue_scripts'] );
31 register_activation_hook( __FILE__, [$this, 'activation'] );
32 add_action( 'init', [$this, 'flush_rules_on_activation'], 99 );
33
34 $this->load_dependencies();
35 $this->init_classes();
36 }
37
38 function load_dependencies()
39 {
40 require_once EASY_QUOTES_PLUGIN_DIR . 'includes/data.php';
41 require_once EASY_QUOTES_PLUGIN_DIR . 'includes/stars.php';
42 require_once EASY_QUOTES_PLUGIN_DIR . 'includes/post-type.php';
43 require_once EASY_QUOTES_PLUGIN_DIR . 'includes/font.php';
44 require_once EASY_QUOTES_PLUGIN_DIR . 'includes/fonts-database.php';
45 }
46
47 function init_classes() {
48 new Easy_Quotes_Data();
49 new Easy_Quotes_Stars();
50 new Easy_Quotes_Post_Type();
51
52 // Clean up the old database silently
53 $fontsDb = new Easy_Quotes_Fonts_Database();
54 if ($fontsDb->legacyTablesExist()) {
55 $fontsDb->dropTables();
56 error_log('Easy Quotes: Legacy font tables cleaned up successfully');
57 }
58 }
59
60 function register_blocks() {
61 if ( function_exists( 'wp_register_block_types_from_metadata_collection' ) ) {
62 wp_register_block_types_from_metadata_collection( __DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php' );
63 return;
64 }
65
66 if ( function_exists( 'wp_register_block_metadata_collection' ) ) {
67 wp_register_block_metadata_collection( __DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php' );
68 }
69
70 $manifest_data = require __DIR__ . '/build/blocks-manifest.php';
71 foreach ( array_keys( $manifest_data ) as $block_type ) {
72 register_block_type( __DIR__ . "/build/{$block_type}" );
73 }
74 }
75
76 /**
77 * Enqueue javascript helper functions in header
78 *
79 * @return void
80 */
81 function enqueue_scripts() {
82 wp_enqueue_script(
83 'easy-quotes-script',
84 EASY_QUOTES_PLUGIN_URL . 'public/js/easy-quotes.js',
85 [],
86 EASY_QUOTES_VERSION,
87 false
88 );
89 }
90
91 function activation() {
92 register_uninstall_hook(__FILE__, array('Easy_Quotes', 'uninstall'));
93 update_option( 'easy_quotes_flush_rewrite_rules', true );
94 }
95
96 public static function uninstall()
97 {
98 // nothing to do.
99 }
100
101 function flush_rules_on_activation() {
102 if ( get_option( 'easy_quotes_flush_rewrite_rules' ) ) {
103 flush_rewrite_rules();
104 delete_option( 'easy_quotes_flush_rewrite_rules' );
105 }
106 }
107 }
108
109 new Easy_Quotes();
110