// LVGR Main Tables Generator
// wp-admin top-level menu "MAIN TABLES" -> [lvgr_main_table id="N"] shortcode.
// Renders the CLASSIC #tbl_top_casinos look (rank / logo / priority-3..5 columns) -
// pixel-matching the live homepage table (snippet 11743) - with ALL of its CSS
// embedded inline, so it looks right on ANY page/site regardless of whether
// jannah-child/assets/home.css happens to be loaded there.
// Casino data (name/logo/link/rating/offer/pros/review/legal) is the SAME shared
// pool used by "Casino Table" (option lvgr_ct_items) - edit casinos there; this
// admin only picks which casinos go in which table, their order, and what shows.
// Delivered as a single Woody snippet per project rules.
if ( ! defined( 'ABSPATH' ) ) { return; }
if ( ! class_exists( 'LVGR_Main_Tables' ) ) :
class LVGR_Main_Tables {
const TABLES = 'lvgr_mt_tables';
const NEXTID = 'lvgr_mt_next_id';
const NONCE = 'lvgr_mt_save';
public static function init() {
add_shortcode( 'lvgr_main_table', array( __CLASS__, 'shortcode' ) );
add_action( 'admin_menu', array( __CLASS__, 'menu' ) );
add_action( 'admin_post_lvgr_mt_save', array( __CLASS__, 'save' ) );
add_action( 'wp_ajax_lvgr_mt_preview', array( __CLASS__, 'ajax_preview' ) );
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueue_dashicons' ) );
}
// Dashicons (star icons) are core-registered but only auto-loaded in admin;
// enqueue them front-end too so this table is portable to any page/site.
public static function enqueue_dashicons() {
wp_enqueue_style( 'dashicons' );
}
// ---------------------------------------------------------------- DATA
// Shared casino pool owned by the "Casino Table" generator (snippet 21653).
// Read-only here on purpose - casino data is edited in ONE place.
public static function items() {
$items = get_option( 'lvgr_ct_items' );
return is_array( $items ) ? $items : array();
}
public static function tables() {
$t = get_option( self::TABLES );
return is_array( $t ) ? $t : array();
}
public static function next_id() {
$n = (int) get_option( self::NEXTID, 0 );
if ( $n < 1 ) {
$n = 1;
foreach ( array_keys( self::tables() ) as $k ) { $n = max( $n, (int) $k + 1 ); }
}
return $n;
}
public static function bump_next_id( $used ) {
update_option( self::NEXTID, max( self::next_id(), (int) $used + 1 ) );
}
public static function table_defaults() {
return array(
'label' => '',
'selected' => array(),
'cta_text' => 'ΕΓΓΡΑΦΗ',
'review_text' => 'Διάβασε την αξιολόγηση',
'legal' => '21+ | Ρυθμ. ΕΕΕΠ | ΕΟΠΑΕ 1114 | Υπεύθυνο Παιχνίδι',
'ribbon1' => 'Επιλογή Συντακτών',
'ribbon2' => 'Επιλογή Παικτών',
'ribbon3' => 'Καλύτερη Προσφορά* Γνωριμίας',
'max_width' => 900,
'show_rank' => true,
'show_stars' => true,
'show_offer' => true,
'show_pros' => true,
'show_review' => true,
'show_legal' => false,
'show_ribbons' => true,
);
}
public static function table( $id ) {
$tables = self::tables();
$id = (string) (int) $id;
if ( ! isset( $tables[ $id ] ) || ! is_array( $tables[ $id ] ) ) { return null; }
$t = array_merge( self::table_defaults(), $tables[ $id ] );
if ( ! is_array( $t['selected'] ) ) { $t['selected'] = array(); }
$t['id'] = (int) $id;
return $t;
}
// -------------------------------------------------------------- RENDER
protected static function stars_dashicons( $rating ) {
$n = (int) round( (float) $rating );
$n = max( 0, min( 5, $n ) );
$out = '';
for ( $i = 0; $i < $n; $i++ ) { $out .= ''; }
return $out;
}
public static function render( $args = array(), $items_override = null ) {
$def = self::table_defaults();
$s = array_merge( $def, $args );
$items = is_array( $items_override ) ? $items_override : self::items();
$keys = is_array( $s['selected'] ) ? $s['selected'] : array();
$rows = '';
$rank = 0;
foreach ( $keys as $k ) {
$k = trim( $k );
if ( ! isset( $items[ $k ] ) ) { continue; }
$c = $items[ $k ];
$rank++;
$rankhtml = $s['show_rank'] ? '' . $rank . '' : '';
$stars = $s['show_stars'] ? '' : '';
$review = '';
if ( $s['show_review'] && ! empty( $c['review'] ) && trim( (string) $c['review'] ) !== '' ) {
$review = '' . esc_html( $s['review_text'] ) . '';
}
$offer = '';
if ( $s['show_offer'] && ! empty( $c['offer'] ) && trim( (string) $c['offer'] ) !== '' ) {
$offer = '' . esc_html( $c['offer'] ) . '';
}
$pros = '';
if ( $s['show_pros'] && ! empty( $c['pros'] ) && trim( (string) $c['pros'] ) !== '' ) {
$lines = array_slice( array_values( array_filter( array_map( 'trim', preg_split( '#\r\n|\r|\n#', (string) $c['pros'] ) ), function ( $l ) { return $l !== ''; } ) ), 0, 3 );
foreach ( $lines as $line ) {
$pros .= '✔ ' . esc_html( $line ) . '
';
}
}
$legal_row = '';
if ( $s['show_legal'] ) {
$legal_txt = ( isset( $c['legal'] ) && trim( (string) $c['legal'] ) !== '' ) ? $c['legal'] : $s['legal'];
if ( trim( (string) $legal_txt ) !== '' ) {
$legal_row = '' . esc_html( $legal_txt ) . '';
}
}
$mobile_review = '';
if ( $review !== '' || $stars !== '' ) {
$mobile_review = '' . $stars . ' ' . $review . '';
}
$rows .= '
' . $review . '
' : '' ) . '| Όνομα (εσωτ.) | |
|---|---|
| Shortcode | |
| Κείμενο κουμπιού | |
| Κείμενο κριτικής | |
| Νομικό κείμενο (fallback) | |
| Κείμενο κορδελών (Top 3) | ' . '' . '' . ' |
| Μέγιστο πλάτος | px |
| Τι εμφανίζεται | '; foreach ( $tog as $tk => $tl ) { $h .= ''; } $h .= ' |
Τα καζίνο (logo, link, βαθμολογία, προσφορά, pros, νομικό) διαχειρίζονται στο Casino Table. Εδώ διαλέγεις ποια μπαίνουν σε αυτόν τον πίνακα και με τι σειρά.
'; $h .= '| Εμφ. | Σειρά | Όνομα | Logo URL | Affiliate link | Κριτική (link) | Βαθμ. | Κείμενο προσφοράς | Pros | Νομικό κείμενο |
|---|---|---|---|---|---|---|---|---|---|
| '; $h .= ' | '; $h .= ' | ' . esc_html( $c['name'] ) . ' | '; $h .= '' . esc_html( $c['logo'] ) . ' | '; $h .= '' . esc_html( $c['url'] ) . ' | '; $h .= '' . esc_html( $c['review'] ) . ' | '; $h .= '' . esc_html( $c['rating'] ) . ' | '; $h .= '' . esc_html( $c['offer'] ) . ' | '; $h .= '' . esc_html( isset( $c['pros'] ) ? $c['pros'] : '' ) . ' | '; $h .= '' . esc_html( isset( $c['legal'] ) ? $c['legal'] : '' ) . ' | '; $h .= '
Προεπισκόπηση (ζωντανή)
'; $h .= 'Αυτόνομο HTML
'; $h .= ''; $h .= ''; $h .= 'Αποθηκεύτηκε. Οι κρυφές μνήμες καθαρίστηκαν.
Ίδιο σκεπτικό με το Casino Table, αλλά ο πίνακας βγαίνει ακριβώς όπως ο πίνακας της αρχικής σελίδας (ίδιο CSS, ενσωματωμένο — δουλεύει σε οποιαδήποτε σελίδα, χωρίς να εξαρτάται από το home.css). Κάθε πίνακας παίρνει το δικό του shortcode [lvgr_main_table id="N"].