' | 'letter' | 'media:'), * url, enabled. Only rows with a URL and enabled=1 are shown to reviewers. * * @return array */ function praisebloom_default_platforms() { return array( array( 'id' => 'google', 'name' => 'Google', 'icon' => 'brand:google', 'url' => '', 'enabled' => 1, ), array( 'id' => 'yelp', 'name' => 'Yelp', 'icon' => 'brand:yelp', 'url' => '', 'enabled' => 1, ), array( 'id' => 'trustpilot', 'name' => 'Trustpilot', 'icon' => 'brand:trustpilot', 'url' => '', 'enabled' => 1, ), array( 'id' => 'facebook', 'name' => 'Facebook', 'icon' => 'brand:facebook', 'url' => '', 'enabled' => 1, ), array( 'id' => 'tripadvisor', 'name' => 'Tripadvisor', 'icon' => 'brand:tripadvisor', 'url' => '', 'enabled' => 1, ), array( 'id' => 'g2', 'name' => 'G2', 'icon' => 'brand:g2', 'url' => '', 'enabled' => 1, ), ); } /** * Default settings, merged with saved options. * * @return array */ function praisebloom_get_settings() { $defaults = array( 'threshold' => 4, 'thankyou_message' => __( 'Thank you for your honest feedback. We read every review carefully and we will do better.', 'praisebloom' ), 'success_message' => __( 'Thank you! Your review has been submitted.', 'praisebloom' ), 'share_prompt' => __( 'Could you also share this review on one of these platforms? It only takes a minute and helps us a lot.', 'praisebloom' ), 'platforms' => praisebloom_default_platforms(), 'share_all' => 1, 'collection_page_id' => 0, 'consent_text' => __( 'I agree that this review may be published on this website.', 'praisebloom' ), 'auto_approve' => 0, 'notify_email' => get_option( 'admin_email' ), 'notify_on_review' => 1, 'accent_color' => '#6C5CE7', 'star_color' => '#F5B301', 'card_radius' => 12, 'default_template' => 'classic', 'schema' => 0, 'delete_data' => 0, ); $saved = get_option( 'praisebloom_settings', array() ); if ( ! is_array( $saved ) ) { $saved = array(); } // Migrate the 1.0.x single-URL fields into the platform list. if ( empty( $saved['platforms'] ) || ! is_array( $saved['platforms'] ) ) { $platforms = praisebloom_default_platforms(); $old_urls = array( 'google' => isset( $saved['google_url'] ) ? $saved['google_url'] : '', 'yelp' => isset( $saved['yelp_url'] ) ? $saved['yelp_url'] : '', 'trustpilot' => isset( $saved['trustpilot_url'] ) ? $saved['trustpilot_url'] : '', ); foreach ( $platforms as $i => $platform ) { if ( ! empty( $old_urls[ $platform['id'] ] ) ) { $platforms[ $i ]['url'] = $old_urls[ $platform['id'] ]; } } $saved['platforms'] = $platforms; } return wp_parse_args( $saved, $defaults ); } /** * The URL of the review collection page (live permalink, so slug changes * always stay in sync). Falls back to the home URL. * * @return string */ function praisebloom_collection_url() { $settings = praisebloom_get_settings(); $page_id = (int) $settings['collection_page_id']; if ( $page_id && 'publish' === get_post_status( $page_id ) ) { $url = get_permalink( $page_id ); if ( $url ) { return $url; } } return home_url( '/' ); } /** * Boot the plugin parts. */ function praisebloom_boot() { PraiseBloom_Form::init(); PraiseBloom_Display::init(); PraiseBloom_Privacy::init(); if ( is_admin() ) { PraiseBloom_Admin::init(); } } add_action( 'plugins_loaded', 'praisebloom_boot' ); /** * Tags and attributes PraiseBloom's own markup helpers produce (stars, avatars, * brand icons, the dashboard chart). Used with wp_kses() at every echo. * * @return array */ function praisebloom_allowed_html() { $common = array( 'class' => true, 'style' => true, 'aria-hidden' => true, 'aria-label' => true, 'role' => true, ); $svg = array( 'fill' => true, 'fill-opacity' => true, 'stroke' => true, 'stroke-width' => true, 'stroke-linecap' => true, 'stroke-linejoin' => true, 'vector-effect' => true, 'd' => true, 'points' => true, 'x1' => true, 'y1' => true, 'x2' => true, 'y2' => true, 'cx' => true, 'cy' => true, 'r' => true, 'x' => true, 'y' => true, 'rx' => true, 'width' => true, 'height' => true, 'viewbox' => true, 'preserveaspectratio' => true, 'focusable' => true, 'xmlns' => true, ); return array( 'span' => $common, 'div' => $common, 'p' => $common, 'br' => array(), 'li' => $common, 'a' => array_merge( $common, array( 'href' => true ) ), 'img' => array_merge( $common, array( 'src' => true, 'srcset' => true, 'sizes' => true, 'alt' => true, 'width' => true, 'height' => true, 'loading' => true, 'decoding' => true, ) ), 'svg' => array_merge( $common, $svg ), 'path' => array_merge( $common, $svg ), 'polyline' => array_merge( $common, $svg ), 'line' => array_merge( $common, $svg ), 'circle' => array_merge( $common, $svg ), 'rect' => array_merge( $common, $svg ), 'g' => array_merge( $common, $svg ), ); } /** * Asset version: plugin version plus the file's modified time, so browsers * pick up changed CSS/JS straight away. * * @param string $relative Path relative to the plugin folder. * @return string */ function praisebloom_asset_ver( $relative ) { $file = PRAISEBLOOM_PATH . $relative; return file_exists( $file ) ? PRAISEBLOOM_VERSION . '.' . filemtime( $file ) : PRAISEBLOOM_VERSION; } /** * Run the (idempotent) install routine after an update: uploading a new * version over an active plugin does not fire the activation hook. */ function praisebloom_maybe_upgrade() { if ( get_option( 'praisebloom_db_version' ) !== PRAISEBLOOM_VERSION ) { PraiseBloom_Activator::activate(); update_option( 'praisebloom_db_version', PRAISEBLOOM_VERSION ); } } add_action( 'admin_init', 'praisebloom_maybe_upgrade' ); /** * "Settings" and "Dashboard" links on the Plugins screen. * * @param array $links Existing action links. * @return array */ function praisebloom_action_links( $links ) { $own = array( '' . esc_html__( 'Settings', 'praisebloom' ) . '', '' . esc_html__( 'Dashboard', 'praisebloom' ) . '', ); return array_merge( $own, $links ); } add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'praisebloom_action_links' );