@@ -37,138 +37,138 @@ |
||
| 37 | 37 | * @since 4.0 |
| 38 | 38 | */ |
| 39 | 39 | if (function_exists('espresso_version')) { |
| 40 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 41 | - /** |
|
| 42 | - * espresso_duplicate_plugin_error |
|
| 43 | - * displays if more than one version of EE is activated at the same time. |
|
| 44 | - */ |
|
| 45 | - function espresso_duplicate_plugin_error() |
|
| 46 | - { |
|
| 47 | - ?> |
|
| 40 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 41 | + /** |
|
| 42 | + * espresso_duplicate_plugin_error |
|
| 43 | + * displays if more than one version of EE is activated at the same time. |
|
| 44 | + */ |
|
| 45 | + function espresso_duplicate_plugin_error() |
|
| 46 | + { |
|
| 47 | + ?> |
|
| 48 | 48 | <div class="error"> |
| 49 | 49 | <p> |
| 50 | 50 | <?php |
| 51 | - echo esc_html__( |
|
| 52 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 53 | - 'event_espresso' |
|
| 54 | - ); ?> |
|
| 51 | + echo esc_html__( |
|
| 52 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 53 | + 'event_espresso' |
|
| 54 | + ); ?> |
|
| 55 | 55 | </p> |
| 56 | 56 | </div> |
| 57 | 57 | <?php |
| 58 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 59 | - } |
|
| 60 | - } |
|
| 61 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 58 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 62 | 62 | } else { |
| 63 | - define('EE_MIN_PHP_VER_REQUIRED', '7.4.0'); |
|
| 64 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 65 | - /** |
|
| 66 | - * espresso_minimum_php_version_error |
|
| 67 | - * |
|
| 68 | - * @return void |
|
| 69 | - */ |
|
| 70 | - function espresso_minimum_php_version_error() |
|
| 71 | - { |
|
| 72 | - ?> |
|
| 63 | + define('EE_MIN_PHP_VER_REQUIRED', '7.4.0'); |
|
| 64 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 65 | + /** |
|
| 66 | + * espresso_minimum_php_version_error |
|
| 67 | + * |
|
| 68 | + * @return void |
|
| 69 | + */ |
|
| 70 | + function espresso_minimum_php_version_error() |
|
| 71 | + { |
|
| 72 | + ?> |
|
| 73 | 73 | <div class="error"> |
| 74 | 74 | <p> |
| 75 | 75 | <?php |
| 76 | - printf( |
|
| 77 | - esc_html__( |
|
| 78 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 79 | - 'event_espresso' |
|
| 80 | - ), |
|
| 81 | - EE_MIN_PHP_VER_REQUIRED, |
|
| 82 | - PHP_VERSION, |
|
| 83 | - '<br/>', |
|
| 84 | - '<a href="https://www.php.net/downloads.php">https://php.net/downloads.php</a>' |
|
| 85 | - ); |
|
| 86 | - ?> |
|
| 76 | + printf( |
|
| 77 | + esc_html__( |
|
| 78 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 79 | + 'event_espresso' |
|
| 80 | + ), |
|
| 81 | + EE_MIN_PHP_VER_REQUIRED, |
|
| 82 | + PHP_VERSION, |
|
| 83 | + '<br/>', |
|
| 84 | + '<a href="https://www.php.net/downloads.php">https://php.net/downloads.php</a>' |
|
| 85 | + ); |
|
| 86 | + ?> |
|
| 87 | 87 | </p> |
| 88 | 88 | </div> |
| 89 | 89 | <?php |
| 90 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 91 | - } |
|
| 90 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 94 | - } else { |
|
| 95 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 93 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 94 | + } else { |
|
| 95 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 96 | 96 | |
| 97 | - require_once __DIR__ . '/vendor/autoload.php'; |
|
| 97 | + require_once __DIR__ . '/vendor/autoload.php'; |
|
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * espresso_version |
|
| 101 | - * Returns the plugin version |
|
| 102 | - * |
|
| 103 | - * @return string |
|
| 104 | - */ |
|
| 105 | - function espresso_version(): string |
|
| 106 | - { |
|
| 107 | - return apply_filters('FHEE__espresso__espresso_version', '5.0.27.rc.000'); |
|
| 108 | - } |
|
| 99 | + /** |
|
| 100 | + * espresso_version |
|
| 101 | + * Returns the plugin version |
|
| 102 | + * |
|
| 103 | + * @return string |
|
| 104 | + */ |
|
| 105 | + function espresso_version(): string |
|
| 106 | + { |
|
| 107 | + return apply_filters('FHEE__espresso__espresso_version', '5.0.27.rc.000'); |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * espresso_plugin_activation |
|
| 112 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 113 | - */ |
|
| 114 | - function espresso_plugin_activation() |
|
| 115 | - { |
|
| 116 | - update_option('ee_espresso_activation', true); |
|
| 117 | - update_option('event-espresso-core_allow_tracking', 'no'); |
|
| 118 | - update_option('event-espresso-core_tracking_notice', 'hide'); |
|
| 119 | - // Run WP GraphQL activation callback |
|
| 120 | - espressoLoadWpGraphQL(); |
|
| 121 | - graphql_activation_callback(); |
|
| 122 | - } |
|
| 110 | + /** |
|
| 111 | + * espresso_plugin_activation |
|
| 112 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 113 | + */ |
|
| 114 | + function espresso_plugin_activation() |
|
| 115 | + { |
|
| 116 | + update_option('ee_espresso_activation', true); |
|
| 117 | + update_option('event-espresso-core_allow_tracking', 'no'); |
|
| 118 | + update_option('event-espresso-core_tracking_notice', 'hide'); |
|
| 119 | + // Run WP GraphQL activation callback |
|
| 120 | + espressoLoadWpGraphQL(); |
|
| 121 | + graphql_activation_callback(); |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 124 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * espresso_plugin_deactivation |
|
| 128 | - */ |
|
| 129 | - function espresso_plugin_deactivation() |
|
| 130 | - { |
|
| 131 | - // Run WP GraphQL deactivation callback |
|
| 132 | - espressoLoadWpGraphQL(); |
|
| 133 | - graphql_deactivation_callback(); |
|
| 134 | - delete_option('event-espresso-core_allow_tracking'); |
|
| 135 | - delete_option('event-espresso-core_tracking_notice'); |
|
| 136 | - } |
|
| 137 | - register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation'); |
|
| 126 | + /** |
|
| 127 | + * espresso_plugin_deactivation |
|
| 128 | + */ |
|
| 129 | + function espresso_plugin_deactivation() |
|
| 130 | + { |
|
| 131 | + // Run WP GraphQL deactivation callback |
|
| 132 | + espressoLoadWpGraphQL(); |
|
| 133 | + graphql_deactivation_callback(); |
|
| 134 | + delete_option('event-espresso-core_allow_tracking'); |
|
| 135 | + delete_option('event-espresso-core_tracking_notice'); |
|
| 136 | + } |
|
| 137 | + register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation'); |
|
| 138 | 138 | |
| 139 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
| 140 | - bootstrap_espresso(); |
|
| 141 | - } |
|
| 139 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
| 140 | + bootstrap_espresso(); |
|
| 141 | + } |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | if (! function_exists('espresso_deactivate_plugin')) { |
| 145 | - /** |
|
| 146 | - * deactivate_plugin |
|
| 147 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 148 | - * |
|
| 149 | - * @access public |
|
| 150 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 151 | - * @return void |
|
| 152 | - */ |
|
| 153 | - function espresso_deactivate_plugin(string $plugin_basename = '') |
|
| 154 | - { |
|
| 155 | - if (! function_exists('deactivate_plugins')) { |
|
| 156 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 157 | - } |
|
| 158 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
| 159 | - deactivate_plugins($plugin_basename); |
|
| 160 | - } |
|
| 145 | + /** |
|
| 146 | + * deactivate_plugin |
|
| 147 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 148 | + * |
|
| 149 | + * @access public |
|
| 150 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 151 | + * @return void |
|
| 152 | + */ |
|
| 153 | + function espresso_deactivate_plugin(string $plugin_basename = '') |
|
| 154 | + { |
|
| 155 | + if (! function_exists('deactivate_plugins')) { |
|
| 156 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 157 | + } |
|
| 158 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 159 | + deactivate_plugins($plugin_basename); |
|
| 160 | + } |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | |
| 164 | 164 | if (! function_exists('espressoLoadWpGraphQL')) { |
| 165 | - function espressoLoadWpGraphQL() |
|
| 166 | - { |
|
| 167 | - if ( |
|
| 168 | - ! class_exists('WPGraphQL') |
|
| 169 | - && is_readable(__DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php') |
|
| 170 | - ) { |
|
| 171 | - require_once __DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php'; |
|
| 172 | - } |
|
| 173 | - } |
|
| 165 | + function espressoLoadWpGraphQL() |
|
| 166 | + { |
|
| 167 | + if ( |
|
| 168 | + ! class_exists('WPGraphQL') |
|
| 169 | + && is_readable(__DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php') |
|
| 170 | + ) { |
|
| 171 | + require_once __DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php'; |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | 174 | } |
@@ -11,80 +11,80 @@ |
||
| 11 | 11 | |
| 12 | 12 | class InterfaceManager implements GQLManagerInterface |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * @var InterfaceCollection|GraphQLInterface[] |
|
| 16 | - */ |
|
| 17 | - protected InterfaceCollection $interfaces; |
|
| 14 | + /** |
|
| 15 | + * @var InterfaceCollection|GraphQLInterface[] |
|
| 16 | + */ |
|
| 17 | + protected InterfaceCollection $interfaces; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Method name used for resolving fields |
|
| 21 | - */ |
|
| 22 | - protected string $methodName = 'resolveField'; |
|
| 19 | + /** |
|
| 20 | + * Method name used for resolving fields |
|
| 21 | + */ |
|
| 22 | + protected string $methodName = 'resolveField'; |
|
| 23 | 23 | |
| 24 | 24 | |
| 25 | - public function __construct(InterfaceCollection $interfaces) |
|
| 26 | - { |
|
| 27 | - $this->interfaces = $interfaces; |
|
| 28 | - } |
|
| 25 | + public function __construct(InterfaceCollection $interfaces) |
|
| 26 | + { |
|
| 27 | + $this->interfaces = $interfaces; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | - public function init(): void |
|
| 32 | - { |
|
| 33 | - $this->interfaces->loadInterfaces(); |
|
| 34 | - add_action('graphql_register_types', [$this, 'callback']); |
|
| 35 | - } |
|
| 31 | + public function init(): void |
|
| 32 | + { |
|
| 33 | + $this->interfaces->loadInterfaces(); |
|
| 34 | + add_action('graphql_register_types', [$this, 'callback']); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @param TypeRegistry $registry |
|
| 40 | - * @return void |
|
| 41 | - * @throws Exception |
|
| 42 | - */ |
|
| 43 | - public function callback(TypeRegistry $registry): void |
|
| 44 | - { |
|
| 45 | - foreach ($this->interfaces as $interface) { |
|
| 46 | - $registry->register_interface_type( |
|
| 47 | - $interface->getName(), |
|
| 48 | - [ |
|
| 49 | - 'description' => $interface->getDescription(), |
|
| 50 | - 'fields' => $this->fieldsToArray($interface), |
|
| 51 | - ] |
|
| 52 | - ); |
|
| 53 | - } |
|
| 54 | - } |
|
| 38 | + /** |
|
| 39 | + * @param TypeRegistry $registry |
|
| 40 | + * @return void |
|
| 41 | + * @throws Exception |
|
| 42 | + */ |
|
| 43 | + public function callback(TypeRegistry $registry): void |
|
| 44 | + { |
|
| 45 | + foreach ($this->interfaces as $interface) { |
|
| 46 | + $registry->register_interface_type( |
|
| 47 | + $interface->getName(), |
|
| 48 | + [ |
|
| 49 | + 'description' => $interface->getDescription(), |
|
| 50 | + 'fields' => $this->fieldsToArray($interface), |
|
| 51 | + ] |
|
| 52 | + ); |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Convert an array of GraphQLFieldInterface into compatible format with WPGraphQL |
|
| 58 | - * @param GraphQLInterfaceInterface $interface |
|
| 59 | - * @return array |
|
| 60 | - */ |
|
| 61 | - protected function fieldsToArray(GraphQLInterfaceInterface $interface): array |
|
| 62 | - { |
|
| 63 | - $this->validateMethodResolve($interface); |
|
| 64 | - $array = []; |
|
| 65 | - foreach ($interface->getFields() as $f) { |
|
| 66 | - $name = $f->name(); |
|
| 67 | - $array[$name] = $f->toArray(); |
|
| 68 | - if ($f->useForOutput()) { |
|
| 69 | - $array[$name]['resolve'] = [$interface, $this->methodName]; |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - return $array; |
|
| 73 | - } |
|
| 56 | + /** |
|
| 57 | + * Convert an array of GraphQLFieldInterface into compatible format with WPGraphQL |
|
| 58 | + * @param GraphQLInterfaceInterface $interface |
|
| 59 | + * @return array |
|
| 60 | + */ |
|
| 61 | + protected function fieldsToArray(GraphQLInterfaceInterface $interface): array |
|
| 62 | + { |
|
| 63 | + $this->validateMethodResolve($interface); |
|
| 64 | + $array = []; |
|
| 65 | + foreach ($interface->getFields() as $f) { |
|
| 66 | + $name = $f->name(); |
|
| 67 | + $array[$name] = $f->toArray(); |
|
| 68 | + if ($f->useForOutput()) { |
|
| 69 | + $array[$name]['resolve'] = [$interface, $this->methodName]; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + return $array; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - protected function validateMethodResolve(GraphQLInterfaceInterface $interface): void |
|
| 76 | - { |
|
| 77 | - if (! is_callable([$interface, $this->methodName])) { |
|
| 78 | - throw new RuntimeException( |
|
| 79 | - __( |
|
| 80 | - sprintf( |
|
| 81 | - 'GraphQL interface "%1$s" has no accessible method "%2$s"!', |
|
| 82 | - get_class($interface), |
|
| 83 | - $this->methodName |
|
| 84 | - ), |
|
| 85 | - 'event_espresso' |
|
| 86 | - ) |
|
| 87 | - ); |
|
| 88 | - } |
|
| 89 | - } |
|
| 75 | + protected function validateMethodResolve(GraphQLInterfaceInterface $interface): void |
|
| 76 | + { |
|
| 77 | + if (! is_callable([$interface, $this->methodName])) { |
|
| 78 | + throw new RuntimeException( |
|
| 79 | + __( |
|
| 80 | + sprintf( |
|
| 81 | + 'GraphQL interface "%1$s" has no accessible method "%2$s"!', |
|
| 82 | + get_class($interface), |
|
| 83 | + $this->methodName |
|
| 84 | + ), |
|
| 85 | + 'event_espresso' |
|
| 86 | + ) |
|
| 87 | + ); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | 90 | } |