Admin
2 weeks ago
Ajax
2 weeks ago
Asset
2 weeks ago
Context
2 weeks ago
Customizer
2 weeks ago
Debug_Bar
2 weeks ago
Dialog
2 weeks ago
Documentation
2 weeks ago
Duplicate
2 weeks ago
Editor
2 weeks ago
Image
2 weeks ago
JSON_LD
2 weeks ago
Languages
2 weeks ago
Log
2 weeks ago
Meta
2 weeks ago
Models
2 weeks ago
PUE
2 weeks ago
Process
2 weeks ago
Promoter
2 weeks ago
REST
2 weeks ago
Repository
2 weeks ago
Service_Providers
2 weeks ago
Shortcode
2 weeks ago
Support
2 weeks ago
Tabbed_View
2 weeks ago
Tooltip
2 weeks ago
Traits
2 weeks ago
Utils
2 weeks ago
Validator
2 weeks ago
Widget
2 weeks ago
Abstract_Deactivation.php
2 weeks ago
Abstract_Plugin_Register.php
2 weeks ago
App_Shop.php
2 weeks ago
Assets.php
2 weeks ago
Assets_Pipeline.php
2 weeks ago
Autoloader.php
2 weeks ago
Cache.php
2 weeks ago
Cache_Listener.php
2 weeks ago
Changelog_Reader.php
2 weeks ago
Container.php
2 weeks ago
Context.php
2 weeks ago
Cost_Utils.php
2 weeks ago
Credits.php
2 weeks ago
Customizer.php
2 weeks ago
DB_Lock.php
2 weeks ago
Data.php
2 weeks ago
Date_Utils.php
2 weeks ago
Db.php
2 weeks ago
Debug.php
2 weeks ago
Dependency.php
2 weeks ago
Deprecation.php
2 weeks ago
Editor.php
2 weeks ago
Error.php
2 weeks ago
Exception.php
2 weeks ago
Extension.php
2 weeks ago
Extension_Loader.php
2 weeks ago
Feature_Detection.php
2 weeks ago
Field.php
2 weeks ago
Field_Conditional.php
2 weeks ago
Freemius.php
2 weeks ago
Log.php
2 weeks ago
Main.php
2 weeks ago
Notices.php
2 weeks ago
Plugin_Meta_Links.php
2 weeks ago
Plugins.php
2 weeks ago
Plugins_API.php
2 weeks ago
Post_History.php
2 weeks ago
Post_Transient.php
2 weeks ago
Promise.php
2 weeks ago
Repository.php
2 weeks ago
Rewrite.php
2 weeks ago
Settings.php
2 weeks ago
Settings_Manager.php
2 weeks ago
Settings_Tab.php
2 weeks ago
Simple_Table.php
2 weeks ago
Support.php
2 weeks ago
Tabbed_View.php
2 weeks ago
Template.php
2 weeks ago
Template_Factory.php
2 weeks ago
Template_Part_Cache.php
2 weeks ago
Templates.php
2 weeks ago
Terms.php
2 weeks ago
Timezones.php
2 weeks ago
Tracker.php
2 weeks ago
Updater.php
2 weeks ago
Validate.php
2 weeks ago
View_Helpers.php
2 weeks ago
Credits.php
103 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Handles output of The Events Calendar credits |
| 5 | */ |
| 6 | class Tribe__Credits { |
| 7 | |
| 8 | public static function init() { |
| 9 | self::instance()->hook(); |
| 10 | } |
| 11 | |
| 12 | /** |
| 13 | * Hook the functionality of this class into the world |
| 14 | */ |
| 15 | public function hook() { |
| 16 | add_filter( 'tribe_events_after_html', [ $this, 'html_comment_credit' ] ); |
| 17 | add_filter( 'admin_footer_text', [ $this, 'rating_nudge' ], 1, 2 ); |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * Add credit in HTML page source |
| 22 | * |
| 23 | * @return void |
| 24 | **/ |
| 25 | public function html_comment_credit( $after_html ) { |
| 26 | |
| 27 | if ( ! class_exists( 'Tribe__Events__Main' ) ) { |
| 28 | return $after_html; |
| 29 | } |
| 30 | |
| 31 | $html_credit = "\n<!--\n" . esc_html__( 'This calendar is powered by The Events Calendar.', 'tribe-common' ) . "\nhttp://evnt.is/18wn\n-->\n"; |
| 32 | $after_html .= apply_filters( 'tribe_html_credit', $html_credit ); |
| 33 | return $after_html; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Add ratings nudge in admin footer |
| 38 | * |
| 39 | * @param $footer_text |
| 40 | * |
| 41 | * @return string |
| 42 | */ |
| 43 | public function rating_nudge( $footer_text ) { |
| 44 | $admin_helpers = Tribe__Admin__Helpers::instance(); |
| 45 | |
| 46 | add_filter( 'tribe_tickets_post_types', [ $this, 'tmp_return_tribe_events' ], 99 ); |
| 47 | |
| 48 | // only display custom text on Tribe Admin Pages |
| 49 | if ( $admin_helpers->is_screen() || $admin_helpers->is_post_type_screen() ) { |
| 50 | |
| 51 | if ( class_exists( 'Tribe__Events__Main' ) ) { |
| 52 | $review_url = 'https://wordpress.org/support/plugin/the-events-calendar/reviews/?filter=5'; |
| 53 | |
| 54 | $footer_text = sprintf( |
| 55 | esc_html__( 'Rate %1$sThe Events Calendar%2$s %3$s', 'tribe-common' ), |
| 56 | '<strong>', |
| 57 | '</strong>', |
| 58 | '<a href="' . $review_url . '" target="_blank" class="tribe-rating">★★★★★</a>' |
| 59 | ); |
| 60 | } else { |
| 61 | $review_url = 'https://wordpress.org/support/plugin/event-tickets/reviews/?filter=5'; |
| 62 | |
| 63 | $footer_text = sprintf( |
| 64 | esc_html__( 'Rate %1$sEvent Tickets%2$s %3$s', 'tribe-common' ), |
| 65 | '<strong>', |
| 66 | '</strong>', |
| 67 | '<a href="' . $review_url . '" target="_blank" class="tribe-rating">★★★★★</a>' |
| 68 | ); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | remove_filter( 'tribe_tickets_post_types', [ $this, 'tmp_return_tribe_events' ], 99 ); |
| 73 | |
| 74 | return $footer_text; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * temporary function to filter event types down to only tribe-specific types |
| 79 | * |
| 80 | * This will limit the request for ratings to only those post type pages |
| 81 | */ |
| 82 | public function tmp_return_tribe_events( $unused_post_types ) { |
| 83 | return [ 'tribe_events' ]; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * @var $instance |
| 88 | */ |
| 89 | private static $instance = null; |
| 90 | |
| 91 | /** |
| 92 | * @return self |
| 93 | */ |
| 94 | public static function instance() { |
| 95 | if ( empty( self::$instance ) ) { |
| 96 | self::$instance = new self(); |
| 97 | } |
| 98 | |
| 99 | return self::$instance; |
| 100 | } |
| 101 | |
| 102 | } |
| 103 |