|
|
|
@ -13,7 +13,39 @@ declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace footnotes\general;
|
|
|
|
|
|
|
|
|
|
use footnotes\includes as Includes;
|
|
|
|
|
use footnotes\includes\{Settings, Convert, Template};
|
|
|
|
|
use const footnotes\includes\settings\general\ReferenceContainerSettingsGroup\{
|
|
|
|
|
COMBINE_IDENTICAL_FOOTNOTES,
|
|
|
|
|
REFERENCE_CONTAINER_NAME,
|
|
|
|
|
REFERENCE_CONTAINER_LABEL_ELEMENT,
|
|
|
|
|
REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER,
|
|
|
|
|
REFERENCE_CONTAINER_COLLAPSE,
|
|
|
|
|
REFERENCE_CONTAINER_START_PAGE_ENABLE,
|
|
|
|
|
REFERENCE_CONTAINER_TOP_MARGIN,
|
|
|
|
|
REFERENCE_CONTAINER_BOTTOM_MARGIN,
|
|
|
|
|
REFERENCE_CONTAINER_ROW_BORDERS_ENABLE,
|
|
|
|
|
BACKLINKS_COLUMN_WIDTH_ENABLED,
|
|
|
|
|
BACKLINKS_COLUMN_WIDTH_SCALAR,
|
|
|
|
|
BACKLINKS_COLUMN_WIDTH_UNIT,
|
|
|
|
|
BACKLINKS_COLUMN_MAX_WIDTH_ENABLED,
|
|
|
|
|
BACKLINKS_COLUMN_MAX_WIDTH_SCALAR,
|
|
|
|
|
BACKLINKS_COLUMN_MAX_WIDTH_UNIT,
|
|
|
|
|
REFERENCE_CONTAINER_POSITION,
|
|
|
|
|
FOOTNOTE_SECTION_SHORTCODE,
|
|
|
|
|
REFERENCE_CONTAINER_POSITION_SHORTCODE,
|
|
|
|
|
FOOTNOTE_URL_WRAP_ENABLED,
|
|
|
|
|
LINK_ELEMENT_ENABLED,
|
|
|
|
|
REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE,
|
|
|
|
|
REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH,
|
|
|
|
|
BACKLINKS_SEPARATOR_ENABLED,
|
|
|
|
|
BACKLINKS_SEPARATOR_OPTION,
|
|
|
|
|
BACKLINKS_SEPARATOR_CUSTOM,
|
|
|
|
|
BACKLINKS_TERMINATOR_ENABLED,
|
|
|
|
|
BACKLINKS_TERMINATOR_OPTION,
|
|
|
|
|
BACKLINKS_TERMINATOR_CUSTOM,
|
|
|
|
|
REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE,
|
|
|
|
|
BACKLINKS_LINE_BREAKS_ENABLED
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Searches and replaces the footnotes and generates the reference container.
|
|
|
|
@ -272,11 +304,11 @@ class Parser {
|
|
|
|
|
*/
|
|
|
|
|
public function register_hooks(): void {
|
|
|
|
|
// Get values from settings.
|
|
|
|
|
$the_title_priority = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL );
|
|
|
|
|
$the_content_priority = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL );
|
|
|
|
|
$the_excerpt_priority = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL );
|
|
|
|
|
$widget_title_priority = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL );
|
|
|
|
|
$widget_text_priority = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL );
|
|
|
|
|
$the_title_priority = (int) Settings::instance()->get( Settings::EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL );
|
|
|
|
|
$the_content_priority = (int) Settings::instance()->get( Settings::EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL );
|
|
|
|
|
$the_excerpt_priority = (int) Settings::instance()->get( Settings::EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL );
|
|
|
|
|
$widget_title_priority = (int) Settings::instance()->get( Settings::EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL );
|
|
|
|
|
$widget_text_priority = (int) Settings::instance()->get( Settings::EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL );
|
|
|
|
|
|
|
|
|
|
// PHP_INT_MAX can be set by -1.
|
|
|
|
|
$the_title_priority = ( -1 === $the_title_priority ) ? PHP_INT_MAX : $the_title_priority;
|
|
|
|
@ -299,7 +331,7 @@ class Parser {
|
|
|
|
|
PHP_INT_MAX
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::EXPERT_LOOKUP_THE_TITLE ) ) ) {
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( Settings::EXPERT_LOOKUP_THE_TITLE ) ) ) {
|
|
|
|
|
add_filter(
|
|
|
|
|
'the_title',
|
|
|
|
|
fn( string $content): string => $this->footnotes_in_title( $content ),
|
|
|
|
@ -308,7 +340,7 @@ class Parser {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Configurable priority level for reference container relative positioning; default 98.
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::EXPERT_LOOKUP_THE_CONTENT ) ) ) {
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( Settings::EXPERT_LOOKUP_THE_CONTENT ) ) ) {
|
|
|
|
|
add_filter(
|
|
|
|
|
'the_content',
|
|
|
|
|
fn( string $content): string => $this->footnotes_in_content( $content ),
|
|
|
|
@ -350,7 +382,7 @@ class Parser {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::EXPERT_LOOKUP_THE_EXCERPT ) ) ) {
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( Settings::EXPERT_LOOKUP_THE_EXCERPT ) ) ) {
|
|
|
|
|
/**
|
|
|
|
|
* Adds a filter to the excerpt hook.
|
|
|
|
|
*
|
|
|
|
@ -366,7 +398,7 @@ class Parser {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::EXPERT_LOOKUP_WIDGET_TITLE ) ) ) {
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( Settings::EXPERT_LOOKUP_WIDGET_TITLE ) ) ) {
|
|
|
|
|
/**
|
|
|
|
|
* TODO
|
|
|
|
|
*/
|
|
|
|
@ -377,7 +409,7 @@ class Parser {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::EXPERT_LOOKUP_WIDGET_TEXT ) ) ) {
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( Settings::EXPERT_LOOKUP_WIDGET_TEXT ) ) ) {
|
|
|
|
|
/**
|
|
|
|
|
* TODO
|
|
|
|
|
*/
|
|
|
|
@ -409,7 +441,7 @@ class Parser {
|
|
|
|
|
*
|
|
|
|
|
* Native smooth scrolling only works in recent browsers.
|
|
|
|
|
*/
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_CSS_SMOOTH_SCROLLING ) ) ) {
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( Settings::FOOTNOTES_CSS_SMOOTH_SCROLLING ) ) ) {
|
|
|
|
|
echo "html {scroll-behavior: smooth;}\r\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -419,7 +451,7 @@ class Parser {
|
|
|
|
|
* Cannot be included in external stylesheet, as it is only optional.
|
|
|
|
|
* The scope is variable too: referrers only, or all superscript elements.
|
|
|
|
|
*/
|
|
|
|
|
$normalize_superscript = Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT );
|
|
|
|
|
$normalize_superscript = Settings::instance()->get( Settings::FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT );
|
|
|
|
|
if ( 'no' !== $normalize_superscript ) {
|
|
|
|
|
if ( 'all' === $normalize_superscript ) {
|
|
|
|
|
echo 'sup {';
|
|
|
|
@ -430,14 +462,14 @@ class Parser {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reference container display on home page.
|
|
|
|
|
if ( ! Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_START_PAGE_ENABLE ) ) ) {
|
|
|
|
|
if ( ! Convert::to_bool( Settings::instance()->get( REFERENCE_CONTAINER_START_PAGE_ENABLE['key'] ) ) ) {
|
|
|
|
|
|
|
|
|
|
echo ".home .footnotes_reference_container { display: none; }\r\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reference container top and bottom margins.
|
|
|
|
|
$reference_container_top_margin = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_TOP_MARGIN );
|
|
|
|
|
$reference_container_bottom_margin = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_BOTTOM_MARGIN );
|
|
|
|
|
$reference_container_top_margin = (int) Settings::instance()->get( REFERENCE_CONTAINER_TOP_MARGIN['key'] );
|
|
|
|
|
$reference_container_bottom_margin = (int) Settings::instance()->get( REFERENCE_CONTAINER_BOTTOM_MARGIN['key'] );
|
|
|
|
|
echo '.footnotes_reference_container {margin-top: ';
|
|
|
|
|
echo empty( $reference_container_top_margin ) ? '0' : $reference_container_top_margin;
|
|
|
|
|
echo 'px !important; margin-bottom: ';
|
|
|
|
@ -445,9 +477,9 @@ class Parser {
|
|
|
|
|
echo "px !important;}\r\n";
|
|
|
|
|
|
|
|
|
|
// Reference container label bottom border.
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER ) ) ) {
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER['key'] ) ) ) {
|
|
|
|
|
echo '.footnote_container_prepare > ';
|
|
|
|
|
echo Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_LABEL_ELEMENT );
|
|
|
|
|
echo Settings::instance()->get( REFERENCE_CONTAINER_LABEL_ELEMENT );
|
|
|
|
|
echo " {border-bottom: 1px solid #aaaaaa !important;}\r\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -460,7 +492,7 @@ class Parser {
|
|
|
|
|
* issues as browsers won’t reload these style sheets after settings are
|
|
|
|
|
* changed while the version string is not.
|
|
|
|
|
*/
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_ROW_BORDERS_ENABLE ) ) ) {
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( REFERENCE_CONTAINER_ROW_BORDERS_ENABLE['key'] ) ) ) {
|
|
|
|
|
echo '.footnotes_table, .footnotes_plugin_reference_row {';
|
|
|
|
|
echo 'border: 1px solid #060606;';
|
|
|
|
|
echo " !important;}\r\n";
|
|
|
|
@ -470,16 +502,16 @@ class Parser {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ref container first column width and max-width.
|
|
|
|
|
$column_width_enabled = Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::BACKLINKS_COLUMN_WIDTH_ENABLED ) );
|
|
|
|
|
$column_max_width_enabled = Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::BACKLINKS_COLUMN_MAX_WIDTH_ENABLED ) );
|
|
|
|
|
$column_width_enabled = Convert::to_bool( Settings::instance()->get( BACKLINKS_COLUMN_WIDTH_ENABLED['key'] ) );
|
|
|
|
|
$column_max_width_enabled = Convert::to_bool( Settings::instance()->get( BACKLINKS_COLUMN_MAX_WIDTH_ENABLED['key'] ) );
|
|
|
|
|
|
|
|
|
|
if ( $column_width_enabled || $column_max_width_enabled ) {
|
|
|
|
|
echo '.footnote-reference-container { table-layout: fixed; }';
|
|
|
|
|
echo '.footnote_plugin_index, .footnote_plugin_index_combi {';
|
|
|
|
|
|
|
|
|
|
if ( $column_width_enabled ) {
|
|
|
|
|
$column_width_scalar = Includes\Settings::instance()->get( \footnotes\includes\Settings::BACKLINKS_COLUMN_WIDTH_SCALAR );
|
|
|
|
|
$column_width_unit = Includes\Settings::instance()->get( \footnotes\includes\Settings::BACKLINKS_COLUMN_WIDTH_UNIT );
|
|
|
|
|
$column_width_scalar = Settings::instance()->get( BACKLINKS_COLUMN_WIDTH_SCALAR['key'] );
|
|
|
|
|
$column_width_unit = Settings::instance()->get( BACKLINKS_COLUMN_WIDTH_UNIT['key'] );
|
|
|
|
|
|
|
|
|
|
if ( ! empty( $column_width_scalar ) ) {
|
|
|
|
|
if ( '%' === $column_width_unit && $column_width_scalar > 100 ) {
|
|
|
|
@ -493,8 +525,8 @@ class Parser {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $column_max_width_enabled ) {
|
|
|
|
|
$column_max_width_scalar = Includes\Settings::instance()->get( \footnotes\includes\Settings::BACKLINKS_COLUMN_MAX_WIDTH_SCALAR );
|
|
|
|
|
$column_max_width_unit = Includes\Settings::instance()->get( \footnotes\includes\Settings::BACKLINKS_COLUMN_MAX_WIDTH_UNIT );
|
|
|
|
|
$column_max_width_scalar = Settings::instance()->get( BACKLINKS_COLUMN_MAX_WIDTH_SCALAR['key'] );
|
|
|
|
|
$column_max_width_unit = Settings::instance()->get( BACKLINKS_COLUMN_MAX_WIDTH_UNIT['key'] );
|
|
|
|
|
|
|
|
|
|
if ( ! empty( $column_max_width_scalar ) ) {
|
|
|
|
|
if ( '%' === $column_max_width_unit && $column_max_width_scalar > 100 ) {
|
|
|
|
@ -511,14 +543,14 @@ class Parser {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Hard links scroll offset.
|
|
|
|
|
self::$hard_links_enabled = Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_HARD_LINKS_ENABLE ) );
|
|
|
|
|
self::$hard_links_enabled = Convert::to_bool( Settings::instance()->get( Settings::FOOTNOTES_HARD_LINKS_ENABLE ) );
|
|
|
|
|
|
|
|
|
|
// Correct hard links enabled status depending on AMP-compatible or alternative reference container enabled status.
|
|
|
|
|
if ( General::$amp_enabled || 'jquery' !== General::$script_mode ) {
|
|
|
|
|
self::$hard_links_enabled = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self::$scroll_offset = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_SCROLL_OFFSET );
|
|
|
|
|
self::$scroll_offset = (int) Settings::instance()->get( Settings::FOOTNOTES_SCROLL_OFFSET );
|
|
|
|
|
if ( self::$hard_links_enabled ) {
|
|
|
|
|
echo '.footnote_referrer_anchor, .footnote_item_anchor {bottom: ';
|
|
|
|
|
echo self::$scroll_offset;
|
|
|
|
@ -531,46 +563,46 @@ class Parser {
|
|
|
|
|
|
|
|
|
|
// Tooltip appearance: Tooltip font size.
|
|
|
|
|
echo ' font-size: ';
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::MOUSE_OVER_BOX_FONT_SIZE_ENABLED ) ) ) {
|
|
|
|
|
echo Includes\Settings::instance()->get( \footnotes\includes\Settings::MOUSE_OVER_BOX_FONT_SIZE_SCALAR );
|
|
|
|
|
echo Includes\Settings::instance()->get( \footnotes\includes\Settings::MOUSE_OVER_BOX_FONT_SIZE_UNIT );
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( Settings::MOUSE_OVER_BOX_FONT_SIZE_ENABLED ) ) ) {
|
|
|
|
|
echo Settings::instance()->get( Settings::MOUSE_OVER_BOX_FONT_SIZE_SCALAR );
|
|
|
|
|
echo Settings::instance()->get( Settings::MOUSE_OVER_BOX_FONT_SIZE_UNIT );
|
|
|
|
|
} else {
|
|
|
|
|
echo 'inherit';
|
|
|
|
|
}
|
|
|
|
|
echo ' !important;';
|
|
|
|
|
|
|
|
|
|
// Tooltip Text color.
|
|
|
|
|
$color = Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_COLOR );
|
|
|
|
|
$color = Settings::instance()->get( Settings::FOOTNOTES_MOUSE_OVER_BOX_COLOR );
|
|
|
|
|
if ( ! empty( $color ) ) {
|
|
|
|
|
printf( ' color: %s !important;', $color );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Tooltip Background color.
|
|
|
|
|
$background = Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND );
|
|
|
|
|
$background = Settings::instance()->get( Settings::FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND );
|
|
|
|
|
if ( ! empty( $background ) ) {
|
|
|
|
|
printf( ' background-color: %s !important;', $background );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Tooltip Border width.
|
|
|
|
|
$border_width = Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH );
|
|
|
|
|
$border_width = Settings::instance()->get( Settings::FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH );
|
|
|
|
|
if ( ! empty( $border_width ) && (int) $border_width > 0 ) {
|
|
|
|
|
printf( ' border-width: %dpx !important; border-style: solid !important;', $border_width );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Tooltip Border color.
|
|
|
|
|
$border_color = Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR );
|
|
|
|
|
$border_color = Settings::instance()->get( Settings::FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR );
|
|
|
|
|
if ( ! empty( $border_color ) ) {
|
|
|
|
|
printf( ' border-color: %s !important;', $border_color );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Tooltip Corner radius.
|
|
|
|
|
$border_radius = Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS );
|
|
|
|
|
$border_radius = Settings::instance()->get( Settings::FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS );
|
|
|
|
|
if ( ! empty( $border_radius ) && (int) $border_radius > 0 ) {
|
|
|
|
|
printf( ' border-radius: %dpx !important;', $border_radius );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Tooltip Shadow color.
|
|
|
|
|
$box_shadow_color = Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR );
|
|
|
|
|
$box_shadow_color = Settings::instance()->get( Settings::FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR );
|
|
|
|
|
if ( ! empty( $box_shadow_color ) ) {
|
|
|
|
|
printf( ' -webkit-box-shadow: 2px 2px 11px %s;', $box_shadow_color );
|
|
|
|
|
printf( ' -moz-box-shadow: 2px 2px 11px %s;', $box_shadow_color );
|
|
|
|
@ -584,7 +616,7 @@ class Parser {
|
|
|
|
|
*
|
|
|
|
|
* Position and timing of jQuery tooltips are script-defined.
|
|
|
|
|
*/
|
|
|
|
|
$max_width = Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH );
|
|
|
|
|
$max_width = Settings::instance()->get( Settings::FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH );
|
|
|
|
|
if ( ! empty( $max_width ) && (int) $max_width > 0 ) {
|
|
|
|
|
printf( ' max-width: %dpx !important;', $max_width );
|
|
|
|
|
}
|
|
|
|
@ -595,7 +627,7 @@ class Parser {
|
|
|
|
|
echo "}\r\n";
|
|
|
|
|
|
|
|
|
|
// Dimensions.
|
|
|
|
|
$alternative_tooltip_width = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_WIDTH );
|
|
|
|
|
$alternative_tooltip_width = (int) Settings::instance()->get( Settings::FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_WIDTH );
|
|
|
|
|
echo '.footnote_tooltip.position {';
|
|
|
|
|
echo ' width: max-content; ';
|
|
|
|
|
|
|
|
|
@ -603,8 +635,8 @@ class Parser {
|
|
|
|
|
echo ' max-width: ' . $alternative_tooltip_width . 'px;';
|
|
|
|
|
|
|
|
|
|
// Position.
|
|
|
|
|
$alternative_position = Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_POSITION );
|
|
|
|
|
$offset_x = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_X );
|
|
|
|
|
$alternative_position = Settings::instance()->get( Settings::FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_POSITION );
|
|
|
|
|
$offset_x = (int) Settings::instance()->get( Settings::FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_X );
|
|
|
|
|
|
|
|
|
|
if ( 'top left' === $alternative_position || 'bottom left' === $alternative_position ) {
|
|
|
|
|
echo ' right: ' . ( empty( $offset_x ) ? 0 : $offset_x ) . 'px;';
|
|
|
|
@ -612,7 +644,7 @@ class Parser {
|
|
|
|
|
echo ' left: ' . ( empty( $offset_x ) ? 0 : $offset_x ) . 'px;';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$offset_y = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_Y );
|
|
|
|
|
$offset_y = (int) Settings::instance()->get( Settings::FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_Y );
|
|
|
|
|
|
|
|
|
|
if ( 'top left' === $alternative_position || 'top right' === $alternative_position ) {
|
|
|
|
|
echo ' bottom: ' . ( empty( $offset_y ) ? 0 : $offset_y ) . 'px;';
|
|
|
|
@ -622,13 +654,13 @@ class Parser {
|
|
|
|
|
echo "}\r\n";
|
|
|
|
|
|
|
|
|
|
// Timing.
|
|
|
|
|
$fade_in_delay = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::MOUSE_OVER_BOX_FADE_IN_DELAY );
|
|
|
|
|
$fade_in_delay = (int) Settings::instance()->get( Settings::MOUSE_OVER_BOX_FADE_IN_DELAY );
|
|
|
|
|
$fade_in_delay = empty( $fade_in_delay ) ? '0' : $fade_in_delay;
|
|
|
|
|
$fade_in_duration = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::MOUSE_OVER_BOX_FADE_IN_DURATION );
|
|
|
|
|
$fade_in_duration = (int) Settings::instance()->get( Settings::MOUSE_OVER_BOX_FADE_IN_DURATION );
|
|
|
|
|
$fade_in_duration = empty( $fade_in_duration ) ? '0' : $fade_in_duration;
|
|
|
|
|
$fade_out_delay = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::MOUSE_OVER_BOX_FADE_OUT_DELAY );
|
|
|
|
|
$fade_out_delay = (int) Settings::instance()->get( Settings::MOUSE_OVER_BOX_FADE_OUT_DELAY );
|
|
|
|
|
$fade_out_delay = empty( $fade_out_delay ) ? '0' : $fade_out_delay;
|
|
|
|
|
$fade_out_duration = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::MOUSE_OVER_BOX_FADE_OUT_DURATION );
|
|
|
|
|
$fade_out_duration = (int) Settings::instance()->get( Settings::MOUSE_OVER_BOX_FADE_OUT_DURATION );
|
|
|
|
|
$fade_out_duration = empty( $fade_out_duration ) ? '0' : $fade_out_duration;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
@ -674,11 +706,11 @@ class Parser {
|
|
|
|
|
* Set custom CSS to override settings, not conversely.
|
|
|
|
|
* Legacy Custom CSS is used until it’s set to disappear after dashboard tab migration.
|
|
|
|
|
*/
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::CUSTOM_CSS_LEGACY_ENABLE ) ) ) {
|
|
|
|
|
echo Includes\Settings::instance()->get( \footnotes\includes\Settings::CUSTOM_CSS );
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( Settings::CUSTOM_CSS_LEGACY_ENABLE ) ) ) {
|
|
|
|
|
echo Settings::instance()->get( Settings::CUSTOM_CSS );
|
|
|
|
|
echo "\r\n";
|
|
|
|
|
}
|
|
|
|
|
echo Includes\Settings::instance()->get( \footnotes\includes\Settings::CUSTOM_CSS_NEW );
|
|
|
|
|
echo Settings::instance()->get( Settings::CUSTOM_CSS_NEW );
|
|
|
|
|
|
|
|
|
|
// Insert end tag without switching out of PHP.
|
|
|
|
|
echo "\r\n</style>\r\n";
|
|
|
|
@ -711,17 +743,17 @@ class Parser {
|
|
|
|
|
* @since 1.5.0
|
|
|
|
|
*/
|
|
|
|
|
public function footnotes_output_footer(): void {
|
|
|
|
|
if ( 'footer' === Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_POSITION ) ) {
|
|
|
|
|
if ( 'footer' === Settings::instance()->get( REFERENCE_CONTAINER_POSITION['key'] ) ) {
|
|
|
|
|
echo $this->reference_container();
|
|
|
|
|
}
|
|
|
|
|
// Get setting for love and share this plugin.
|
|
|
|
|
$love_me_index = Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_LOVE );
|
|
|
|
|
$love_me_index = Settings::instance()->get( Settings::FOOTNOTES_LOVE );
|
|
|
|
|
// Check if the admin allows to add a link to the footer.
|
|
|
|
|
if ( empty( $love_me_index ) || 'no' === strtolower( $love_me_index ) || ! self::$allow_love_me ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// Set a hyperlink to the word "footnotes" in the Love slug.
|
|
|
|
|
$linked_name = sprintf( '<a href="https://wordpress.org/plugins/footnotes/" target="_blank" style="text-decoration:none;">%s</a>', \footnotes\includes\Config::PLUGIN_PUBLIC_NAME );
|
|
|
|
|
$linked_name = sprintf( '<a href="https://wordpress.org/plugins/footnotes/" target="_blank" style="text-decoration:none;">%s</a>', Config::PLUGIN_PUBLIC_NAME );
|
|
|
|
|
// Get random love me text.
|
|
|
|
|
if ( 'random' === strtolower( $love_me_index ) ) {
|
|
|
|
|
$love_me_index = 'text-' . wp_rand( 1, 7 );
|
|
|
|
@ -730,7 +762,7 @@ class Parser {
|
|
|
|
|
// Options named wrt backcompat, simplest is default.
|
|
|
|
|
case 'text-1':
|
|
|
|
|
/* Translators: 2: Link to plugin page 1: Love heart symbol */
|
|
|
|
|
$love_me_text = sprintf( __( 'I %2$s %1$s', 'footnotes' ), $linked_name, \footnotes\includes\Config::LOVE_SYMBOL );
|
|
|
|
|
$love_me_text = sprintf( __( 'I %2$s %1$s', 'footnotes' ), $linked_name, Config::LOVE_SYMBOL );
|
|
|
|
|
break;
|
|
|
|
|
case 'text-2':
|
|
|
|
|
/* Translators: %s: Link to plugin page */
|
|
|
|
@ -738,11 +770,11 @@ class Parser {
|
|
|
|
|
break;
|
|
|
|
|
case 'text-4':
|
|
|
|
|
/* Translators: 1: Link to plugin page 2: Love heart symbol */
|
|
|
|
|
$love_me_text = sprintf( '%1$s %2$s', $linked_name, \footnotes\includes\Config::LOVE_SYMBOL );
|
|
|
|
|
$love_me_text = sprintf( '%1$s %2$s', $linked_name, Config::LOVE_SYMBOL );
|
|
|
|
|
break;
|
|
|
|
|
case 'text-5':
|
|
|
|
|
/* Translators: 1: Love heart symbol 2: Link to plugin page */
|
|
|
|
|
$love_me_text = sprintf( '%1$s %2$s', \footnotes\includes\Config::LOVE_SYMBOL, $linked_name );
|
|
|
|
|
$love_me_text = sprintf( '%1$s %2$s', Config::LOVE_SYMBOL, $linked_name );
|
|
|
|
|
break;
|
|
|
|
|
case 'text-6':
|
|
|
|
|
/* Translators: %s: Link to plugin page */
|
|
|
|
@ -784,8 +816,8 @@ class Parser {
|
|
|
|
|
*/
|
|
|
|
|
public function footnotes_in_content( string $content ): string {
|
|
|
|
|
|
|
|
|
|
$ref_container_position = Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_POSITION );
|
|
|
|
|
$footnote_section_shortcode = Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTE_SECTION_SHORTCODE );
|
|
|
|
|
$ref_container_position = Settings::instance()->get( REFERENCE_CONTAINER_POSITION['key'] );
|
|
|
|
|
$footnote_section_shortcode = Settings::instance()->get( FOOTNOTE_SECTION_SHORTCODE['key'] );
|
|
|
|
|
$footnote_section_shortcode_length = strlen( $footnote_section_shortcode );
|
|
|
|
|
|
|
|
|
|
// TODO: Replace with `str_contains()`, but currently breaks Rector downgrade.
|
|
|
|
@ -833,7 +865,7 @@ class Parser {
|
|
|
|
|
* @return string $excerpt Processed or new excerpt.
|
|
|
|
|
*/
|
|
|
|
|
public function footnotes_in_excerpt( string $excerpt ): string {
|
|
|
|
|
$excerpt_mode = Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_IN_EXCERPT );
|
|
|
|
|
$excerpt_mode = Settings::instance()->get( Settings::FOOTNOTES_IN_EXCERPT );
|
|
|
|
|
|
|
|
|
|
if ( 'yes' === $excerpt_mode ) {
|
|
|
|
|
return $this->generate_excerpt_with_footnotes( $excerpt );
|
|
|
|
@ -1021,7 +1053,7 @@ class Parser {
|
|
|
|
|
public function footnotes_in_widget_text( string $content ): string {
|
|
|
|
|
// phpcs:disable WordPress.PHP.YodaConditions.NotYoda
|
|
|
|
|
// Appends the reference container if set to "post_end".
|
|
|
|
|
return $this->exec( $content, 'post_end' === Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_POSITION ) );
|
|
|
|
|
return $this->exec( $content, 'post_end' === Settings::instance()->get( REFERENCE_CONTAINER_POSITION['key'] ) );
|
|
|
|
|
// phpcs:enable WordPress.PHP.YodaConditions.NotYoda
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1044,7 +1076,7 @@ class Parser {
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Append the reference container or insert at shortcode.
|
|
|
|
|
$reference_container_position_shortcode = Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_POSITION_SHORTCODE );
|
|
|
|
|
$reference_container_position_shortcode = Settings::instance()->get( REFERENCE_CONTAINER_POSITION_SHORTCODE['key'] );
|
|
|
|
|
if ( empty( $reference_container_position_shortcode ) ) {
|
|
|
|
|
$reference_container_position_shortcode = '[[references]]';
|
|
|
|
|
}
|
|
|
|
@ -1069,9 +1101,9 @@ class Parser {
|
|
|
|
|
$content = str_replace( $reference_container_position_shortcode, '', $content );
|
|
|
|
|
|
|
|
|
|
// Take a look if the LOVE ME slug should NOT be displayed on this page/post, remove the short code if found.
|
|
|
|
|
if ( strpos( $content, \footnotes\includes\Config::NO_LOVE_SLUG ) ) {
|
|
|
|
|
if ( strpos( $content, Config::NO_LOVE_SLUG ) ) {
|
|
|
|
|
self::$allow_love_me = false;
|
|
|
|
|
$content = str_replace( \footnotes\includes\Config::NO_LOVE_SLUG, '', $content );
|
|
|
|
|
$content = str_replace( Config::NO_LOVE_SLUG, '', $content );
|
|
|
|
|
}
|
|
|
|
|
// Return the content with replaced footnotes and optional reference container appended.
|
|
|
|
|
return $content;
|
|
|
|
@ -1092,11 +1124,11 @@ class Parser {
|
|
|
|
|
public function unify_delimiters( string $content ): string {
|
|
|
|
|
|
|
|
|
|
// Get footnotes start and end tag short codes.
|
|
|
|
|
$starting_tag = Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_SHORT_CODE_START );
|
|
|
|
|
$ending_tag = Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_SHORT_CODE_END );
|
|
|
|
|
$starting_tag = Settings::instance()->get( Settings::FOOTNOTES_SHORT_CODE_START );
|
|
|
|
|
$ending_tag = Settings::instance()->get( Settings::FOOTNOTES_SHORT_CODE_END );
|
|
|
|
|
if ( 'userdefined' === $starting_tag || 'userdefined' === $ending_tag ) {
|
|
|
|
|
$starting_tag = Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_SHORT_CODE_START_USER_DEFINED );
|
|
|
|
|
$ending_tag = Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_SHORT_CODE_END_USER_DEFINED );
|
|
|
|
|
$starting_tag = Settings::instance()->get( Settings::FOOTNOTES_SHORT_CODE_START_USER_DEFINED );
|
|
|
|
|
$ending_tag = Settings::instance()->get( Settings::FOOTNOTES_SHORT_CODE_END_USER_DEFINED );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If any footnotes short code is empty, return the content without changes.
|
|
|
|
@ -1169,7 +1201,7 @@ class Parser {
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// If enabled.
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE ) ) ) {
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( Settings::FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE ) ) ) {
|
|
|
|
|
|
|
|
|
|
// Apply different regex depending on whether start shortcode is double/triple opening parenthesis.
|
|
|
|
|
if ( '((' === self::$start_tag || '(((' === self::$start_tag ) {
|
|
|
|
@ -1238,7 +1270,7 @@ class Parser {
|
|
|
|
|
} while ( preg_match( $value_regex, $content ) );
|
|
|
|
|
|
|
|
|
|
// Optionally moves footnotes outside at the end of the label element.
|
|
|
|
|
$label_issue_solution = Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_LABEL_ISSUE_SOLUTION );
|
|
|
|
|
$label_issue_solution = Settings::instance()->get( Settings::FOOTNOTES_LABEL_ISSUE_SOLUTION );
|
|
|
|
|
|
|
|
|
|
if ( 'move' === $label_issue_solution ) {
|
|
|
|
|
|
|
|
|
@ -1309,29 +1341,29 @@ class Parser {
|
|
|
|
|
if ( General::$amp_enabled ) {
|
|
|
|
|
|
|
|
|
|
// Whether first clicking a referrer needs to expand the reference container.
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_COLLAPSE ) ) ) {
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( REFERENCE_CONTAINER_COLLAPSE['key'] ) ) ) {
|
|
|
|
|
|
|
|
|
|
// Load 'public/partials/amp-footnote-expand.html'.
|
|
|
|
|
$template = new Includes\Template( \footnotes\includes\Template::PUBLIC, 'amp-footnote-expand' );
|
|
|
|
|
$template = new Template( Template::PUBLIC, 'amp-footnote-expand' );
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
// Load 'public/partials/amp-footnote.html'.
|
|
|
|
|
$template = new Includes\Template( \footnotes\includes\Template::PUBLIC, 'amp-footnote' );
|
|
|
|
|
$template = new Template( Template::PUBLIC, 'amp-footnote' );
|
|
|
|
|
}
|
|
|
|
|
} elseif ( General::$alternative_tooltips_enabled ) {
|
|
|
|
|
|
|
|
|
|
// Load 'public/partials/footnote-alternative.html'.
|
|
|
|
|
$template = new Includes\Template( \footnotes\includes\Template::PUBLIC, 'footnote-alternative' );
|
|
|
|
|
$template = new Template( Template::PUBLIC, 'footnote-alternative' );
|
|
|
|
|
|
|
|
|
|
// Else jQuery tooltips are enabled.
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
// Load 'public/partials/footnote.html'.
|
|
|
|
|
$template = new Includes\Template( \footnotes\includes\Template::PUBLIC, 'footnote' );
|
|
|
|
|
$template = new Template( Template::PUBLIC, 'footnote' );
|
|
|
|
|
|
|
|
|
|
// Load tooltip inline script.
|
|
|
|
|
$template_tooltip = new Includes\Template( \footnotes\includes\Template::PUBLIC, 'tooltip' );
|
|
|
|
|
$template_tooltip = new Template( Template::PUBLIC, 'tooltip' );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1360,7 +1392,7 @@ class Parser {
|
|
|
|
|
$footnote_text = substr( $content, $pos_start + strlen( self::$start_tag ), $length - strlen( self::$start_tag ) );
|
|
|
|
|
|
|
|
|
|
// Get tooltip text if present.
|
|
|
|
|
self::$tooltip_shortcode = Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_TOOLTIP_EXCERPT_DELIMITER );
|
|
|
|
|
self::$tooltip_shortcode = Settings::instance()->get( Settings::FOOTNOTES_TOOLTIP_EXCERPT_DELIMITER );
|
|
|
|
|
self::$tooltip_shortcode_length = strlen( self::$tooltip_shortcode );
|
|
|
|
|
$tooltip_text_length = strpos( $footnote_text, (string) self::$tooltip_shortcode );
|
|
|
|
|
$has_tooltip_text = (bool) $tooltip_text_length;
|
|
|
|
@ -1384,7 +1416,7 @@ class Parser {
|
|
|
|
|
*
|
|
|
|
|
* TODO: Split into own method.
|
|
|
|
|
*/
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTE_URL_WRAP_ENABLED ) ) ) {
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( FOOTNOTE_URL_WRAP_ENABLED['key'] ) ) ) {
|
|
|
|
|
|
|
|
|
|
$footnote_text = preg_replace(
|
|
|
|
|
'#(?<![-\w\.!~\*\'\(\);]=[\'"])(?<![-\w\.!~\*\'\(\);]=[\'"] )(?<![-\w\.!~\*\'\(\);]=[\'"] )(?<![-\w\.!~\*\'\(\);]=)(?<!/)((ht|f)tps?://[^\\s<]+)#',
|
|
|
|
@ -1400,9 +1432,9 @@ class Parser {
|
|
|
|
|
if ( self::$hard_links_enabled ) {
|
|
|
|
|
|
|
|
|
|
// Get the configurable parts.
|
|
|
|
|
self::$referrer_link_slug = Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERRER_FRAGMENT_ID_SLUG );
|
|
|
|
|
self::$footnote_link_slug = Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTE_FRAGMENT_ID_SLUG );
|
|
|
|
|
self::$link_ids_separator = Includes\Settings::instance()->get( \footnotes\includes\Settings::HARD_LINK_IDS_SEPARATOR );
|
|
|
|
|
self::$referrer_link_slug = Settings::instance()->get( Settings::REFERRER_FRAGMENT_ID_SLUG );
|
|
|
|
|
self::$footnote_link_slug = Settings::instance()->get( Settings::FOOTNOTE_FRAGMENT_ID_SLUG );
|
|
|
|
|
self::$link_ids_separator = Settings::instance()->get( Settings::HARD_LINK_IDS_SEPARATOR );
|
|
|
|
|
|
|
|
|
|
// Streamline ID concatenation.
|
|
|
|
|
self::$post_container_id_compound = self::$link_ids_separator;
|
|
|
|
@ -1415,11 +1447,11 @@ class Parser {
|
|
|
|
|
|
|
|
|
|
// Display the footnote referrers and the tooltips.
|
|
|
|
|
if ( ! $hide_footnotes_text ) {
|
|
|
|
|
$index = Includes\Convert::index( $footnote_index, Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_COUNTER_STYLE ) );
|
|
|
|
|
$index = Convert::index( $footnote_index, Settings::instance()->get( Settings::FOOTNOTES_COUNTER_STYLE ) );
|
|
|
|
|
|
|
|
|
|
// Display only a truncated footnote text if option enabled.
|
|
|
|
|
$enable_excerpt = Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED ) );
|
|
|
|
|
$max_length = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH );
|
|
|
|
|
$enable_excerpt = Convert::to_bool( Settings::instance()->get( Settings::FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED ) );
|
|
|
|
|
$max_length = (int) Settings::instance()->get( Settings::FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH );
|
|
|
|
|
|
|
|
|
|
// Define excerpt text as footnote text by default.
|
|
|
|
|
$excerpt_text = $footnote_text;
|
|
|
|
@ -1445,7 +1477,7 @@ class Parser {
|
|
|
|
|
if ( General::$amp_enabled ) {
|
|
|
|
|
|
|
|
|
|
// If the reference container is also collapsed by default.
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_COLLAPSE ) ) ) {
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( REFERENCE_CONTAINER_COLLAPSE['key'] ) ) ) {
|
|
|
|
|
|
|
|
|
|
$excerpt_text .= ' on="tap:footnote_references_container_';
|
|
|
|
|
$excerpt_text .= self::$post_id . '_' . self::$reference_container_id;
|
|
|
|
@ -1479,7 +1511,7 @@ class Parser {
|
|
|
|
|
$excerpt_text .= '>';
|
|
|
|
|
|
|
|
|
|
// Configurable read-on button label.
|
|
|
|
|
$excerpt_text .= Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_TOOLTIP_READON_LABEL );
|
|
|
|
|
$excerpt_text .= Settings::instance()->get( Settings::FOOTNOTES_TOOLTIP_READON_LABEL );
|
|
|
|
|
|
|
|
|
|
$excerpt_text .= self::$hard_links_enabled ? '</a>' : '</span>';
|
|
|
|
|
}
|
|
|
|
@ -1490,7 +1522,7 @@ class Parser {
|
|
|
|
|
*
|
|
|
|
|
* Define the HTML element to use for the referrers.
|
|
|
|
|
*/
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS ) ) ) {
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( Settings::FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS ) ) ) {
|
|
|
|
|
|
|
|
|
|
$sup_span = 'sup';
|
|
|
|
|
|
|
|
|
@ -1533,7 +1565,7 @@ class Parser {
|
|
|
|
|
$referrer_anchor_element = '';
|
|
|
|
|
|
|
|
|
|
// The link element is set independently as it may be needed for styling.
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::LINK_ELEMENT_ENABLED ) ) ) {
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( LINK_ELEMENT_ENABLED['key'] ) ) ) {
|
|
|
|
|
|
|
|
|
|
self::$link_span = 'a';
|
|
|
|
|
self::$link_open_tag = '<a>';
|
|
|
|
@ -1577,9 +1609,9 @@ class Parser {
|
|
|
|
|
'note_id' => $index,
|
|
|
|
|
'hard-link' => $footnote_link_argument,
|
|
|
|
|
'sup-span' => $sup_span,
|
|
|
|
|
'before' => Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_STYLING_BEFORE ),
|
|
|
|
|
'before' => Settings::instance()->get( Settings::FOOTNOTES_STYLING_BEFORE ),
|
|
|
|
|
'index' => $index,
|
|
|
|
|
'after' => Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_STYLING_AFTER ),
|
|
|
|
|
'after' => Settings::instance()->get( Settings::FOOTNOTES_STYLING_AFTER ),
|
|
|
|
|
'anchor-element' => $referrer_anchor_element,
|
|
|
|
|
'style' => $tooltip_style,
|
|
|
|
|
'text' => $tooltip_content,
|
|
|
|
@ -1593,12 +1625,12 @@ class Parser {
|
|
|
|
|
// If tooltips are enabled but neither AMP nor alternative are.
|
|
|
|
|
if ( General::$tooltips_enabled && ! General::$amp_enabled && ! General::$alternative_tooltips_enabled ) {
|
|
|
|
|
|
|
|
|
|
$offset_y = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y );
|
|
|
|
|
$offset_x = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X );
|
|
|
|
|
$fade_in_delay = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::MOUSE_OVER_BOX_FADE_IN_DELAY );
|
|
|
|
|
$fade_in_duration = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::MOUSE_OVER_BOX_FADE_IN_DURATION );
|
|
|
|
|
$fade_out_delay = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::MOUSE_OVER_BOX_FADE_OUT_DELAY );
|
|
|
|
|
$fade_out_duration = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::MOUSE_OVER_BOX_FADE_OUT_DURATION );
|
|
|
|
|
$offset_y = (int) Settings::instance()->get( Settings::FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y );
|
|
|
|
|
$offset_x = (int) Settings::instance()->get( Settings::FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X );
|
|
|
|
|
$fade_in_delay = (int) Settings::instance()->get( Settings::MOUSE_OVER_BOX_FADE_IN_DELAY );
|
|
|
|
|
$fade_in_duration = (int) Settings::instance()->get( Settings::MOUSE_OVER_BOX_FADE_IN_DURATION );
|
|
|
|
|
$fade_out_delay = (int) Settings::instance()->get( Settings::MOUSE_OVER_BOX_FADE_OUT_DELAY );
|
|
|
|
|
$fade_out_duration = (int) Settings::instance()->get( Settings::MOUSE_OVER_BOX_FADE_OUT_DURATION );
|
|
|
|
|
|
|
|
|
|
// Fill in 'public/partials/tooltip.html'.
|
|
|
|
|
$template_tooltip->replace(
|
|
|
|
@ -1606,7 +1638,7 @@ class Parser {
|
|
|
|
|
'post_id' => self::$post_id,
|
|
|
|
|
'container_id' => self::$reference_container_id,
|
|
|
|
|
'note_id' => $index,
|
|
|
|
|
'position' => Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_POSITION ),
|
|
|
|
|
'position' => Settings::instance()->get( Settings::FOOTNOTES_MOUSE_OVER_BOX_POSITION ),
|
|
|
|
|
'offset-y' => empty( $offset_y ) ? 0 : $offset_y,
|
|
|
|
|
'offset-x' => empty( $offset_x ) ? 0 : $offset_x,
|
|
|
|
|
'fade-in-delay' => empty( $fade_in_delay ) ? 0 : $fade_in_delay,
|
|
|
|
@ -1679,16 +1711,16 @@ class Parser {
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// If the backlink symbol is enabled.
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE ) ) ) {
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE['key'] ) ) ) {
|
|
|
|
|
|
|
|
|
|
// Get html arrow.
|
|
|
|
|
$arrow = Includes\Convert::get_arrow( Includes\Settings::instance()->get( \footnotes\includes\Settings::HYPERLINK_ARROW ) );
|
|
|
|
|
$arrow = Convert::get_arrow( Settings::instance()->get( Settings::HYPERLINK_ARROW ) );
|
|
|
|
|
// Set html arrow to the first one if invalid index defined.
|
|
|
|
|
if ( is_array( $arrow ) ) {
|
|
|
|
|
$arrow = Includes\Convert::get_arrow( 0 );
|
|
|
|
|
$arrow = Convert::get_arrow( 0 );
|
|
|
|
|
}
|
|
|
|
|
// Get user defined arrow.
|
|
|
|
|
$arrow_user_defined = Includes\Settings::instance()->get( \footnotes\includes\Settings::HYPERLINK_ARROW_USER_DEFINED );
|
|
|
|
|
$arrow_user_defined = Settings::instance()->get( Settings::HYPERLINK_ARROW_USER_DEFINED );
|
|
|
|
|
if ( ! empty( $arrow_user_defined ) ) {
|
|
|
|
|
$arrow = $arrow_user_defined;
|
|
|
|
|
}
|
|
|
|
@ -1711,12 +1743,12 @@ class Parser {
|
|
|
|
|
* Initially an appended comma was hard-coded in this algorithm for enumerations.
|
|
|
|
|
* The comma in enumerations is not universally preferred.
|
|
|
|
|
*/
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::BACKLINKS_SEPARATOR_ENABLED ) ) ) {
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( BACKLINKS_SEPARATOR_ENABLED['key'] ) ) ) {
|
|
|
|
|
|
|
|
|
|
if ( empty( $separator ) ) {
|
|
|
|
|
|
|
|
|
|
// If it is not, check which option is on.
|
|
|
|
|
$separator_option = Includes\Settings::instance()->get( \footnotes\includes\Settings::BACKLINKS_SEPARATOR_OPTION );
|
|
|
|
|
$separator_option = Settings::instance()->get( BACKLINKS_SEPARATOR_OPTION['key'] );
|
|
|
|
|
// TODO: replace with `match` (but currently it breaks the Rector
|
|
|
|
|
// downgrade to PHP 7.4.
|
|
|
|
|
// https://github.com/rectorphp/rector/issues/6315
|
|
|
|
@ -1731,7 +1763,7 @@ class Parser {
|
|
|
|
|
$separator = ' –';
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
$separator = Includes\Settings::instance()->get( \footnotes\includes\Settings::BACKLINKS_SEPARATOR_CUSTOM );
|
|
|
|
|
$separator = Settings::instance()->get( BACKLINKS_SEPARATOR_CUSTOM['key'] );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1745,12 +1777,12 @@ class Parser {
|
|
|
|
|
*
|
|
|
|
|
* Initially a dot was appended in the table row template.
|
|
|
|
|
*/
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::BACKLINKS_TERMINATOR_ENABLED ) ) ) {
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( BACKLINKS_TERMINATOR_ENABLED['key'] ) ) ) {
|
|
|
|
|
|
|
|
|
|
if ( empty( $terminator ) ) {
|
|
|
|
|
|
|
|
|
|
// If it is not, check which option is on.
|
|
|
|
|
$terminator_option = Includes\Settings::instance()->get( \footnotes\includes\Settings::BACKLINKS_TERMINATOR_OPTION );
|
|
|
|
|
$terminator_option = Settings::instance()->get( BACKLINKS_TERMINATOR_OPTION['key'] );
|
|
|
|
|
// TODO: replace with `match` (but currently it breaks the Rector
|
|
|
|
|
// downgrade to PHP 7.4.
|
|
|
|
|
// https://github.com/rectorphp/rector/issues/6315
|
|
|
|
@ -1765,7 +1797,7 @@ class Parser {
|
|
|
|
|
$terminator = ':';
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
$terminator = Includes\Settings::instance()->get( \footnotes\includes\Settings::BACKLINKS_TERMINATOR_CUSTOM );
|
|
|
|
|
$terminator = Settings::instance()->get( BACKLINKS_TERMINATOR_CUSTOM['key'] );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1782,7 +1814,7 @@ class Parser {
|
|
|
|
|
* Variable number length and proportional character width require explicit line breaks.
|
|
|
|
|
* Otherwise, an ordinary space character offering a line break opportunity is inserted.
|
|
|
|
|
*/
|
|
|
|
|
$line_break = Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::BACKLINKS_LINE_BREAKS_ENABLED ) ) ? '<br />' : ' ';
|
|
|
|
|
$line_break = Convert::to_bool( Settings::instance()->get( BACKLINKS_LINE_BREAKS_ENABLED['key'] ) ) ? '<br />' : ' ';
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Line breaks for source readability.
|
|
|
|
@ -1796,42 +1828,42 @@ class Parser {
|
|
|
|
|
/*
|
|
|
|
|
* Reference container table row template load.
|
|
|
|
|
*/
|
|
|
|
|
$combine_identical_footnotes = Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::COMBINE_IDENTICAL_FOOTNOTES ) );
|
|
|
|
|
$combine_identical_footnotes = Convert::to_bool( Settings::instance()->get( COMBINE_IDENTICAL_FOOTNOTES['key'] ) );
|
|
|
|
|
|
|
|
|
|
// AMP compatibility requires a full set of AMP compatible table row templates.
|
|
|
|
|
if ( General::$amp_enabled ) {
|
|
|
|
|
// When combining identical footnotes is turned on, another template is needed.
|
|
|
|
|
if ( $combine_identical_footnotes ) {
|
|
|
|
|
// The combining template allows for backlink clusters and supports cell clicking for single notes.
|
|
|
|
|
$template = new Includes\Template( \footnotes\includes\Template::PUBLIC, 'amp-reference-container-body-combi' );
|
|
|
|
|
} elseif ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE ) ) ) {
|
|
|
|
|
$template = new Includes\Template( \footnotes\includes\Template::PUBLIC, 'amp-reference-container-body-3column' );
|
|
|
|
|
} elseif ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH ) ) ) {
|
|
|
|
|
$template = new Includes\Template( \footnotes\includes\Template::PUBLIC, 'amp-reference-container-body-switch' );
|
|
|
|
|
$template = new Template( Template::PUBLIC, 'amp-reference-container-body-combi' );
|
|
|
|
|
} elseif ( Convert::to_bool( Settings::instance()->get( REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE['key'] ) ) ) {
|
|
|
|
|
$template = new Template( Template::PUBLIC, 'amp-reference-container-body-3column' );
|
|
|
|
|
} elseif ( Convert::to_bool( Settings::instance()->get( REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH['key'] ) ) ) {
|
|
|
|
|
$template = new Template( Template::PUBLIC, 'amp-reference-container-body-switch' );
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
// Default is the standard template.
|
|
|
|
|
$template = new Includes\Template( \footnotes\includes\Template::PUBLIC, 'amp-reference-container-body' );
|
|
|
|
|
$template = new Template( Template::PUBLIC, 'amp-reference-container-body' );
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} elseif ( $combine_identical_footnotes ) {
|
|
|
|
|
// The combining template allows for backlink clusters and supports cell clicking for single notes.
|
|
|
|
|
$template = new Includes\Template( \footnotes\includes\Template::PUBLIC, 'reference-container-body-combi' );
|
|
|
|
|
} elseif ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE ) ) ) {
|
|
|
|
|
$template = new Includes\Template( \footnotes\includes\Template::PUBLIC, 'reference-container-body-3column' );
|
|
|
|
|
} elseif ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH ) ) ) {
|
|
|
|
|
$template = new Includes\Template( \footnotes\includes\Template::PUBLIC, 'reference-container-body-switch' );
|
|
|
|
|
$template = new Template( Template::PUBLIC, 'reference-container-body-combi' );
|
|
|
|
|
} elseif ( Convert::to_bool( Settings::instance()->get( REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE['key'] ) ) ) {
|
|
|
|
|
$template = new Template( Template::PUBLIC, 'reference-container-body-3column' );
|
|
|
|
|
} elseif ( Convert::to_bool( Settings::instance()->get( REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH['key'] ) ) ) {
|
|
|
|
|
$template = new Template( Template::PUBLIC, 'reference-container-body-switch' );
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
// Default is the standard template.
|
|
|
|
|
$template = new Includes\Template( \footnotes\includes\Template::PUBLIC, 'reference-container-body' );
|
|
|
|
|
$template = new Template( Template::PUBLIC, 'reference-container-body' );
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Switch backlink symbol and footnote number.
|
|
|
|
|
*/
|
|
|
|
|
$symbol_switch = Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH ) );
|
|
|
|
|
$symbol_switch = Convert::to_bool( Settings::instance()->get( REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH['key'] ) );
|
|
|
|
|
|
|
|
|
|
// Loop through all footnotes found in the page.
|
|
|
|
|
$num_footnotes = count( self::$footnotes );
|
|
|
|
@ -1851,7 +1883,7 @@ class Parser {
|
|
|
|
|
|
|
|
|
|
// Get the footnote index string and.
|
|
|
|
|
// Keep supporting legacy index placeholder.
|
|
|
|
|
$footnote_id = Includes\Convert::index( ( $index + 1 ), Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_COUNTER_STYLE ) );
|
|
|
|
|
$footnote_id = Convert::index( ( $index + 1 ), Settings::instance()->get( Settings::FOOTNOTES_COUNTER_STYLE ) );
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Case of only one backlink per table row.
|
|
|
|
@ -1871,9 +1903,9 @@ class Parser {
|
|
|
|
|
*
|
|
|
|
|
* @since 2.5.4
|
|
|
|
|
*/
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_BACKLINK_TOOLTIP_ENABLE ) ) ) {
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( Settings::FOOTNOTES_BACKLINK_TOOLTIP_ENABLE ) ) ) {
|
|
|
|
|
$use_backbutton_hint = ' title="';
|
|
|
|
|
$use_backbutton_hint .= Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_BACKLINK_TOOLTIP_TEXT );
|
|
|
|
|
$use_backbutton_hint .= Settings::instance()->get( Settings::FOOTNOTES_BACKLINK_TOOLTIP_TEXT );
|
|
|
|
|
$use_backbutton_hint .= '"';
|
|
|
|
|
} else {
|
|
|
|
|
$use_backbutton_hint = '';
|
|
|
|
@ -1996,7 +2028,7 @@ class Parser {
|
|
|
|
|
$flag_combined = true;
|
|
|
|
|
|
|
|
|
|
// Update the footnote ID.
|
|
|
|
|
$footnote_id = Includes\Convert::index( ( $check_index + 1 ), Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_COUNTER_STYLE ) );
|
|
|
|
|
$footnote_id = Convert::index( ( $check_index + 1 ), Settings::instance()->get( Settings::FOOTNOTES_COUNTER_STYLE ) );
|
|
|
|
|
|
|
|
|
|
// Resume composing the backlinks enumeration.
|
|
|
|
|
$footnote_backlinks .= "$separator</";
|
|
|
|
@ -2059,10 +2091,10 @@ class Parser {
|
|
|
|
|
$has_tooltip_text = (bool) $tooltip_text_length;
|
|
|
|
|
if ( $has_tooltip_text ) {
|
|
|
|
|
$not_tooltip_text = substr( $footnote_text, ( $tooltip_text_length + self::$tooltip_shortcode_length ) );
|
|
|
|
|
self::$mirror_tooltip_text = Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_ENABLE ) );
|
|
|
|
|
self::$mirror_tooltip_text = Convert::to_bool( Settings::instance()->get( Settings::FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_ENABLE ) );
|
|
|
|
|
if ( self::$mirror_tooltip_text ) {
|
|
|
|
|
$tooltip_text = substr( $footnote_text, 0, $tooltip_text_length );
|
|
|
|
|
$reference_text_introducer = Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_SEPARATOR );
|
|
|
|
|
$reference_text_introducer = Settings::instance()->get( Settings::FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_SEPARATOR );
|
|
|
|
|
$reference_text = $tooltip_text . $reference_text_introducer . $not_tooltip_text;
|
|
|
|
|
} else {
|
|
|
|
|
$reference_text = $not_tooltip_text;
|
|
|
|
@ -2081,7 +2113,7 @@ class Parser {
|
|
|
|
|
// Used in standard layout W/O COMBINED FOOTNOTES.
|
|
|
|
|
'post_id' => self::$post_id,
|
|
|
|
|
'container_id' => self::$reference_container_id,
|
|
|
|
|
'note_id' => Includes\Convert::index( $first_footnote_index, Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_COUNTER_STYLE ) ),
|
|
|
|
|
'note_id' => Convert::index( $first_footnote_index, Settings::instance()->get( Settings::FOOTNOTES_COUNTER_STYLE ) ),
|
|
|
|
|
'link-start' => self::$link_open_tag,
|
|
|
|
|
'link-end' => self::$link_close_tag,
|
|
|
|
|
'link-span' => self::$link_span,
|
|
|
|
@ -2110,10 +2142,10 @@ class Parser {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Call again for robustness when priority levels don’t match any longer.
|
|
|
|
|
self::$scroll_offset = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_SCROLL_OFFSET );
|
|
|
|
|
self::$scroll_offset = (int) Settings::instance()->get( Settings::FOOTNOTES_SCROLL_OFFSET );
|
|
|
|
|
|
|
|
|
|
// Streamline.
|
|
|
|
|
$collapse_default = Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_COLLAPSE ) );
|
|
|
|
|
$collapse_default = Convert::to_bool( Settings::instance()->get( REFERENCE_CONTAINER_COLLAPSE['key'] ) );
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Reference container label.
|
|
|
|
@ -2122,32 +2154,32 @@ class Parser {
|
|
|
|
|
* In case of empty label that would apply to the left half button character.
|
|
|
|
|
* Hence the point in setting an empty label to U+202F NARROW NO-BREAK SPACE.
|
|
|
|
|
*/
|
|
|
|
|
$reference_container_label = Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_NAME );
|
|
|
|
|
$reference_container_label = Settings::instance()->get( REFERENCE_CONTAINER_NAME['key'] );
|
|
|
|
|
|
|
|
|
|
// Select the reference container template.
|
|
|
|
|
// Whether AMP compatibility mode is enabled.
|
|
|
|
|
if ( General::$amp_enabled ) {
|
|
|
|
|
|
|
|
|
|
// Whether the reference container is collapsed by default.
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_COLLAPSE ) ) ) {
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( REFERENCE_CONTAINER_COLLAPSE['key'] ) ) ) {
|
|
|
|
|
|
|
|
|
|
// Load 'public/partials/amp-reference-container-collapsed.html'.
|
|
|
|
|
$template_container = new Includes\Template( \footnotes\includes\Template::PUBLIC, 'amp-reference-container-collapsed' );
|
|
|
|
|
$template_container = new Template( Template::PUBLIC, 'amp-reference-container-collapsed' );
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
// Load 'public/partials/amp-reference-container.html'.
|
|
|
|
|
$template_container = new Includes\Template( \footnotes\includes\Template::PUBLIC, 'amp-reference-container' );
|
|
|
|
|
$template_container = new Template( Template::PUBLIC, 'amp-reference-container' );
|
|
|
|
|
}
|
|
|
|
|
} elseif ( 'js' === General::$script_mode ) {
|
|
|
|
|
|
|
|
|
|
// Load 'public/partials/js-reference-container.html'.
|
|
|
|
|
$template_container = new Includes\Template( \footnotes\includes\Template::PUBLIC, 'js-reference-container' );
|
|
|
|
|
$template_container = new Template( Template::PUBLIC, 'js-reference-container' );
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
// Load 'public/partials/reference-container.html'.
|
|
|
|
|
$template_container = new Includes\Template( \footnotes\includes\Template::PUBLIC, 'reference-container' );
|
|
|
|
|
$template_container = new Template( Template::PUBLIC, 'reference-container' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$scroll_offset = '';
|
|
|
|
@ -2159,11 +2191,11 @@ class Parser {
|
|
|
|
|
if ( 'jquery' === General::$script_mode ) {
|
|
|
|
|
|
|
|
|
|
$scroll_offset = ( self::$scroll_offset / 100 );
|
|
|
|
|
$scroll_up_duration = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_SCROLL_DURATION );
|
|
|
|
|
$scroll_up_duration = (int) Settings::instance()->get( Settings::FOOTNOTES_SCROLL_DURATION );
|
|
|
|
|
|
|
|
|
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_SCROLL_DURATION_ASYMMETRICITY ) ) ) {
|
|
|
|
|
if ( Convert::to_bool( Settings::instance()->get( Settings::FOOTNOTES_SCROLL_DURATION_ASYMMETRICITY ) ) ) {
|
|
|
|
|
|
|
|
|
|
$scroll_down_duration = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_SCROLL_DOWN_DURATION );
|
|
|
|
|
$scroll_down_duration = (int) Settings::instance()->get( Settings::FOOTNOTES_SCROLL_DOWN_DURATION );
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
@ -2171,8 +2203,8 @@ class Parser {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$scroll_down_delay = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_SCROLL_DOWN_DELAY );
|
|
|
|
|
$scroll_up_delay = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::FOOTNOTES_SCROLL_UP_DELAY );
|
|
|
|
|
$scroll_down_delay = (int) Settings::instance()->get( Settings::FOOTNOTES_SCROLL_DOWN_DELAY );
|
|
|
|
|
$scroll_up_delay = (int) Settings::instance()->get( Settings::FOOTNOTES_SCROLL_UP_DELAY );
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2180,7 +2212,7 @@ class Parser {
|
|
|
|
|
array(
|
|
|
|
|
'post_id' => self::$post_id,
|
|
|
|
|
'container_id' => self::$reference_container_id,
|
|
|
|
|
'element' => Includes\Settings::instance()->get( \footnotes\includes\Settings::REFERENCE_CONTAINER_LABEL_ELEMENT ),
|
|
|
|
|
'element' => Settings::instance()->get( REFERENCE_CONTAINER_LABEL_ELEMENT ),
|
|
|
|
|
'name' => empty( $reference_container_label ) ? ' ' : $reference_container_label,
|
|
|
|
|
'button-style' => $collapse_default ? '' : 'display: none;',
|
|
|
|
|
'style' => $collapse_default ? 'display: none;' : '',
|
|
|
|
|