-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugin.php
114 lines (97 loc) · 3.34 KB
/
plugin.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php declare(strict_types=1);
/**
* Plugin Name: UCSC Custom Functionality
* Plugin URI: https://github.com/ucsc/ucsc-custom-functionality.git
* Description: Adds custom functionality to UCSC WordPress Websites.
* Version: 1.7.4
* Author: UC Santa Cruz
* Author URI: https://github.com/ucsc
* License: GPL2
*
* @package ucsc-custom-functionality
*/
if ( ! function_exists( 'ucsc_custom_functionality_hidden' ) ) {
/**
* Don't Update Plugin
*
* @since 1.0.0
*
* This prevents you being prompted to update if there's a public plugin
* with the same name.
*
* @author Mark Jaquith
*
* @link http://markjaquith.wordpress.com/2009/12/14/excluding-your-plugin-or-theme-from-update-checks/
*
* @param array $r, request arguments
* @param string $url, request url
*
* @return array request arguments
*/
function ucsc_custom_functionality_hidden( array $r, string $url ): array {
if ( 0 !== strpos( $url, 'http://api.wordpress.org/plugins/update-check' ) ) {
return $r; // Not a plugin update request. Bail immediately.
}
$plugins = unserialize( $r['body']['plugins'] );
unset( $plugins->plugins[ plugin_basename( __FILE__ ) ] );
unset( $plugins->active[ array_search( plugin_basename( __FILE__ ), $plugins->active ) ] );
$r['body']['plugins'] = serialize( $plugins );
return $r;
}
}
add_filter( 'http_request_args', 'ucsc_custom_functionality_hidden', 5, 2 );
// Set plugin directory.
define( 'UCSC_DIR', dirname( __FILE__ ) );
define( 'UCSC_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
// Include Customization files.
if ( file_exists( UCSC_DIR . '/vendor/autoload.php' ) ) {
include_once UCSC_DIR . '/vendor/autoload.php';
}
// Shortcodes.
if ( file_exists( UCSC_DIR . '/lib/functions/shortcodes.php' ) ) {
include_once UCSC_DIR . '/lib/functions/shortcodes.php';
}
// Admin options.
if ( file_exists( UCSC_DIR . '/lib/functions/admin-menus.php' ) ) {
include_once UCSC_DIR . '/lib/functions/admin-menus.php';
}
// Scripts.
if ( file_exists( UCSC_DIR . '/lib/functions/scripts.php' ) ) {
include_once UCSC_DIR . '/lib/functions/scripts.php';
}
// Settings.
if ( file_exists( UCSC_DIR . '/lib/functions/settings.php' ) ) {
include_once UCSC_DIR . '/lib/functions/settings.php';
}
if ( ! function_exists( 'ucsc_enqueue_admin_styles' ) ) {
/**
* Enqueue admin settings styles
*
* No styles are enqueued for raw HTML in setting panel.
* In order to output HTML in the settings panel we need some basic styles.
*
* @since 1.7.0
*
* @author UCSC
*
* @link https://developer.wordpress.org/reference/hooks/admin_enqueue_scripts/#Example:_Load_CSS_File_from_a_plugin_on_specific_Admin_Page
*/
function ucsc_enqueue_admin_styles($hook): void {
$settings_css = plugin_dir_url( __FILE__ ) . 'lib/css/admin-settings.css';
$current_screen = get_current_screen();
// Check if it's "?page=ucsc-custom-functionality-settings." If not, just empty return.
if ( strpos( $current_screen->base, 'ucsc-custom-functionality-settings' ) === false ) {
return;
}
// Load css.
wp_register_style( 'ucsc-cf-admin-settings', $settings_css, );
wp_enqueue_style( 'ucsc-cf-admin-settings' );
}
}
add_action( 'admin_enqueue_scripts', 'ucsc_enqueue_admin_styles' );
add_action( 'plugins_loaded', static function (): void {
if ( ! function_exists( 'acf_add_local_field_group' ) ) {
return;
}
\UCSC\Blocks\Core::instance()->init();
}, 100, 0 );