diff --git a/README.md b/README.md index 1c0c63fa..5249ea96 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ help you with this. [See the Wiki for Installation instructions and other documentation.](https://github.com/TenthPres/TouchPoint-WP/wiki) [Sign up here for occasional, non-annoying email updates.](https://my.tenth.org/OnePageReg/396) +If you're a developer looking to leverage this for a church, you're welcome to browse the source code, [but we also have API docs here](https://tenthpres.github.io/TouchPoint-WP/). + ## Features ### Involvement Lists & Small Group Finder - Publish a list and map of involvements, with dynamic filtering based on actual data, such as demographics and location. diff --git a/i18n/TouchPoint-WP-es_ES.po b/i18n/TouchPoint-WP-es_ES.po index 05653e47..b2143829 100644 --- a/i18n/TouchPoint-WP-es_ES.po +++ b/i18n/TouchPoint-WP-es_ES.po @@ -118,13 +118,13 @@ msgstr "Género" #: src/templates/admin/invKoForm.php:179 #: src/TouchPoint-WP/Involvement.php:1445 -#: src/TouchPoint-WP/TouchPointWP.php:1445 +#: src/TouchPoint-WP/TouchPointWP.php:1515 msgid "Weekday" msgstr "Día laborable" #: src/templates/admin/invKoForm.php:183 #: src/TouchPoint-WP/Involvement.php:1471 -#: src/TouchPoint-WP/TouchPointWP.php:1527 +#: src/TouchPoint-WP/TouchPointWP.php:1597 msgid "Time of Day" msgstr "Hora del día" @@ -133,7 +133,7 @@ msgid "Prevailing Marital Status" msgstr "Estado civil prevaleciente" #: src/templates/admin/invKoForm.php:191 -#: src/TouchPoint-WP/TouchPointWP.php:1581 +#: src/TouchPoint-WP/TouchPointWP.php:1651 msgid "Age Group" msgstr "Grupo de edad" @@ -303,38 +303,38 @@ msgstr "Contacta" msgid "RSVP" msgstr "RSVP" -#: src/TouchPoint-WP/TouchPointWP.php:2431 +#: src/TouchPoint-WP/TouchPointWP.php:2501 msgid "Unknown Type" msgstr "Tipo desconocido" -#: src/TouchPoint-WP/TouchPointWP.php:2488 +#: src/TouchPoint-WP/TouchPointWP.php:2558 msgid "Your Searches" msgstr "Tus búsquedas" -#: src/TouchPoint-WP/TouchPointWP.php:2491 +#: src/TouchPoint-WP/TouchPointWP.php:2561 msgid "Public Searches" msgstr "Búsquedas públicas" -#: src/TouchPoint-WP/TouchPointWP.php:2494 +#: src/TouchPoint-WP/TouchPointWP.php:2564 msgid "Status Flags" msgstr "Indicadores de Estado" -#: src/TouchPoint-WP/TouchPointWP.php:2499 -#: src/TouchPoint-WP/TouchPointWP.php:2500 +#: src/TouchPoint-WP/TouchPointWP.php:2569 +#: src/TouchPoint-WP/TouchPointWP.php:2570 msgid "Current Value" msgstr "Valor actual" -#: src/TouchPoint-WP/TouchPointWP.php:2628 -#: src/TouchPoint-WP/TouchPointWP.php:2668 +#: src/TouchPoint-WP/TouchPointWP.php:2698 +#: src/TouchPoint-WP/TouchPointWP.php:2738 msgid "Invalid or incomplete API Settings." msgstr "Configuración de API no válida o incompleta." -#: src/TouchPoint-WP/TouchPointWP.php:2636 -#: src/TouchPoint-WP/TouchPointWP.php:2675 +#: src/TouchPoint-WP/TouchPointWP.php:2706 +#: src/TouchPoint-WP/TouchPointWP.php:2745 msgid "Host appears to be missing from TouchPoint-WP configuration." msgstr "Parece que falta el host en la configuración de TouchPoint-WP." -#: src/TouchPoint-WP/TouchPointWP.php:2795 +#: src/TouchPoint-WP/TouchPointWP.php:2865 msgid "People Query Failed" msgstr "Consulta de registros de personas fallida" @@ -973,7 +973,7 @@ msgstr "Enviar" msgid "Nothing to submit." msgstr "Nada que enviar." -#: src/TouchPoint-WP/TouchPointWP.php:2736 +#: src/TouchPoint-WP/TouchPointWP.php:2806 msgid "The scripts on TouchPoint that interact with this plugin are out-of-date, and an automatic update failed." msgstr "Los scripts en TouchPoint que interactúan con este complemento están desactualizados y falló una actualización automática." @@ -1029,7 +1029,7 @@ msgid "Next" msgstr "Siguiente" #: src/TouchPoint-WP/Involvement.php:1493 -#: src/TouchPoint-WP/TouchPointWP.php:1620 +#: src/TouchPoint-WP/TouchPointWP.php:1690 msgid "Marital Status" msgstr "Estado civil" @@ -1289,17 +1289,17 @@ msgid "Could not locate." msgstr "No se pudo localizar." #: src/TouchPoint-WP/Meeting.php:91 -#: src/TouchPoint-WP/TouchPointWP.php:940 +#: src/TouchPoint-WP/TouchPointWP.php:1010 msgid "Only GET requests are allowed." msgstr "Solo se permiten solicitudes GET." #: src/TouchPoint-WP/Meeting.php:119 -#: src/TouchPoint-WP/TouchPointWP.php:369 +#: src/TouchPoint-WP/TouchPointWP.php:439 msgid "Only POST requests are allowed." msgstr "Solo se permiten solicitudes POST." #: src/TouchPoint-WP/Meeting.php:129 -#: src/TouchPoint-WP/TouchPointWP.php:378 +#: src/TouchPoint-WP/TouchPointWP.php:448 msgid "Invalid data provided." msgstr "Datos proporcionados no válidos." @@ -1312,64 +1312,64 @@ msgstr "Tipo de publicación no válida." msgid "Enable Campuses" msgstr "Habilitar Campus" -#: src/TouchPoint-WP/TouchPointWP.php:1252 +#: src/TouchPoint-WP/TouchPointWP.php:1322 msgid "Classify posts by their general locations." msgstr "clasificar las publicaciones por sus ubicaciones generales." -#: src/TouchPoint-WP/TouchPointWP.php:1305 +#: src/TouchPoint-WP/TouchPointWP.php:1375 msgid "Classify posts by their church campus." msgstr "Clasifique las publicaciones por el campus." #. translators: %s: taxonomy name, singular -#: src/TouchPoint-WP/TouchPointWP.php:1357 +#: src/TouchPoint-WP/TouchPointWP.php:1427 msgid "Classify things by %s." msgstr "Clasifica las cosas por %s." -#: src/TouchPoint-WP/TouchPointWP.php:1444 +#: src/TouchPoint-WP/TouchPointWP.php:1514 msgid "Classify involvements by the day on which they meet." msgstr "Clasificar las participaciones por el día en que se reúnen." -#: src/TouchPoint-WP/TouchPointWP.php:1445 +#: src/TouchPoint-WP/TouchPointWP.php:1515 msgid "Weekdays" msgstr "Días de semana" -#: src/TouchPoint-WP/TouchPointWP.php:1482 +#: src/TouchPoint-WP/TouchPointWP.php:1552 msgid "Classify involvements by tense (present, future, past)" msgstr "Clasificar las implicaciones por tiempo (presente, futuro, pasado)" -#: src/TouchPoint-WP/TouchPointWP.php:1483 +#: src/TouchPoint-WP/TouchPointWP.php:1553 msgid "Tense" msgstr "Tiempo" -#: src/TouchPoint-WP/TouchPointWP.php:1483 +#: src/TouchPoint-WP/TouchPointWP.php:1553 msgid "Tenses" msgstr "Tiempos" -#: src/TouchPoint-WP/TouchPointWP.php:1526 +#: src/TouchPoint-WP/TouchPointWP.php:1596 msgid "Classify involvements by the portion of the day in which they meet." msgstr "Clasifique las participaciones por la parte del día en que se reúnen." -#: src/TouchPoint-WP/TouchPointWP.php:1527 +#: src/TouchPoint-WP/TouchPointWP.php:1597 msgid "Times of Day" msgstr "Tiempos del Día" -#: src/TouchPoint-WP/TouchPointWP.php:1580 +#: src/TouchPoint-WP/TouchPointWP.php:1650 msgid "Classify involvements and users by their age groups." msgstr "Clasifica las implicaciones y los usuarios por sus grupos de edad." -#: src/TouchPoint-WP/TouchPointWP.php:1581 +#: src/TouchPoint-WP/TouchPointWP.php:1651 msgid "Age Groups" msgstr "Grupos de Edad" -#: src/TouchPoint-WP/TouchPointWP.php:1619 +#: src/TouchPoint-WP/TouchPointWP.php:1689 msgid "Classify involvements by whether participants are mostly single or married." msgstr "Clasifique las participaciones según si los participantes son en su mayoría solteros o casados." -#: src/TouchPoint-WP/TouchPointWP.php:1620 +#: src/TouchPoint-WP/TouchPointWP.php:1690 msgid "Marital Statuses" msgstr "Estados Civiles" -#: src/TouchPoint-WP/TouchPointWP.php:1664 +#: src/TouchPoint-WP/TouchPointWP.php:1734 msgid "Classify Partners by category chosen in settings." msgstr "Clasifique a los ministeriales por categoría elegida en la configuración." @@ -1378,32 +1378,32 @@ msgid "Import campuses as a taxonomy. (You probably want to do this if you're mu msgstr "Importar campus como taxonomía. (Probablemente quieras hacer esto si tienes varios campus)." #. translators: %s: taxonomy name, plural -#: src/TouchPoint-WP/TouchPointWP.php:1225 +#: src/TouchPoint-WP/TouchPointWP.php:1295 msgid "Search %s" msgstr "Buscar %s" #. translators: %s: taxonomy name, plural -#: src/TouchPoint-WP/TouchPointWP.php:1227 +#: src/TouchPoint-WP/TouchPointWP.php:1297 msgid "All %s" msgstr "Todos los %s" #. translators: %s: taxonomy name, singular -#: src/TouchPoint-WP/TouchPointWP.php:1229 +#: src/TouchPoint-WP/TouchPointWP.php:1299 msgid "Edit %s" msgstr "Editar %s" #. translators: %s: taxonomy name, singular -#: src/TouchPoint-WP/TouchPointWP.php:1231 +#: src/TouchPoint-WP/TouchPointWP.php:1301 msgid "Update %s" msgstr "Actualizar %s" #. translators: %s: taxonomy name, singular -#: src/TouchPoint-WP/TouchPointWP.php:1233 +#: src/TouchPoint-WP/TouchPointWP.php:1303 msgid "Add New %s" msgstr "Agregar Nuevo %s" #. translators: %s: taxonomy name, singular -#: src/TouchPoint-WP/TouchPointWP.php:1235 +#: src/TouchPoint-WP/TouchPointWP.php:1305 msgid "New %s" msgstr "Nuevo %s" @@ -1420,7 +1420,7 @@ msgstr "Informe de TouchPoint" msgid "Updated on %1$s at %2$s" msgstr "Actualizada %1$s %2$s" -#: src/TouchPoint-WP/TouchPointWP.php:274 +#: src/TouchPoint-WP/TouchPointWP.php:279 msgid "Every 15 minutes" msgstr "Cada 15 minutos" @@ -1474,3 +1474,31 @@ msgstr "Contacto bloqueado por spam." #: src/TouchPoint-WP/Person.php:1541 msgid "Registration Blocked for Spam." msgstr "Registro bloqueado por spam." + +#: src/TouchPoint-WP/TouchPointWP.php:309 +msgctxt "Explanation for the sandwich emoji in \"Made with (emoji) in Philly by Tenth\"" +msgid "Sandwiches (probably cheesesteaks)" +msgstr "Sándwiches (probablemente cheesesteaks)" + +#: src/TouchPoint-WP/TouchPointWP.php:310 +msgctxt "Explanation for the heart emoji in \"Made with (emoji) in Philly by Tenth\"" +msgid "love. obviously." +msgstr "amar. obviamente." + +#: src/TouchPoint-WP/TouchPointWP.php:311 +msgctxt "Explanation for the pretzel emoji in \"Made with (emoji) in Philly by Tenth\"" +msgid "Soft Pretzels" +msgstr "pretzels suaves" + +#: src/TouchPoint-WP/TouchPointWP.php:312 +msgctxt "Explanation for the Donut emoji in \"Made with (emoji) in Philly by Tenth\"" +msgid "Donuts (preferably Federal)" +msgstr "Donuts (preferiblemente de Federal)" + +#: src/TouchPoint-WP/TouchPointWP.php:320 +msgid "Made with %s in Philly by Tenth" +msgstr "Hecho con %s en Filadelfia por Tenth" + +#: src/TouchPoint-WP/TouchPointWP.php:344 +msgid "Documentation" +msgstr "Documentación" diff --git a/i18n/TouchPoint-WP.pot b/i18n/TouchPoint-WP.pot index a748c21d..1384f1bb 100644 --- a/i18n/TouchPoint-WP.pot +++ b/i18n/TouchPoint-WP.pot @@ -9,9 +9,9 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2024-02-07T14:00:10+00:00\n" +"POT-Creation-Date: 2024-02-09T02:18:05+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"X-Generator: WP-CLI 2.8.1\n" +"X-Generator: WP-CLI 2.9.0\n" "X-Domain: TouchPoint-WP\n" #. Plugin Name of the plugin @@ -149,13 +149,13 @@ msgstr "" #: src/templates/admin/invKoForm.php:179 #: src/TouchPoint-WP/Involvement.php:1445 -#: src/TouchPoint-WP/TouchPointWP.php:1445 +#: src/TouchPoint-WP/TouchPointWP.php:1515 msgid "Weekday" msgstr "" #: src/templates/admin/invKoForm.php:183 #: src/TouchPoint-WP/Involvement.php:1471 -#: src/TouchPoint-WP/TouchPointWP.php:1527 +#: src/TouchPoint-WP/TouchPointWP.php:1597 msgid "Time of Day" msgstr "" @@ -164,7 +164,7 @@ msgid "Prevailing Marital Status" msgstr "" #: src/templates/admin/invKoForm.php:191 -#: src/TouchPoint-WP/TouchPointWP.php:1581 +#: src/TouchPoint-WP/TouchPointWP.php:1651 msgid "Age Group" msgstr "" @@ -337,7 +337,7 @@ msgid "Language" msgstr "" #: src/TouchPoint-WP/Involvement.php:1493 -#: src/TouchPoint-WP/TouchPointWP.php:1620 +#: src/TouchPoint-WP/TouchPointWP.php:1690 msgid "Marital Status" msgstr "" @@ -451,17 +451,17 @@ msgid "Contact Prohibited." msgstr "" #: src/TouchPoint-WP/Meeting.php:91 -#: src/TouchPoint-WP/TouchPointWP.php:940 +#: src/TouchPoint-WP/TouchPointWP.php:1010 msgid "Only GET requests are allowed." msgstr "" #: src/TouchPoint-WP/Meeting.php:119 -#: src/TouchPoint-WP/TouchPointWP.php:369 +#: src/TouchPoint-WP/TouchPointWP.php:439 msgid "Only POST requests are allowed." msgstr "" #: src/TouchPoint-WP/Meeting.php:129 -#: src/TouchPoint-WP/TouchPointWP.php:378 +#: src/TouchPoint-WP/TouchPointWP.php:448 msgid "Invalid data provided." msgstr "" @@ -522,137 +522,165 @@ msgstr "" msgid "RSVP" msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:274 +#: src/TouchPoint-WP/TouchPointWP.php:279 msgid "Every 15 minutes" msgstr "" +#: src/TouchPoint-WP/TouchPointWP.php:309 +msgctxt "Explanation for the sandwich emoji in \"Made with (emoji) in Philly by Tenth\"" +msgid "Sandwiches (probably cheesesteaks)" +msgstr "" + +#: src/TouchPoint-WP/TouchPointWP.php:310 +msgctxt "Explanation for the heart emoji in \"Made with (emoji) in Philly by Tenth\"" +msgid "love. obviously." +msgstr "" + +#: src/TouchPoint-WP/TouchPointWP.php:311 +msgctxt "Explanation for the pretzel emoji in \"Made with (emoji) in Philly by Tenth\"" +msgid "Soft Pretzels" +msgstr "" + +#: src/TouchPoint-WP/TouchPointWP.php:312 +msgctxt "Explanation for the Donut emoji in \"Made with (emoji) in Philly by Tenth\"" +msgid "Donuts (preferably Federal)" +msgstr "" + +#: src/TouchPoint-WP/TouchPointWP.php:320 +msgid "Made with %s in Philly by Tenth" +msgstr "" + +#: src/TouchPoint-WP/TouchPointWP.php:344 +msgid "Documentation" +msgstr "" + #. translators: %s: taxonomy name, plural -#: src/TouchPoint-WP/TouchPointWP.php:1225 +#: src/TouchPoint-WP/TouchPointWP.php:1295 msgid "Search %s" msgstr "" #. translators: %s: taxonomy name, plural -#: src/TouchPoint-WP/TouchPointWP.php:1227 +#: src/TouchPoint-WP/TouchPointWP.php:1297 msgid "All %s" msgstr "" #. translators: %s: taxonomy name, singular -#: src/TouchPoint-WP/TouchPointWP.php:1229 +#: src/TouchPoint-WP/TouchPointWP.php:1299 msgid "Edit %s" msgstr "" #. translators: %s: taxonomy name, singular -#: src/TouchPoint-WP/TouchPointWP.php:1231 +#: src/TouchPoint-WP/TouchPointWP.php:1301 msgid "Update %s" msgstr "" #. translators: %s: taxonomy name, singular -#: src/TouchPoint-WP/TouchPointWP.php:1233 +#: src/TouchPoint-WP/TouchPointWP.php:1303 msgid "Add New %s" msgstr "" #. translators: %s: taxonomy name, singular -#: src/TouchPoint-WP/TouchPointWP.php:1235 +#: src/TouchPoint-WP/TouchPointWP.php:1305 msgid "New %s" msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:1252 +#: src/TouchPoint-WP/TouchPointWP.php:1322 msgid "Classify posts by their general locations." msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:1305 +#: src/TouchPoint-WP/TouchPointWP.php:1375 msgid "Classify posts by their church campus." msgstr "" #. translators: %s: taxonomy name, singular -#: src/TouchPoint-WP/TouchPointWP.php:1357 +#: src/TouchPoint-WP/TouchPointWP.php:1427 msgid "Classify things by %s." msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:1444 +#: src/TouchPoint-WP/TouchPointWP.php:1514 msgid "Classify involvements by the day on which they meet." msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:1445 +#: src/TouchPoint-WP/TouchPointWP.php:1515 msgid "Weekdays" msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:1482 +#: src/TouchPoint-WP/TouchPointWP.php:1552 msgid "Classify involvements by tense (present, future, past)" msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:1483 +#: src/TouchPoint-WP/TouchPointWP.php:1553 msgid "Tense" msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:1483 +#: src/TouchPoint-WP/TouchPointWP.php:1553 msgid "Tenses" msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:1526 +#: src/TouchPoint-WP/TouchPointWP.php:1596 msgid "Classify involvements by the portion of the day in which they meet." msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:1527 +#: src/TouchPoint-WP/TouchPointWP.php:1597 msgid "Times of Day" msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:1580 +#: src/TouchPoint-WP/TouchPointWP.php:1650 msgid "Classify involvements and users by their age groups." msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:1581 +#: src/TouchPoint-WP/TouchPointWP.php:1651 msgid "Age Groups" msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:1619 +#: src/TouchPoint-WP/TouchPointWP.php:1689 msgid "Classify involvements by whether participants are mostly single or married." msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:1620 +#: src/TouchPoint-WP/TouchPointWP.php:1690 msgid "Marital Statuses" msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:1664 +#: src/TouchPoint-WP/TouchPointWP.php:1734 msgid "Classify Partners by category chosen in settings." msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:2431 +#: src/TouchPoint-WP/TouchPointWP.php:2501 msgid "Unknown Type" msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:2488 +#: src/TouchPoint-WP/TouchPointWP.php:2558 msgid "Your Searches" msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:2491 +#: src/TouchPoint-WP/TouchPointWP.php:2561 msgid "Public Searches" msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:2494 +#: src/TouchPoint-WP/TouchPointWP.php:2564 msgid "Status Flags" msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:2499 -#: src/TouchPoint-WP/TouchPointWP.php:2500 +#: src/TouchPoint-WP/TouchPointWP.php:2569 +#: src/TouchPoint-WP/TouchPointWP.php:2570 msgid "Current Value" msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:2628 -#: src/TouchPoint-WP/TouchPointWP.php:2668 +#: src/TouchPoint-WP/TouchPointWP.php:2698 +#: src/TouchPoint-WP/TouchPointWP.php:2738 msgid "Invalid or incomplete API Settings." msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:2636 -#: src/TouchPoint-WP/TouchPointWP.php:2675 +#: src/TouchPoint-WP/TouchPointWP.php:2706 +#: src/TouchPoint-WP/TouchPointWP.php:2745 msgid "Host appears to be missing from TouchPoint-WP configuration." msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:2736 +#: src/TouchPoint-WP/TouchPointWP.php:2806 msgid "The scripts on TouchPoint that interact with this plugin are out-of-date, and an automatic update failed." msgstr "" -#: src/TouchPoint-WP/TouchPointWP.php:2795 +#: src/TouchPoint-WP/TouchPointWP.php:2865 msgid "People Query Failed" msgstr "" diff --git a/src/TouchPoint-WP/TouchPointWP.php b/src/TouchPoint-WP/TouchPointWP.php index e2ccd442..420d09c9 100644 --- a/src/TouchPoint-WP/TouchPointWP.php +++ b/src/TouchPoint-WP/TouchPointWP.php @@ -39,6 +39,9 @@ class TouchPointWP * The Token */ public const TOKEN = "TouchPointWP"; + public const SLUG = "touchpoint-wp"; + + public const DOCS_URL = "https://github.com/TenthPres/TouchPoint-WP/wiki"; /** * API Endpoint prefix, and specific endpoints. All must be lower-case. @@ -105,6 +108,7 @@ class TouchPointWP * Typical amount of time in hours for metadata to last (e.g. genders and resCodes). */ public const CACHE_TTL = 8; + public const CACHE_SHORT_TTL = 5/60; /** * Caching @@ -200,6 +204,8 @@ class TouchPointWP public bool $debug; + protected static string $apiVersion = ""; + /** * Indicates that the current request is being processed through the API. * @@ -258,6 +264,8 @@ protected function __construct(string $file = '') add_filter('cron_schedules', [self::class, 'cronAdd15Minutes']); + add_filter('plugin_row_meta', [self::class, 'pluginRowMeta'], 10, 3); + self::scheduleCleanup(); } @@ -277,6 +285,71 @@ public static function cronAdd15Minutes($schedules) return $schedules; } + /** + * Adjust the meta info in the Plugin list with better information. + * + * @param $pluginMeta array The links and stuff that gets joined by pipes. + * @param $pluginFile string Not used here, but points to the root plugin file. + * @param $pluginData array metadata from the plugin header. + * + * @return array + * @noinspection PhpUnusedParameterInspection + */ + public static function pluginRowMeta(array $pluginMeta, string $pluginFile, array $pluginData): array + { + if (isset($pluginData['slug']) && $pluginData['slug'] === self::SLUG) { + + // Remove default View Details link. + foreach ($pluginMeta as $k => $m) { + if (str_contains($m, 'plugin-install.php?tab=plugin-information') || + str_contains($m, 'github.com/jkrrv')) { + unset($pluginMeta[$k]); + } + } + + // Made with X in Philly by Tenth + $madeWiths = [ + "🥪" => _x("Sandwiches (probably cheesesteaks)", "Explanation for the sandwich emoji in \"Made with (emoji) in Philly by Tenth\"", "TouchPoint-WP"), + "❤️" => _x("love. obviously.", "Explanation for the heart emoji in \"Made with (emoji) in Philly by Tenth\"", "TouchPoint-WP"), + "🥨" => _x("Soft Pretzels", "Explanation for the pretzel emoji in \"Made with (emoji) in Philly by Tenth\"", "TouchPoint-WP"), + "🍩" => _x("Donuts (preferably Federal)", "Explanation for the Donut emoji in \"Made with (emoji) in Philly by Tenth\"", "TouchPoint-WP"), + ]; + $madeWithK = array_rand($madeWiths); + /** @noinspection HtmlUnknownTarget */ + $pluginMeta[] = sprintf( + '%s', + "https://www.tenth.org/tech/wp", + sprintf( + __("Made with %s in Philly by Tenth", "TouchPoint-WP"), + sprintf( + '%s', + $madeWiths[$madeWithK], + $madeWithK + ) + ) + ); + + // View details link + // note for i18n: these deliberately don't have the domain in order to use the WordPress defaults. + /** @noinspection HtmlUnknownTarget */ + $pluginMeta[] = sprintf( + '%s', + $pluginData['PluginURI'], + esc_attr(sprintf(__('More information about %s'), $pluginData['Name'])), + __('View details') + ); + + // Documentation link + /** @noinspection HtmlUnknownTarget */ + $pluginMeta[] = sprintf( + '%s', + self::DOCS_URL, + __('Documentation', "TouchPoint-WP") + ); + } + return $pluginMeta; + } + /** * Find and replace links to /pyscript with their more functional brother, /PyScript. That small typo makes bad * things happen. @@ -1933,10 +2006,11 @@ public function host(): ?string * Get the member types currently in use for the named divisions. * * @param string[] $divisions + * @param bool $shortCache Set to true to make it much more likely that the division cache will refresh. * * @return array */ - public function getMemberTypesForDivisions(array $divisions = []): array + public function getMemberTypesForDivisions(array $divisions = [], bool $shortCache = false): array { $divisions = implode(",", $divisions); $divisions = str_replace('div', '', $divisions); @@ -1950,9 +2024,10 @@ public function getMemberTypesForDivisions(array $divisions = []): array $mtObj = (object)[]; } else { $mtObj = json_decode($mtObj); + $cacheTime = $shortCache ? self::CACHE_SHORT_TTL : self::CACHE_TTL; if ( ! isset($mtObj->$divKey)) { $needsUpdate = true; - } else if (strtotime($mtObj->$divKey->_updated) < time() - 3600 * self::CACHE_TTL || ! is_array($mtObj->$divKey->memTypes)) { + } else if (strtotime($mtObj->$divKey->_updated) < time() - 3600 * $cacheTime || ! is_array($mtObj->$divKey->memTypes)) { $needsUpdate = true; } } @@ -1975,18 +2050,20 @@ public function getMemberTypesForDivisions(array $divisions = []): array * * @return string[] */ - public function getDivisionsAsKVArray(): array + public function getDivisionsAsKVArray(bool $shortCache = false): array { - return self::flattenArrayToKV($this->getDivisions(), 'id', 'name', 'div'); + return self::flattenArrayToKV($this->getDivisions($shortCache), 'id', 'name', 'div'); } /** * Returns an array of objects that correspond to divisions. Each Division has a name and an id. The name is both * the Program and Division. * + * @param bool $shortCache Set to true to make it much more likely that the division cache will refresh. + * * @returns object[] */ - public function getDivisions(): array + public function getDivisions(bool $shortCache = false): array { $divsObj = $this->settings->get('meta_divisions'); @@ -1995,7 +2072,8 @@ public function getDivisions(): array $needsUpdate = true; } else { $divsObj = json_decode($divsObj); - if (strtotime($divsObj->_updated) < time() - 3600 * self::CACHE_TTL || ! is_array($divsObj->divs)) { + $cacheTime = $shortCache ? self::CACHE_SHORT_TTL : self::CACHE_TTL; + if (strtotime($divsObj->_updated) < time() - 3600 * $cacheTime || ! is_array($divsObj->divs)) { $needsUpdate = true; } } @@ -2240,9 +2318,11 @@ private function updateGenders() /** * Returns an array of objects that correspond to keywords. Each Keyword has a name and an id. * + * @param bool $shortCache Set to true to make it much more likely that the division cache will refresh. + * * @returns object[] */ - public function getKeywords(): array + public function getKeywords(bool $shortCache = false): array { $kObj = $this->settings->get('meta_keywords'); @@ -2251,7 +2331,8 @@ public function getKeywords(): array $needsUpdate = true; } else { $kObj = json_decode($kObj); - if (strtotime($kObj->_updated) < time() - 3600 * self::CACHE_TTL || ! is_array($kObj->keywords)) { + $cacheTime = $shortCache ? self::CACHE_SHORT_TTL : self::CACHE_TTL; + if (strtotime($kObj->_updated) < time() - 3600 * $cacheTime || ! is_array($kObj->keywords)) { $needsUpdate = true; } } @@ -2709,27 +2790,15 @@ private static function parseApiResponse($response) $respDecoded = json_decode($response['body']); - if ($respDecoded === null) { - throw new TouchPointWP_Exception("Connection Error", 179000); - } - - // Most likely the issue where a module import failed for no apparent reason. - if (property_exists($respDecoded, 'output') && - strpos($respDecoded->output, "Traceback (most recent call last):") === 0) { - throw new TouchPointWP_Exception("Script error: " . $respDecoded->output, 179001); - } - - // Some other script error - if (property_exists($respDecoded, 'output') && $respDecoded->output !== '') { - throw new TouchPointWP_Exception("Script error: " . $respDecoded->output, 179002); + if (property_exists($respDecoded->data, "VERSION")) { + self::$apiVersion = $respDecoded->data->VERSION; } - // Error caught by error handling within Python script - if (property_exists($respDecoded, 'message') && $respDecoded->message !== '') { - throw new TouchPointWP_Exception($respDecoded->message, 179003); + if ($respDecoded === null) { + throw new TouchPointWP_Exception("Connection Error", 179000); } - if ( ! property_exists($respDecoded->data, "VERSION") || $respDecoded->data->VERSION !== self::VERSION) { + if (self::$apiVersion !== self::VERSION && self::$apiVersion !== "") { if (in_array("updateScripts", $respDecoded->data->a ?? [])) { if (class_exists("TouchPointWP_AdminAPI")) { TouchPointWP_AdminAPI::showError( @@ -2744,6 +2813,22 @@ private static function parseApiResponse($response) } } + // Most likely the issue where a module import failed for no apparent reason. + if (property_exists($respDecoded, 'output') && + strpos($respDecoded->output, "Traceback (most recent call last):") === 0) { + throw new TouchPointWP_Exception("Script error: " . $respDecoded->output, 179001, null, $response); + } + + // Some other script error + if (property_exists($respDecoded, 'output') && $respDecoded->output !== '') { + throw new TouchPointWP_Exception("Script error: " . $respDecoded->output, 179002, null, $response); + } + + // Error caught by error handling within Python script + if (property_exists($respDecoded, 'message') && $respDecoded->message !== '') { + throw new TouchPointWP_Exception($respDecoded->message, 179003); + } + return $respDecoded->data; } diff --git a/src/TouchPoint-WP/TouchPointWP_AdminAPI.php b/src/TouchPoint-WP/TouchPointWP_AdminAPI.php index 4f1b7706..d524d692 100644 --- a/src/TouchPoint-WP/TouchPointWP_AdminAPI.php +++ b/src/TouchPoint-WP/TouchPointWP_AdminAPI.php @@ -45,7 +45,7 @@ public static function api(array $uri): bool case "memtypes": header('Content-Type: application/json'); $divs = explode(",", $_GET['divs']); - $mt = TouchPointWP::instance()->getMemberTypesForDivisions($divs); + $mt = TouchPointWP::instance()->getMemberTypesForDivisions($divs, true); echo json_encode($mt); exit; @@ -484,13 +484,21 @@ private static function getTpFilenameForRepoFilename(string $fn): string /** * Display an error when there's something wrong with the TouchPoint connection. + * + * @param string $message + * @param ?mixed $devDetail */ - public static function showError($message) + public static function showError(string $message, $devDetail = null) { add_action('admin_notices', - function () use ($message) { + function () use ($message, $devDetail) { $class = 'notice notice-error'; printf('

TouchPoint-WP: %2$s

', esc_attr($class), $message); + + if ($devDetail !== null) { + /** @noinspection JSCheckFunctionSignatures */ + printf('', json_encode(json_encode($devDetail))); + } }, 10, 2 ); } diff --git a/src/TouchPoint-WP/TouchPointWP_Exception.php b/src/TouchPoint-WP/TouchPointWP_Exception.php index b3fbe51b..aca16672 100644 --- a/src/TouchPoint-WP/TouchPointWP_Exception.php +++ b/src/TouchPoint-WP/TouchPointWP_Exception.php @@ -29,8 +29,9 @@ class TouchPointWP_Exception extends Exception * @param string $message * @param int $code * @param ?Throwable $previous + * @param mixed $devDetail */ - public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null) + public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null, $devDetail = null) { parent::__construct($message, $code, $previous); if (is_admin() && TouchPointWP::currentUserIsAdmin()) { @@ -39,10 +40,10 @@ public function __construct(string $message = "", int $code = 0, ?Throwable $pre $message .= "
" . $this->getFile() . " @ " . $this->getLine() . "
"; $message .= str_replace("\n", "
", $this->getTraceAsString()); } - TouchPointWP_AdminAPI::showError($message); + TouchPointWP_AdminAPI::showError($message, $devDetail); } error_log($message); - self::debugLog($this->getCode(), $this->getFile(), $this->getLine(), $this->getMessage()); + self::debugLog($this->getCode(), $this->getFile(), $this->getLine(), $this->getMessage() . $devDetail); } /** diff --git a/src/TouchPoint-WP/TouchPointWP_Settings.php b/src/TouchPoint-WP/TouchPointWP_Settings.php index 03b22d80..d8a4d0be 100644 --- a/src/TouchPoint-WP/TouchPointWP_Settings.php +++ b/src/TouchPoint-WP/TouchPointWP_Settings.php @@ -139,7 +139,7 @@ public function __construct(TouchPointWP $parent) * @param ?TouchPointWP $parent Object instance. * * @return TouchPointWP_Settings instance - * @since 1.0.0 + * @since 0.0.37 * @static * @see TouchPointWP() */ @@ -768,7 +768,7 @@ private function settingsFields($includeDetail = false): array 'TouchPoint-WP' ), 'type' => 'checkbox_multi', - 'options' => $includeThis ? $this->parent->getDivisionsAsKVArray() : [], + 'options' => $includeThis ? $this->parent->getDivisionsAsKVArray(true) : [], 'default' => [], 'callback' => function($new) { sort($new); return $new; } ], @@ -1597,7 +1597,7 @@ protected function validation_updateScriptsIfChanged($new, string $field) /** * Cloning is forbidden. * - * @since 1.0.0 + * @since 0.0.37 */ public function __clone() { @@ -1611,7 +1611,7 @@ public function __clone() /** * Unserializing instances of this class is forbidden. * - * @since 1.0.0 + * @since 0.0.37 */ public function __wakeup() { diff --git a/src/TouchPoint-WP/Utilities.php b/src/TouchPoint-WP/Utilities.php index c40a2192..c8647342 100644 --- a/src/TouchPoint-WP/Utilities.php +++ b/src/TouchPoint-WP/Utilities.php @@ -418,7 +418,7 @@ public static function insertTerm(string $term, string $taxonomy, $args = []) */ public static function createGuid(): string { - mt_srand(( double )microtime() * 10000); + mt_srand(intval(microtime(true) * 10000) % PHP_INT_MAX); $char = strtoupper(md5(uniqid(rand(), true))); $hyphen = chr(45); // "-" @@ -626,7 +626,7 @@ public static function checkForUpdate(): ?object return (object)[ 'id' => 'touchpoint-wp/touchpoint-wp.php', - 'slug' => 'touchpoint-wp', + 'slug' => TouchPointWP::SLUG, 'plugin' => 'touchpoint-wp/touchpoint-wp.php', 'new_version' => $newV, 'url' => 'https://github.com/TenthPres/TouchPoint-WP/', diff --git a/src/templates/admin/invKoForm.php b/src/templates/admin/invKoForm.php index 81a1d8e4..ab07f234 100644 --- a/src/templates/admin/invKoForm.php +++ b/src/templates/admin/invKoForm.php @@ -3,8 +3,8 @@ /** @var TouchPointWP_Settings $this */ -$divs = json_encode($this->parent->getDivisions()); -$kws = json_encode($this->parent->getKeywords()); +$divs = json_encode($this->parent->getDivisions(true)); +$kws = json_encode($this->parent->getKeywords(true)); /** @noinspection CommaExpressionJS */ echo ""; ?> diff --git a/touchpoint-wp.php b/touchpoint-wp.php index c23ced2c..2a834854 100644 --- a/touchpoint-wp.php +++ b/touchpoint-wp.php @@ -23,6 +23,7 @@ Tested up to: 6.2 Requires PHP: 7.4 Release Asset: true +Domain Path: /i18n */ namespace tp\TouchPointWP;