Skip to content
This repository has been archived by the owner on Mar 29, 2021. It is now read-only.

Commit

Permalink
php 7.0 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
dsifford committed Jan 29, 2019
1 parent dcf3c95 commit 85a282b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
10 changes: 5 additions & 5 deletions src/academic-bloggers-toolkit.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@
/**
* Load plugin translations.
*/
function textdomain(): void {
function textdomain() {
load_plugin_textdomain( 'academic-bloggers-toolkit', false, basename( ABT_ROOT_PATH ) . '/languages' );
}
add_action( 'plugins_loaded', __NAMESPACE__ . '\textdomain' );

/**
* Cleans up options during uninstall.
*/
function uninstall(): void {
function uninstall() {
delete_option( ABT_OPTIONS_KEY );
}
register_uninstall_hook( __FILE__, __NAMESPACE__ . '\uninstall' );
Expand All @@ -64,7 +64,7 @@ function uninstall(): void {
*
* @link https://app.quicktype.io?share=E2qRt1Cg3TR6qmHbXDcY
*/
function refactor_options(): void {
function refactor_options() {
$options = get_option( ABT_OPTIONS_KEY );
if ( version_compare( ABT_VERSION, $options['VERSION'] ?? '0', '>' ) ) {
// Move custom css to customizer if it exists.
Expand Down Expand Up @@ -127,7 +127,7 @@ function add_donate_link( array $links, string $file ): array {
/**
* Registers all scripts/styles used by this plugin.
*/
function register_scripts(): void {
function register_scripts() {
$deps = get_dependencies();

//
Expand Down Expand Up @@ -195,7 +195,7 @@ function register_scripts(): void {
/**
* Adds an ajax nonce to pages that require it.
*/
function ajax_nonce(): void {
function ajax_nonce() {
?>
<script type="text/javascript">
window._abt_nonce = <?php echo wp_json_encode( wp_create_nonce( 'abt-ajax' ) ); ?>
Expand Down
14 changes: 7 additions & 7 deletions src/php/editor-legacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* Registers load hooks.
*/
function register(): void {
function register() {
$has_rich_editing = (bool) get_user_option( 'rich_editing' );
if ( class_exists( '\Classic_Editor' ) ) {
if ( $has_rich_editing ) {
Expand All @@ -41,7 +41,7 @@ function register(): void {
/**
* Ensures that classic editor is enabled for existing posts.
*/
function check_classic_state(): void {
function check_classic_state() {
$post_id = filter_input( INPUT_GET, 'post', FILTER_VALIDATE_INT );
$saved_mode = get_post_meta( $post_id, 'classic-editor-remember', true );
$is_swapping_mode = (
Expand Down Expand Up @@ -69,7 +69,7 @@ function check_classic_state(): void {
/**
* Ensures that classic editor is enabled for new posts.
*/
function check_classic_option(): void {
function check_classic_option() {
if ( get_option( 'classic-editor-replace' ) !== 'block' ) {
load_post();
}
Expand All @@ -78,7 +78,7 @@ function check_classic_option(): void {
/**
* Registers hooks for classic editor.
*/
function load_post(): void {
function load_post() {
$post_type = get_current_screen()->post_type;
$disabled_post_types = apply_filters( 'abt_disabled_post_types', [ 'acf', 'um_form' ] );
$is_valid_post_type = ! in_array(
Expand Down Expand Up @@ -122,7 +122,7 @@ function( array $plugins ): array {
*
* @param string $post_type The post type.
*/
function add_metaboxes( string $post_type ): void {
function add_metaboxes( string $post_type ) {
add_meta_box(
'abt-reflist',
__( 'Reference List', 'academic-bloggers-toolkit' ),
Expand Down Expand Up @@ -152,7 +152,7 @@ function() {
*
* @param int $post_id The post ID.
*/
function save_meta( int $post_id ): void {
function save_meta( int $post_id ) {
if (
! wp_is_post_autosave( $post_id ) &&
! wp_is_post_revision( $post_id ) &&
Expand All @@ -167,7 +167,7 @@ function save_meta( int $post_id ): void {
/**
* Enqueues legacy editor scripts.
*/
function enqueue_scripts(): void {
function enqueue_scripts() {
global $post;

require_once __DIR__ . '/i18n.php';
Expand Down
4 changes: 2 additions & 2 deletions src/php/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* Enqueue admin scripts.
*/
function enqueue_scripts(): void {
function enqueue_scripts() {
global $post;
wp_enqueue_style( get_handle( 'editor-blocks', 'style' ) );
wp_enqueue_style( get_handle( 'editor-formats', 'style' ) );
Expand All @@ -40,7 +40,7 @@ function enqueue_scripts(): void {
/**
* Register post meta to store editor state.
*/
function register_metadata(): void {
function register_metadata() {
register_meta(
'post',
'_abt_state',
Expand Down
6 changes: 3 additions & 3 deletions src/php/frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Injects post author metadata into the <head> of posts so that others using
* the plugin can easily extract author information.
*/
function inject_author_meta(): void {
function inject_author_meta() {
global $post;
if ( ! $post || ! is_singular() ) {
return;
Expand Down Expand Up @@ -60,7 +60,7 @@ function( $coauthor ) {
*
* @param WP_Post $post The post.
*/
function collect_bibliography( WP_Post $post ): void {
function collect_bibliography( WP_Post $post ) {
if ( is_singular() && has_block( 'abt/bibliography', $post ) ) {
$blocks = parse_blocks( $post->post_content );
$bib_index = array_search( 'abt/bibliography', array_column( $blocks, 'blockName' ), true );
Expand All @@ -74,7 +74,7 @@ function collect_bibliography( WP_Post $post ): void {
/**
* Enqueues frontend CSS and JS.
*/
function enqueue_scripts(): void {
function enqueue_scripts() {
global $post;
if ( is_singular() ) {
$base_handle = has_blocks( $post ) ? 'frontend' : 'frontend-legacy';
Expand Down
6 changes: 3 additions & 3 deletions src/php/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* Registers the plugin options page.
*/
function register_options_page(): void {
function register_options_page() {
add_options_page(
__( "Academic Blogger's Toolkit Options", 'academic-bloggers-toolkit' ),
__( "Academic Blogger's Toolkit", 'academic-bloggers-toolkit' ),
Expand All @@ -37,7 +37,7 @@ function register_options_page(): void {
*
* @param string $hook The hook suffix of the page being loaded.
*/
function enqueue_scripts( string $hook ): void {
function enqueue_scripts( string $hook ) {
if ( 'settings_page_abt-options' !== $hook ) {
return;
}
Expand All @@ -50,7 +50,7 @@ function enqueue_scripts( string $hook ): void {
/**
* Renders the options page.
*/
function render_options_page(): void {
function render_options_page() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die(
esc_html__(
Expand Down
6 changes: 3 additions & 3 deletions src/php/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @param mixed $data The data to be JSON encoded.
* @throws \RuntimeException If the provided action is already done and over with.
*/
function add_json_script( string $id, $data ): void {
function add_json_script( string $id, $data ) {
$prefix = is_admin() ? 'admin_' : 'wp_';
$action = $prefix . 'footer';
if ( did_action( $action ) ) {
Expand All @@ -42,7 +42,7 @@ function () use ( $id, $data ) {
* @param string $kind Optional. The notice kind. Accepts 'error', 'info',
* 'success', 'warning'. Default 'info'.
*/
function create_admin_notice( string $message, string $kind = 'info' ): void {
function create_admin_notice( string $message, string $kind = 'info' ) {
if ( is_admin() ) {
add_action(
'admin_notices',
Expand Down Expand Up @@ -140,7 +140,7 @@ function_exists( 'is_gutenberg_page' ) && is_gutenberg_page()
*
* @throws \InvalidArgumentException If the relative path refers to a non-existent file.
*/
function register_script( string $relpath, array $deps = [] ): void {
function register_script( string $relpath, array $deps = [] ) {
$style_suffix = "/bundle/$relpath.css";
$script_suffix = "/bundle/$relpath.js";

Expand Down

0 comments on commit 85a282b

Please sign in to comment.