From 544cc6aa9a3e6a8c39055d0b52e4a94769b05c3c Mon Sep 17 00:00:00 2001 From: dcooperdalrymple Date: Thu, 6 Jun 2024 13:07:22 -0500 Subject: [PATCH] Initial build. --- .gitignore | 9 + .vscode/ftp-sync.json | 32 + .vscode/settings.json | 5 + .vscode/tasks.json | 25 + Makefile | 38 + acf-json/schema.json | 2020 ++++++++++++++++++ acf-json/settings.json | 77 + composer.json | 27 + composer.lock | 53 + data/business-type.json | 177 ++ data/organization-type.json | 46 + includes/abstract-plugin-base.php | 239 +++ includes/class-data.php | 261 +++ includes/class-fields.php | 60 + includes/class-output.php | 31 + includes/class-settings.php | 72 + includes/index.php | 2 + includes/integration/class-wordpress-seo.php | 60 + includes/integration/index.php | 2 + includes/trait-singleton.php | 27 + ogre-schema.php | 54 + package.json | 12 + phpcs.xml | 56 + readme.txt | 34 + 24 files changed, 3419 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/ftp-sync.json create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json create mode 100644 Makefile create mode 100644 acf-json/schema.json create mode 100644 acf-json/settings.json create mode 100644 composer.json create mode 100644 composer.lock create mode 100644 data/business-type.json create mode 100644 data/organization-type.json create mode 100644 includes/abstract-plugin-base.php create mode 100644 includes/class-data.php create mode 100644 includes/class-fields.php create mode 100644 includes/class-output.php create mode 100644 includes/class-settings.php create mode 100644 includes/index.php create mode 100644 includes/integration/class-wordpress-seo.php create mode 100644 includes/integration/index.php create mode 100644 includes/trait-singleton.php create mode 100644 ogre-schema.php create mode 100644 package.json create mode 100644 phpcs.xml create mode 100644 readme.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e707243 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*.js +*.map +*.css +ogre-schema.zip +/ogre-schema +composer.phar +/vendor/ +/lib/* +/node_modules/ diff --git a/.vscode/ftp-sync.json b/.vscode/ftp-sync.json new file mode 100644 index 0000000..ab4d07a --- /dev/null +++ b/.vscode/ftp-sync.json @@ -0,0 +1,32 @@ +{ + "remotePath": "./public_html/wp-content/plugins/ogre-schema/", + "host": "dev.ogre.me", + "username": "dev4ogre", + "password": "0M1$6O@J5j?)", + "port": 22, + "secure": true, + "protocol": "sftp", + "uploadOnSave": true, + "passive": false, + "debug": false, + "privateKeyPath": null, + "passphrase": null, + "agent": null, + "allow": [], + "ignore": [ + "\\.vscode", + "\\.git", + "\\.DS_Store", + "\\.gitignore", + "\\Makefile", + "\\ogre-schema.zip" + ], + "generatedFiles": { + "extensionsToInclude": [ + ".js", + ".css", + ".map" + ], + "path": "" + } +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..25773a2 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "java.project.sourcePaths": [ + "" + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..d0a0ae4 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,25 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Package", + "type": "shell", + "command": "make", + "group": "build", + "presentation": { + "reveal": "silent", + "panel": "shared", + } + }, + { + "label": "Compile", + "type": "shell", + "command": "make compile", + "group": "build", + "presentation": { + "reveal": "silent", + "panel": "shared", + } + } + ] +} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d2fd6fd --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +PACKAGE = ogre-schema + +COMPOSER = composer + +all: $(PACKAGE).zip + +$(PACKAGE).zip: clean composer dir copy zip + +composer: + $(COMPOSER) update + +dir: + mkdir ./$(PACKAGE) + +copy: + cp -RT ./acf-json ./$(PACKAGE)/acf-json + cp -RT ./data ./$(PACKAGE)/data + cp -RT ./includes ./$(PACKAGE)/includes + cp -RT ./lang ./$(PACKAGE)/lang + cp -RT ./lib ./$(PACKAGE)/lib + cp -RT ./vendor ./$(PACKAGE)/vendor + cp -f ./* ./$(PACKAGE) || true + + rm ./$(PACKAGE)/composer.json + rm ./$(PACKAGE)/composer.lock + rm ./$(PACKAGE)/Makefile + rm ./$(PACKAGE)/$(PACKAGE).zip || true + +zip: + zip -r ./$(PACKAGE).zip ./$(PACKAGE) + rm -r ./$(PACKAGE) || true + +clean: + rm -r ./$(PACKAGE) || true + rm ./$(PACKAGE).zip || true + for file in $(SASS_SCSS) ; do \ + rm ./assets/css/$${file}.css || true ; \ + done diff --git a/acf-json/schema.json b/acf-json/schema.json new file mode 100644 index 0000000..c37e208 --- /dev/null +++ b/acf-json/schema.json @@ -0,0 +1,2020 @@ +{ + "key": "group_5a05f48ad5e1a", + "title": "Schema", + "fields": [ + { + "key": "field_5a05e7ed18795", + "label": "Select the type of markup you want to create", + "name": "schema_type", + "type": "select", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "choices": { + "none": "None", + "business": "Local Business", + "person": "Person", + "product": "Product", + "event": "Event", + "organization": "Organization", + "website": "Website", + "custom": "Custom" + }, + "default_value": [ + "none" + ], + "allow_null": 0, + "multiple": 0, + "ui": 1, + "ajax": 0, + "return_format": "value", + "placeholder": "" + }, + { + "key": "field_5a05e86418796", + "label": "Business", + "name": "schema_business", + "type": "group", + "instructions": "", + "required": 0, + "conditional_logic": [ + [ + { + "field": "field_5a05e7ed18795", + "operator": "==", + "value": "business" + } + ] + ], + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "layout": "block", + "sub_fields": [ + { + "key": "field_5a05e86e18797", + "label": "Select Local Business Type", + "name": "type", + "type": "select", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "choices": [], + "default_value": [], + "allow_null": 0, + "multiple": 0, + "ui": 1, + "ajax": 0, + "return_format": "value", + "placeholder": "" + }, + { + "key": "field_5a05ed2d00a11", + "label": "Name", + "name": "name", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a05ed5900a12", + "label": "Other Urls", + "name": "urls", + "type": "repeater", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "collapsed": "", + "min": 0, + "max": 0, + "layout": "table", + "button_label": "Add Another Link", + "sub_fields": [ + { + "key": "field_5a05ed7c00a13", + "label": "", + "name": "url", + "type": "url", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "" + } + ] + }, + { + "key": "field_5a05ed9700a14", + "label": "Logo", + "name": "logo", + "type": "image", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "50", + "class": "", + "id": "" + }, + "return_format": "array", + "preview_size": "medium", + "library": "all", + "min_width": "", + "min_height": "", + "min_size": "", + "max_width": "", + "max_height": "", + "max_size": "", + "mime_types": "" + }, + { + "key": "field_5a05eda500a15", + "label": "Image", + "name": "image", + "type": "image", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "50", + "class": "", + "id": "" + }, + "return_format": "array", + "preview_size": "medium", + "library": "all", + "min_width": "", + "min_height": "", + "min_size": "", + "max_width": "", + "max_height": "", + "max_size": "", + "mime_types": "" + }, + { + "key": "field_5a05edc200a16", + "label": "Description", + "name": "description", + "type": "textarea", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "maxlength": "", + "rows": 3, + "new_lines": "" + }, + { + "key": "field_5a09bd97f95e6", + "label": "Address", + "name": "address", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "34", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5e8c85ccbde4e", + "label": "PO Box", + "name": "po_box", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "33", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a09bdc4f95e7", + "label": "City", + "name": "city", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "33", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a09bdd7f95e8", + "label": "State\/Region", + "name": "state", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "34", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a09bde7f95e9", + "label": "Zip\/Postal Code", + "name": "postal_code", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "33", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a09be0bf95ea", + "label": "Country", + "name": "country", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "33", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a05eddc00a17", + "label": "Location", + "name": "location", + "type": "google_map", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "center_lat": "", + "center_lng": "", + "zoom": "", + "height": 200 + }, + { + "key": "field_5a05ee3e00a19", + "label": "Select Business Hours", + "name": "hours", + "type": "repeater", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "collapsed": "", + "min": 0, + "max": 0, + "layout": "table", + "button_label": "Add Hours", + "sub_fields": [ + { + "key": "field_5a05ee6100a1a", + "label": "Day", + "name": "day", + "type": "select", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "choices": { + "Mo": "Monday", + "Tu": "Tuesday", + "We": "Wednesday", + "Th": "Thursday", + "Fr": "Friday", + "Sa": "Saturday", + "Su": "Sunday" + }, + "default_value": [], + "allow_null": 0, + "multiple": 0, + "ui": 0, + "ajax": 0, + "return_format": "value", + "placeholder": "" + }, + { + "key": "field_5a05ee8f00a1b", + "label": "Open", + "name": "open", + "type": "time_picker", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "display_format": "g:i a", + "return_format": "H:i" + }, + { + "key": "field_5a05eeb200a1c", + "label": "Close", + "name": "close", + "type": "time_picker", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "display_format": "g:i a", + "return_format": "H:i" + } + ] + }, + { + "key": "field_5d9631f6e5730", + "label": "Price Range", + "name": "price", + "type": "range", + "instructions": "Outputs $ to $$$$$. If set to 0, price range will not be included in schema.", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "100", + "class": "", + "id": "" + }, + "default_value": 0, + "min": 0, + "max": 5, + "step": "", + "prepend": "", + "append": "" + }, + { + "key": "field_5a05eed700a1d", + "label": "Telephone", + "name": "phone", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "34", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "+1 (XXX) XXX-XXXX", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a05ef0100a1e", + "label": "Contact Type", + "name": "contact_type", + "type": "select", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "33", + "class": "", + "id": "" + }, + "choices": { + "none": "None", + "customer service": "Customer Service", + "technical support": "Technical Support", + "billing support": "Billing Support", + "bill payment": "Bill Payment", + "sales": "Sales", + "reservations": "Reservations", + "credit card support": "Credit Card Support", + "emergency": "Emergency", + "baggage tracking": "Baggage Tracking", + "roadside assistance": "Roadside Assistance", + "package tracking": "Package Tracking" + }, + "default_value": [ + "none" + ], + "allow_null": 0, + "multiple": 0, + "ui": 0, + "ajax": 0, + "return_format": "value", + "placeholder": "" + }, + { + "key": "field_5a09e5033aac4", + "label": "Contact Option", + "name": "contact_option", + "type": "select", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "33", + "class": "", + "id": "" + }, + "choices": { + "none": "None", + "TollFree": "Toll Free", + "HearingImpairedSupported": "Hearing Impaired Supported" + }, + "default_value": [], + "allow_null": 0, + "multiple": 0, + "ui": 0, + "ajax": 0, + "return_format": "value", + "placeholder": "" + } + ] + }, + { + "key": "field_5a05ef3300a1f", + "label": "Person", + "name": "schema_person", + "type": "group", + "instructions": "", + "required": 0, + "conditional_logic": [ + [ + { + "field": "field_5a05e7ed18795", + "operator": "==", + "value": "person" + } + ] + ], + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "layout": "block", + "sub_fields": [ + { + "key": "field_5a05ef4700a20", + "label": "Name", + "name": "name", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a05ef4f00a21", + "label": "Job Title", + "name": "job_title", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a09be2df14bd", + "label": "Address", + "name": "address", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "34", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a09be3df14be", + "label": "PO Box", + "name": "po_box", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "33", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a09be56f14bf", + "label": "City", + "name": "city", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "33", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a09be60f14c0", + "label": "State\/Region", + "name": "state", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "34", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a09be6af14c1", + "label": "Zip\/Postal Code", + "name": "postal_code", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "33", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a09be7af14c2", + "label": "Country", + "name": "country", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "33", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a05efa800a25", + "label": "Email", + "name": "email", + "type": "email", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "" + }, + { + "key": "field_5a05efb100a26", + "label": "Telephone", + "name": "phone", + "type": "text", + "instructions": "Please include country code, +1 for USA.", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "+1 (XXX) XXX-XXXX", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a05efeb00a27", + "label": "Birth Date", + "name": "birth_date", + "type": "date_picker", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "display_format": "d\/m\/Y", + "return_format": "YY-MM-DD", + "first_day": 1 + } + ] + }, + { + "key": "field_5a05f08c00a28", + "label": "Product", + "name": "schema_product", + "type": "group", + "instructions": "", + "required": 0, + "conditional_logic": [ + [ + { + "field": "field_5a05e7ed18795", + "operator": "==", + "value": "product" + } + ] + ], + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "layout": "block", + "sub_fields": [ + { + "key": "field_5a05f0ae00a29", + "label": "Brand", + "name": "brand", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a05f0b600a2a", + "label": "Name", + "name": "name", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a05f0c100a2b", + "label": "Image", + "name": "image", + "type": "image", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "return_format": "array", + "preview_size": "thumbnail", + "library": "all", + "min_width": "", + "min_height": "", + "min_size": "", + "max_width": "", + "max_height": "", + "max_size": "", + "mime_types": "" + }, + { + "key": "field_5a05f0cc00a2c", + "label": "Description", + "name": "description", + "type": "textarea", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "maxlength": "", + "rows": 3, + "new_lines": "" + }, + { + "key": "field_5a05f0d700a2d", + "label": "Rating", + "name": "rating_value", + "type": "range", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "50", + "class": "", + "id": "" + }, + "default_value": "", + "min": 0, + "max": 5, + "step": "0.1", + "prepend": "", + "append": "" + }, + { + "key": "field_5a05f10a00a2e", + "label": "Based on how many reviews?", + "name": "review_count", + "type": "number", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "50", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "min": 1, + "max": "", + "step": 1 + } + ] + }, + { + "key": "field_5a05f14a00a2f", + "label": "Event", + "name": "schema_event", + "type": "group", + "instructions": "", + "required": 0, + "conditional_logic": [ + [ + { + "field": "field_5a05e7ed18795", + "operator": "==", + "value": "event" + } + ] + ], + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "layout": "block", + "sub_fields": [ + { + "key": "field_5a09ef316f180", + "label": "Event Type", + "name": "type", + "type": "select", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "choices": { + "Event": "Event", + "BusinessEvent": "Business Event", + "ChildrensEvent": "Childrens Event", + "ComedyEvent": "Comedy Event", + "DanceEvent": "Dance Event", + "EducationEvent": "Educational Event", + "Festival": "Festival", + "FoodEvent": "Food Event", + "LiteraryEvent": "Literary Event", + "MusicEvent": "Music Event", + "SaleEvent": "Sales Event", + "SocialEvent": "Social Event", + "SportsEvent": "Sports Event", + "TheaterEvent": "Theater Event", + "UserInteraction": "User Interaction", + "VisualArtsEvent": "Visual Arts Event" + }, + "default_value": [], + "allow_null": 0, + "multiple": 0, + "ui": 0, + "ajax": 0, + "return_format": "value", + "placeholder": "" + }, + { + "key": "field_5a05f16000a30", + "label": "Name", + "name": "name", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a05f16500a31", + "label": "Description", + "name": "description", + "type": "textarea", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "maxlength": "", + "rows": 3, + "new_lines": "" + }, + { + "key": "field_5a05f17300a32", + "label": "Start Date", + "name": "date_start", + "type": "date_time_picker", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "50", + "class": "", + "id": "" + }, + "display_format": "d\/m\/Y g:i a", + "return_format": "m\/d\/Y h:i a", + "first_day": 1 + }, + { + "key": "field_5a05f23900a33", + "label": "End Date", + "name": "date_end", + "type": "date_time_picker", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "50", + "class": "", + "id": "" + }, + "display_format": "d\/m\/Y g:i a", + "return_format": "m\/d\/Y h:i a", + "first_day": 1 + }, + { + "key": "field_5a05f26200a34", + "label": "Venue Name", + "name": "venue_name", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a05f26800a35", + "label": "Venue Url", + "name": "venue_url", + "type": "url", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "" + }, + { + "key": "field_5a09bea5badc5", + "label": "Address", + "name": "address", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "50", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a09bebabadc6", + "label": "City", + "name": "city", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "50", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a09bec2badc7", + "label": "State\/Region", + "name": "state", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "34", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a09becfbadc8", + "label": "Zip\/Postal Code", + "name": "postal_code", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "33", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a09bedcbadc9", + "label": "Country", + "name": "country", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "33", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a05f26f00a36", + "label": "Location", + "name": "location", + "type": "google_map", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "center_lat": "", + "center_lng": "", + "zoom": "", + "height": "" + }, + { + "key": "field_5a05f27e00a37", + "label": "Offer Description", + "name": "offer_description", + "type": "textarea", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "maxlength": "", + "rows": 3, + "new_lines": "" + }, + { + "key": "field_5a05f28c00a38", + "label": "Offer Url", + "name": "offer_url", + "type": "url", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "" + }, + { + "key": "field_5a05f29500a39", + "label": "Offer Price", + "name": "offer_price", + "type": "number", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "min": "0.00", + "max": "", + "step": "0.01" + } + ] + }, + { + "key": "field_5a05f2c400a3a", + "label": "Organization", + "name": "schema_organization", + "type": "group", + "instructions": "", + "required": 0, + "conditional_logic": [ + [ + { + "field": "field_5a05e7ed18795", + "operator": "==", + "value": "organization" + } + ] + ], + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "layout": "block", + "sub_fields": [ + { + "key": "field_5a09f1e06f181", + "label": "Select Organization Type", + "name": "type", + "type": "select", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "choices": [], + "default_value": [], + "allow_null": 0, + "multiple": 0, + "ui": 1, + "return_format": "value", + "ajax": 0, + "placeholder": "" + }, + { + "key": "field_5a05f2d500a3b", + "label": "Name", + "name": "name", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a05f2da00a3c", + "label": "Other Urls", + "name": "urls", + "type": "repeater", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "collapsed": "", + "min": 0, + "max": 0, + "layout": "table", + "button_label": "Add Another Link", + "sub_fields": [ + { + "key": "field_5a05f31000a3d", + "label": "Url", + "name": "url", + "type": "url", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "" + } + ] + }, + { + "key": "field_5a05f31c00a3e", + "label": "Logo", + "name": "logo", + "type": "image", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "50", + "class": "", + "id": "" + }, + "return_format": "array", + "preview_size": "thumbnail", + "library": "all", + "min_width": "", + "min_height": "", + "min_size": "", + "max_width": "", + "max_height": "", + "max_size": "", + "mime_types": "" + }, + { + "key": "field_5a05f32800a3f", + "label": "Image", + "name": "image", + "type": "image", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "50", + "class": "", + "id": "" + }, + "return_format": "array", + "preview_size": "thumbnail", + "library": "all", + "min_width": "", + "min_height": "", + "min_size": "", + "max_width": "", + "max_height": "", + "max_size": "", + "mime_types": "" + }, + { + "key": "field_5a05f34300a40", + "label": "Description", + "name": "description", + "type": "textarea", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "maxlength": "", + "rows": 3, + "new_lines": "" + }, + { + "key": "field_5a09c02156983", + "label": "Address", + "name": "address", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "34", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a09c03256984", + "label": "PO Box", + "name": "po_box", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "33", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a09c03d56985", + "label": "City", + "name": "city", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "33", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a09c04356986", + "label": "State\/Region", + "name": "state", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "34", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a09c05156987", + "label": "Zip\/Postal Code", + "name": "postal_code", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "33", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a09c06d56988", + "label": "Country", + "name": "country", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "33", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a05f34f00a41", + "label": "Location", + "name": "location", + "type": "google_map", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "center_lat": "", + "center_lng": "", + "zoom": "", + "height": "" + }, + { + "key": "field_5e8c8537bde49", + "label": "Select Business Hours", + "name": "hours", + "type": "repeater", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "collapsed": "", + "min": 0, + "max": 0, + "layout": "table", + "button_label": "Add Hours", + "sub_fields": [ + { + "key": "field_5e8c8551bde4a", + "label": "Day", + "name": "day", + "type": "select", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "choices": { + "Mo": "Monday", + "Tu": "Tuesday", + "We": "Wednesday", + "Th": "Thursday", + "Fr": "Friday", + "Sa": "Saturday", + "Su": "Sunday" + }, + "default_value": [], + "allow_null": 0, + "multiple": 0, + "ui": 0, + "return_format": "value", + "ajax": 0, + "placeholder": "" + }, + { + "key": "field_5e8c8562bde4b", + "label": "Open", + "name": "open", + "type": "time_picker", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "display_format": "g:i a", + "return_format": "H:i" + }, + { + "key": "field_5e8c8573bde4c", + "label": "Close", + "name": "close", + "type": "time_picker", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "display_format": "g:i a", + "return_format": "H:i" + } + ] + }, + { + "key": "field_5e8c8476bde46", + "label": "Telephone", + "name": "phone", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "34", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "+1 (XXX) XXX-XXXX", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5e8c8489bde47", + "label": "Contact Type", + "name": "contact_type", + "type": "select", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "33", + "class": "", + "id": "" + }, + "choices": { + "none": "None", + "customer service": "Customer Service", + "technical support": "Technical Support", + "billing support": "Billing Support", + "bill payment": "Bill Payment", + "sales": "Sales", + "reservations": "Reservations", + "credit card support": "Credit Card Support", + "emergency": "Emergency", + "baggage tracking": "Baggage Tracking", + "roadside assistance": "Roadside Assistance", + "package tracking": "Package Tracking" + }, + "default_value": [ + "none" + ], + "allow_null": 0, + "multiple": 0, + "ui": 0, + "return_format": "value", + "ajax": 0, + "placeholder": "" + }, + { + "key": "field_5e8c84a6bde48", + "label": "Contact Option", + "name": "contact_option", + "type": "select", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "33", + "class": "", + "id": "" + }, + "choices": { + "none": "None", + "TollFree": "Toll Free", + "HearingImpairedSupported": "Hearing Impaired Supported" + }, + "default_value": [], + "allow_null": 0, + "multiple": 0, + "ui": 0, + "return_format": "value", + "ajax": 0, + "placeholder": "" + } + ] + }, + { + "key": "field_5a05f4e8d2888", + "label": "Website", + "name": "schema_website", + "type": "group", + "instructions": "", + "required": 0, + "conditional_logic": [ + [ + { + "field": "field_5a05e7ed18795", + "operator": "==", + "value": "website" + } + ] + ], + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "layout": "block", + "sub_fields": [ + { + "key": "field_5a05f4f2d2889", + "label": "Name", + "name": "name", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5a05f4f8d288a", + "label": "Alternate Name", + "name": "name_alternate", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + } + ] + }, + { + "key": "field_5c62dd67eac74", + "label": "Custom", + "name": "schema_custom", + "type": "group", + "instructions": "", + "required": 0, + "conditional_logic": [ + [ + { + "field": "field_5a05e7ed18795", + "operator": "==", + "value": "custom" + } + ] + ], + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "layout": "block", + "sub_fields": [ + { + "key": "field_5c62dd8eeac75", + "label": "", + "name": "fields", + "type": "repeater", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "collapsed": "", + "min": 0, + "max": 0, + "layout": "block", + "button_label": "Add Field", + "sub_fields": [ + { + "key": "field_5c62de7ceac76", + "label": "Key", + "name": "key", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "25", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5c62de8feac77", + "label": "Value", + "name": "value", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": [ + [ + { + "field": "field_5c62de92eac78", + "operator": "==", + "value": "" + } + ] + ], + "wrapper": { + "width": "65", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5c62debdeac79", + "label": "Array", + "name": "array", + "type": "repeater", + "instructions": "", + "required": 0, + "conditional_logic": [ + [ + { + "field": "field_5c62de92eac78", + "operator": "==", + "value": "array" + } + ] + ], + "wrapper": { + "width": "65", + "class": "", + "id": "" + }, + "collapsed": "", + "min": 0, + "max": 0, + "layout": "table", + "button_label": "Add Item", + "sub_fields": [ + { + "key": "field_5c62dec5eac7a", + "label": "", + "name": "value", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "100", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + } + ] + }, + { + "key": "field_5c62dee8eac7b", + "label": "Object", + "name": "object", + "type": "repeater", + "instructions": "", + "required": 0, + "conditional_logic": [ + [ + { + "field": "field_5c62de92eac78", + "operator": "==", + "value": "object" + } + ] + ], + "wrapper": { + "width": "65", + "class": "", + "id": "" + }, + "collapsed": "", + "min": 0, + "max": 0, + "layout": "table", + "button_label": "Add Item", + "sub_fields": [ + { + "key": "field_5c62def3eac7c", + "label": "Key", + "name": "key", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "25", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + }, + { + "key": "field_5c62df26eac7d", + "label": "Value", + "name": "value", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "75", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + } + ] + }, + { + "key": "field_5c62de92eac78", + "label": "", + "name": "type", + "type": "button_group", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "10", + "class": "", + "id": "" + }, + "choices": { + "array": "Array", + "object": "Object" + }, + "allow_null": 1, + "default_value": "", + "layout": "horizontal", + "return_format": "value" + } + ] + } + ] + } + ], + "location": [ + [ + { + "param": "options_page", + "operator": "==", + "value": "ogreschema" + } + ] + ], + "menu_order": 100, + "position": "normal", + "style": "seamless", + "label_placement": "top", + "instruction_placement": "label", + "hide_on_screen": "", + "active": true, + "description": "" +} diff --git a/acf-json/settings.json b/acf-json/settings.json new file mode 100644 index 0000000..414486e --- /dev/null +++ b/acf-json/settings.json @@ -0,0 +1,77 @@ +{ + "key": "group_5c62eb4b1bf8b", + "title": "Post Settings", + "fields": [ + { + "key": "field_5c62eb66b90a5", + "label": "Enable schema on individual posts?", + "name": "schema_setting_post_enable", + "type": "true_false", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "message": "", + "default_value": 0, + "ui": 1, + "ui_on_text": "", + "ui_off_text": "" + }, + { + "key": "field_5c62eb9db90a6", + "label": "Enabled Post Types", + "name": "schema_setting_post_type", + "type": "checkbox", + "instructions": "", + "required": 0, + "conditional_logic": [ + [ + { + "field": "field_5c62eb66b90a5", + "operator": "==", + "value": "1" + } + ] + ], + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "choices": { + "post": "Posts", + "page": "Pages", + "attachment": "Media" + }, + "allow_custom": 0, + "default_value": [ + "page" + ], + "layout": "vertical", + "toggle": 0, + "return_format": "value", + "save_custom": 0 + } + ], + "location": [ + [ + { + "param": "options_page", + "operator": "==", + "value": "ogreschema" + } + ] + ], + "menu_order": 10, + "position": "normal", + "style": "seamless", + "label_placement": "top", + "instruction_placement": "label", + "hide_on_screen": "", + "active": true, + "description": "" +} diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..6c62b50 --- /dev/null +++ b/composer.json @@ -0,0 +1,27 @@ +{ + "name": "cleverogre/ogreschema", + "description": "Output schema site-wide for your website.", + "repositories": [ + { + "type": "composer", + "url": "https://wpackagist.org", + "only": [ + "wpackagist-plugin/*", + "wpackagist-theme/*" + ] + } + ], + "require": { + "magicoli/wp-package-updater-lib": "^0.1.9" + }, + "config": { + "allow-plugins": { + "composer/installers": true + } + }, + "scripts": { + "post-update-cmd": [ + "php vendor/magicoli/wp-package-updater-lib/install.php" + ] + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..3a4e037 --- /dev/null +++ b/composer.lock @@ -0,0 +1,53 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "62a6a51cbea614094e050f847730af97", + "packages": [ + { + "name": "magicoli/wp-package-updater-lib", + "version": "v0.1.10", + "source": { + "type": "git", + "url": "https://github.com/magicoli/wp-package-updater-lib.git", + "reference": "e822132741c08d054fb97f249b1143c220f30e6f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/magicoli/wp-package-updater-lib/zipball/e822132741c08d054fb97f249b1143c220f30e6f", + "reference": "e822132741c08d054fb97f249b1143c220f30e6f", + "shasum": "" + }, + "require-dev": { + "froger-me/wp-plugin-update-server": "*" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "AGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Magiiic" + } + ], + "description": "Composer package for wp-package-updater library.", + "support": { + "issues": "https://github.com/magicoli/wp-package-updater-lib/issues", + "source": "https://github.com/magicoli/wp-package-updater-lib/tree/v0.1.10" + }, + "time": "2023-06-09T12:42:28+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.6.0" +} diff --git a/data/business-type.json b/data/business-type.json new file mode 100644 index 0000000..5940b6e --- /dev/null +++ b/data/business-type.json @@ -0,0 +1,177 @@ +{ + "None": "None", + "AnimalShelter": "Animal Shelter", + "ArchiveOrganization": "Archive Organization", + "Automotive Business": { + "AutomotiveBusiness": "Automotive Business", + "AutoBodyShop": "Auto Body Shop", + "AutoDealer": "Auto Dealer", + "AutoPartsStore": "Auto Parts Store", + "AutoRental": "Auto Rental", + "AutoRepair": "Auto Repair", + "AutoWash": "Auto Wash", + "GasStation": "Gas Station", + "MotorcycleDealer": "Motorcycle Dealer", + "MotorcycleRepair": "Motorcycle Repair" + }, + "ChildCare": "Child Care", + "Dentist": "Dentist", + "DryCleaningOrLaundry": "Dry Cleaning Or Laundry", + "Emergency Service": { + "EmergencyService": "Emergency Service", + "FireStation": "FireStation", + "Hospital": "Hospital", + "PoliceStation": "PoliceStation" + }, + "EmploymentAgency": "Employment Agency", + "Entertainment Business": { + "EntertainmentBusiness": "Entertainment Business", + "AdultEntertainment": "Adult Entertainment", + "AmusementPark": "Amusement Park", + "ArtGallery": "Art Gallery", + "Casino": "Casino", + "ComedyClub": "Comedy Club", + "MovieTheater": "Movie Theater", + "NightClub": "Night Club" + }, + "Financial Service": { + "FinancialService": "Financial Service", + "AccountingService": "Accounting Service", + "AutomatedTeller": "Automated Teller", + "BankOrCreditUnion": "Bank or Credit Union", + "InsuranceAgency": "Insurance Agency" + }, + "Food Establishment": { + "FoodEstablishment": "Food Establishment", + "Bakery": "Bakery", + "BarOrPub": "Bar or Pub", + "Brewery": "Brewery", + "CafeOrCoffeeShop": "Cafe or Coffee Shop", + "Distillery": "Distillery", + "FastFoodRestaurant": "Fast Food Restaurant", + "IceCreamShop": "Ice Cream Shop", + "Restaurant": "Restaurant", + "Winery": "Winery" + }, + "Government Office": { + "GovernmentOffice": "Government Office", + "PostOffice": "Post Office" + }, + "Health and Beauty Business": { + "HealthAndBeautyBusiness": "Health And Beauty Business", + "BeautySalon": "Beauty Salon", + "DaySpa": "Day Spa", + "HairSalon": "Hair Salon", + "HealthClub": "Health Club", + "NailSalon": "Nail Salon", + "TattooParlor": "Tattoo Parlor" + }, + "Home and Construction Business": { + "HomeAndConstructionBusiness": "Home And Construction Business", + "Electrician": "Electrician", + "GeneralContractor": "General Contractor", + "HVACBusiness": "HVAC Business", + "HousePainter": "House Painter", + "Locksmith": "Locksmith", + "MovingCompany": "Moving Company", + "Plumber": "Plumber", + "RoofingContractor": "Roofing Contractor" + }, + "InternetCafe": "Internet Cafe", + "Legal Service": { + "LegalService": "Legal Services", + "Attorney": "Attorney", + "Notary": "Notary" + }, + "Library": "Library", + "Lodging Business": { + "LodgingBusiness": "Lodging Business", + "BedAndBreakfast": "Bed and Breakfast", + "Campground": "Campground", + "Hostel": "Hostel", + "Hotel": "Hotel", + "Motel": "Motel", + "Resort": "Resort" + }, + "Medical Business": { + "MedicalBusiness": "Medical Business", + "CommunityHealth": "Community Health", + "Dentist": "Dentist", + "Dermatology": "Dermatology", + "DietNutrition": "Diet Nutrition", + "Emergency": "Emergency", + "Geriatric": "Geriatric", + "Gynecologic": "Gynecologic", + "MedicalClinic": "Medical Clinic", + "Midwifery": "Midwifery", + "Nursing": "Nursing", + "Obstetric": "Obstetric", + "Oncologic": "Oncologic", + "Optician": "Optician", + "Optometric": "Optometric", + "Otolaryngologic": "Otolaryngologic", + "Pediatric": "Pediatric", + "Pharmacy": "Pharmacy", + "Physician": "Physician", + "Physiotherapy": "Physiotherapy", + "PlasticSurgery": "Plastic Surgery", + "Podiatric": "Podiatric", + "PrimaryCare": "Primary Care", + "Psychiatric": "Psychiatric", + "PublicHealth": "Public Health" + }, + "ProfessionalService": "Professional Service", + "RadioStation": "Radio Station", + "RealEstateAgent": "Real Estate Agent", + "RecyclingCenter": "Recycling Center", + "SelfStorage": "Self Storage", + "ShoppingCenter": "Shopping Center", + "Sports Activity Location": { + "SportsActivityLocation": "Sports Activity Location", + "BowlingAlley": "Bowling Alley", + "ExerciseGym": "Exercise Gym", + "GolfCourse": "Golf Course", + "HealthClub": "Health Club", + "PublicSwimmingPool": "Public Swimming Pool", + "SkiResort": "Ski Resort", + "SportsClub": "Sports Club", + "StadiumOrArena": "Stadium or Arena", + "TennisComplex": "Tennis Complex" + }, + "Store": { + "Store": "Store", + "AutoPartsStore": "Auto Parts Store", + "BikeStore": "Bike Store", + "BookStore": "Book Store", + "ClothingStore": "Clothing Store", + "ComputerStore": "Computer Store", + "ConvenienceStore": "Convenience Store", + "DepartmentStore": "Department Store", + "ElectronicsStore": "Electronics Store", + "Florist": "Florist", + "FurnitureStore": "Furniture Store", + "GardenStore": "Garden Store", + "GroceryStore": "Grocery Store", + "HardwareStore": "Hardware Store", + "HobbyShop": "Hobby Shop", + "HomeGoodsStore": "Home Goods Store", + "JewelryStore": "Jewelry Store", + "LiquorStore": "Liquor Store", + "MensClothingStore": "Mens Clothing Store", + "MobilePhoneStore": "Mobile Phone Store", + "MovieRentalStore": "Movie Rental Store", + "MusicStore": "Music Store", + "OfficeEquipmentStore": "Office Equipment Store", + "OutletStore": "Outlet Store", + "PawnShop": "Pawn Shop", + "PetStore": "Pet Store", + "ShoeStore": "Shoe Store", + "SportingGoodsStore": "Sporting Goods Store", + "TireShop": "Tire Shop", + "ToyStore": "Toy Store", + "WholesaleStore": "Wholesale Store" + }, + "TelevisionStation": "Television Station", + "TouristInformationCenter": "Tourist Information Center", + "TravelAgency": "Travel Agency" +} diff --git a/data/organization-type.json b/data/organization-type.json new file mode 100644 index 0000000..6c8bb10 --- /dev/null +++ b/data/organization-type.json @@ -0,0 +1,46 @@ +{ + "Airline": "Airline", + "Consortium": "Consortium", + "Corporation": "Corporation", + "Educational Organization": { + "EducationalOrganization": "Educational Organization", + "CollegeOrUniversity": "College or University", + "ElementarySchool": "Elementary School", + "HighSchool": "High School", + "MiddleSchool": "Middle School", + "Preschool": "Preschool", + "School": "School" + }, + "FundingScheme": "Funding Scheme", + "GovernmentOrganization": "Government Organization", + "LibrarySystem": "Library System", + "LocalBusiness": "Local Business", + "Medical Organization": { + "MedicalOrganization": "Medical Organization", + "Dentist": "Dentist", + "DiagnosticLab": "Diagnostic Lab", + "Hospital": "Hospital", + "MedicalClinic": "Medical Clinic", + "Pharmacy": "Pharmacy", + "Physician": "Physician", + "VeterinaryCare": "Veterinary Care" + }, + "NGO": "NGO", + "NewsMediaOrganization": "News Media Organization", + "Performing Group": { + "PerformingGroup": "Performing Group", + "DanceGroup": "Dance Group", + "MusicGroup": "Music Group", + "TheaterGroup": "Theater Group" + }, + "Project": { + "Project": "Project", + "FundingAgency": "Funding Agency", + "ResearchProject": "Research Project" + }, + "Sports Organization": { + "SportsOrganization": "Sports Organization", + "SportsTeam": "Sports Team" + }, + "WorkersUnion": "Workers Union" +} diff --git a/includes/abstract-plugin-base.php b/includes/abstract-plugin-base.php new file mode 100644 index 0000000..14ab449 --- /dev/null +++ b/includes/abstract-plugin-base.php @@ -0,0 +1,239 @@ +file = $file; + $this->requirements = []; + $this->files = []; + $this->plugin_data = []; + + // Load composer packages + $this->setup_composer(); + + // Setup Plugin Updates + $this->setup_updater(); + + // Set Text Domain + load_plugin_textdomain($this->get_textdomain(), false, plugin_basename(dirname($this->file)) . '/lang'); + + // Requirements Check + add_action('plugins_loaded', [$this, 'check_requirements'], 1, 0); + + $this->enable(); + } + + // Plugin Initialization + + protected function enable() { + add_action('plugins_loaded', [$this, 'load'], 10, 0); + add_filter('acf/settings/load_json', [$this, 'register_acf_json'], 10, 1); + } + protected function disable() { + remove_action('plugins_loaded', [$this, 'load'], 10, 0); + remove_filter('acf/settings/load_json', [$this, 'register_acf_json'], 10, 1); + } + + public function load() { + $this->load_files(); + } + + public function register_acf_json(array $paths):array { + $path = $this->get_path() . 'acf-json'; + if (!in_array($path, $paths)) $paths[] = $path; + return $paths; + } + + // Setup + + protected function setup_composer() { + require_once($this->get_path() . 'vendor/autoload.php'); + } + + protected function setup_updater() { + global $wppul_plugin_file, $wppul_server, $wppul_license_required; + $wppul_plugin_file = $this->get_file(); + $wppul_server = 'https://plugins.cleverogre.com'; + $wppul_license_required = false; + if (!class_exists('Puc_v4_Factory')) require_once($this->get_path() . 'lib/wp-package-updater-lib/plugin-update-checker/plugin-update-checker.php'); + require_once($this->get_path() . 'lib/wp-package-updater-lib/package-updater.php'); + } + + // Requirements + + protected function add_requirement(string $key, array $data) { + $this->requirements[$key] = wp_parse_args($data, [ + 'name' => '', + 'url' => '', + 'type' => self::REQUIREMENT_NONE, + 'plugin' => '', + 'class' => '', + ]); + } + + public function check_requirements() { + $invalid = false; + foreach ($this->requirements as $key => $data) { + if ($data['type'] & self::REQUIREMENT_NONE) continue; + if ($data['type'] & self::REQUIREMENT_PLUGIN && !empty($data['plugin']) && function_exists('is_plugin_active') && is_plugin_active($data['plugin'])) continue; + if ($data['type'] & self::REQUIREMENT_CLASS && !empty($data['class']) && class_exists($data['class'])) continue; + + $this->add_requirement_notice($data); + $invalid = true; + } + + if (!!$invalid) $this->disable(); + } + + protected function add_requirement_notice($data) { + add_action('admin_notices', function () use ($data) { + $message = sprintf( + __('In order to use the %1$s plugin, it is required that you install and activate the %3$s plugin. You can do this on the plugins page when logged in as an administrator. To download this plugin, visit the %3$s website.', $this->get_textdomain()), + $this->get_title(), + esc_url(admin_url('plugins.php')), + esc_html($data['name']), + esc_url($data['url']) + ); + printf('

%s

', esc_attr('notice notice-error'), wpautop(wp_kses_post($message))); + }); + } + + // Plugin Files + + protected function add_file(string $relpath):bool { + if (!is_string($relpath) || empty($relpath)) return false; + $this->files[] = $relpath; + return true; + } + protected function add_files(array $relpaths):bool { + $valid = true; + foreach ($relpaths as $relpath) { + if (!$this->add_file($relpath)) $valid = false; + } + return $valid; + } + + protected function load_files():bool { + if (empty($this->files)) return false; + $valid = true; + foreach ($this->files as $relpath) { + $path = rtrim($this->get_path(), '/') . '/' . ltrim($relpath, '/'); + if (!file_exists($path)) $valid = false; + else include_once($path); + } + return $valid; + } + + // Plugin Data Accessors + + private function get_data(string $key):string { + if (!function_exists('get_plugin_data')) require_once(ABSPATH . 'wp-admin/includes/plugin.php'); + if (!is_array($this->plugin_data) || empty($this->plugin_data)) { + $this->plugin_data = get_plugin_data($this->file); + } + if (!array_key_exists($key, $this->plugin_data)) return ''; + return $this->plugin_data[$key]; + } + + public function get_textdomain():string { + return $this->get_data('TextDomain'); + } + + public function get_id():string { + return $this->get_textdomain(); + } + + public function get_version():string { + return $this->get_data('Version'); + } + + public function get_title():string { + return __($this->get_data('Name'), $this->get_textdomain()); + } + + public function get_description():string { + return __($this->get_data('Description'), $this->get_textdomain()); + } + + // Plugin File Path Calculations + + public function get_file():string { + return $this->file; + } + + public function get_path(string $file = ''):string { + if (empty($file)) $file = $this->file; + return trailingslashit(dirname($file)); + } + + public function get_dir(string $file = ''):string { + $dir = $this->get_path($file); + $count = 0; + + // Sanitize for Win32 installs + $dir = str_replace('\\', '/', $dir); + + // If file is in plugins folder + $wp_plugin_dir = str_replace('\\', '/', WP_PLUGIN_DIR); + $dir = str_replace($wp_plugin_dir, plugins_url(), $dir, $count); + + if ($count < 1) { + // If file is in wp-content folder + $wp_content_dir = str_replace('\\', '/', WP_CONTENT_DIR); + $dir = str_replace($wp_content_dir, content_url(), $dir, $count); + } + + if ($count < 1) { + // If file is in ??? folder + $wp_dir = str_replace('\\', '/', ABSPATH); + $dir = str_replace($wp_dir, site_url('/'), $dir); + } + + return $dir; + } + + public function get_hook(string $file = ''):string { + if (empty($file)) $file = $this->file; + return basename(dirname($file)) . '/' . basename($file); + } + + public function get_url(string $file = ''):string { + if (empty($file)) $file = $this->file; + return plugin_dir_url($file); + } + + // Static Translation Functions + + public static function __(string $text):string { + return __($text, self::instance()->get_textdomain()); + } + + public static function esc_html__(string $text):string { + return esc_html__($text, self::instance()->get_textdomain()); + } + + public static function esc_attr__(string $text):string { + return esc_attr__($text, self::instance()->get_textdomain()); + } + +} diff --git a/includes/class-data.php b/includes/class-data.php new file mode 100644 index 0000000..af94d7f --- /dev/null +++ b/includes/class-data.php @@ -0,0 +1,261 @@ + 'PostalAddress'); + if (isset($acf_object['address']) && !empty($acf_object['address'])) $schema_object['address']['streetAddress'] = $acf_object['address']; + if (isset($acf_object['po_box']) && !empty($acf_object['po_box'])) $schema_object['address']['postOfficeBoxNumber'] = $acf_object['po_box']; + if (isset($acf_object['city']) && !empty($acf_object['city'])) $schema_object['address']['addressLocality'] = $acf_object['city']; + if (isset($acf_object['state']) && !empty($acf_object['state'])) $schema_object['address']['addressRegion'] = $acf_object['state']; + if (isset($acf_object['postal_code']) && !empty($acf_object['postal_code'])) $schema_object['address']['postalCode'] = $acf_object['postal_code']; + if (isset($acf_object['country']) && !empty($acf_object['country'])) $schema_object['address']['addressCountry'] = $acf_object['country']; + } + + if (isset($acf_object['location']) && is_array($acf_object['location']) && !empty($acf_object['location'])) { + $schema_object['geo'] = array( + '@type' => 'GeoCoordinates', + 'latitude' => $acf_object['location']['lat'], + 'longitude' => $acf_object['location']['lng'], + ); + $schema_object['hasMap'] = 'https://www.google.com/maps/place/' . urlencode($acf_object['location']['address']); + } + + if (isset($acf_object['hours']) && !empty($acf_object['hours']) && is_array($acf_object['hours'])) { + $schema_object['openingHours'] = self::build_hours($acf_object['hours']); + } + + if (isset($acf_object['price']) && is_numeric($acf_object['price']) && intval($acf_object['price']) >= 1 && intval($acf_object['price']) <= 5) { + $schema_object['priceRange'] = str_repeat('$', intval($acf_object['price'])); + } + + if (isset($acf_object['phone']) && !empty($acf_object['phone'])) { + $contact = array( + '@type' => 'ContactPoint', + 'telephone' => $acf_object['phone'], + ); + if (isset($acf_object['contact_type']) && !empty($acf_object['contact_type']) && strtolower($acf_object['contact_type']) != 'none') $contact['contactType'] = $acf_object['contact_type']; + if (isset($acf_object['contact_option']) && !empty($acf_object['contact_option']) && strtolower($acf_object['contact_option']) != 'none') $contact['contactOption'] = $acf_object['contact_option']; + + $schema_object['contactPoint'] = $contact; + $schema_object['telephone'] = $acf_object['phone']; + } + + break; + + case 'person': + $schema_object['@type'] = 'person'; + + if (isset($acf_object['name']) && !empty($acf_object['name'])) $schema_object['name'] = $acf_object['name']; + if (isset($acf_object['job_title']) && !empty($acf_object['job_title'])) $schema_object['jobTitle'] = $acf_object['job_title']; + + if (isset($acf_object['address']) || isset($acf_object['po_box']) || isset($acf_object['city']) || isset($acf_object['state']) || isset($acf_object['postal_code']) || isset($acf_object['country'])) { + $schema_object['address'] = array('@type' => 'PostalAddress'); + if (isset($acf_object['address']) && !empty($acf_object['address'])) $schema_object['address']['streetAddress'] = $acf_object['address']; + if (isset($acf_object['po_box']) && !empty($acf_object['po_box'])) $schema_object['address']['postOfficeBoxNumber'] = $acf_object['po_box']; + if (isset($acf_object['city']) && !empty($acf_object['city'])) $schema_object['address']['addressLocality'] = $acf_object['city']; + if (isset($acf_object['state']) && !empty($acf_object['state'])) $schema_object['address']['addressRegion'] = $acf_object['state']; + if (isset($acf_object['postal_code']) && !empty($acf_object['postal_code'])) $schema_object['address']['postalCode'] = $acf_object['postal_code']; + if (isset($acf_object['country']) && !empty($acf_object['country'])) $schema_object['address']['addressCountry'] = $acf_object['country']; + } + + if (isset($acf_object['email']) && !empty($acf_object['email']) && is_email($acf_object['email'])) $schema_object['email'] = $acf_object['email']; + if (isset($acf_object['phone']) && !empty($acf_object['phone'])) $schema_object['telephone'] = $acf_object['phone']; + if (isset($acf_object['birth_date']) && !empty($acf_object['birth_date'])) $schema_object['birthDate'] = $acf_object['birth_date']; + + break; + + case 'product': + $schema_object['@type'] = 'product'; + + if (isset($acf_object['brand']) && !empty($acf_object['brand'])) $schema_object['brand'] = $acf_object['brand']; + if (isset($acf_object['name']) && !empty($acf_object['name'])) $schema_object['name'] = $acf_object['name']; + if (isset($acf_object['description']) && !empty($acf_object['description'])) $schema_object['description'] = $acf_object['description']; + + if (isset($acf_object['image']) && !empty($acf_object['image']) && isset($acf_object['image']['url']) && !empty($acf_object['image']['url'])) $schema_object['image'] = $acf_object['image']['url']; + + if (isset($acf_object['rating_value']) && !empty($acf_object['rating_value'])) { + $schema_object['aggregateRating'] = array( + '@type' => 'aggregateRating', + 'ratingValue' => $acf_object['rating_value'], + ); + if (isset($acf_object['review_count']) && $acf_object['review_count'] > 0) $schema_object['aggregateRating']['reviewCount'] = $acf_object['review_count']; + } + + break; + + case 'event': + if (isset($acf_object['type']) && !empty($acf_object['type']) && strtolower($acf_object['type']) != 'none') { + $schema_object['@type'] = $acf_object['type']; // type field with capitals but without spaces + } else { + $schema_object['@type'] = 'Event'; + } + + if (isset($acf_object['name']) && !empty($acf_object['name'])) $schema_object['name'] = $acf_object['name']; + if (isset($acf_object['description']) && !empty($acf_object['description'])) $schema_object['description'] = $acf_object['description']; + if (isset($acf_object['date_start']) && !empty($acf_object['date_start'])) $schema_object['startDate'] = $acf_object['date_start']; + if (isset($acf_object['date_end']) && !empty($acf_object['date_end'])) $schema_object['endDate'] = $acf_object['date_end']; + + if (isset($acf_object['venue_name']) || isset($acf_object['address'])) { + $location = array('@type' => 'Place'); + + if (isset($acf_object['venue_name']) && !empty($acf_object['venue_name'])) $location['name'] = $acf_object['venue_name']; + if (isset($acf_object['venue_url']) && !empty($acf_object['venue_url'])) $location['sameAs'] = $acf_object['venue_url']; + + if (isset($acf_object['address']) && !empty($acf_object['address'])) { + $location['address'] = array( + '@type' => 'PostalAddress', + 'streetAddress' => $acf_object['address'], + ); + + if (isset($acf_object['city']) && !empty($acf_object['city'])) $location['address']['addressLocality'] = $acf_object['city']; + if (isset($acf_object['state']) && !empty($acf_object['state'])) $location['address']['addressRegion'] = $acf_object['state']; + if (isset($acf_object['postal_code']) && !empty($acf_object['postal_code'])) $location['address']['postalCode'] = $acf_object['postal_code']; + if (isset($acf_object['country']) && !empty($acf_object['country'])) $location['address']['addressCountry'] = $acf_object['country']; + } + + if (count($location) > 1) $schema_object['location'] = $location; + } + + if (isset($acf_object['offer_description']) || isset($acf_object['offer_url']) || isset($acf_object['offer_price'])) { + $offer = array('@type' => 'Offer'); + + if (isset($acf_object['offer_description']) && !empty($acf_object['offer_description'])) $offer['description'] = $acf_object['offer_description']; + if (isset($acf_object['offer_url']) && !empty($acf_object['offer_url'])) $offer['url'] = $acf_object['offer_url']; + if (isset($acf_object['offer_price']) && !empty($acf_object['offer_price'])) $offer['price'] = $acf_object['offer_price']; + + if (count($offer) > 1) $schema_object['offer'] = $offer; + } + + break; + + case 'website': + $schema_object['@type'] = 'WebSite'; + + if (isset($acf_object['name']) && !empty($acf_object['name'])) $schema_object['name'] = $acf_object['name']; + if (isset($acf_object['name_alternate']) && !empty($acf_object['name_alternate'])) $schema_object['alternateName'] = $acf_object['name_alternate']; + + break; + + case 'custom': + if (isset($acf_object['fields']) && !empty($acf_object['fields'])) { + foreach ($acf_object['fields'] as $field) { + if (!isset($field['key']) || empty($field['key'])) continue; + + switch ($field['type']) { + case 'array': + $schema_object[$field['key']] = array(); + foreach ($field['array'] as $array_item) { + if (!isset($array_item['value']) || empty($array_item['value'])) continue; + $schema_object[$field['key']][] = $array_item['value']; + } + break; + + case 'object': + $schema_object[$field['key']] = array(); + foreach ($field['object'] as $object_item) { + if (!isset($object_item['key']) || empty($object_item['key'])) continue; + $schema_object[$field['key']][$object_item['key']] = $object_item['value']; + } + break; + + default: + $schema_object[$field['key']] = $field['value']; + break; + } + } + } + + break; + + } + + if (empty($schema_object)) return []; + + // Global Settings + if (!isset($schema_object['url'])) $schema_object['url'] = get_site_url(); + if (!isset($schema_object['@context'])) $schema_object['@context'] = 'http://www.schema.org'; + + $schema_object = apply_filters('ogreschema/get_schema_object', $schema_object, $id); + + // Set Cache + wp_cache_set($cache_key, $schema_object, 'ogre_schema'); + return $schema_object; + } + + private static function build_hours($hours_object) { + $hours = ''; + foreach ($hours_object as $row) { + if (!isset($row['day']) || empty($row['day'])) continue; + if ($hours != '') $hours .= ', '; + $hours .= $row['day']; + if (isset($row['open']) && isset($row['close']) && !empty($row['open']) && !empty($row['close'])) { + $hours .= ' ' . $row['open'] . '-' . $row['close']; + } + } + return $hours; + } + +} diff --git a/includes/class-fields.php b/includes/class-fields.php new file mode 100644 index 0000000..5b532d2 --- /dev/null +++ b/includes/class-fields.php @@ -0,0 +1,60 @@ + 'post_type', + 'operator' => '==', + 'value' => $post_type, + ]]; + } + return $group; + } + + public function load_post_types(array $field):array { + $field['choices'] = wp_list_pluck(get_post_types(['public' => true], 'objects'), 'label', 'name'); + return $field; + } + + public function load_business_types(array $field):array { + $field['choices'] = $this->get_json_data('data/business-type.json'); + return $field; + } + + public function load_organization_types(array $field):array { + $field['choices'] = $this->get_json_data('data/organization-type.json'); + return $field; + } + + private function get_json_data(string $relpath):array { + $path = Plugin::instance()->get_path() . ltrim($relpath, '/'); + if (!str_ends_with($path, '.json') || !file_exists($path)) return []; + $data = json_decode(file_get_contents($path), true); + return is_array($data) ? $data : []; + } + +} + +Fields::instance(); diff --git a/includes/class-output.php b/includes/class-output.php new file mode 100644 index 0000000..fc25e8c --- /dev/null +++ b/includes/class-output.php @@ -0,0 +1,31 @@ +%s', + json_encode(Data::get_schema()) // NOTE: esc_js()? + ); + } + +} + +Output::instance(); diff --git a/includes/class-settings.php b/includes/class-settings.php new file mode 100644 index 0000000..8685483 --- /dev/null +++ b/includes/class-settings.php @@ -0,0 +1,72 @@ +get_file()), [$this, 'plugin_action_links'], 10, 1); + } + + // Add Schema Page to Theme Options + public function admin_menu():void { + if (!function_exists('acf_add_options_sub_page')) return; + $this->page = acf_add_options_sub_page([ + 'page_title' => Plugin::__('Schema Metadata'), + 'menu_title' => Plugin::__('Schema'), + 'parent_slug' => self::PARENT_SLUG, + 'menu_slug' => Plugin::instance()->get_id(), + 'update_button' => Plugin::__('Save'), + 'updated_message' => Plugin::__('Schema Updated'), + ]); + } + + // Add plugin link + public function plugin_action_links(array $links):array { + array_unshift($links, sprintf( + '%s', + esc_url($this->get_url()), + Plugin::esc_html__('Settings') + )); + return $links; + } + + private function get_menu_slug():string { + if (empty($this->page) || !isset($this->page['menu_slug'])) return ''; + return (string)$this->page['menu_slug']; + } + + public function get_url():string { + return add_query_arg(array_filter([ + 'page' => $this->get_menu_slug(), + ]), admin_url(self::PARENT_SLUG)); + } + + // Settings Accessors + + public static function get_post_types():array { + if (get_field('schema_setting_post_enable', 'option') !== true) return []; + return is_array($post_types = get_field('schema_setting_post_type', 'option')) ? $post_types : []; + } + + public static function has_post_types():bool { + return !empty(self::get_post_types()); + } + +} + +Settings::instance(); diff --git a/includes/index.php b/includes/index.php new file mode 100644 index 0000000..eea59b9 --- /dev/null +++ b/includes/index.php @@ -0,0 +1,2 @@ +get_wpseo_schema(); + if (empty($wpseo_schema)) return $schema_object; + foreach ($wpseo_schema as $key => $value) { + if (isset($schema_object[$key]) && !empty($schema_object[$key])) continue; + $schema_object[$key] = $value; + } + return $schema_object; + } + + // Override filter and get Yoast JSON data + private function get_wpseo_schema():array { + remove_filter('wpseo_json_ld_output', [$this, 'disable_wpseo'], 10, 2); + ob_start(); + do_action('wpseo_json_ld'); + $html = ob_get_clean(); + add_filter('wpseo_json_ld_output', [$this, 'disable_wpseo'], 10, 2); + + if (empty($html) || !preg_match_all('/]*>(.+)<\/script>/m', $html, $matches)) return []; + + $data = []; + foreach ($matches[1] as $json_str) { + $json_data = json_decode($json_str, true); + if (!is_null($json_data) && is_array($json_data)) $data = array_merge($data, $json_data); + } + return $data; + } + +} + +YoastSEO::instance(); diff --git a/includes/integration/index.php b/includes/integration/index.php new file mode 100644 index 0000000..eea59b9 --- /dev/null +++ b/includes/integration/index.php @@ -0,0 +1,2 @@ +add_requirement('advanced-custom-fields', [ + 'name' => __('Advanced Custom Fields PRO', $this->get_textdomain()), + 'url' => 'https://www.advancedcustomfields.com/', + 'type' => self::REQUIREMENT_PLUGIN, + 'plugin' => 'advanced-custom-fields-pro/acf.php', + ]); + + $this->add_files([ + 'includes/class-data.php', + 'includes/class-settings.php', + 'includes/class-fields.php', + 'includes/class-output.php', + 'includes/integration/class-wordpress-seo.php', + ]); + } + +} + +Plugin::instance(); diff --git a/package.json b/package.json new file mode 100644 index 0000000..a4ae344 --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ + "name": "ogre-schema", + "title": "OgreSchema", + "version": "0.1.0", + "author": "CleverOgre", + "license": "GPL-3.0+", + "keywords": [], + "engines": { + "node": ">=6.9.4", + "npm": ">=1.1.0" + } +} diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..3130395 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,56 @@ + + + SomewhereWarm Coding Standards + + + tests/ + */node_modules/* + */assets/* + */src/* + */vendor/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + tests/ + + + + + + + + + + + + + + diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..8466a6d --- /dev/null +++ b/readme.txt @@ -0,0 +1,34 @@ +=== OgreSchema === +Contributors: ogrecooper +Donate link: https://cleverogre.com/ +Tags: gravityforms, feed, jobs, resume, application +Requires at least: 6.0.0 +Tested up to: 6.4.3 +Stable tag: 0.1.0 +License: GPLv2 or later +License URI: https://www.gnu.org/licenses/gpl-2.0.html + +Output schema site-wide for your website. + +== Description == + +Output schema site-wide for your website. Requires OgreCore plugin. + +Prerequisites: +* [OgreCore](https://plugins.cleverogre.com/plugin/ogrecore/) + +== Installation == + +1. Upload the plugin files to the `/wp-content/plugins/ogre-schema` directory and ensure that it is active. +2. Activate the plugin through the 'Plugins' screen in WordPress. + +== FAQ == + += What is this plugin? = + +If you do know what plugin you have downloaded, please contact [CleverOgre](team@cleverogre.com) for more information. This plugin is only developed for a small, private audience. + +== Changelog == + += 0.1.0 - 2024-06-06 = +* Initial build of OgreSchema plugin. Ported from OgreCore.