├── README.md
├── access-monitor
├── am-change-notification-email.php
└── am-editor-access-to-settings.php
├── my-calendar
├── mc-change-grid-date.php
├── mc-change-primary-sort.php
├── mc-close-button.php
├── mc-conflict-filter.php
├── mc-custom-date-format.php
├── mc-custom-image-size.php
├── mc-custom-import.php
├── mc-custom-list-title.php
├── mc-custom-list-titles.php
├── mc-custom-location-fields.php
├── mc-custom-navigation-elements.php
├── mc-custom-template-tag.php
├── mc-custom-template.php
├── mc-disable-datepicker.php
├── mc-event-accessibility.php
├── mc-facebook.php
├── mc-filter-location-access.php
├── mc-hide-subsequent-days.php
├── mc-ical-alarms.php
├── mc-insert-class-in-nav.php
├── mc-limit-after-event-end.php
├── mc-limit-categories.php
├── mc-multiple-sites.php
├── mc-notify.php
├── mc-post-submission-redirect.php
├── mc-propagate-events.php
├── mc-redirect-single-event-view.php
├── mc-remove-adminbar.php
├── mc-rsvp
│ ├── css
│ │ └── rsvp.css
│ ├── js
│ │ └── rsvp.js
│ └── mc-rsvp.php
├── mc-time-format.php
├── mc-twitter.php
├── mc-user-filter.php
├── mcs-refresh-after-submit.php
├── my-calendar-custom-fields.php
├── my-calendar-event-open.php
└── my-week
│ ├── css
│ └── style.css
│ └── my-calendar-week.php
├── my-tickets
├── my-ticket-custom-cart-fields.php
├── my-tickets-add-currency.php
├── my-tickets-add-to-cart-and-checkout.php
├── my-tickets-closure-recipient.php
├── my-tickets-custom-fields.php
├── my-tickets-default-tickets.php
├── my-tickets-filter-text-noargs.php
├── my-tickets-filter-text.php
├── my-tickets-gettext.php
├── my-tickets-limit-purchases.php
├── my-tickets-nimble-builder-compatibility.php
├── my-tickets-report-list.php
├── my-tickets-select-list.php
├── my-tickets-ticket-used-notification.php
└── my-tickets-ultimate-member.php
├── tester.php
├── wp-accessibility
├── custom-fontsize-css.php
├── relocate-toolbar.php
└── remove-toolbar.php
└── wp-to-twitter
├── alternate-tweet-schedule.php
├── always-large-images.php
├── always-upload.php
├── bypass-authors-array.php
├── change-tweet-repeat-limit.php
├── change-utm-medium.php
├── custom-autopost-schedule.php
├── custom-autopost-selection.php
├── custom-field-content.php
├── custom-hashtag-source.php
├── custom-image-directory.php
├── custom-post-filter.php
├── custom-tag-filter.php
├── custom-taxonomy-terms.php
├── customize-post-title.php
├── disable-url-storage.php
├── edited-or-new.php
├── editor-power.php
├── filter-by-author-and-category.php
├── filter-to-author-by-category.php
├── hashtags-in-titles.php
├── multipostthumbnails.php
├── only-tweet-today.php
├── owly-custom-url-shortener.php
├── qtranslate-one-title.php
├── randomized-delay.php
├── readability-custom-url-shortener.php
├── remove-author-by-category.php
├── replace-space-character-in-tags.php
├── restrict-tweets-by-category.php
├── send-random-post-image-to-twitter.php
├── shorten-custom-url.php
├── tags-as-cashtags.php
├── tweet-disqus-comments.php
├── tweet-facebook-comments.php
├── video-importer-bridge.php
├── wpt-remove-metabox.php
└── wpt-tweet-events.php
/README.md:
--------------------------------------------------------------------------------
1 | # Joe Dolson: Plug-in Extensions
2 |
3 | How to use these references:
4 |
5 | Every file in this repository can be installed as a plug-in. When installed, it'll perform some action that modifies or extends the behavior of one of my other plug-ins. The files are grouped into folders that should make it clear which plug-in they pertain to.
6 |
7 | To install:
8 |
9 | * Cut and paste the code into a new file.
10 | * Save that file with whatever name works for you, making whatever changes you need.
11 | * Upload the file into /wp-content/plug-ins/
12 | * Go to WordPress > Plugins and activate it.
13 |
14 | With plug-ins that have premium extensions, such as WP Tweets PRO for WP to Twitter, some extensions only work when the premium add-on is also installed.
15 |
16 | # What makes it a plugin?
17 |
18 | The header block is a section of comments that describe the plugin, and are used to identify that this is a plugin. A header block will look something like this:
19 |
20 | ```
21 | Plugin Name: Name of my Custom Plugin
22 | Plugin URI: http://www.joedolson.com
23 | Description: Describe what this plug-in does
24 | Author: Joe Dolson
25 | Version: 1.0.0
26 | Author URI: http://www.joedolson.com/
27 | ```
28 |
29 | Any PHP file in the `/wp-content/` directory that has this comment will be recognized as a plug-in.
30 |
31 | The plug-ins in this repository are simple examples. They don't have options or settings, they are examples for manipulating the filters and actions in my plugins to customize their functionality. In most cases, you'll need to edit the code to change how they operate.
32 |
33 | Thanks!
34 |
--------------------------------------------------------------------------------
/access-monitor/am-change-notification-email.php:
--------------------------------------------------------------------------------
1 | Close';
20 | /**
21 | * Example using custom image
22 | */
23 | $return = '';
24 |
25 | return $return;
26 | }
--------------------------------------------------------------------------------
/my-calendar/mc-conflict-filter.php:
--------------------------------------------------------------------------------
1 | <\s\p\a\n \c\l\a\s\s="\m\o\b\i\l\e-\o\n\l\y">l\s\p\a\n><\s\t\r\o\n\g>j\s\t\r\o\n\g><\s\p\a\n>M Y\s\p\a\n>\s\p\a\n>';
27 | /**
28 | * Renders as:
29 |
30 | Monday
31 | 9
32 | Nov 2020
33 |
34 | */
35 | }
36 |
37 | return $format;
38 | }
--------------------------------------------------------------------------------
/my-calendar/mc-custom-image-size.php:
--------------------------------------------------------------------------------
1 | occur_begin ) );
25 | $title = "$event_time: $title";
26 |
27 | return $title;
28 | }
--------------------------------------------------------------------------------
/my-calendar/mc-custom-list-titles.php:
--------------------------------------------------------------------------------
1 | ' . $title . '';
22 | }
23 | }
24 |
25 | return ( $output ) ? '
" . sprintf( _n( '%s guest attending', '%s guests attending', $total, 'my-calendar-submissions' ), "$total" ) . '
64 |
65 | 66 | 67 |
RSVP's are closed for this event.
"; 70 | } 71 | 72 | $e['rsvp'] = " 73 | $guest_list 74 | $form"; 75 | 76 | } else { 77 | $e['rsvp'] = "Log in to view the attendee list and to RSVP!"; 78 | } 79 | 80 | return $e; 81 | } 82 | add_filter( 'mc_filter_shortcodes', 'mc_rsvp', 10, 2 ); 83 | 84 | /** 85 | * Update RSVP. 86 | * 87 | * @param int $post_ID Post ID for event. 88 | * @param object $post Post object. 89 | * 90 | * @return string 91 | */ 92 | function mc_update_rsvp( $post_ID, $post ) { 93 | if ( isset( $post['save_rsvp'] ) && $post_ID == $post['event_post'] ) { 94 | if ( ! wp_verify_nonce( $post['_wpnonce'], 'mc-save-rsvp' ) ) { 95 | return; 96 | } 97 | $user = wp_get_current_user(); 98 | $meta = get_post_meta( $post_ID, '_event_rsvp' ); 99 | if ( ( isset( $post['mc_rsvp'] ) && $post['mc_rsvp'] != 'false' ) && !in_array( $user->ID, $meta ) ) { 100 | // add User ID to meta data 101 | add_post_meta( $post_ID, '_event_rsvp', $user->ID ); 102 | add_post_meta( $post_ID, "_event_guests_$user->ID", intval( $post['mc_guests'] ) ); 103 | $return = 'RSVP added'; 104 | 105 | } elseif ( ( ! isset( $post['mc_rsvp'] ) || 'false' === $post['mc_rsvp'] ) && in_array( $user->ID, $meta ) ) { 106 | // remove User ID from meta data 107 | delete_post_meta( $post_ID, '_event_rsvp', $user->ID ); 108 | delete_post_meta( $post_ID, "_event_guests_$user->ID" ); 109 | $return = 'RSVP removed'; 110 | 111 | } elseif ( ( isset( $post['mc_rsvp'] ) && $post['mc_rsvp'] != 'false' ) && in_array( $user->ID, $meta ) ) { 112 | update_post_meta( $post_ID, "_event_guests_$user->ID", intval( $post['mc_guests'] ) ); 113 | $return = 'RSVP updated'; 114 | 115 | } else { 116 | $return = 'No change to RSVP'; 117 | } 118 | 119 | return "$return
"; 120 | } 121 | } 122 | 123 | /** 124 | * Enqueue RSVP scripts. 125 | */ 126 | function mc_rsvp_scripts() { 127 | if ( ! is_admin() ) { 128 | wp_enqueue_style( 'rsvp.styles', plugins_url( 'css/rsvp.css', __FILE__ ) ); 129 | wp_enqueue_script( 'rsvp.update', plugins_url( 'js/rsvp.js', __FILE__ ), array( 'jquery' ), '1.0.0', true ); 130 | wp_localize_script( 131 | 'rsvp.update', 132 | 'mcrsvp', 133 | array( 134 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), 135 | 'security' => wp_create_nonce( 'mc-save-rsvp' ), 136 | 'action' => 'mc_rsvp_ajax' 137 | ) 138 | ); 139 | } 140 | } 141 | add_action( 'wp_enqueue_scripts', 'mc_rsvp_scripts' ); 142 | 143 | /** 144 | * Handle RSVP. 145 | */ 146 | function mc_rsvp_ajax() { 147 | if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'mc_rsvp_ajax' ) { 148 | $data = $_REQUEST['data']; 149 | $post_id = $data['post_id']; 150 | $rsvp = $data['rsvp']; 151 | if ( 'false' === $rsvp ) { 152 | $guests = 0; 153 | } else { 154 | $guests = $data['guests']; 155 | } 156 | $security = $_REQUEST['security']; 157 | $name = wp_get_current_user()->display_name; 158 | 159 | $response = mc_update_rsvp( 160 | $post_id, 161 | array( 162 | 'mc_rsvp' => $rsvp, 163 | 'mc_guests' => $guests, 164 | 'event_post' => $post_id, 165 | '_wpnonce' => $security, 166 | 'save_rsvp' => 'true', 167 | ) 168 | ); 169 | wp_send_json( 170 | array( 171 | 'success' => 1, 172 | 'rsvp' => $rsvp, 173 | 'guests' => $guests, 174 | 'name' => $name, 175 | 'response'=> $response, 176 | ) 177 | ); 178 | } 179 | } 180 | add_action( 'wp_ajax_mc_rsvp_ajax', 'mc_rsvp_ajax' ); 181 | add_action( 'wp_ajax_nopriv_mc_rsvp_ajax', 'mc_rsvp_ajax' ); -------------------------------------------------------------------------------- /my-calendar/mc-time-format.php: -------------------------------------------------------------------------------- 1 | event_title . ' ' . mc_event_link( $event ) ) . "'>Tweet this event"; 14 | return $e; 15 | } -------------------------------------------------------------------------------- /my-calendar/mc-user-filter.php: -------------------------------------------------------------------------------- 1 | var current = window.location.href; setTimeout('window.location = current', 4000);"; 41 | } else { 42 | $reload = ''; 43 | } 44 | 45 | return $return . $reload; 46 | } -------------------------------------------------------------------------------- /my-calendar/my-calendar-custom-fields.php: -------------------------------------------------------------------------------- 1 | event_post; 28 | /* Any custom fields are saved as custom post meta */ 29 | $email = esc_attr( get_post_meta( $post_id, '_mc_event_email', true ) ); 30 | } else { 31 | $email = ''; 32 | } 33 | $form .= ""; 34 | } 35 | 36 | return $form; 37 | } 38 | 39 | /** 40 | * Add fields that are sortable in My Calendar Pro. 41 | * 42 | * @param array $fields Array of fields available in Pro. 43 | * @param boolean $has_data If true, this is an event being edited or corrected. 44 | * @param object $event The event object saved. 45 | * @param string $context 'public' or 'admin', depending on whether this is being rendered in the Pro submissions form or WP Admin. 46 | * 47 | * @since My Calendar Pro 2.0.0 48 | * 49 | * @return array of fields 50 | */ 51 | function mcs_event_email( $fields, $has_data, $event, $context ) { 52 | if ( $has_data ) { 53 | $post_id = $event->event_post; 54 | /* Any custom fields are saved as custom post meta */ 55 | $email = esc_attr( get_post_meta( $post_id, '_mc_event_email', true ) ); 56 | } else { 57 | $email = ''; 58 | } 59 | $form = "
"; 60 | $fields['event_email'] = $form; 61 | 62 | return $fields; 63 | } 64 | add_filter( 'mc_custom_fields', 'mcs_event_email', 10, 5 ); 65 | 66 | 67 | /** 68 | * Save custom fields into post meta. 69 | * 70 | * @param int $post_id ID of the post where event meta is saved. 71 | * @param array $post $_POST array 72 | * @param array $data Checked array of My Calendar data after processing. 73 | * @param integer event_id ID of event in my_calendar custom table. 74 | * 75 | **/ 76 | add_action( 'mc_update_event_post', 'my_event_email_save', 10, 4 ); 77 | function my_event_email_save( $post_id, $post, $data, $event_id ) { 78 | if ( is_email( $post['event_email'] ) ) { 79 | $email = $post['event_email']; 80 | update_post_meta( $post_id, '_mc_event_email', $email ); 81 | } 82 | } 83 | 84 | /** 85 | * Add custom field into template tags array. 86 | * 87 | * @param array $details Array of template tags as $tag => $value 88 | * @param object $event Event object as fetched from database. 89 | * 90 | * @return array $details 91 | **/ 92 | add_filter( 'mc_filter_shortcodes', 'my_event_email_tag', 10, 2 ); 93 | function my_event_email_tag( $details, $event ) { 94 | $post_id = $event->event_post; 95 | /* This content will be accessible as {contact_email} in templates. */ 96 | $details['contact_email'] = get_post_meta( $post_id, '_mc_event_email', true ); 97 | 98 | return $details; 99 | } 100 | -------------------------------------------------------------------------------- /my-calendar/my-calendar-event-open.php: -------------------------------------------------------------------------------- 1 | event_post; 26 | /* Any custom fields are saved as custom post meta */ 27 | $checked = ( get_post_meta( $post_id, '_mc_event_open', true ) == 'true' ) ? 'checked="checked"' : ''; 28 | } else { 29 | $checked = ''; 30 | } 31 | $form .= "
"; 32 | 33 | return $form; 34 | } 35 | 36 | 37 | /** 38 | * Save custom fields into post meta. 39 | * 40 | * @param int $post_id ID of the post where event meta is saved. 41 | * @param array $post $_POST array 42 | * @param array $data Checked array of My Calendar data after processing. 43 | * @param integer event_id ID of event in my_calendar custom table. 44 | * 45 | **/ 46 | add_action( 'mc_update_event_post', 'my_event_email_save', 10, 4 ); 47 | function my_event_email_save( $post_id, $post, $data, $event_id ) { 48 | if ( isset( $post['event_open'] ) ) { 49 | $open = $post['event_open']; 50 | update_post_meta( $post_id, '_mc_event_open', 'true' ); 51 | } else { 52 | delete_post_meta( $post_id, '_mc_event_open' ); 53 | } 54 | } 55 | 56 | /** 57 | * Add custom field into template tags array. 58 | * 59 | * @param array $details Array of template tags as $tag => $value 60 | * @param object $event Event object as fetched from database. 61 | * 62 | * @return array $details 63 | **/ 64 | add_filter( 'mc_filter_shortcodes', 'my_event_email_tag', 10, 2 ); 65 | function my_event_email_tag( $details, $event ) { 66 | $post_id = $event->event_post; 67 | /* This content will be accessible as {contact_email} in templates. */ 68 | $details['event_open'] = ( get_post_meta( $post_id, '_mc_event_open', true ) == 'true' ) ? 'This event is open for registration.' : 'This event is closed for registration.'; 69 | 70 | return $details; 71 | } 72 | 73 | -------------------------------------------------------------------------------- /my-calendar/my-week/css/style.css: -------------------------------------------------------------------------------- 1 | .mc-week { 2 | display: table; 3 | width: 100%; 4 | background-color: #2C3242; 5 | } 6 | 7 | .mc-week .mc-week-list { 8 | display: table-row; 9 | } 10 | 11 | .mc-week .mc-week-list li { 12 | display: table-cell; 13 | text-align: center; 14 | } 15 | 16 | .mc-week .mc-week-list a { 17 | display: block; 18 | padding: .5em; 19 | color: #fff !important; 20 | } 21 | 22 | .mc-week .mc-week-list a:hover, 23 | .mc-week .mc-week-list a:focus { 24 | background: #485169 !important; 25 | } 26 | 27 | 28 | .mc-week .mc-week-list .current-day { 29 | background-color: #485169; 30 | } 31 | 32 | @media (max-width: 768px) { 33 | .mc-week { display: block; } 34 | .mc-week .mc-week-list { display: block; } 35 | .mc-week .mc-week-list li { display: block; } 36 | } -------------------------------------------------------------------------------- /my-calendar/my-week/my-calendar-week.php: -------------------------------------------------------------------------------- 1 | $date[0], 23 | 'month' => $date[1], 24 | 'dy' => $date[2], 25 | 'time' => 'day' 26 | ), $url ); 27 | 28 | for ( $i = 1; $i<8; $i++ ) { 29 | $day = date( 'Y-m-d', strtotime( $today . " + $i day" ) ); 30 | $date = explode( '-', $day ); 31 | $name = date( 'l', strtotime( $day ) ); 32 | $links[$name] = add_query_arg( array( 33 | 'yr'=>$date[0], 34 | 'month' => $date[1], 35 | 'dy' => $date[2], 36 | 'time' => 'day' 37 | ), $url ); 38 | } 39 | 40 | foreach( $links as $day => $link ) { 41 | if ( isset( $_GET['yr'] ) ) { 42 | $current = date( 'l', strtotime( $_GET['month'] . '-' . $_GET['dy'] . '-' . $_GET['yr'] ) ); 43 | } else { 44 | $current = date( 'l', current_time( 'timestamp' ) ); 45 | } 46 | $class = sanitize_title( $day ); 47 | $link = esc_url( $link ); 48 | if ( $day == $current ) { 49 | $class .= ' current-day'; 50 | } 51 | $list .= "
27 | 28 | 29 |
'; 30 | } 31 | 32 | return $output; 33 | } 34 | 35 | add_filter( 'wpt_save_shortener_settings', 'my_save_shortener_settings' ); 36 | function my_save_shortener_settings( $message ) { 37 | if ( isset( $_POST['owly_api_key'] ) ) { 38 | $api_key = sanitize_text_field( $_POST['owly_api_key'] ); 39 | update_option( 'owly_api_key', $api_key ); 40 | $message .= __( 'Your Ow.ly API key has been updated.', 'textdomain' ); 41 | } 42 | 43 | return $message; 44 | } 45 | 46 | add_filter( 'wpt_do_shortening', 'my_do_shortening', 10, 6 ); 47 | function my_do_shortening( $shrink, $shortener, $url, $post_title, $post_ID, $testmode ) { 48 | // ensure that $shrink is always defined as a valid URL 49 | $shrink = $url; 50 | if ( $shortener == 'owly' ) { 51 | // URL is not encoded when passed to this filter 52 | $url = urlencode( $url ); 53 | // jd_remote_json returns an array decoded from the JSON response 54 | $apiKey = get_option( 'owly_api_key' ); 55 | $response = wpt_remote_json( add_query_arg( array( 'apiKey' => $apiKey, 'longUrl'=>$url ), 'http://ow.ly/api/1.1/url/shorten' ) ); 56 | // if the response is a string, then this was an error. 57 | // Ignore error and continue with default plug-in shortening. 58 | if ( !is_string( $response ) ) { 59 | $shrink = $response['results']['shortUrl']; 60 | } 61 | } 62 | 63 | return $shrink; 64 | } -------------------------------------------------------------------------------- /wp-to-twitter/qtranslate-one-title.php: -------------------------------------------------------------------------------- 1 | Readability'; 19 | 20 | return $output; 21 | } 22 | 23 | add_filter( 'wpt_shortener_settings', 'my_shortener_settings', 10, 4 ); 24 | function my_shortener_settings( $output, $selected ) { 25 | if ( $selected == 'readability' ) { 26 | $output .= 'No settings are required for your chosen URL shortener.'; 27 | } 28 | 29 | return $output; 30 | } 31 | 32 | // This is an example of how you would do this if it were required. 33 | /* 34 | add_filter( 'wpt_save_shortener_settings', 'my_save_shortener_settings' ); 35 | function my_save_shortener_settings( $message ) { 36 | if ( isset( $_POST['readability_api_key'] ) ) { 37 | $api_key = sanitize_text_field( $_POST['readability_api_key'] ); 38 | update_option( 'readability_api_key', $api_key ); 39 | $message .= __( 'Your Readability API key has been updated.', 'textdomain' ); 40 | } 41 | 42 | return $message; 43 | } 44 | */ 45 | 46 | add_filter( 'wpt_do_shortening', 'my_do_shortening', 10, 6 ); 47 | function my_do_shortening( $shrink, $shortener, $url, $post_title, $post_ID, $testmode ) { 48 | // ensure that the return value is always defined as a valid URL. 49 | $shrink = $url; 50 | if ( $shortener == 'readability' ) { 51 | // if you needed an API key, you'd fetch it now. 52 | //$apiKey = get_option( 'readability_api_key' ); 53 | $response = wp_remote_post( add_query_arg( 'url', $url, 'http://readability.com/api/shortener/v1/urls' ), array( 'body' => array( 'url' => $url ) ) ); 54 | 55 | if ( !is_wp_error( $response ) ) { 56 | $json = json_decode( $response['body'] ); 57 | $meta = $json->meta; 58 | // Ignore error and continue with default plug-in shortening. 59 | if ( ! empty( $meta ) ) { 60 | $shrink = $meta->rdd_url; 61 | } else { 62 | // this was an error 63 | } 64 | } 65 | } 66 | 67 | return $shrink; 68 | } -------------------------------------------------------------------------------- /wp-to-twitter/remove-author-by-category.php: -------------------------------------------------------------------------------- 1 | 'attachment', 25 | 'numberposts' => 1, 26 | 'orderby' => 'rand', 27 | 'post_parent' => $post_ID, 28 | 'post_status' => 'any', 29 | 'post_mime_type' => 'image', 30 | ); 31 | $posts = get_posts( $args ); 32 | $attachment_ID = $posts[0]->post_ID; 33 | 34 | return $attachment_ID; 35 | } -------------------------------------------------------------------------------- /wp-to-twitter/shorten-custom-url.php: -------------------------------------------------------------------------------- 1 | comment_approved; 18 | $agent = $comment->comment_agent; 19 | if ( $approved == 1 && strpos( $agent, 'Disqus' ) !== false ) { 20 | wpt_set_comment_tweet( $id, 1 ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /wp-to-twitter/tweet-facebook-comments.php: -------------------------------------------------------------------------------- 1 | comment_approved; 18 | $url = $comment->comment_author_url; 19 | if ( $approved == 1 && strpos( $url, '//www.facebook.com' ) !== false ) { 20 | wpt_set_comment_tweet( $id, 1 ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /wp-to-twitter/video-importer-bridge.php: -------------------------------------------------------------------------------- 1 | $value ) { 20 | if ( '1' === $value['post-published-update'] || '1' === $value['post-edited-update'] ) { 21 | remove_meta_box( 'wp2t', $key, 'side' ); 22 | } 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /wp-to-twitter/wpt-tweet-events.php: -------------------------------------------------------------------------------- 1 |