Skip to content

Commit

Permalink
Add Hypothesis namespace to custom functions and classes
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya committed Jan 26, 2024
1 parent 33a055e commit 95e0986
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 2 additions & 0 deletions class-hypothesissettingspage.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Hypothesis;

/**
* Create settings page (see https://codex.wordpress.org/Creating_Options_Pages)
*/
Expand Down
20 changes: 15 additions & 5 deletions hypothesis.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,24 @@
* Domain Path: /languages
**/

namespace Hypothesis;

use function add_action;
use function define;
use function defined;
use function get_option;
use function is_admin;
use function load_plugin_textdomain as wp_load_plugin_textdomain;
use function wp_enqueue_script;

// Exit if called directly.
defined( 'ABSPATH' ) || die( 'Cannot access pages directly.' );

// Load textdomain
function hypothesis_load_plugin_textdomain() {
load_plugin_textdomain( 'hypothesis', false, basename( __DIR__ ) . '/languages/' );
function load_plugin_textdomain() {
wp_load_plugin_textdomain( 'hypothesis', false, basename( __DIR__ ) . '/languages/' );
}
add_action( 'plugins_loaded', 'hypothesis_load_plugin_textdomain' );
add_action( 'plugins_loaded', 'Hypothesis\load_plugin_textdomain' );

define( 'HYPOTHESIS_PLUGIN_VERSION', '0.7.1' );

Expand All @@ -34,7 +44,7 @@ function hypothesis_load_plugin_textdomain() {
/**
* Add Hypothesis based on conditions set in the plugin settings.
*/
add_action( 'wp', 'add_hypothesis' );
add_action( 'wp', 'Hypothesis\add_scripts' );

/**
* Wrapper for the primary Hypothesis wp_enqueue call.
Expand All @@ -46,7 +56,7 @@ function enqueue_hypothesis() {
/**
* Add Hypothesis script(s) to front end.
*/
function add_hypothesis() {
function add_scripts() {
$options = get_option( 'wp_hypothesis_options' );
$posttypes = HypothesisSettingsPage::get_posttypes();

Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ An open platform for the collaborative evaluation of knowledge.

Hypothesis is a web annotation tool that allows users to provide commentary, references, and insight on top of news, blogs, scientific articles, books, terms of service, ballot initiatives, legislation and regulations, software code and more. You can find out more at [http://hypothes.is/](http://hypothes.is/)

This plugin will allow you to automatically embed Hypothesis in your site, and integrate with the Hypothesis annotations API.
This plugin will allow you to automatically embed Hypothesis in your site.

Without this plugin, you would have to follow [these steps](https://web.hypothes.is/help/embedding-hypothesis-in-websites-and-platforms/), but with this plugin you only need to check some checkboxes, and you will be good to go.

Expand Down

0 comments on commit 95e0986

Please sign in to comment.