$synonym ) : ?>
-
@@ -207,11 +207,11 @@ class="button"
*/
public static function save_meta_boxes( $post_id ): void {
// Check nonce.
- if ( ! isset( $_POST['pp_glossary_meta_box_nonce'] ) ) {
+ if ( ! isset( $_POST['inline_glossary_meta_box_nonce'] ) ) {
return;
}
- if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['pp_glossary_meta_box_nonce'] ) ), 'pp_glossary_meta_box' ) ) {
+ if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['inline_glossary_meta_box_nonce'] ) ), 'inline_glossary_meta_box' ) ) {
return;
}
@@ -227,26 +227,26 @@ public static function save_meta_boxes( $post_id ): void {
// Build data array.
$data = [
- 'case_sensitive' => isset( $_POST['pp_glossary_case_sensitive'] ),
- 'disable_autolink' => isset( $_POST['pp_glossary_disable_autolink'] ),
+ 'case_sensitive' => isset( $_POST['inline_glossary_case_sensitive'] ),
+ 'disable_autolink' => isset( $_POST['inline_glossary_disable_autolink'] ),
'short_description' => '',
'long_description' => '',
'synonyms' => [],
];
// Sanitize short description.
- if ( isset( $_POST['pp_glossary_short_description'] ) ) {
- $data['short_description'] = sanitize_textarea_field( wp_unslash( $_POST['pp_glossary_short_description'] ) );
+ if ( isset( $_POST['inline_glossary_short_description'] ) ) {
+ $data['short_description'] = sanitize_textarea_field( wp_unslash( $_POST['inline_glossary_short_description'] ) );
}
// Sanitize long description.
- if ( isset( $_POST['pp_glossary_long_description'] ) ) {
- $data['long_description'] = wp_kses_post( wp_unslash( $_POST['pp_glossary_long_description'] ) );
+ if ( isset( $_POST['inline_glossary_long_description'] ) ) {
+ $data['long_description'] = wp_kses_post( wp_unslash( $_POST['inline_glossary_long_description'] ) );
}
// Sanitize synonyms.
- if ( isset( $_POST['pp_glossary_synonyms'] ) && is_array( $_POST['pp_glossary_synonyms'] ) ) {
- foreach ( wp_unslash( $_POST['pp_glossary_synonyms'] ) as $synonym ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sanitization handled below.
+ if ( isset( $_POST['inline_glossary_synonyms'] ) && is_array( $_POST['inline_glossary_synonyms'] ) ) {
+ foreach ( wp_unslash( $_POST['inline_glossary_synonyms'] ) as $synonym ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sanitization handled below.
$synonym = sanitize_text_field( $synonym );
if ( ! empty( $synonym ) ) {
$data['synonyms'][] = $synonym;
@@ -254,7 +254,7 @@ public static function save_meta_boxes( $post_id ): void {
}
}
- update_post_meta( $post_id, '_pp_glossary_data', $data );
+ update_post_meta( $post_id, '_inline_glossary_data', $data );
}
/**
@@ -269,16 +269,16 @@ public static function enqueue_admin_scripts( $hook ): void {
}
$screen = get_current_screen();
- if ( ! $screen || 'pp_glossary' !== $screen->post_type ) {
+ if ( ! $screen || 'inline_glossary' !== $screen->post_type ) {
return;
}
// Enqueue admin script for synonyms management.
wp_enqueue_script(
- 'pp-glossary-admin',
- PP_GLOSSARY_PLUGIN_URL . 'assets/js/admin.js',
+ 'inline-glossary-admin',
+ INLINE_GLOSSARY_PLUGIN_URL . 'assets/js/admin.js',
[],
- PP_GLOSSARY_VERSION,
+ INLINE_GLOSSARY_VERSION,
true
);
}
diff --git a/includes/class-migrations.php b/includes/class-migrations.php
index ecf1189..dc9f9f9 100644
--- a/includes/class-migrations.php
+++ b/includes/class-migrations.php
@@ -2,10 +2,10 @@
/**
* Migrations for Glossary
*
- * @package PP_Glossary
+ * @package Inline_Glossary
*/
-namespace PP_Glossary;
+namespace Inline_Glossary;
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
@@ -43,7 +43,7 @@ public static function run_migrations(): void {
$current_version = '1.0.0';
} else {
// Fresh install - set to current version and skip migrations.
- Settings::update_setting( 'db_version', PP_GLOSSARY_VERSION );
+ Settings::update_setting( 'db_version', INLINE_GLOSSARY_VERSION );
return;
}
} else {
@@ -65,7 +65,7 @@ public static function run_migrations(): void {
private static function has_glossary_posts(): bool {
$query = new \WP_Query(
[
- 'post_type' => 'pp_glossary',
+ 'post_type' => 'inline_glossary',
'posts_per_page' => 1,
'post_status' => 'any',
'fields' => 'ids',
@@ -81,7 +81,7 @@ private static function has_glossary_posts(): bool {
private static function migrate_to_1_1_0(): void {
$query = new \WP_Query(
[
- 'post_type' => 'pp_glossary',
+ 'post_type' => 'inline_glossary',
'posts_per_page' => -1,
'post_status' => 'any',
'fields' => 'ids',
@@ -96,17 +96,17 @@ private static function migrate_to_1_1_0(): void {
$post_id = $post instanceof \WP_Post ? $post->ID : (int) $post;
// Check if already migrated (new data exists).
- $existing_data = get_post_meta( $post_id, '_pp_glossary_data', true );
+ $existing_data = get_post_meta( $post_id, '_inline_glossary_data', true );
if ( is_array( $existing_data ) && ! empty( $existing_data ) ) {
continue;
}
// Get old individual meta values.
- $short_description = get_post_meta( $post_id, '_pp_glossary_short_description', true );
- $long_description = get_post_meta( $post_id, '_pp_glossary_long_description', true );
- $synonyms = get_post_meta( $post_id, '_pp_glossary_synonyms', true );
- $case_sensitive = get_post_meta( $post_id, '_pp_glossary_case_sensitive', true );
- $disable_autolink = get_post_meta( $post_id, '_pp_glossary_disable_autolink', true );
+ $short_description = get_post_meta( $post_id, '_inline_glossary_short_description', true );
+ $long_description = get_post_meta( $post_id, '_inline_glossary_long_description', true );
+ $synonyms = get_post_meta( $post_id, '_inline_glossary_synonyms', true );
+ $case_sensitive = get_post_meta( $post_id, '_inline_glossary_case_sensitive', true );
+ $disable_autolink = get_post_meta( $post_id, '_inline_glossary_disable_autolink', true );
// Only migrate if there's actually old data.
if ( empty( $short_description ) && empty( $long_description ) && empty( $synonyms ) ) {
@@ -123,12 +123,12 @@ private static function migrate_to_1_1_0(): void {
];
// Save new format.
- update_post_meta( $post_id, '_pp_glossary_data', $data );
+ update_post_meta( $post_id, '_inline_glossary_data', $data );
// Delete old meta keys.
- delete_post_meta( $post_id, '_pp_glossary_short_description' );
- delete_post_meta( $post_id, '_pp_glossary_long_description' );
- delete_post_meta( $post_id, '_pp_glossary_synonyms' );
+ delete_post_meta( $post_id, '_inline_glossary_short_description' );
+ delete_post_meta( $post_id, '_inline_glossary_long_description' );
+ delete_post_meta( $post_id, '_inline_glossary_synonyms' );
}
}
}
diff --git a/includes/class-post-type.php b/includes/class-post-type.php
index 30d7669..89635b6 100644
--- a/includes/class-post-type.php
+++ b/includes/class-post-type.php
@@ -2,10 +2,10 @@
/**
* Glossary Post Type Registration.
*
- * @package PP_Glossary
+ * @package Inline_Glossary
*/
-namespace PP_Glossary;
+namespace Inline_Glossary;
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
@@ -36,7 +36,7 @@ public static function init(): void {
* @return array
Modified array of excluded post types.
*/
public static function exclude_from_yoast_indexables( array $excluded_post_types ): array {
- $excluded_post_types[] = 'pp_glossary';
+ $excluded_post_types[] = 'inline_glossary';
return $excluded_post_types;
}
@@ -49,7 +49,7 @@ public static function exclude_from_yoast_indexables( array $excluded_post_types
* @return bool Whether to exclude this post type.
*/
public static function exclude_from_yoast_sitemap( bool $exclude, string $post_type ): bool {
- if ( 'pp_glossary' === $post_type ) {
+ if ( 'inline_glossary' === $post_type ) {
return true;
}
return $exclude;
@@ -60,33 +60,33 @@ public static function exclude_from_yoast_sitemap( bool $exclude, string $post_t
*/
public static function register_post_type(): void {
$labels = [
- 'name' => _x( 'Glossary', 'Post Type General Name', 'pp-glossary' ),
- 'singular_name' => _x( 'Entry', 'Post Type Singular Name', 'pp-glossary' ),
- 'menu_name' => __( 'Glossary', 'pp-glossary' ),
- 'name_admin_bar' => __( 'Glossary entry', 'pp-glossary' ),
- 'archives' => __( 'Glossary archives', 'pp-glossary' ),
- 'attributes' => __( 'Entry attributes', 'pp-glossary' ),
- 'all_items' => __( 'All entries', 'pp-glossary' ),
- 'add_new_item' => __( 'Add new entry', 'pp-glossary' ),
- 'add_new' => __( 'Add new', 'pp-glossary' ),
- 'new_item' => __( 'New entry', 'pp-glossary' ),
- 'edit_item' => __( 'Edit entry', 'pp-glossary' ),
- 'update_item' => __( 'Update entry', 'pp-glossary' ),
- 'view_item' => __( 'View entry', 'pp-glossary' ),
- 'view_items' => __( 'View entries', 'pp-glossary' ),
- 'search_items' => __( 'Search entries', 'pp-glossary' ),
- 'not_found' => __( 'Not found', 'pp-glossary' ),
- 'not_found_in_trash' => __( 'Not found in Trash', 'pp-glossary' ),
- 'insert_into_item' => __( 'Insert into entry', 'pp-glossary' ),
- 'uploaded_to_this_item' => __( 'Uploaded to this entry', 'pp-glossary' ),
- 'items_list' => __( 'Entries list', 'pp-glossary' ),
- 'items_list_navigation' => __( 'Entries list navigation', 'pp-glossary' ),
- 'filter_items_list' => __( 'Filter entries list', 'pp-glossary' ),
+ 'name' => _x( 'Glossary', 'Post Type General Name', 'inline-glossary' ),
+ 'singular_name' => _x( 'Entry', 'Post Type Singular Name', 'inline-glossary' ),
+ 'menu_name' => __( 'Glossary', 'inline-glossary' ),
+ 'name_admin_bar' => __( 'Glossary entry', 'inline-glossary' ),
+ 'archives' => __( 'Glossary archives', 'inline-glossary' ),
+ 'attributes' => __( 'Entry attributes', 'inline-glossary' ),
+ 'all_items' => __( 'All entries', 'inline-glossary' ),
+ 'add_new_item' => __( 'Add new entry', 'inline-glossary' ),
+ 'add_new' => __( 'Add new', 'inline-glossary' ),
+ 'new_item' => __( 'New entry', 'inline-glossary' ),
+ 'edit_item' => __( 'Edit entry', 'inline-glossary' ),
+ 'update_item' => __( 'Update entry', 'inline-glossary' ),
+ 'view_item' => __( 'View entry', 'inline-glossary' ),
+ 'view_items' => __( 'View entries', 'inline-glossary' ),
+ 'search_items' => __( 'Search entries', 'inline-glossary' ),
+ 'not_found' => __( 'Not found', 'inline-glossary' ),
+ 'not_found_in_trash' => __( 'Not found in Trash', 'inline-glossary' ),
+ 'insert_into_item' => __( 'Insert into entry', 'inline-glossary' ),
+ 'uploaded_to_this_item' => __( 'Uploaded to this entry', 'inline-glossary' ),
+ 'items_list' => __( 'Entries list', 'inline-glossary' ),
+ 'items_list_navigation' => __( 'Entries list navigation', 'inline-glossary' ),
+ 'filter_items_list' => __( 'Filter entries list', 'inline-glossary' ),
];
$args = [
- 'label' => __( 'Entry', 'pp-glossary' ),
- 'description' => __( 'Glossary entries with definitions', 'pp-glossary' ),
+ 'label' => __( 'Entry', 'inline-glossary' ),
+ 'description' => __( 'Glossary entries with definitions', 'inline-glossary' ),
'labels' => $labels,
'supports' => [ 'title' ],
'hierarchical' => false,
@@ -106,6 +106,6 @@ public static function register_post_type(): void {
'rewrite' => false,
];
- register_post_type( 'pp_glossary', $args );
+ register_post_type( 'inline_glossary', $args );
}
}
diff --git a/includes/class-schema.php b/includes/class-schema.php
index bc63b0c..14eceec 100644
--- a/includes/class-schema.php
+++ b/includes/class-schema.php
@@ -2,10 +2,10 @@
/**
* Schema.org Integration for Glossary
*
- * @package PP_Glossary
+ * @package Inline_Glossary
*/
-namespace PP_Glossary;
+namespace Inline_Glossary;
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
@@ -41,7 +41,7 @@ public static function add_to_yoast_schema_graph( $graph ): array {
}
// Get all glossary entries.
- $entries = pp_glossary_get_entries();
+ $entries = inline_glossary_get_entries();
if ( empty( $entries ) ) {
return $graph;
diff --git a/includes/class-settings.php b/includes/class-settings.php
index c6049d6..cb19509 100644
--- a/includes/class-settings.php
+++ b/includes/class-settings.php
@@ -2,10 +2,10 @@
/**
* Glossary Settings Page
*
- * @package PP_Glossary
+ * @package Inline_Glossary
*/
-namespace PP_Glossary;
+namespace Inline_Glossary;
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
@@ -20,7 +20,7 @@ class Settings {
/**
* Option name for settings
*/
- const OPTION_NAME = 'pp_glossary_settings';
+ const OPTION_NAME = 'inline_glossary_settings';
/**
* Default excluded tags for term highlighting
@@ -41,11 +41,11 @@ public static function init(): void {
*/
public static function add_settings_page(): void {
add_submenu_page(
- 'edit.php?post_type=pp_glossary',
- __( 'Glossary Settings', 'pp-glossary' ),
- __( 'Settings', 'pp-glossary' ),
+ 'edit.php?post_type=inline_glossary',
+ __( 'Glossary Settings', 'inline-glossary' ),
+ __( 'Settings', 'inline-glossary' ),
'manage_options',
- 'pp-glossary-settings',
+ 'inline-glossary-settings',
[ __CLASS__, 'render_settings_page' ]
);
}
@@ -55,7 +55,7 @@ public static function add_settings_page(): void {
*/
public static function register_settings(): void {
register_setting(
- 'pp_glossary_settings_group',
+ 'inline_glossary_settings_group',
self::OPTION_NAME,
[
'sanitize_callback' => [ __CLASS__, 'sanitize_settings' ],
@@ -63,34 +63,34 @@ public static function register_settings(): void {
);
add_settings_section(
- 'pp_glossary_display_section',
- __( 'Display settings', 'pp-glossary' ),
+ 'inline_glossary_display_section',
+ __( 'Display settings', 'inline-glossary' ),
[ __CLASS__, 'render_display_section' ],
- 'pp-glossary-settings'
+ 'inline-glossary-settings'
);
add_settings_field(
'glossary_page',
- __( 'Glossary page', 'pp-glossary' ),
+ __( 'Glossary page', 'inline-glossary' ),
[ __CLASS__, 'render_glossary_page_field' ],
- 'pp-glossary-settings',
- 'pp_glossary_display_section'
+ 'inline-glossary-settings',
+ 'inline_glossary_display_section'
);
add_settings_field(
'excluded_tags',
- __( 'Excluded HTML tags', 'pp-glossary' ),
+ __( 'Excluded HTML tags', 'inline-glossary' ),
[ __CLASS__, 'render_excluded_tags_field' ],
- 'pp-glossary-settings',
- 'pp_glossary_display_section'
+ 'inline-glossary-settings',
+ 'inline_glossary_display_section'
);
add_settings_field(
'excluded_post_types',
- __( 'Excluded post types', 'pp-glossary' ),
+ __( 'Excluded post types', 'inline-glossary' ),
[ __CLASS__, 'render_excluded_post_types_field' ],
- 'pp-glossary-settings',
- 'pp_glossary_display_section'
+ 'inline-glossary-settings',
+ 'inline_glossary_display_section'
);
}
@@ -105,22 +105,22 @@ public static function render_settings_page(): void {
// Check if settings were saved.
if ( isset( $_GET['settings-updated'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing -- Nonce check not needed here.
add_settings_error(
- 'pp_glossary_messages',
- 'pp_glossary_message',
- esc_html__( 'Settings saved.', 'pp-glossary' ),
+ 'inline_glossary_messages',
+ 'inline_glossary_message',
+ esc_html__( 'Settings saved.', 'inline-glossary' ),
'updated'
);
}
- settings_errors( 'pp_glossary_messages' );
+ settings_errors( 'inline_glossary_messages' );
?>
@@ -131,7 +131,7 @@ public static function render_settings_page(): void {
* Render display section description
*/
public static function render_display_section(): void {
- echo '' . esc_html__( 'Configure how and where the glossary is displayed on your site.', 'pp-glossary' ) . '
';
+ echo '' . esc_html__( 'Configure how and where the glossary is displayed on your site.', 'inline-glossary' ) . '
';
}
/**
@@ -145,13 +145,13 @@ public static function render_glossary_page_field(): void {
[
'name' => esc_attr( self::OPTION_NAME ) . '[glossary_page]',
'selected' => esc_attr( (string) $page_id ),
- 'show_option_none' => esc_html__( '— Select a Page —', 'pp-glossary' ),
+ 'show_option_none' => esc_html__( '— Select a Page —', 'inline-glossary' ),
'option_none_value' => '0',
]
);
echo '';
- echo esc_html__( 'Select the page where the glossary block is located. This page will be used for "Read more" links in popovers.', 'pp-glossary' );
+ echo esc_html__( 'Select the page where the glossary block is located. This page will be used for "Read more" links in popovers.', 'inline-glossary' );
echo '
';
}
@@ -170,11 +170,11 @@ public static function render_excluded_tags_field(): void {
);
echo '';
- echo esc_html__( 'HTML tags where glossary terms should not be highlighted (comma-separated, without angle brackets).', 'pp-glossary' );
+ echo esc_html__( 'HTML tags where glossary terms should not be highlighted (comma-separated, without angle brackets).', 'inline-glossary' );
echo '
';
printf(
/* translators: %s: default tags */
- esc_html__( 'Default: %s', 'pp-glossary' ),
+ esc_html__( 'Default: %s', 'inline-glossary' ),
esc_html( implode( ', ', self::DEFAULT_EXCLUDED_TAGS ) )
);
echo '
';
@@ -196,10 +196,10 @@ public static function render_excluded_post_types_field(): void {
);
// Remove the glossary post type from the list.
- unset( $post_types['pp_glossary'] );
+ unset( $post_types['inline_glossary'] );
if ( empty( $post_types ) ) {
- echo '' . esc_html__( 'No public post types found.', 'pp-glossary' ) . '
';
+ echo '' . esc_html__( 'No public post types found.', 'inline-glossary' ) . '
';
return;
}
@@ -217,7 +217,7 @@ public static function render_excluded_post_types_field(): void {
echo '';
echo '';
- echo esc_html__( 'Glossary terms will not be highlighted in content from the selected post types.', 'pp-glossary' );
+ echo esc_html__( 'Glossary terms will not be highlighted in content from the selected post types.', 'inline-glossary' );
echo '
';
}
@@ -270,7 +270,7 @@ public static function get_settings(): array {
'glossary_page' => 0,
'excluded_tags' => self::DEFAULT_EXCLUDED_TAGS,
'excluded_post_types' => [],
- 'db_version' => PP_GLOSSARY_VERSION,
+ 'db_version' => INLINE_GLOSSARY_VERSION,
];
$settings = get_option( self::OPTION_NAME, [] );
diff --git a/includes/class-term-linker.php b/includes/class-term-linker.php
index 5ebead3..d52dfd2 100644
--- a/includes/class-term-linker.php
+++ b/includes/class-term-linker.php
@@ -2,10 +2,10 @@
/**
* Term Linker Utility
*
- * @package PP_Glossary
+ * @package Inline_Glossary
*/
-namespace PP_Glossary;
+namespace Inline_Glossary;
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
@@ -36,7 +36,7 @@ public static function link_terms_in_text( string $text, int $exclude_id = 0 ):
return $text;
}
- $entries = pp_glossary_get_linkable_entries();
+ $entries = inline_glossary_get_linkable_entries();
if ( empty( $entries ) ) {
return $text;
}
@@ -64,8 +64,8 @@ public static function link_terms_in_text( string $text, int $exclude_id = 0 ):
* @return string Modified text.
*/
private static function replace_first_term_occurrence( string $text, array $entry, string $glossary_url ): string {
- $excluded_tags = pp_glossary_get_excluded_tags();
- $parts = pp_glossary_split_by_excluded_tags( $text, $excluded_tags );
+ $excluded_tags = inline_glossary_get_excluded_tags();
+ $parts = inline_glossary_split_by_excluded_tags( $text, $excluded_tags );
$excluded_pattern = '/^<(?:' . implode( '|', $excluded_tags ) . ')\b/i';
if ( false === $parts ) {
@@ -91,7 +91,7 @@ private static function replace_first_term_occurrence( string $text, array $entr
$offset = $matches[1][1];
$link_html = sprintf(
- '%s',
+ '%s',
esc_url( $glossary_url ),
esc_attr( $entry['slug'] ),
esc_html( $matched_term )
diff --git a/includes/functions.php b/includes/functions.php
index 3d858d0..18b3032 100644
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -2,7 +2,7 @@
/**
* Functions for Glossary.
*
- * @package PP_Glossary
+ * @package Inline_Glossary
*/
// If this file is called directly, abort.
@@ -16,7 +16,7 @@
* @param string $text The string to convert to lowercase.
* @return string Lowercase string.
*/
-function pp_glossary_strtolower( string $text ): string {
+function inline_glossary_strtolower( string $text ): string {
if ( function_exists( 'mb_strtolower' ) ) {
return mb_strtolower( $text, 'UTF-8' );
}
@@ -29,7 +29,7 @@ function pp_glossary_strtolower( string $text ): string {
* @param string $text The string to convert to uppercase.
* @return string Uppercase string.
*/
-function pp_glossary_strtoupper( string $text ): string {
+function inline_glossary_strtoupper( string $text ): string {
if ( function_exists( 'mb_strtoupper' ) ) {
return mb_strtoupper( $text, 'UTF-8' );
}
@@ -44,7 +44,7 @@ function pp_glossary_strtoupper( string $text ): string {
* @param int|null $length Optional. Maximum length of the substring.
* @return string The substring.
*/
-function pp_glossary_substr( string $text, int $start, ?int $length = null ): string {
+function inline_glossary_substr( string $text, int $start, ?int $length = null ): string {
if ( function_exists( 'mb_substr' ) ) {
return mb_substr( $text, $start, $length, 'UTF-8' );
}
@@ -54,12 +54,12 @@ function pp_glossary_substr( string $text, int $start, ?int $length = null ): st
/**
* Get the HTML tags that should be excluded from glossary term linking.
*
- * Retrieves the configured excluded tags and applies the pp_glossary_excluded_tags filter.
+ * Retrieves the configured excluded tags and applies the inline_glossary_excluded_tags filter.
*
* @return array Array of HTML tag names.
*/
-function pp_glossary_get_excluded_tags(): array {
- $excluded_tags = PP_Glossary\Settings::get_excluded_tags();
+function inline_glossary_get_excluded_tags(): array {
+ $excluded_tags = Inline_Glossary\Settings::get_excluded_tags();
/**
* Filter the excluded tags.
@@ -68,7 +68,7 @@ function pp_glossary_get_excluded_tags(): array {
*
* @return array The excluded tags.
*/
- return apply_filters( 'pp_glossary_excluded_tags', $excluded_tags );
+ return apply_filters( 'inline_glossary_excluded_tags', $excluded_tags );
}
/**
@@ -82,7 +82,7 @@ function pp_glossary_get_excluded_tags(): array {
* @param array $excluded_tags Array of HTML tag names to split on.
* @return array|false Array of parts, or false on regex failure.
*/
-function pp_glossary_split_by_excluded_tags( string $text, array $excluded_tags ) {
+function inline_glossary_split_by_excluded_tags( string $text, array $excluded_tags ) {
$excluded_pattern = implode(
'|',
array_map(
@@ -104,7 +104,7 @@ function ( $tag ) {
*
* @return array> Array of glossary entries with full metadata.
*/
-function pp_glossary_get_entries(): array {
+function inline_glossary_get_entries(): array {
static $cache = null;
if ( null !== $cache ) {
@@ -115,7 +115,7 @@ function pp_glossary_get_entries(): array {
$query = new WP_Query(
[
- 'post_type' => 'pp_glossary',
+ 'post_type' => 'inline_glossary',
'posts_per_page' => -1,
'post_status' => 'publish',
'orderby' => 'title',
@@ -126,11 +126,11 @@ function pp_glossary_get_entries(): array {
foreach ( $query->posts as $post ) {
$post_id = ( $post instanceof \WP_Post ) ? $post->ID : (int) $post;
$title = ( $post instanceof \WP_Post ) ? $post->post_title : get_the_title( $post_id );
- $data = PP_Glossary\Meta_Boxes::get_entry_data( $post_id );
+ $data = Inline_Glossary\Meta_Boxes::get_entry_data( $post_id );
// Build array of terms (title + non-empty synonyms).
$terms = [ $title ];
- $synonyms = pp_glossary_filter_synonyms( $data['synonyms'] );
+ $synonyms = inline_glossary_filter_synonyms( $data['synonyms'] );
$terms = array_merge( $terms, $synonyms );
$entries[] = [
@@ -157,7 +157,7 @@ function pp_glossary_get_entries(): array {
* @param mixed $synonyms The synonyms array (or other value).
* @return array Filtered array of non-empty synonym strings.
*/
-function pp_glossary_filter_synonyms( $synonyms ): array {
+function inline_glossary_filter_synonyms( $synonyms ): array {
if ( ! is_array( $synonyms ) ) {
return [];
}
@@ -173,7 +173,7 @@ function pp_glossary_filter_synonyms( $synonyms ): array {
* @param array> $entries Array of glossary entries.
* @return array> Sorted array of glossary entries.
*/
-function pp_glossary_sort_by_term_length( array $entries ): array {
+function inline_glossary_sort_by_term_length( array $entries ): array {
usort(
$entries,
function ( $a, $b ) {
@@ -199,14 +199,14 @@ function ( $a, $b ) {
*
* @return array> Array of linkable glossary entries.
*/
-function pp_glossary_get_linkable_entries(): array {
+function inline_glossary_get_linkable_entries(): array {
static $cache = null;
if ( null !== $cache ) {
return $cache;
}
- $all_entries = pp_glossary_get_entries();
+ $all_entries = inline_glossary_get_entries();
// Filter out entries with auto-linking disabled.
$linkable_entries = array_filter(
@@ -217,7 +217,7 @@ function ( $entry ) {
);
// Sort by longest term first.
- $cache = pp_glossary_sort_by_term_length( array_values( $linkable_entries ) );
+ $cache = inline_glossary_sort_by_term_length( array_values( $linkable_entries ) );
return $cache;
}
diff --git a/inline-glossary.php b/inline-glossary.php
new file mode 100644
index 0000000..32b886e
--- /dev/null
+++ b/inline-glossary.php
@@ -0,0 +1,100 @@
+ class-settings.php -> includes/class-settings.php.
+ $file_name = 'class-' . str_replace( '_', '-', strtolower( $class_name ) ) . '.php';
+ $file_path = INLINE_GLOSSARY_PLUGIN_DIR . 'includes/' . $file_name;
+
+ // Load the file if it exists.
+ if ( file_exists( $file_path ) ) {
+ require_once $file_path;
+ }
+}
+
+// Register the autoloader.
+spl_autoload_register( 'inline_glossary_autoloader' );
+
+/**
+ * Initialize the plugin.
+ */
+function inline_glossary_init(): void {
+ // Initialize components.
+ \Inline_Glossary\Settings::init();
+ \Inline_Glossary\Post_Type::init();
+ \Inline_Glossary\Blocks::init();
+ \Inline_Glossary\Schema::init();
+
+ if ( is_admin() ) {
+ \Inline_Glossary\Meta_Boxes::init();
+ \Inline_Glossary\Migrations::init();
+ } else {
+ \Inline_Glossary\Content_Filter::init();
+ \Inline_Glossary\Assets::init();
+ }
+}
+add_action( 'plugins_loaded', 'inline_glossary_init' );
+
+/**
+ * Activation hook
+ */
+function inline_glossary_activate(): void {
+ // Flush rewrite rules.
+ inline_glossary_init();
+ flush_rewrite_rules();
+}
+register_activation_hook( __FILE__, 'inline_glossary_activate' );
+
+/**
+ * Deactivation hook
+ */
+function inline_glossary_deactivate(): void {
+ flush_rewrite_rules();
+}
+register_deactivation_hook( __FILE__, 'inline_glossary_deactivate' );
diff --git a/phpcs.xml b/phpcs.xml
index 21ca9ee..55a05a7 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -1,7 +1,7 @@
-
+
- A custom set of rules to check for the Glossary by Progress Planner project
+ A custom set of rules to check for the Inline Glossary by Progress Planner project