├── .gitattributes ├── .gitignore ├── README.md ├── api-template-snippets └── api-prepend-repeater-item.php ├── api ├── README.md ├── api-create-new-superuser.php ├── api-create-page.php ├── api-create-shortlinks-for-jumplinks-module.php ├── api-formbuilder-entries-to-mailchimp.php ├── api-get-formbuilder-entries.php ├── api-limit-repeater-results.php ├── api-move-field-data-to-another-field.php ├── api-page-subselect.php ├── api-reset-password.php ├── api-set-value-multilanguage.php └── api-update-created-date.php ├── backup-full-local ├── Modules │ ├── wbmnfktrAmazonUpdater │ │ ├── _amz │ │ │ ├── amz-action.php │ │ │ ├── amz-func.php │ │ │ └── amz-vars.php │ │ ├── amazon.php │ │ └── wbmnfktrAmazonUpdater.module │ ├── wbmnfktrGoogleMapsUpdater │ │ └── wbmnfktrGoogleMapsUpdater.module │ └── wbmnfktrInventoryChecker │ │ └── wbmnfktrInventoryChecker.module ├── Snippets │ ├── _functions.php │ ├── api-create-page.php │ ├── api-create-shortlinks-for-jumplinks-module.php │ ├── api-formbuilder-entries.php │ ├── api-move-field-data-to-another-field.php │ ├── api-page-subselect.php │ ├── api-reset-password.php │ ├── api-set-value-by-language.php │ ├── api-update-created-date.php │ ├── ckeditor-text-align.txt │ ├── config-serial-key-procache.txt │ ├── config-session-allow.php │ ├── delete-form-builder-entries-after-time.php │ ├── form-refocus.js │ ├── google-analytics-opt-out.js │ ├── init.php │ ├── mailer.php │ ├── module-default-language.php │ ├── module-page-edit-only-by-creator.php │ ├── pages2pdf-custom.php │ ├── paypal-payment.txt │ ├── ready-automatite-cron-site-check.php │ ├── ready-formbuilder-renderReady.php │ ├── ready-google-maps-adress-lat-long.php │ ├── ready-log-outgoing-emails.php │ ├── ready-loginregister-mailchimp.php │ ├── ready-redirect-to-formbuilder-page.php │ ├── ready-set-session-variable.php │ ├── ready-sort-templates-by-label.php │ ├── ready-submit-to-mailchimp-from-formbuilder-entries.php │ ├── ready-submit-to-mailchimp.php │ ├── ready-validate-formbuilder-fields.php │ ├── snippet-check-ip-country.php │ └── template-breadcrumb.php └── dnt.js ├── hannacode ├── README.md ├── hannacode-embed-rumble-privacywire.php ├── hannacode-embed-rumble.php └── hannacode-table-of-contents-jumplinks-demo.php ├── hooks-ready-php ├── README.md ├── ready-automate-cron-site-check.php ├── ready-clean-youtube-url.php ├── ready-formbuilder-newsletter-subscription.php ├── ready-google-maps-adress-lat-long.php ├── ready-log-outgoing-emails.php ├── ready-set-session-variable.php └── ready-sort-templates-by-label.php ├── hooks ├── README.md ├── hook-ready-formbuilder-from.php ├── hook-ready-formbuilder-redirect-created-page.php ├── hook-ready-formbuilder-subject.php ├── hook-ready-formbuilder-submit-to-mailchimp.php ├── hook-ready-formbuilder-validate-fields.php └── hook-ready-loginregister-to-mailchimp.php └── ready-hook-on-demand-mirroring-web-files.php /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ProcessWire Snippets 2 | 3 | A curated collection of various ProcessWire-related code snippets collected throughout the years and projects. 4 | 5 | ## Various flavours of snippets 6 | 7 | 1. ready.php Hooks 8 | 2. API/Template Snippets 9 | 3. Snippets for Snippets Module 10 | 11 | ## Update in progress 12 | 13 | The whole collection of snippets is under maintenance and rebuild now. 14 | -------------------------------------------------------------------------------- /api-template-snippets/api-prepend-repeater-item.php: -------------------------------------------------------------------------------- 1 | of(false); 8 | $newItem = $thatPage->my_repeater->getNew(); 9 | $newItem->foo = 'bar'; 10 | $newItem->save(); 11 | $thatPage->my_repeater->add($newItem); 12 | $thatPage->save(); 13 | // Set the sort value of the new item to 0 and adjust sibling sort values 14 | $pages->sort($newItem, 0); 15 | -------------------------------------------------------------------------------- /api/README.md: -------------------------------------------------------------------------------- 1 | # ProcessWire API snippets -------------------------------------------------------------------------------- /api/api-create-new-superuser.php: -------------------------------------------------------------------------------- 1 | of(false); 9 | $newadmin->name = "newCmsAdminUser"; 10 | $newadmin->email = "user@domain.tld"; 11 | $newadmin->pass = "aSecurePasswordHere"; 12 | $newadmin->addRole("superuser"); 13 | $newadmin->save(); 14 | $newadmin->of(true); 15 | 16 | ?> -------------------------------------------------------------------------------- /api/api-create-page.php: -------------------------------------------------------------------------------- 1 | setOutputFormatting(false); 8 | 9 | // example template 10 | $newpage->template = 'yourTemplate'; 11 | 12 | // example parent 13 | $newpage->parent = wire('pages')->get('/parent/'); 14 | 15 | // example name - leave empty and let ProcessWire create a name for the page based on title 16 | $newpage->name = "foo"; 17 | 18 | //example title 19 | $newpage->title = "My API-generated new PW page"; 20 | 21 | // example field with example value 22 | $newpage->fieldname = "my field value"; 23 | 24 | // save page 25 | $newpage->save(); -------------------------------------------------------------------------------- /api/api-create-shortlinks-for-jumplinks-module.php: -------------------------------------------------------------------------------- 1 | find('template=yourTemplate') as $yourpages) { 7 | 8 | // define a Jumplink path 9 | $from = "out/" . $yourpages->id; 10 | 11 | // define destination 12 | $to = $yourpages->www; 13 | 14 | // http://cheatsheet.processwire.com/page/built-in-methods-reference/page-setoutputformatting-true-false/ 15 | $yourpages->setOutputFormatting(false); 16 | 17 | // add jumplink path to page 18 | $yourpages->shorturl = "/" . $from; 19 | 20 | // save page 21 | $yourpages->save(); 22 | 23 | // create jumplink in Jumplinks module 24 | $this->modules->ProcessJumplinks->add($from, $to); 25 | 26 | }; -------------------------------------------------------------------------------- /api/api-formbuilder-entries-to-mailchimp.php: -------------------------------------------------------------------------------- 1 | get("mailchimp")->entries()->find('sort=id'); 7 | 8 | foreach($entries as $entry){ 9 | $mc = $modules->get("SubscribeToMailchimp"); 10 | 11 | $mc_mail = $entry['e_mail']; 12 | $mc_fname = $entry['vorname']; 13 | 14 | $subscriber = [ 15 | 'FNAME' => $mc_fname 16 | ]; 17 | 18 | $mc->subscribe($mc_mail, $subscriber, 'SUPERSECRETMCHASH'); 19 | 20 | wire('log')->save('mailchimp', $mc_mail . " - " . $mc_fname ); 21 | 22 | } -------------------------------------------------------------------------------- /api/api-get-formbuilder-entries.php: -------------------------------------------------------------------------------- 1 | get('your-form-name'); 8 | 9 | // define entries you want to find (example: created 3 months ago) 10 | // Todo: more examples 11 | $entries = $form->entries()->find("created<=" . strtotime("-3 MONTH")); 12 | -------------------------------------------------------------------------------- /api/api-limit-repeater-results.php: -------------------------------------------------------------------------------- 1 | repeater; 5 | 6 | // parts of your repeater with limited items based on your selection 7 | $myRepeaterSelection = $myRepeater->find('anotherField=value'); 8 | 9 | // do whatever you want with your repeater selection 10 | echo count( $myRepeaterSelection ); 11 | 12 | foreach( $myRepeaterSelection as $mrs) { 13 | // ... 14 | } 15 | 16 | // same as above but way shorter 17 | echo count( $page->repeater->find('anotherField=value') ); 18 | 19 | foreach( $page->repeater->find('anotherField=value') as $item) { 20 | // ... 21 | } 22 | 23 | ?> -------------------------------------------------------------------------------- /api/api-move-field-data-to-another-field.php: -------------------------------------------------------------------------------- 1 | find('template=yourTemplate') as $yourpages) { 7 | 8 | // define old field 9 | $old = $yourpages->oldfield; 10 | 11 | // http://cheatsheet.processwire.com/#sanitizer 12 | $oldcleaned = $sanitizer->text($old); 13 | 14 | // http://cheatsheet.processwire.com/page/built-in-methods-reference/page-setoutputformatting-true-false/ 15 | $yourpages->setOutputFormatting(false); 16 | 17 | // place content in new field 18 | $yourpages->newfield = $oldcleaned; 19 | 20 | // save page 21 | $yourpages->save(); 22 | 23 | }; 24 | 25 | -------------------------------------------------------------------------------- /api/api-page-subselect.php: -------------------------------------------------------------------------------- 1 | find("template=productTemplate") as $product) { 10 | 11 | // add brand from product page to brands array 12 | $brands->add($product->brandField); 13 | 14 | }; -------------------------------------------------------------------------------- /api/api-reset-password.php: -------------------------------------------------------------------------------- 1 | get('yourUsername'); 7 | 8 | //http://cheatsheet.processwire.com/page/built-in-methods-reference/page-setoutputformatting-true-false/ 9 | $thatGuyWhoForgotHisPassword->of(false); 10 | 11 | // set new password 12 | $thatGuyWhoForgotHisPassword->pass = 'your-new-super-secret-password-1111-elf'; 13 | 14 | // save user 15 | $thatGuyWhoForgotHisPassword->save(); 16 | 17 | -------------------------------------------------------------------------------- /api/api-set-value-multilanguage.php: -------------------------------------------------------------------------------- 1 | language = $languages->get('en'); 7 | $page->setAndSave('title', 'My title'); 8 | 9 | $user->language = $languages->get('de'); 10 | $page->setAndSave('title', 'Mein Titel'); 11 | 12 | // Option 2 13 | 14 | // http://cheatsheet.processwire.com/page/built-in-methods-reference/page-setoutputformatting-true-false/ 15 | $page->of(false); 16 | $page->title->setLanguageValue($languages->get('en'), 'My title'); 17 | $page->title->setLanguageValue($languages->get('de'), 'Mein Titel'); 18 | 19 | 20 | // save page 21 | $page->save(); 22 | 23 | -------------------------------------------------------------------------------- /api/api-update-created-date.php: -------------------------------------------------------------------------------- 1 | created = $timestamp 7 | 8 | // save page - yeah, a different way of saving a page 9 | // necessary in this case 10 | $page->save(array('quiet' => true)) -------------------------------------------------------------------------------- /backup-full-local/Modules/wbmnfktrAmazonUpdater/_amz/amz-action.php: -------------------------------------------------------------------------------- 1 | amz_asin; 7 | $request = aws_signed_request('de', array( 'Operation' => 'ItemLookup', 'ItemId' => $asin, 'ResponseGroup' => 'Images,ItemAttributes,Offers'), AWS_API_KEY, AWS_API_SECRET_KEY, AWS_ASSOCIATE_TAG); 8 | $response = @file_get_contents($request); 9 | 10 | if ($response === FALSE) { 11 | 12 | echo $asin . " - " . "Request failed.\n" . "
"; 13 | // wenn keine Rückmeldung, Datensatz markieren 14 | $product = $pages->get("amz_asin=$asin"); 15 | $product->of(false); 16 | $product->amz_failed = 1; 17 | $product->save(); 18 | 19 | } else { 20 | 21 | // parse XML 22 | $pxml = simplexml_load_string($response); 23 | if ($pxml === FALSE) { 24 | 25 | echo "Response could not be parsed.\n"; 26 | 27 | // wenn keine Rückmeldung, Datensatz markieren 28 | $product = $pages->get("amz_asin=$asin"); 29 | $product->of(false); 30 | $product->amz_failed = 1; 31 | $product->save(); 32 | 33 | 34 | } else { 35 | 36 | $titel = $pxml->Items->Item->ItemAttributes->Title; 37 | $brand = $pxml->Items->Item->ItemAttributes->Brand; 38 | $manufacturer = $pxml->Items->Item->ItemAttributes->Manufacturer; 39 | $preis = $pxml->Items->Item->OfferSummary->LowestNewPrice->Amount; 40 | $price = number_format($preis, 2, ',' , '.'); 41 | 42 | $largeimage = $pxml->Items->Item->LargeImage->URL; 43 | $link = $pxml->Items->Item->DetailPageURL; 44 | $feature1 = $pxml->Items->Item->ItemAttributes->Feature[0]; 45 | $feature2 = $pxml->Items->Item->ItemAttributes->Feature[1]; 46 | $feature3 = $pxml->Items->Item->ItemAttributes->Feature[2]; 47 | $feature4 = $pxml->Items->Item->ItemAttributes->Feature[3]; 48 | $feature5 = $pxml->Items->Item->ItemAttributes->Feature[4]; 49 | $prime = $pxml->Items->Item->Offers->Offer->OfferListing->IsEligibleForPrime; 50 | // $features = $feature1 . " " . $feature2 . " " . $feature3 . " " . $feature4 ; 51 | // $largeimage = $pxml->Items->Item->ImageSets->ImageSet->LargeImage->URL; 52 | 53 | 54 | if($product->amz_check) { 55 | 56 | $product = $pages->get("amz_asin=$asin"); 57 | $product->of(false); 58 | $product->amz_prime = $prime; 59 | $product->amz_link = $link; 60 | $product->amz_manufacturer = $manufacturer; 61 | $product->amz_price = number_format(($preis / 100), 2, ',' , '.'); 62 | $product->amz_failed = 0; 63 | $product->save(); 64 | echo $product->amz_asin . " - " . "aktualisiert (kleine Abfrage).\n" . "
"; 65 | 66 | } else { 67 | 68 | $product = $pages->get("amz_asin=$asin"); 69 | $product->of(false); 70 | $product->amz_prod = $titel; 71 | $product->amz_brand = $brand; 72 | $product->brand = $brand; 73 | $product->amz_manufacturer = $manufacturer; 74 | $product->amz_f1 = $feature1; 75 | $product->amz_f2 = $feature2; 76 | $product->amz_f3 = $feature3; 77 | $product->amz_f4 = $feature4; 78 | $product->amz_f5 = $feature5; 79 | $product->amz_prime = $prime; 80 | $product->amz_link = $link; 81 | $product->amz_price = number_format(($preis / 100), 2, ',' , '.'); 82 | $product->amz_imageurl = $largeimage; 83 | $product->amz_failed = 0; 84 | $product->amz_check = 1; 85 | $product->save(); 86 | if(count($product->amz_image)) { $product->of(false); $product->amz_image->removeAll(); }; 87 | $product->save(); 88 | $product->of(false); 89 | $product->amz_image->add("$product->amz_imageurl"); 90 | $product->save(); 91 | 92 | echo $product->amz_asin . " - " . "aktualisiert (Initialabfrage).\n" . "
"; 93 | 94 | 95 | // echo $largeimage; 96 | // echo "
"; 97 | // var_dump($pxml); 98 | 99 | }; 100 | 101 | } 102 | }; 103 | 104 | 105 | echo "
"; 106 | 107 | 108 | 109 | }; -------------------------------------------------------------------------------- /backup-full-local/Modules/wbmnfktrAmazonUpdater/_amz/amz-func.php: -------------------------------------------------------------------------------- 1 | $value) 36 | { 37 | $param = str_replace('%7E', '~', rawurlencode($param)); 38 | $value = str_replace('%7E', '~', rawurlencode($value)); 39 | $canonicalized_query[] = $param.'='.$value; 40 | } 41 | $canonicalized_query = implode('&', $canonicalized_query); 42 | 43 | 44 | // create the string to sign 45 | $string_to_sign = $method."\n".$host."\n".$uri."\n".$canonicalized_query; 46 | 47 | 48 | // calculate HMAC with SHA256 and base64-encoding 49 | $signature = base64_encode(hash_hmac('sha256', $string_to_sign, $private_key, TRUE)); 50 | 51 | 52 | // encode the signature for the request 53 | $signature = str_replace('%7E', '~', rawurlencode($signature)); 54 | 55 | 56 | // create request 57 | $request = 'http://'.$host.$uri.'?'.$canonicalized_query.'&Signature='.$signature; 58 | 59 | return $request; 60 | }; -------------------------------------------------------------------------------- /backup-full-local/Modules/wbmnfktrAmazonUpdater/_amz/amz-vars.php: -------------------------------------------------------------------------------- 1 | get("id=1289")->amz_asin; 11 | 12 | $request = aws_signed_request('de', array( 'Operation' => 'ItemLookup', 'ItemId' => $asin, 'ResponseGroup' => 'Images,ItemAttributes,Offers'), AWS_API_KEY, AWS_API_SECRET_KEY, AWS_ASSOCIATE_TAG); 13 | $response = @file_get_contents($request); 14 | 15 | if ($response === FALSE) { 16 | 17 | echo $asin . " - " . "Request failed." . "
"; 18 | // wenn keine Rückmeldung, Datensatz markieren 19 | $product = wire('pages')->get("amz_asin=$asin"); 20 | $product->of(false); 21 | $product->amz_failed = 1; 22 | $product->save(); 23 | 24 | } else { 25 | 26 | // parse XML 27 | $pxml = simplexml_load_string($response); 28 | if ($pxml === FALSE) { 29 | 30 | echo "Response could not be parsed.\n"; 31 | 32 | // wenn keine Rückmeldung, Datensatz markieren 33 | $product = wire('pages')->get("amz_asin=$asin"); 34 | $product->of(false); 35 | $product->amz_failed = 1; 36 | $product->save(); 37 | 38 | 39 | } else { 40 | 41 | $titel = $pxml->Items->Item->ItemAttributes->Title; 42 | $brand = $pxml->Items->Item->ItemAttributes->Brand; 43 | $manufacturer = $pxml->Items->Item->ItemAttributes->Manufacturer; 44 | $preis = $pxml->Items->Item->OfferSummary->LowestNewPrice->Amount; 45 | $price = number_format($preis, 2, ',' , '.'); 46 | 47 | $largeimage = $pxml->Items->Item->LargeImage->URL; 48 | $link = $pxml->Items->Item->DetailPageURL; 49 | $feature1 = $pxml->Items->Item->ItemAttributes->Feature[0]; 50 | $feature2 = $pxml->Items->Item->ItemAttributes->Feature[1]; 51 | $feature3 = $pxml->Items->Item->ItemAttributes->Feature[2]; 52 | $feature4 = $pxml->Items->Item->ItemAttributes->Feature[3]; 53 | $feature5 = $pxml->Items->Item->ItemAttributes->Feature[4]; 54 | $prime = $pxml->Items->Item->Offers->Offer->OfferListing->IsEligibleForPrime; 55 | 56 | 57 | $product = wire('pages')->get("amz_asin=$asin"); 58 | $product->of(false); 59 | $product->title = $titel; 60 | $product->amz_prod = $titel; 61 | $product->amz_brand = $brand; 62 | $product->brand = $brand; 63 | $product->amz_manufacturer = $manufacturer; 64 | $product->amz_f1 = $feature1; 65 | $product->amz_f2 = $feature2; 66 | $product->amz_f3 = $feature3; 67 | $product->amz_f4 = $feature4; 68 | $product->amz_f5 = $feature5; 69 | $product->amz_prime = $prime; 70 | $product->amz_link = $link; 71 | $product->amz_price = number_format(($preis / 100), 2, ',' , '.'); 72 | $product->amz_imageurl = $largeimage; 73 | $product->amz_failed = 0; 74 | $product->amz_check = 1; 75 | $product->save(); 76 | if(count($product->amz_image)) { $product->of(false); $product->amz_image->removeAll(); }; 77 | $product->save(); 78 | $product->of(false); 79 | $product->amz_image->add("$product->amz_imageurl"); 80 | $product->save(); 81 | 82 | echo $product->amz_asin . " - " . "aktualisiert." . "
"; 83 | 84 | 85 | 86 | } 87 | }; 88 | 89 | 90 | echo "
"; 91 | 92 | }; 93 | 94 | 95 | 96 | ?> -------------------------------------------------------------------------------- /backup-full-local/Modules/wbmnfktrAmazonUpdater/wbmnfktrAmazonUpdater.module: -------------------------------------------------------------------------------- 1 | "Amazon API Updater", 22 | 'version' => "0.0.1", 23 | 'summary' => "Amazon Affiliate API Abfrage auf Basis der ASIN.", 24 | 25 | 'author' => "webmanufaktur", 26 | 'href' => "https://webmanufaktur.net/", 27 | 28 | 'icon' => 'amazon', 29 | 30 | 'autoload' => true, 31 | 'singular' => true 32 | 33 | 34 | ); 35 | } 36 | 37 | // static public function getDefaults() { 38 | // return array( 39 | // "key" => "value" 40 | // ); 41 | // } 42 | 43 | public function __construct() 44 | { 45 | parent::__construct(); 46 | 47 | $this->set('amazonkey', ''); 48 | $this->set('amazonsecretkey', ''); 49 | $this->set('amazontag', 'yourtag-20'); 50 | $this->set('amazonasinfield', 'asin'); 51 | $this->set('amazontemplate', 'amazon'); 52 | } 53 | 54 | public function getModuleConfigInputfields(InputfieldWrapper $wrapper) 55 | { 56 | 57 | $amazonkey = $this->modules->InputfieldText; 58 | $amazonkey->name = 'amazonkey'; 59 | $amazonkey->label = $this->_('Amazon API Key'); 60 | $amazonkey->value = $this->amazonkey; 61 | $amazonkey->required = true; 62 | $wrapper->add($amazonkey); 63 | 64 | $amazonsecretkey = $this->modules->InputfieldText; 65 | $amazonsecretkey->name = 'amazonsecretkey'; 66 | $amazonsecretkey->label = $this->_('Amazon Secret Key'); 67 | $amazonsecretkey->value = $this->amazonsecretkey; 68 | $amazonsecretkey->required = true; 69 | $wrapper->add($amazonsecretkey); 70 | 71 | $amazontag = $this->modules->InputfieldText; 72 | $amazontag->name = 'amazontag'; 73 | $amazontag->label = $this->_('Amazon Affiliate Tag'); 74 | $amazontag->value = $this->amazontag; 75 | $amazontag->required = true; 76 | $wrapper->add($amazontag); 77 | 78 | $amazonasinfield = $this->modules->InputfieldText; 79 | $amazonasinfield->name = 'amazonasinfield'; 80 | $amazonasinfield->label = $this->_('Amazon ASIN Feld'); 81 | $amazonasinfield->value = $this->amazonasinfield; 82 | $amazonasinfield->required = true; 83 | $wrapper->add($amazonasinfield); 84 | 85 | $amazontemplate = $this->modules->InputfieldText; 86 | $amazontemplate->name = 'amazontemplate'; 87 | $amazontemplate->label = $this->_('Amazon Produkt Template'); 88 | $amazontemplate->value = $this->amazontemplate; 89 | $amazontemplate->required = true; 90 | $wrapper->add($amazontemplate); 91 | 92 | return $wrapper; 93 | 94 | } 95 | 96 | public function init() 97 | { 98 | $this->pages->addHookAfter('Pages::saveReady', $this, 'wbmfktrUpdateGMaps'); 99 | } 100 | 101 | public function wbmfktrUpdateGMaps($event) 102 | { 103 | 104 | $page = $event->arguments[0]; 105 | 106 | if($page->template == "$this->amazontemplate" && !$page->isTrash()){ 107 | 108 | $this->message("Amazon ist bereit"); 109 | 110 | if($page->strasse && $page->plz && $page->ort) { 111 | 112 | $location = $page->strasse . " " . $page->plz . " " . $page->ort; 113 | $page->googlemaps->address = $location; 114 | $page->trackChange('googlemaps'); 115 | // $this->message("Google Maps aktualisiert"); 116 | 117 | } 118 | 119 | // $this->message("You just saved page: {$page->strasse}"); 120 | 121 | } 122 | 123 | } 124 | 125 | } -------------------------------------------------------------------------------- /backup-full-local/Modules/wbmnfktrGoogleMapsUpdater/wbmnfktrGoogleMapsUpdater.module: -------------------------------------------------------------------------------- 1 | 'Google Maps Updater', 10 | 'summary' => 'Befüllt Google Maps Marker Felder auf Basis eingegebener Daten', 11 | 'version' => '101', 12 | 'author' => 'webmanufaktur', 13 | 'href' => 'https://webmanufaktur.net/', 14 | 'icon' => 'map-marker', 15 | 'requires' => 'FieldtypeMapMarker', 16 | 'singular' => true, 17 | 'autoload' => true 18 | 19 | ); 20 | } 21 | 22 | public function init() { 23 | $this->pages->addHookAfter('Pages::saveReady', $this, 'wbmfktrUpdateGMaps'); 24 | } 25 | public function wbmfktrUpdateGMaps($event) { 26 | 27 | $page = $event->arguments[0]; 28 | 29 | if($page->template == "partner" && !$page->isTrash()){ 30 | 31 | if($page->strasse && $page->plz && $page->ort) { 32 | 33 | $location = $page->strasse . " " . $page->plz . " " . $page->ort; 34 | $page->googlemaps->address = $location; 35 | $page->trackChange('googlemaps'); 36 | // $this->message("Google Maps aktualisiert"); 37 | 38 | } 39 | 40 | // $this->message("You just saved page: {$page->strasse}"); 41 | 42 | } 43 | 44 | } 45 | 46 | }; 47 | -------------------------------------------------------------------------------- /backup-full-local/Modules/wbmnfktrInventoryChecker/wbmnfktrInventoryChecker.module: -------------------------------------------------------------------------------- 1 | 'Bestandsmelder für Mittagstischangebote', 11 | 'summary' => 'Überprüft die Bestände der Mittagstischangebote und meldet per E-Mail, wenn ein bestimmter Stand erreicht bzw. unterschritten wird.', 12 | 'version' => '001', 13 | 'author' => 'webmanufaktur', 14 | 'href' => 'https://webmanufaktur.net/', 15 | 'icon' => 'cutlery', 16 | 'singular' => true, 17 | 'autoload' => true 18 | 19 | ); 20 | 21 | } 22 | 23 | public function init() { 24 | 25 | // wire('log')->save('wbmnfktr-debug', "Bestandsprüfer: " . $this->date); 26 | 27 | if(!$this->template or !$this->criticalamount or !$this->subject or !$this->receiver or !$this->sender or !$this->text or !$this->date) { 28 | 29 | 30 | 31 | } else { 32 | 33 | 34 | wire()->addHookAfter('LazyCron::everyDay', function (HookEvent $e) { //everyDay every30Seconds 35 | 36 | $pages = wire('pages'); 37 | $gerichte = $pages->find("template=$this->template, $this->date>now"); 38 | $kritischemenge = $this->criticalamount; 39 | $vorhandenemenge = count($gerichte); 40 | 41 | wire('log')->save('wbmnfktr-debug', "Bestandsprüfer: " . $vorhandenemenge); 42 | 43 | if($vorhandenemenge <= $kritischemenge ) { 44 | 45 | wire('log')->save('wbmnfktr-debug', "Bestandsprüfung erfolgt." . $vorhandenemenge); 46 | 47 | if( wire('config')->https ) { $host = "https://"; } else { $host = "http://"; }; 48 | $to = $this->receiver; 49 | $from = $this->sender; 50 | $subject = $this->subject; 51 | $body = $this->text; 52 | $body .= "\n\nMittagstischangebote: " . $vorhandenemenge; 53 | $body .= "\n\nAdmin-Backend aufrufen: " . $host . wire('config')->httpHost . wire('config')->urls->admin; 54 | 55 | if($this->signature) { 56 | $body .= "\n\n" . $this->signature . "\n\n"; 57 | }; 58 | 59 | wire('mail')->send($to, $from, $subject, $body); 60 | 61 | // wire('log')->save('wbmnfktr-debug', $vorhandenemenge . " - " . $to . " " . $from . " " . $subject . " " . $body); 62 | 63 | }; 64 | 65 | }); 66 | 67 | }; 68 | 69 | } 70 | 71 | 72 | public function getModuleConfigInputfields(InputfieldWrapper $wrapper) 73 | { 74 | 75 | // Template ==================== 76 | $tpl = $this->modules->InputfieldText; 77 | $tpl->name = 'template'; 78 | $tpl->label = $this->_('Template'); 79 | $tpl->value = $this->template; 80 | 81 | $tpl->description = $this->_('Template der Mittagstischangeboten'); 82 | $tpl->notes = $this->_('Zum Beispiel: gericht'); 83 | // $tpl->placeholder = 'gericht'; 84 | $tpl->required = true; 85 | $tpl->columnWidth = 33; 86 | $wrapper->add($tpl); 87 | 88 | // Datumsfeld ==================== 89 | $dte = $this->modules->InputfieldText; 90 | $dte->name = 'date'; 91 | $dte->label = $this->_('Datumsfeld'); 92 | $dte->value = $this->date; 93 | 94 | $dte->description = $this->_('Datumsfeld'); 95 | $dte->notes = $this->_('Zum Beispiel: gericht'); 96 | // $dte->placeholder = 'gericht'; 97 | $dte->required = true; 98 | $dte->columnWidth = 33; 99 | $wrapper->add($dte); 100 | 101 | // Kritische Menge ==================== 102 | $cra = $this->modules->InputfieldInteger; 103 | $cra->name = 'criticalamount'; 104 | $cra->label = $this->_('Kritische Menge'); 105 | $cra->value = $this->criticalamount; 106 | 107 | $cra->description = $this->_('Kritische Menge'); 108 | $cra->notes = $this->_('5 oder 15, Hauptsache eine Ganzzahl'); 109 | // $cra->placeholder = '5'; 110 | $cra->required = true; 111 | $cra->columnWidth = 34; 112 | $wrapper->add($cra); 113 | 114 | // Betreff ==================== 115 | $sbj = $this->modules->InputfieldText; 116 | $sbj->name = 'subject'; 117 | $sbj->label = $this->_('E-Mail Betreff'); 118 | $sbj->value = $this->subject; 119 | 120 | $sbj->description = $this->_('Betreff der E-Mail.'); 121 | $sbj->notes = $this->_('Beispiel: [Bestandswarnung] Nicht mehr viele Mittagstischangebote'); 122 | $sbj->placeholder = '[Bestandswarnung] Nicht mehr viele Mittagstischangebote'; 123 | $sbj->required = true; 124 | $sbj->columnWidth = 33; 125 | $wrapper->add($sbj); 126 | 127 | // Empfänger ==================== 128 | $rcv = $this->modules->InputfieldText; 129 | $rcv->name = 'receiver'; 130 | $rcv->label = $this->_('E-Mail Empfänger'); 131 | $rcv->value = $this->receiver; 132 | 133 | $rcv->description = $this->_('E-Mail Adresse des Empfängers.'); 134 | $rcv->notes = $this->_('Beispiel: to@' . wire('config')->httpHost); 135 | $rcv->placeholder = 'to@' . wire('config')->httpHost; 136 | $rcv->required = true; 137 | $rcv->columnWidth = 33; 138 | $wrapper->add($rcv); 139 | 140 | // Absender ==================== 141 | $snd = $this->modules->InputfieldText; 142 | $snd->name = 'sender'; 143 | $snd->label = $this->_('E-Mail Absender'); 144 | $snd->value = $this->sender; 145 | 146 | $snd->description = $this->_('E-Mail Adresse des Empfängers.'); 147 | $snd->notes = $this->_('Beispiel: from@' . wire('config')->httpHost); 148 | $snd->placeholder = 'from@' . wire('config')->httpHost; 149 | $snd->required = true; 150 | $snd->columnWidth = 34; 151 | $wrapper->add($snd); 152 | 153 | // Text ==================== 154 | $txt = $this->modules->InputfieldTextarea; 155 | $txt->name = 'text'; 156 | $txt->label = $this->_('E-Mail Text'); 157 | $txt->value = $this->text; 158 | 159 | $txt->description = $this->_('E-Mail Text mit weiteren Informationen oder Anmerkungen.'); 160 | $txt->notes = $this->_('Beispiel: Es sind nur noch wenige Mittagstischangebote vorhanden. Bitte überprüfen.'); 161 | // $txt->placeholder = '[Bestandswarnung] Nicht mehr viele Mittagstischangebote'; 162 | $txt->required = false; 163 | $txt->columnWidth = 100; 164 | $wrapper->add($txt); 165 | 166 | // Signature ==================== 167 | $sig = $this->modules->InputfieldTextarea; 168 | $sig->name = 'signature'; 169 | $sig->label = $this->_('E-Mail Signatur'); 170 | $sig->value = $this->signature; 171 | 172 | // $sig->description = $this->_('E-Mail Text mit weiteren Informationen oder Anmerkungen.'); 173 | // $sig->notes = $this->_('Beispiel: Es sind nur noch wenige Mittagstischangebote vorhanden. Bitte überprüfen.'); 174 | // $sig->placeholder = '[Bestandswarnung] Nicht mehr viele Mittagstischangebote'; 175 | $sig->required = false; 176 | $sig->columnWidth = 100; 177 | $wrapper->add($sig); 178 | 179 | return $wrapper; 180 | 181 | } 182 | 183 | }; 184 | -------------------------------------------------------------------------------- /backup-full-local/Snippets/_functions.php: -------------------------------------------------------------------------------- 1 | save('debug', '_functions.php'); 4 | 5 | function listingKurseEnsembles($p, $o) { 6 | return join(' und ', array_filter(array_merge(array(join(', ', array_slice(wire('pages')->get("id=$p")->$o->explode('title'), 0, -1))), array_slice(wire('pages')->get("id=$p")->$o->explode('title'), -1)), 'strlen')); 7 | }; 8 | 9 | function dozentin($p) { 10 | return (wire('pages')->get("id=$p")->anrede == '1') ? 'Dozentin' : 'Dozent'; 11 | } 12 | 13 | function ersie($p) { 14 | return (wire('pages')->get("id=$p")->anrede == '1') ? 'Sie' : 'Er'; 15 | } 16 | 17 | function generateSeoTitle($p, $t) { 18 | 19 | $pages = wire('pages'); 20 | $page = $pages->get("id=$p"); 21 | 22 | $ersie = ersie($p); 23 | $dozentin = dozentin($p); 24 | $kurse = listingKurseEnsembles($p, 'kurs'); 25 | $ensembles = listingKurseEnsembles($p, 'ensemble'); 26 | 27 | // VORNAME NACHNAME ist DOZENT/IN für INSTRUMEKURSE an der Musikschule Neumünster. 28 | // echo $page->title . " ist " . $dozentin . " für " . $kurse . "."; 29 | 30 | if($t == "dozent") { 31 | echo "{$page->title} ist {$dozentin} für {$kurse}. {$ersie}"; 32 | } 33 | 34 | }; 35 | 36 | //
37 | // if($page->template == "dozent") { generateSeoTitle($page->id, $page->template->name); }; 38 | //
39 | 40 | 41 | 42 | 43 | // wire('log')->save('debug', '_init.php'); 44 | 45 | 46 | // Globale Funktionen 47 | //include_once('./_functions.php'); 48 | 49 | function generateSeoTitle($p) { 50 | 51 | $pages = wire('pages'); 52 | $page = $pages->get("id=$p"); 53 | 54 | // ab hier für Dozenten-Seiten 55 | if($page->template->name == 'dozent') { 56 | 57 | // sind Instrumente und Kurse hinterlegt? 58 | if(count($page->kurs) > 0) { 59 | 60 | $pt = $page->title; 61 | $ps = ($page->anrede == '1') ? 'Dozentin' : 'Dozent'; 62 | $pk = $page->kurs->explode('title'); // ->implode(', ', 'title'); 63 | 64 | $pk2 = join(' und ', array_filter(array_merge(array(join(', ', array_slice($pk, 0, -1))), array_slice($pk, -1)), 'strlen')); 65 | $pagetitle = "{$pt} - {$ps} für {$pk2} an der Musikschule Neumünster"; 66 | $gpd = "{$ps} {$pt} unterrichtet {$pk2} an der Musikschule Neumünster."; 67 | 68 | return $pagetitle; // = $gpt; 69 | //$pagedesc = $gpd; 70 | 71 | // sind Ensembles hinterlegt? 72 | } else if(count($page->ensemble) > 0) { 73 | 74 | $pt = $page->title; 75 | $ps = ($page->anrede == '1') ? 'Ensemble-Leiterin' : 'Ensemble-Leiter'; 76 | $pk = $page->ensemble->explode('title'); // ->implode(', ', 'title'); 77 | 78 | $pk2 = join(' und ', array_filter(array_merge(array(join(', ', array_slice($pk, 0, -1))), array_slice($pk, -1)), 'strlen')); 79 | $gpt = "{$pt} - {$ps} des Ensembles {$pk2} an der Musikschule Neumünster"; 80 | $gpd = "{$pt} - {$ps} des Ensembles {$pk2} an der Musikschule Neumünster"; 81 | 82 | return $pagetitle = $gpt; 83 | $pagedesc = $gpd; 84 | 85 | // keine Instrumente, Kurse oder Ensembles? 86 | } else { 87 | 88 | return $pagetitle = $page->get('headline|title'); 89 | $pagedesc = ""; 90 | 91 | }; 92 | 93 | // ab hier für die Dozenten-Übersicht 94 | } else if($page->template->name == 'dozenten') { 95 | 96 | $gpt = "Die {$dozentenCount} Dozentinnen und Dozenten der Musikschule Neumünster stellen sich vor"; 97 | $pagetitle = $gpt; 98 | $pagedesc = ""; 99 | 100 | // ab hier für Intrumenten- und Kurs-Seiten 101 | } else if($page->template->name == 'kurs') { 102 | 103 | if($page->instrumentkurs == "1") { 104 | 105 | $dc = (count($page->dozent) > 1) ? 'Dozenten' : 'Dozent'; 106 | $dcc = count($page->dozent); 107 | 108 | $gpt = "Musikunterricht {$page->title}: {$page->title} lernen in Neumünster ({$dcc} {$dc})"; 109 | 110 | // INSTRUMENT lernen (ANZAHL Dozenten) | Musikschule Neumünster 111 | $pagetitle = $gpt; 112 | $pagedesc = ""; 113 | 114 | } else { 115 | 116 | // INSTRUMENT lernen (ANZAHL Dozenten) | Musikschule Neumünster 117 | $dc = (count($page->dozent) > 1) ? 'Dozenten' : 'Dozent'; 118 | $dcc = count($page->dozent); 119 | 120 | $gpt = "Kurs für {$page->title} an der Musikschule Neumünster ({$dcc} {$dc})"; 121 | 122 | // INSTRUMENT lernen (ANZAHL Dozenten) | Musikschule Neumünster 123 | $pagetitle = $gpt; 124 | $pagedesc = ""; 125 | 126 | }; 127 | 128 | // ab hier für die Kurs/Instrumenten-Übersicht 129 | } else if($page->template->name == 'kurse') { 130 | 131 | $gpt = "Alle {$instrumentekurseCount} Instrumente und Kurse der Musikschule Neumünster"; 132 | $pagetitle = $gpt; 133 | $pagedesc = ""; 134 | 135 | // ab hier für die Ensemble-Übersicht 136 | } else if($page->template->name == 'ensembles') { 137 | 138 | $gpt = "Alle {$ensemblesCount} Ensembles der Musikschule Neumünster"; 139 | $pagetitle = $gpt; 140 | $pagedesc = ""; 141 | 142 | // ab hier für die Ensemble-Übersicht 143 | } else if($page->template->name == 'events') { 144 | 145 | $gpt = "Termine und Veranstaltungsempfehlungen der Musikschule Neumünster ({$eventsCount} Einträge)"; 146 | $pagetitle = $gpt; 147 | $pagedesc = ""; 148 | 149 | // ab hier für die Startseite 150 | } else if($page->template == 'home') { 151 | 152 | $gpt = "Musikschule Neumünster – {$dozentenCount} Dozenten, {$instrumentekurseCount} Instrumente, {$ensemblesCount} Ensembles"; 153 | 154 | echo $pagetitle = $gpt; 155 | $pagedesc = ""; 156 | 157 | } else { 158 | 159 | $pagetitle = $page->get('headline|title'); 160 | $pagedesc = ""; 161 | 162 | }; 163 | 164 | }; 165 | 166 | -------------------------------------------------------------------------------- /backup-full-local/Snippets/api-create-page.php: -------------------------------------------------------------------------------- 1 | setOutputFormatting(false); 7 | $newpage->template = 'your_template'; // example template 8 | $newpage->parent = wire('pages')->get('/parent/'); // example parent 9 | $newpage->name = "foo"; // example name 10 | $newpage->title = "My API-generated new PW page"; 11 | $newpage->fieldname = "my field value"; // example field with example value 12 | $newpage->save(); -------------------------------------------------------------------------------- /backup-full-local/Snippets/api-create-shortlinks-for-jumplinks-module.php: -------------------------------------------------------------------------------- 1 | find('template=your_template') as $yourpages) 7 | { 8 | 9 | $from = "out/".$yourpages->id; 10 | $to = $yourpages->www; 11 | 12 | $yourpages->setOutputFormatting(false); 13 | $yourpages->shorturl = "/".$from; 14 | $yourpages->save(); 15 | 16 | $this->modules->ProcessJumplinks->add($from, $to); 17 | 18 | }; -------------------------------------------------------------------------------- /backup-full-local/Snippets/api-formbuilder-entries.php: -------------------------------------------------------------------------------- 1 | get('your-form-name'); 4 | $entries = $form->entries()->find("created<=" . strtotime("-3 MONTH")); 5 | // $entries now contains all your older-than-3-months entries -------------------------------------------------------------------------------- /backup-full-local/Snippets/api-move-field-data-to-another-field.php: -------------------------------------------------------------------------------- 1 | find('template=your_template') as $yourpages) 7 | { 8 | 9 | $old = $yourpages->oldfield; 10 | $oldcleaned = $sanitizer->text($old); 11 | 12 | $yourpages->setOutputFormatting(false); 13 | $yourpages->newfield = $oldcleaned; 14 | $yourpages->save(); 15 | 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /backup-full-local/Snippets/api-page-subselect.php: -------------------------------------------------------------------------------- 1 | find("template=product, amz_price>0") as $watch) { 5 | $brands->add($watch->brand); 6 | }; -------------------------------------------------------------------------------- /backup-full-local/Snippets/api-reset-password.php: -------------------------------------------------------------------------------- 1 | get('admin'); // or whatever your username is 4 | $u->of(false); 5 | $u->pass = 'your-new-password'; 6 | $u->save(); 7 | 8 | -------------------------------------------------------------------------------- /backup-full-local/Snippets/api-set-value-by-language.php: -------------------------------------------------------------------------------- 1 | language = $languages->get('en'); 6 | $page->setAndSave('title', 'My title'); 7 | 8 | $user->language = $languages->get('de'); 9 | $page->setAndSave('title', 'Mein Titel'); 10 | 11 | // Option 2 12 | 13 | $page->of(false); 14 | $page->title->setLanguageValue($languages->get('en'), 'My title'); 15 | $page->title->setLanguageValue($languages->get('de'), 'Mein Titel'); 16 | $page->save(); 17 | 18 | -------------------------------------------------------------------------------- /backup-full-local/Snippets/api-update-created-date.php: -------------------------------------------------------------------------------- 1 | created = $timestamp 6 | $page->save(array('quiet' => true)) -------------------------------------------------------------------------------- /backup-full-local/Snippets/ckeditor-text-align.txt: -------------------------------------------------------------------------------- 1 | JustifyLeft, JustifyCenter, JustifyRight, JustifyBlock -------------------------------------------------------------------------------- /backup-full-local/Snippets/config-serial-key-procache.txt: -------------------------------------------------------------------------------- 1 | Edit your /site/templates/admin.php file and paste in the following after the opening getModuleConfigData('ProCache'); 4 | $data['licenseKey'] = 'PASTE-YOUR-KEY-HERE'; 5 | $modules->saveModuleConfigData('ProCache', $data); -------------------------------------------------------------------------------- /backup-full-local/Snippets/config-session-allow.php: -------------------------------------------------------------------------------- 1 | sessionAllow = function($session) { 6 | 7 | // if there is a session cookie, chances are user is logged in 8 | if($session->hasCookie()) { 9 | return true; 10 | } 11 | 12 | // if requested URL is an admin URL, allow session 13 | if(strpos($_SERVER['REQUEST_URI'], $session->config->urls->admin) === 0) { 14 | return true; 15 | } 16 | 17 | // otherwise disallow session 18 | return false; 19 | 20 | }; -------------------------------------------------------------------------------- /backup-full-local/Snippets/delete-form-builder-entries-after-time.php: -------------------------------------------------------------------------------- 1 | addHookAfter('LazyCron::every30Seconds', function (HookEvent $e) { 4 | 5 | $age = (time() - (14 * 86400)); 6 | $form = $e->forms->get("contact"); 7 | $entriesOld = $form->entries()->find("created<$age"); 8 | 9 | foreach($entriesOld as $entry) { 10 | $form->entries()->delete($entry[id]); 11 | $e->wire('log')->save('archiv', 'Kontaktanfrage gelöscht ' . $entry[created]); 12 | }; 13 | 14 | }); -------------------------------------------------------------------------------- /backup-full-local/Snippets/form-refocus.js: -------------------------------------------------------------------------------- 1 | // scroll to form submitted message 2 | jQuery(document).ready(function($) { 3 | var f = $('#FormBuilderSubmitted'); 4 | if(!f.length) return; 5 | var y = f.offset().top; 6 | $('body').animate( { scrollTop: y }, 'slow'); 7 | }); -------------------------------------------------------------------------------- /backup-full-local/Snippets/google-analytics-opt-out.js: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /backup-full-local/Snippets/init.php: -------------------------------------------------------------------------------- 1 | get('/'); 4 | 5 | $settings = $pages->get('template=settings'); 6 | 7 | $title = $page->get('seotitle|headline|title'); 8 | 9 | $headline = $page->get('headline|title'); 10 | 11 | $robots = $page->get('seorobots')->value; 12 | 13 | $desc = $page->get('seodesc'); 14 | 15 | // https://github.com/dragan1700/pw/blob/master/init.inc 16 | 17 | $lang = $user->language->name; // e.g. "default" or "en" 18 | 19 | if($lang == 'default') { 20 | $htmlLang = 'de'; 21 | $homeURL = $config->urls->root; 22 | $addtocart = "Zur Liste hinzufügen"; 23 | } 24 | if($lang == 'en') { 25 | $htmlLang = $lang; 26 | $homeURL = $config->urls->root . 'en/'; 27 | $addtocart = "Add to list"; 28 | } -------------------------------------------------------------------------------- /backup-full-local/Snippets/mailer.php: -------------------------------------------------------------------------------- 1 | "; 5 | $formdata = json_decode($formdata); 6 | foreach($formdata as $field) { 7 | switch($field->name) { 8 | case 'email': 9 | case 'name': 10 | case 'tel': 11 | $html .= "

" . $field->name . ": " . $sanitizer->text($field->value) . "

"; 12 | if($field->name == 'email') $email = $sanitizer->email($field->value); 13 | break; 14 | case 'message': 15 | $html .= "

" . $field->name . ":
---
" . nl2br($sanitizer->textarea($field->value)) . "
---

"; 16 | //${$field->name} = $sanitizer->textarea($field->value); 17 | break; 18 | case 'mail': 19 | // honeypot 20 | if($field->value) $subject = 'SPAM: '.$subject; 21 | break; 22 | } 23 | } 24 | $html .= ""; 25 | 26 | $mail = wireMail(); 27 | $mail->to('your@mail.com')->from($email); 28 | $mail->subject($subject); 29 | $mail->bodyHTML($html); 30 | if($mail->send()) { ?> 31 |
32 |

Thank you!

33 |
34 | 37 |
38 |

Error!

39 |
40 | template = 'maillogitem'; 46 | $p->parent = 1234; 47 | $p->title = date('d.m.Y') . ' - ' . $email; 48 | $p->body = $html; 49 | $p->save(); -------------------------------------------------------------------------------- /backup-full-local/Snippets/module-default-language.php: -------------------------------------------------------------------------------- 1 | 'LanguageDefault', 21 | 'version' => 1, 22 | 'summary' => 'A work around to changing the default language.', 23 | 'href' => 'https://processwire.com/talk/topic/9322-change-default-language-for-homepage/?p=89717', 24 | 'singular' => true, 25 | 'autoload' => true, 26 | ); 27 | } 28 | 29 | /** 30 | * Initialize the module 31 | * 32 | * ProcessWire calls this when the module is loaded. For 'autoload' modules, this will be called 33 | * when ProcessWire's API is ready. As a result, this is a good place to attach hooks. 34 | * 35 | */ 36 | public function init() { 37 | $this->session->addHookBefore('redirect', $this, 'setDefaultLanguage'); 38 | } 39 | 40 | public function setDefaultLanguage($event) { 41 | if ($this->page->id == 1 && $event->arguments(0) == $this->page->localUrl('default')) { 42 | $event->arguments(0, $this->page->localUrl('de')); 43 | } 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /backup-full-local/Snippets/module-page-edit-only-by-creator.php: -------------------------------------------------------------------------------- 1 | 'Edit Yours Only', 11 | 'version' => 1, 12 | 'summary' => 'Custom module to allow users only to edit pages they created. Applies to role \'standard\'', 13 | 'author' => 'Christina Holly, TinaciousDesign.com', 14 | 'singular' => true, 15 | 'autoload' => true, 16 | ); 17 | } 18 | 19 | public function init() { 20 | if($this->user->hasRole("standard")) $this->addHookAfter("Page::editable", $this, 'editable'); 21 | } 22 | 23 | public function editable(HookEvent $event) { 24 | // abort if no access 25 | if(!$event->return) return; 26 | $page = $event->object; 27 | // criteria required in order to edit 28 | if($this->user->name !== $page->createdUser->name) $event->return = false; 29 | } 30 | } -------------------------------------------------------------------------------- /backup-full-local/Snippets/pages2pdf-custom.php: -------------------------------------------------------------------------------- 1 | template->name; 6 | $tplRender = "dish.php"; 7 | 8 | $pdf = $modules->get('WirePDF'); 9 | $pdf->markupMain = $config->paths->templates . "pages2pdf/$tplRender"; 10 | 11 | $pdf->save($config->paths->templates . 'pdfs/' . $time . '-' . $tplPage . '-' . $page->name . '.pdf'); 12 | 13 | $modules->get('Pages2Pdf')->render(); 14 | -------------------------------------------------------------------------------- /backup-full-local/Snippets/paypal-payment.txt: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | 6 | 7 | addHookAfter('LazyCron::every30Minutes', function (HookEvent $e) { 6 | 7 | $closables = $e->pages->find("closed=0, enddatesetAndSave('closed', 1); 9 | 10 | $openables = $e->pages->find("closed=1, startdatenow"); 11 | foreach ($openables as $p) $p->setAndSave('closed', 0); 12 | 13 | }); -------------------------------------------------------------------------------- /backup-full-local/Snippets/ready-formbuilder-renderReady.php: -------------------------------------------------------------------------------- 1 | addHookBefore('FormBuilderProcessor::renderReady', function($event) { 4 | $form = $event->arguments(0); 5 | if($form->name != 'YOUR_FORM_NAME') return; 6 | $user = $event->wire('user'); 7 | $field = $form->getChildByName('biography'); 8 | $field->label = "Hi $user->name please tell us about yourself"; 9 | }); 10 | 11 | 12 | $forms->addHookBefore('FormBuilderProcessor::emailForm', function($event) { 13 | $processor = $event->object; 14 | $formData = $event->arguments(1); // associative array of form data, if needed 15 | $subjectField = $formData->getChildByName('your_field')->value; 16 | $processor->emailSubject = $processor->emailSubject . " (" . $subjectField . ")"; 17 | }); -------------------------------------------------------------------------------- /backup-full-local/Snippets/ready-google-maps-adress-lat-long.php: -------------------------------------------------------------------------------- 1 | addHookBefore('saveReady', function($event) { 4 | 5 | $page = $event->arguments[0]; 6 | 7 | if($page->template == 'location') { 8 | 9 | if ( empty($page->street) || empty($page->city) ) { 10 | return; 11 | } 12 | 13 | // Get address 14 | $address = $page->street . ', ' . $page->zip . ' ' . $page->city . ', ' . $page->country; 15 | 16 | // Get JSON results from this request 17 | $geo = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($address) . '&sensor=false'); 18 | 19 | $geo = json_decode($geo, true); 20 | 21 | if ($geo['status'] == 'OK') { 22 | $page->latlong->lat = $geo['results'][0]['geometry']['location']['lat']; 23 | $page->latlong->long = $geo['results'][0]['geometry']['location']['lng']; 24 | $this->message('Saved for: ' . $geo['results'][0]['formatted_address']); 25 | } else { 26 | $this->error('Error msg...'); 27 | } 28 | } 29 | }); -------------------------------------------------------------------------------- /backup-full-local/Snippets/ready-log-outgoing-emails.php: -------------------------------------------------------------------------------- 1 | addHookAfter('WireMail::send', function($event) { 7 | $mail = $event->object; 8 | $event->wire('log')->save('sent-mail', 9 | "SENT ($event->return of " . count($mail->to) . "), " . 10 | "SUBJECT ($mail->subject), " . 11 | "TO (" . implode(", ", $mail->to) . "), " . 12 | "FROM ($mail->from)" 13 | ); 14 | }); 15 | 16 | 17 | 18 | addHookAfter('LazyCron::everyDay', function (HookEvent $e) { 23 | 24 | $now = date('d.m.Y'); 25 | $closables = $e->pages->find("template=event, date<$now"); 26 | 27 | wire('log')->save('archive', "message"); 28 | 29 | foreach ($closables as $p) { 30 | $p->setOutputFormatting(false); 31 | $p->addStatus(Page::statusUnpublished); 32 | $p->save(); 33 | 34 | }; 35 | 36 | }); -------------------------------------------------------------------------------- /backup-full-local/Snippets/ready-loginregister-mailchimp.php: -------------------------------------------------------------------------------- 1 | addHookAfter('LoginRegister::processRegisterForm', function($event) { 4 | $form = $event->arguments[0]; 5 | foreach($form->getAll() as $f) { 6 | $name = $f->attr('name'); 7 | if(strpos($name, 'register_') !== 0) continue; 8 | if($name == 'register_subscribe_newsletter' && wire('input')->post->register_subscribe_newsletter == 1) { 9 | $mc = wire('modules')->get("SubscribeToMailchimp"); 10 | $email = wire('input')->post->register_email; // Do not forget to saninitize the email field 11 | $mc->subscribe($email); 12 | } 13 | } 14 | }); -------------------------------------------------------------------------------- /backup-full-local/Snippets/ready-redirect-to-formbuilder-page.php: -------------------------------------------------------------------------------- 1 | addHookAfter('FormBuilderProcessor::savePage', function($event) { 7 | $processor = $event->object; 8 | if($processor->formName != 'your_form_name') return; 9 | $page = $event->return; 10 | wire('session')->set('savePage', $page->id); 11 | }); 12 | 13 | wire()->addHookAfter('FormBuilderProcessor::render', function($event) { 14 | $processor = $event->object; 15 | if($processor->formName != 'your_form_name' || !$processor->isSubmitted()) return; 16 | $id = wire('session')->get('savePage'); 17 | if(!$id) return; 18 | $page = wire('pages')->get($id); 19 | if($page->id) $event->return = ""; 20 | }); -------------------------------------------------------------------------------- /backup-full-local/Snippets/ready-set-session-variable.php: -------------------------------------------------------------------------------- 1 | addHookAfter('FormBuilderProcessor::savePage', function($event) { 7 | $processor = $event->object; 8 | if($processor->formName != 'your_form_name') return; 9 | $page = $event->return; 10 | wire('session')->set('savePage', $page->id); 11 | }); -------------------------------------------------------------------------------- /backup-full-local/Snippets/ready-sort-templates-by-label.php: -------------------------------------------------------------------------------- 1 | addHookAfter('ProcessPageAdd::getAllowedTemplates', function(HookEvent $event) { 4 | // Get keys (IDs) of returned templates array 5 | $template_ids = array_keys($event->return); 6 | // Implode for use in a selector string 7 | $template_ids_str = implode('|', $template_ids); 8 | // Get TemplatesArray of those templates, sorted by label 9 | $templates = $this->templates->find("id=$template_ids_str, sort=label"); 10 | // Convert to plain array and return 11 | $event->return = $templates->getArray(); 12 | }); -------------------------------------------------------------------------------- /backup-full-local/Snippets/ready-submit-to-mailchimp-from-formbuilder-entries.php: -------------------------------------------------------------------------------- 1 | get("mailchimp")->entries()->find('sort=id'); 5 | 6 | foreach($entries as $entry){ 7 | $mc = $modules->get("SubscribeToMailchimp"); 8 | 9 | $mc_mail = $entry['e_mail']; 10 | $mc_fname = $entry['vorname']; 11 | 12 | $subscriber = [ 13 | 'FNAME' => $mc_fname, 14 | //'SEO' => $input->post->seo, 15 | ]; 16 | 17 | $mc->subscribe($mc_mail, $subscriber, '40f97f3378'); 18 | 19 | wire('log')->save('mailchimp', $mc_mail . " - " . $mc_fname ); 20 | 21 | } -------------------------------------------------------------------------------- /backup-full-local/Snippets/ready-submit-to-mailchimp.php: -------------------------------------------------------------------------------- 1 | addHookBefore("FormBuilderProcessor::processInputDone", function($event) { 9 | 10 | $form = $event->arguments(0); 11 | 12 | if($form->name == 'mailchimp') { 13 | 14 | $mc_EMAIL = $form->getChildByName('e_mail')->value; 15 | $mc_FNAME = $form->getChildByName('vorname')->value; 16 | $mc_SEO = $form->getChildByName('seo')->value; 17 | 18 | 19 | 20 | $mc = wire('modules')->get("SubscribeToMailchimp"); 21 | 22 | $subscriber = [ 23 | 'FNAME' => $mc_FNAME, 24 | 'SEO' => $mc_SEO 25 | ]; 26 | 27 | $mc->subscribe($mc_EMAIL, $subscriber); 28 | 29 | wire('log')->save('mailchimp', $mc_EMAIL ); 30 | 31 | 32 | } 33 | 34 | }); 35 | 36 | -------------------------------------------------------------------------------- /backup-full-local/Snippets/ready-validate-formbuilder-fields.php: -------------------------------------------------------------------------------- 1 | addHookBefore("FormBuilderProcessor::processInputDone", function($event) { 7 | 8 | $form = $event->arguments(0); 9 | 10 | if($form->name == 'your_form_name') { 11 | 12 | $field1 = $form->getChildByName('your_first_field'); 13 | $field2 = $form->getChildByName('your_second_field'); 14 | 15 | $val1 = $field1->value; 16 | $val2 = $field2->value; 17 | 18 | // check, validate, do whatever you want 19 | if($val1 > $val2) { 20 | $field1->error("Error message field1."); 21 | $field2->error("Error message field2."); 22 | } 23 | 24 | } 25 | 26 | }); 27 | 28 | 29 | -------------------------------------------------------------------------------- /backup-full-local/Snippets/snippet-check-ip-country.php: -------------------------------------------------------------------------------- 1 | "; 29 | 30 | $http = new WireHttp(); 31 | $url = "http://ipinfo.io/{$user_ip}/country"; 32 | $response = $http->get($url, ['country' => '']); 33 | 34 | 35 | echo "Country: " . $response . "
"; 36 | echo "Successful response: " . $sanitizer->entities($response) . "
"; 37 | 38 | ?> -------------------------------------------------------------------------------- /backup-full-local/Snippets/template-breadcrumb.php: -------------------------------------------------------------------------------- 1 |
    2 | parents; 5 | //$parentsCount = count($parents); 6 | foreach($parents as $parent): ?> 7 |
  1. 8 | 9 | title; ?> 10 | 11 |
  2. 12 | 13 |
  3. 14 | 15 | title; ?> 16 | 17 |
  4. 18 |
-------------------------------------------------------------------------------- /backup-full-local/dnt.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /hannacode/README.md: -------------------------------------------------------------------------------- 1 | # HannaCode 2 | 3 | ## Installation 4 | 5 | You can either create your very own HannaCode with the provided PHP code and make it your own and customize it or you can just import the provided import code. 6 | -------------------------------------------------------------------------------- /hannacode/hannacode-embed-rumble-privacywire.php: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | 14 |
15 | 16 | -------------------------------------------------------------------------------- /hannacode/hannacode-embed-rumble.php: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | 14 |
15 | 18 | -------------------------------------------------------------------------------- /hannacode/hannacode-table-of-contents-jumplinks-demo.php: -------------------------------------------------------------------------------- 1 | 2 | $v) { 14 | $for[$k] = trim($v); 15 | } 16 | 17 | $for = implode('|', $for); 18 | $anchors = array(); 19 | $value = $hanna->value; 20 | 21 | if (preg_match_all('{<(' . $for . ')[^>]*>(.+?)}i', $value, $matches)) { 22 | foreach ($matches[1] as $key => $tag) { 23 | $text = $matches[2][$key]; 24 | $anchor = $sanitizer->pageName($text, true); 25 | $anchors[$anchor] = $text; 26 | $full = $matches[0][$key]; 27 | $value = str_replace($full, "$full", $value); 28 | } 29 | $hanna->value = $value; 30 | } 31 | 32 | if (count($anchors)) { 33 | echo ""; 38 | } else { 39 | echo ''; 40 | } 41 | ?> 42 | -------------------------------------------------------------------------------- /hooks-ready-php/README.md: -------------------------------------------------------------------------------- 1 | # ProcessWire ready.php Hooks -------------------------------------------------------------------------------- /hooks-ready-php/ready-automate-cron-site-check.php: -------------------------------------------------------------------------------- 1 | addHookAfter('LazyCron::every30Minutes', function (HookEvent $e) { 7 | 8 | $closables = $e->pages->find("closed=0, enddatesetAndSave('closed', 1); 10 | 11 | $openables = $e->pages->find("closed=1, startdatenow"); 12 | foreach ($openables as $p) $p->setAndSave('closed', 0); 13 | 14 | }); -------------------------------------------------------------------------------- /hooks-ready-php/ready-clean-youtube-url.php: -------------------------------------------------------------------------------- 1 | addHookBefore('saveReady', function($event) { 5 | 6 | // makes it easier 7 | $page = $event->arguments[0]; 8 | 9 | // Get your templates 10 | if($page->template == 'templateOne' || $page->template == 'templateTwo') { 11 | 12 | // set the filter 13 | $removeThis = array("https://youtu.be/", "https://www.youtube.com/watch?v="); 14 | 15 | // get your YouTube field 16 | $cleanUpThis = $page->videoYouTube; 17 | 18 | // clean it up 19 | $page->videoYouTube = str_replace($removeThis, "", $cleanUpThis); 20 | 21 | // saved and ready to use 22 | 23 | } 24 | }); 25 | 26 | 27 | ?> 28 | -------------------------------------------------------------------------------- /hooks-ready-php/ready-formbuilder-newsletter-subscription.php: -------------------------------------------------------------------------------- 1 | addHookAfter('FormBuilderProcessor::formSubmitSuccess', function ($event) { 12 | // $listId = 1; // ID of the ProMailer list you want to add them to 13 | $confirmed = false; // set to false if you want to send them confirm email 14 | 15 | $form = $event->arguments(0); // InputfieldForm 16 | if ($form->name != 'newsletter') { 17 | return; 18 | } 19 | 20 | // need an email to add to ProMailer list 21 | $email = $form->getChildByName('e_mail')->val(); 22 | if (!$email) { 23 | return; 24 | } 25 | 26 | // we need a list 27 | $listId = $form->getChildByName('list_id')->val(); 28 | if (!$listId) { 29 | return; 30 | } 31 | 32 | // custom data 33 | $data = [ 34 | // any custom fields you are storing in ProMailer subscriber 35 | // 'first_name' => $form->getChildByName('first_name')->val(), 36 | // 'topics' => $form->getChildByName('topics')->val(), 37 | 'privacy' => $form->getChildByName('privacy')->val(), 38 | // 'einzugsbereich' => $form->getChildByName('einzugsbereich')->val(), 39 | ]; 40 | 41 | $promailer = $event->modules->getModule('ProMailer'); 42 | 43 | wire()->log->save('newsletterdebug', $email); 44 | 45 | foreach ($listId as $li) { 46 | wire()->log->save('newsletterdebug', $li); 47 | // $subscriber = $promailer->subscribers->add($email, $li, $confirmed); 48 | $subscriber = $promailer->subscribers->add($email, $li, $confirmed, $data); 49 | 50 | if (!$subscriber) { 51 | // failed to add subscriber 52 | } elseif (is_int($subscriber)) { 53 | // email is already subscribed to this list 54 | } else { 55 | // success: $subscriber is a ProMailerSubscriber object that was 56 | // either just added or has not yet clicked link in confirm email 57 | if (!$confirmed) { 58 | // send them a confirmation/opt-in email 59 | 60 | // optionally make the email body as you want it 61 | $bodyText = "Bitte bestätigen Sie Ihre Anmeldung zum Newsletter {list}:\n\n{url}\n\nSchwimmschule Wendel\nHauke Wendel\nGablonzer Weg 1\n25524 Itzehoe\n\nTelefon: 04821 / 1489744\nE-Mail: info@schwimmschule-wendel.de"; 62 | $bodyHTML = "

Nur noch einen Klick zur Bestätigung Ihrer Anmeldung zum {list} Newsletter.

Schwimmschule Wendel
Hauke Wendel
Gablonzer Weg 1
25524 Itzehoe

Telefon: 04821 / 1489744
E-Mail: info@schwimmschule-wendel.de

"; 63 | 64 | // <<< _OUT 65 | // 66 | //

Nur noch einen Klick zur Bestätigung Ihrer Anmeldung zum {list} Newsletter.

67 | //

Schwimmschule Wendel
Hauke Wendel
Gablonzer Weg 1
25524 Itzehoe

Telefon: 04821 / 1489744
E-Mail: info@schwimmschule-wendel.de

68 | // 69 | // _OUT; 70 | 71 | // https://processwire.com/talk/topic/21478-how-can-i-send-a-second-confirmation-mail-when-user-has-opted-in/?do=findComment&comment=185472 72 | $promailer->subscribers->sendConfirmEmail($subscriber, [ 73 | 'subject' => '{list} - Newsletteranmeldung bestätigen', 74 | 'body' => $bodyText, 75 | 'bodyHTML' => $bodyHTML, 76 | ]); 77 | } 78 | } 79 | } 80 | }); 81 | -------------------------------------------------------------------------------- /hooks-ready-php/ready-google-maps-adress-lat-long.php: -------------------------------------------------------------------------------- 1 | addHookBefore('saveReady', function($event) { 8 | 9 | $page = $event->arguments[0]; 10 | 11 | if($page->template == 'location') { 12 | 13 | if ( empty($page->street) || empty($page->city) ) { 14 | return; 15 | } 16 | 17 | // Get address 18 | $address = $page->street . ', ' . $page->zip . ' ' . $page->city . ', ' . $page->country; 19 | 20 | // Get JSON results from this request 21 | $geo = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($address) . '&sensor=false'); 22 | 23 | $geo = json_decode($geo, true); 24 | 25 | if ($geo['status'] == 'OK') { 26 | $page->latlong->lat = $geo['results'][0]['geometry']['location']['lat']; 27 | $page->latlong->long = $geo['results'][0]['geometry']['location']['lng']; 28 | $this->message('Saved for: ' . $geo['results'][0]['formatted_address']); 29 | } else { 30 | $this->error('Error msg...'); 31 | } 32 | } 33 | }); -------------------------------------------------------------------------------- /hooks-ready-php/ready-log-outgoing-emails.php: -------------------------------------------------------------------------------- 1 | addHookAfter('WireMail::send', function($event) { 7 | 8 | $mail = $event->object; 9 | 10 | $event->wire('log')->save('sent-mail', 11 | 12 | "SENT ($event->return of " . count($mail->to) . "), " . 13 | 14 | "SUBJECT ($mail->subject), " . 15 | 16 | "TO (" . implode(", ", $mail->to) . "), " . 17 | 18 | "FROM ($mail->from)" 19 | 20 | ); 21 | 22 | }); 23 | -------------------------------------------------------------------------------- /hooks-ready-php/ready-set-session-variable.php: -------------------------------------------------------------------------------- 1 | addHookAfter('FormBuilderProcessor::savePage', function($event) { 7 | $processor = $event->object; 8 | if($processor->formName != 'yourFormName') return; 9 | $page = $event->return; 10 | wire('session')->set('savePage', $page->id); 11 | }); -------------------------------------------------------------------------------- /hooks-ready-php/ready-sort-templates-by-label.php: -------------------------------------------------------------------------------- 1 | addHookAfter('ProcessPageAdd::getAllowedTemplates', function(HookEvent $event) { 8 | 9 | // Get keys (IDs) of returned templates array 10 | $template_ids = array_keys($event->return); 11 | 12 | // Implode for use in a selector string 13 | $template_ids_str = implode('|', $template_ids); 14 | 15 | // Get TemplatesArray of those templates, sorted by label 16 | $templates = $this->templates->find("id=$template_ids_str, sort=label"); 17 | 18 | // Convert to plain array and return 19 | $event->return = $templates->getArray(); 20 | 21 | }); -------------------------------------------------------------------------------- /hooks/README.md: -------------------------------------------------------------------------------- 1 | # copypaste.pw / Hooks 2 | 3 | [https://copypaste.pw/hooks/](https://copypaste.pw/hooks/) 4 | -------------------------------------------------------------------------------- /hooks/hook-ready-formbuilder-from.php: -------------------------------------------------------------------------------- 1 | addHookBefore('FormBuilderProcessor::emailForm', function($event) { 7 | 8 | $form = $event->object; 9 | $formData = $event->arguments(0); 10 | 11 | if($formData->name == "yourFormNameHere") { 12 | $fakefrom = $formData->getChildByName('yourEmailFieldHere')->value; 13 | // Sender 14 | $form->emailFrom = $fakefrom; 15 | // Reply-to 16 | $form->emailFrom2 = $fakefrom; 17 | } 18 | 19 | }); -------------------------------------------------------------------------------- /hooks/hook-ready-formbuilder-redirect-created-page.php: -------------------------------------------------------------------------------- 1 | addHookAfter('FormBuilderProcessor::savePage', function($event) { 7 | $processor = $event->object; 8 | if($processor->formName != 'your_form_name') return; 9 | $page = $event->return; 10 | wire('session')->set('savePage', $page->id); 11 | }); 12 | 13 | wire()->addHookAfter('FormBuilderProcessor::render', function($event) { 14 | $processor = $event->object; 15 | if($processor->formName != 'your_form_name' || !$processor->isSubmitted()) return; 16 | $id = wire('session')->get('savePage'); 17 | if(!$id) return; 18 | $page = wire('pages')->get($id); 19 | if($page->id) $event->return = ""; 20 | }); -------------------------------------------------------------------------------- /hooks/hook-ready-formbuilder-subject.php: -------------------------------------------------------------------------------- 1 | addHookBefore('FormBuilderProcessor::emailForm', function($event) { 7 | 8 | $form = $event->object; 9 | $formData = $event->arguments(0); 10 | 11 | if($formData->name == "yourFormNameHere") { 12 | $subjectField = $formData->getChildByName('yourSubjectField')->value; 13 | $form->emailSubject = $form->emailSubject . " (" . $subjectField . ")"; 14 | } 15 | 16 | }); -------------------------------------------------------------------------------- /hooks/hook-ready-formbuilder-submit-to-mailchimp.php: -------------------------------------------------------------------------------- 1 | addHookBefore("FormBuilderProcessor::processInputDone", function($event) { 10 | 11 | $form = $event->arguments(0); 12 | 13 | if($form->name == 'mailchimp') { 14 | 15 | $mc_EMAIL = $form->getChildByName('e_mail')->value; 16 | $mc_FNAME = $form->getChildByName('vorname')->value; 17 | 18 | $mc = wire('modules')->get("SubscribeToMailchimp"); 19 | 20 | $subscriber = [ 21 | 'FNAME' => $mc_FNAME 22 | ]; 23 | 24 | $mc->subscribe($mc_EMAIL, $subscriber); 25 | 26 | wire('log')->save('mailchimp', $mc_EMAIL ); 27 | 28 | } 29 | 30 | }); -------------------------------------------------------------------------------- /hooks/hook-ready-formbuilder-validate-fields.php: -------------------------------------------------------------------------------- 1 | addHookBefore("FormBuilderProcessor::processInputDone", function($event) { 7 | 8 | $form = $event->arguments(0); 9 | 10 | if($form->name == 'yourFormName') { 11 | 12 | $field1 = $form->getChildByName('your_first_field'); 13 | $field2 = $form->getChildByName('your_second_field'); 14 | 15 | $val1 = $field1->value; 16 | $val2 = $field2->value; 17 | 18 | // check, validate, do whatever you want 19 | if($val1 > $val2) { 20 | $field1->error("Error message field1."); 21 | $field2->error("Error message field2."); 22 | } 23 | 24 | } 25 | 26 | }); 27 | 28 | 29 | -------------------------------------------------------------------------------- /hooks/hook-ready-loginregister-to-mailchimp.php: -------------------------------------------------------------------------------- 1 | addHookAfter('LoginRegister::processRegisterForm', function($event) { 14 | 15 | $form = $event->arguments[0]; 16 | 17 | foreach($form->getAll() as $f) { 18 | 19 | $name = $f->attr('name'); 20 | 21 | if(strpos($name, 'register_') !== 0) continue; 22 | 23 | if($name == 'register_subscribe_newsletter' && wire('input')->post->register_subscribe_newsletter == 1) { 24 | 25 | $mc = wire('modules')->get("SubscribeToMailchimp"); 26 | 27 | $email = wire('input')->post->register_email; // Do not forget to saninitize the email field 28 | 29 | $mc->subscribe($email); 30 | 31 | } 32 | 33 | } 34 | 35 | }); -------------------------------------------------------------------------------- /ready-hook-on-demand-mirroring-web-files.php: -------------------------------------------------------------------------------- 1 | addHookAfter('Pagefile::url, Pagefile::filename', function ($event) { 9 | $config = $event->wire('config'); 10 | $file = $event->return; 11 | 12 | if ($event->method == 'url') { 13 | // convert url to disk path 14 | $file = $config->paths->root . substr($file, strlen($config->urls->root)); 15 | } 16 | 17 | if (!file_exists($file)) { 18 | // download file from source if it doesn't exist here 19 | $src = 'https://domain.com/site/assets/files/'; 20 | $url = str_replace($config->paths->files, $src, $file); 21 | $http = new WireHttp(); 22 | $http->download($url, $file); 23 | } 24 | }); 25 | --------------------------------------------------------------------------------