Changeset 3397379
- Timestamp:
- 11/17/2025 04:05:57 PM (5 months ago)
- Location:
- shortcode-for-mobilizeamerica-api
- Files:
-
- 11 added
- 3 edited
-
tags/1.0.15 (added)
-
tags/1.0.15/css (added)
-
tags/1.0.15/css/shortcode-for-mobilizeamerica-api.css (added)
-
tags/1.0.15/includes (added)
-
tags/1.0.15/includes/elementor-widget.php (added)
-
tags/1.0.15/index.php (added)
-
tags/1.0.15/readme.txt (added)
-
tags/1.0.15/sflwa-notice-handler.php (added)
-
tags/1.0.15/shortcode-for-mobilizeamerica-api.php (added)
-
tags/1.0.15/templates (added)
-
tags/1.0.15/templates/event-templates.php (added)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/sflwa-notice-handler.php (modified) (3 diffs)
-
trunk/shortcode-for-mobilizeamerica-api.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shortcode-for-mobilizeamerica-api/trunk/readme.txt
r3383176 r3397379 4 4 Requires at least: 6.7 5 5 Tested up to: 6.8 6 Stable tag: 1.0.1 46 Stable tag: 1.0.15 7 7 Requires PHP: 8.0 8 8 License: GPLv2 or later … … 90 90 91 91 ## Change Log 92 2025-11-17 v1.0.15 93 * Fixed Single Event Filtering 94 * Updated Using Plugin Notice - Option vs Transient 95 * Cleanup WordPress Coding Standards / Debug Code 96 92 97 2025-10-22 v1.0.14 93 98 * Fixed Sort to be in date order regardless of how it is in the API results -
shortcode-for-mobilizeamerica-api/trunk/sflwa-notice-handler.php
r3340482 r3397379 30 30 * Registers the admin notice if it hasn't been permanently dismissed. 31 31 * 32 * This function checks for a transientset when the user dismisses the notice.33 * If the transient doesn't exist, it means the notice should be displayed.32 * This function checks for a persistent option set when the user dismisses the notice. 33 * If the option is not set or not equal to '1', it means the notice should be displayed. 34 34 */ 35 35 function sflwa_register_admin_notice() { 36 // Construct a unique transientname based on the plugin name.37 // sanitize_title() ensures the name is safe for a transientkey.38 $ transient_name = 'sflwa_notice_dismissed_' . sanitize_title( SFLWA_PLUGIN_NAME );39 40 // Check if the transient exists. If not, add the action to display the notice.41 if ( ! get_transient( $transient_name )) {36 // Construct a unique option name based on the plugin name. 37 // sanitize_title() ensures the name is safe for an option key. 38 $option_name = 'sflwa_notice_dismissed_' . sanitize_title( SFLWA_PLUGIN_NAME ); 39 40 // Check if the permanent option is set to '1'. If not, add the action to display the notice. 41 if ( get_option( $option_name ) !== '1' ) { 42 42 add_action( 'admin_notices', 'sflwa_display_admin_notice' ); 43 43 } … … 273 273 * 274 274 * This function is hooked to 'wp_ajax_sflwa_dismiss_admin_notice'. 275 * It sets a transientto prevent the notice from showing again for this plugin.275 * It sets an option to prevent the notice from showing again for this plugin. 276 276 */ 277 277 add_action( 'wp_ajax_sflwa_dismiss_admin_notice', 'sflwa_dismiss_admin_notice_callback' ); … … 283 283 $plugin_name = isset( $_POST['plugin_name'] ) ? sanitize_text_field( wp_unslash( $_POST['plugin_name'] ) ) : ''; 284 284 285 // Construct the unique transient name. 286 $transient_name = 'sflwa_notice_dismissed_' . sanitize_title( $plugin_name ); 287 288 // Set a transient that never expires (0 seconds lifetime) to permanently hide the notice. 289 set_transient( $transient_name, '1', 0 ); 285 // Construct the unique option name. 286 $option_name = 'sflwa_notice_dismissed_' . sanitize_title( $plugin_name ); 287 288 // Set a permanent option to '1' to permanently hide the notice. 289 // The 'true' flag tells WordPress to autoload the option if it's new (which is good for a quick check). 290 update_option( $option_name, '1', true ); 290 291 291 292 wp_send_json_success( 'Notice dismissed permanently.' ); -
shortcode-for-mobilizeamerica-api/trunk/shortcode-for-mobilizeamerica-api.php
r3382969 r3397379 3 3 * Plugin Name: Shortcode for MobilizeAmerica API 4 4 * Description: Displays events from Mobilize America on your WordPress site. 5 * Version: 1.0.1 45 * Version: 1.0.15 6 6 * Author: South Florida Web Advisors 7 7 * Author URI: https://sflwa.net … … 9 9 * Requires at least: 6.7 10 10 * Tested up to: 6.8 11 * Stable tag: 1.0.1 411 * Stable tag: 1.0.15 12 12 * Text Domain: shortcode-for-mobilizeamerica-api 13 13 */ … … 101 101 } 102 102 103 /**103 /** 104 104 * Get a single event by its ID. 105 105 * … … 108 108 */ 109 109 public function get_event_by_id( $event_id ) { 110 $url = $this->api_url . 'events/' . intval( $event_id ) . '/'; 110 // CORRECTED API ENDPOINT: Must include both organization ID and event ID in the path. 111 // Format: /v1/organizations/:organization_id/events/:event_id 112 $url = $this->api_url . 'organizations/' . intval( $this->organization_id ) . '/events/' . intval( $event_id ); 111 113 112 114 $response = wp_remote_get( $url ); … … 130 132 } 131 133 132 if ( ! is_array( $data ) ) { 134 // FIX: The single event object is wrapped in a 'data' key in the response. 135 if ( ! isset( $data['data'] ) || ! is_array( $data['data'] ) ) { 133 136 return new WP_Error( 'api_error', __( 'Error: Invalid data received from the Mobilize America API.', 'shortcode-for-mobilizeamerica-api' ), $data ); 134 137 } 135 return $data; 138 139 return $data['data']; 136 140 } 137 141 } … … 143 147 * @return string HTML output for the events. 144 148 */ 145 function mobilize_america_events_shortcode( $atts ) {149 function scfmaapi_mobilize_america_events_shortcode( $atts ) { 146 150 $atts = shortcode_atts( 147 151 array( … … 267 271 268 272 } 269 add_shortcode( 'mobilize_america_events', ' mobilize_america_events_shortcode' );273 add_shortcode( 'mobilize_america_events', 'scfmaapi_mobilize_america_events_shortcode' ); 270 274 271 275 // Check if Elementor is installed before hooking into it. … … 281 285 require_once( __DIR__ . '/includes/elementor-widget.php' ); 282 286 283 // Register the widget .284 \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \scfmaapi_Widget_Mobilize_America_Events() );285 } 287 // Register the widget using the correct class name without leading namespace indicator. 288 \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new scfmaapi_Widget_Mobilize_America_Events() ); 289 }
Note: See TracChangeset
for help on using the changeset viewer.