|
<?php |
|
|
|
namespace AGBlog; |
|
|
|
use RPLib\Feature_Module; |
|
use RPLib\Traits; |
|
|
|
if ( ! defined( '' ) ) { |
|
define( 'BIBBLIO_RECOMMENDATION_KEY', 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' ); |
|
} |
|
|
|
/** |
|
* Class AGBlog\Biblio_Related_Posts |
|
*/ |
|
class Biblio_Related_Posts implements Feature_Module { |
|
|
|
use Traits\Feature_Module; |
|
|
|
static function on_load() { |
|
self::register_feature_module( __CLASS__ ); |
|
self::add_class_action( 'wp_head' ); |
|
} |
|
|
|
/** |
|
*/ |
|
static function _wp_head() { |
|
$html = <<<HTML |
|
<link rel="stylesheet" type="text/css" href="https://cdn.bibblio.org/rcm/3.9/bib-related-content.min.css"> |
|
<script src="https://cdn.bibblio.org/rcm/3.9/bib-related-content.min.js"></script> |
|
HTML; |
|
echo $html; |
|
} |
|
|
|
static function the_related_posts( $args = array() ) { |
|
$recommendation_key = BIBBLIO_RECOMMENDATION_KEY; |
|
|
|
$args = wp_parse_args( $args, array( |
|
Bibblio::LAYOUT => Bibblio::GRID4_LAYOUT, |
|
Bibblio::RATIO => Bibblio::DEFAULT_RATIO, |
|
Bibblio::FONT => Bibblio::ARIAL_FONT, |
|
Bibblio::FONT_SIZE => Bibblio::SIZE_18PX, |
|
Bibblio::SHOW_AUTHOR => true, |
|
Bibblio::SHOW_DATE => true, |
|
Bibblio::REVEAL_ON_HOVER => true, |
|
Bibblio::SHINE_ON_HOVER => true, |
|
Bibblio::SEPARATE_TEXT => false, |
|
Bibblio::SHOW_TITLE_ONLY => false, |
|
Bibblio::USE_PORTRAIT => false, |
|
) ); |
|
|
|
$classes = Bibblio::_get_classes($args); |
|
|
|
$html = <<<HTML |
|
<div class="bib--rcm-init" |
|
data-recommendation-key="{$recommendation_key}" |
|
data-auto-ingestion="true" |
|
data-style-classes="{$classes}"> |
|
</div> |
|
HTML; |
|
echo $html; |
|
} |
|
|
|
} |
|
|
|
class Bibblio { |
|
|
|
private static $_options = array(); |
|
|
|
/** |
|
* @param array $args |
|
* |
|
* @return string |
|
*/ |
|
static function _get_classes($args) { |
|
$bib_classes = array(); |
|
foreach ( $args as $key => $value ) { |
|
if ( is_string( $value ) ) { |
|
$bib_classes[] = "bib--{$value}"; |
|
continue; |
|
} |
|
if ( ! $args[$key] ) { |
|
continue; |
|
} |
|
$bib_classes[] = 'bib--' . self::$_options[$key]; |
|
} |
|
return implode( ' ', $bib_classes ); |
|
} |
|
|
|
static function on_load() { |
|
self::$_options = array( |
|
self::REVEAL_ON_HOVER => 'hover', |
|
self::SHINE_ON_HOVER => 'shine', |
|
self::SHOW_AUTHOR => 'author-show', |
|
self::SHOW_DATE => 'recency-show', |
|
self::REVEAL_ON_HOVER => 'hover', |
|
self::SHINE_ON_HOVER => 'shine', |
|
self::SEPARATE_TEXT => 'split', |
|
self::SHOW_TITLE_ONLY => 'title-only', |
|
self::USE_PORTRAIT => 'portrait', |
|
); |
|
} |
|
|
|
// Available Options |
|
const LAYOUT = 'layout'; |
|
const RATIO = 'ratio'; |
|
const FONT = 'font'; |
|
const FONT_SIZE = 'font_size'; |
|
const SHOW_AUTHOR = 'show_author'; |
|
const SHOW_DATE = 'show_date'; |
|
const REVEAL_ON_HOVER = 'reveal_on_hover'; |
|
const SHINE_ON_HOVER = 'shine_on_hover'; |
|
const SEPARATE_TEXT = 'separate_text'; |
|
const SHOW_TITLE_ONLY = 'title_only'; |
|
const USE_PORTRAIT = 'portrait'; |
|
|
|
// Fonts |
|
const ARIAL_FONT = 'font-arial'; |
|
const ARIAL_BLACK_FONT = 'font-arialblack'; |
|
const COMIC_SANS_FONT = 'font-comic'; |
|
const TAHOMA_FONT = 'font-tahoma'; |
|
const TREBUCHET_FONT = 'font-trebuchet'; |
|
const VERDANA_FONT = 'font-verdana'; |
|
|
|
// Tile Ratios |
|
const DEFAULT_RATIO = 'default'; |
|
const SQUARE_RATIO = 'square'; |
|
const WIDE_RATIO = 'wide'; |
|
|
|
// Font Sizes |
|
const SIZE_14PX = 'size-14'; |
|
const SIZE_16PX = 'size-16'; |
|
const SIZE_18PX = 'size-18'; |
|
const SIZE_20PX = 'size-20'; |
|
const SIZE_22PX = 'size-22'; |
|
|
|
// Layouts |
|
const GRID4_LAYOUT = 'grd-4'; |
|
const GRID6_LAYOUT = 'grd-6'; |
|
|
|
const ROW2_LAYOUT = 'row-2'; |
|
const ROW3_LAYOUT = 'row-3'; |
|
const ROW4_LAYOUT = 'row-4'; |
|
|
|
const SHOWCASE3_LAYOUT = 'box-3'; |
|
const SHOWCASE4_LAYOUT = 'box-4'; |
|
const SHOWCASE5_LAYOUT = 'box-5'; |
|
const SHOWCASE6_LAYOUT = 'box-6'; |
|
|
|
const COLUMN1_LAYOUT = 'col-1'; |
|
const COLUMN2_LAYOUT = 'col-2'; |
|
const COLUMN3_LAYOUT = 'col-3'; |
|
const COLUMN4_LAYOUT = 'col-4'; |
|
const COLUMN5_LAYOUT = 'col-5'; |
|
|
|
} |
|
Bibblio::on_load(); |