Changeset 3841458
- Timestamp:
- 12/03/2026 02:24:15 AM (less than one hour ago)
- Location:
- nori-for-elementor
- Files:
-
- 12 edited
- 1 copied
-
tags/0.25.0 (copied) (copied from nori-for-elementor/trunk )
-
tags/0.25.0/includes/class-abilities.php (modified) (2 diffs)
-
tags/0.25.0/includes/class-plugin.php (modified) (1 diff)
-
tags/0.25.0/includes/class-site-tools.php (modified) (4 diffs)
-
tags/0.25.0/nori-for-elementor.php (modified) (2 diffs)
-
tags/0.25.0/readme.txt (modified) (2 diffs)
-
tags/0.25.0/uninstall.php (modified) (1 diff)
-
trunk/includes/class-abilities.php (modified) (2 diffs)
-
trunk/includes/class-plugin.php (modified) (1 diff)
-
trunk/includes/class-site-tools.php (modified) (4 diffs)
-
trunk/nori-for-elementor.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
nori-for-elementor/tags/0.25.0/includes/class-abilities.php
r3748863 r3841458 580 580 array( 581 581 'label' => __( 'Set search and sharing details (Yoast SEO)', 'nori-for-elementor' ), 582 'description' => __( 'Writes each page\'s SEO title, meta description, social sharing image and focus keyphrase into Yoast SEO, and the site\'s organization name, logo and default sharing image. Needs Yoast SEO (free) active. Titles of 60 characters or less and descriptions of 70 to 160 show best; sharing images should be 1200×630 (add them with nori/add-image).', 'nori-for-elementor' ),582 'description' => __( 'Writes each page\'s SEO title, meta description, social sharing image and focus keyphrase into Yoast SEO, and the site\'s organization name, logo and default sharing image. For local search and AI answers, also give site.business (LocalBusiness schema: type, description, phone, address or areas served, hours, license, profiles) and site.llms_txt. Needs Yoast SEO (free) active. Titles of 60 characters or less and descriptions of 70 to 160 show best; sharing images should be 1200×630 (add them with nori/add-image).', 'nori-for-elementor' ), 583 583 'category' => self::CATEGORY, 584 584 'input_schema' => array( … … 600 600 'type' => 'integer', 601 601 'description' => __( 'Media library id of the sharing image for pages without their own (1200×630).', 'nori-for-elementor' ), 602 ), 603 'business' => array( 604 'type' => 'object', 605 'description' => __( 'The business as a schema.org LocalBusiness, added to Yoast\'s Organization schema for local search and AI answers. Real details only; leave out what you don\'t know. An empty object removes them.', 'nori-for-elementor' ), 606 'properties' => array( 607 'type' => array( 608 'type' => 'string', 609 'enum' => Site_Tools::business_types(), 610 'description' => __( 'The closest schema.org type, like Plumber, HomeAndConstructionBusiness or Bakery. Default LocalBusiness.', 'nori-for-elementor' ), 611 ), 612 'description' => array( 613 'type' => 'string', 614 'maxLength' => 500, 615 'description' => __( 'Two or three plain sentences: what the business does, where, since when, and what sets it apart.', 'nori-for-elementor' ), 616 ), 617 'phone' => array( 'type' => 'string', 'maxLength' => 25, 'description' => __( 'Like +1-407-555-0100.', 'nori-for-elementor' ) ), 618 'email' => array( 'type' => 'string', 'maxLength' => 200 ), 619 'founding_year' => array( 'type' => 'integer' ), 620 'address' => array( 621 'type' => 'object', 622 'properties' => array( 623 'street' => array( 'type' => 'string' ), 624 'city' => array( 'type' => 'string' ), 625 'region' => array( 'type' => 'string', 'description' => __( 'State or region, like FL.', 'nori-for-elementor' ) ), 626 'postal_code' => array( 'type' => 'string' ), 627 'country' => array( 'type' => 'string', 'description' => __( 'Two-letter code, like US.', 'nori-for-elementor' ) ), 628 ), 629 'additionalProperties' => false, 630 ), 631 'area_served' => array( 632 'type' => 'array', 633 'items' => array( 'type' => 'string' ), 634 'maxItems' => 50, 635 'description' => __( 'Cities and neighborhoods served, for a business that goes to its customers.', 'nori-for-elementor' ), 636 ), 637 'opening_hours' => array( 638 'type' => 'array', 639 'items' => array( 'type' => 'string' ), 640 'description' => __( 'Like "Mo-Fr 08:00-17:00" and "Sa 09:00-12:00".', 'nori-for-elementor' ), 641 ), 642 'credential' => array( 643 'type' => 'string', 644 'maxLength' => 200, 645 'description' => __( 'A license or certification, like "Florida Certified Pool Contractor, License No. 1458116".', 'nori-for-elementor' ), 646 ), 647 'same_as' => array( 648 'type' => 'array', 649 'items' => array( 'type' => 'string' ), 650 'description' => __( 'https addresses of the business\'s own profiles: Google Business Profile, Facebook, Yelp, BBB.', 'nori-for-elementor' ), 651 ), 652 ), 653 'additionalProperties' => false, 654 ), 655 'llms_txt' => array( 656 'type' => 'boolean', 657 'description' => __( 'Have Yoast SEO publish /llms.txt, a plain summary of the site for AI assistants.', 'nori-for-elementor' ), 602 658 ), 603 659 ), -
nori-for-elementor/tags/0.25.0/includes/class-plugin.php
r3748863 r3841458 115 115 $this->site_parts = new Site_Parts( $this->templates ); 116 116 $this->site_tools = new Site_Tools(); 117 $this->site_tools->register_hooks(); 117 118 $this->site_parts->register_hooks(); 118 119 -
nori-for-elementor/tags/0.25.0/includes/class-site-tools.php
r3748863 r3841458 268 268 } 269 269 270 /** The business details nori/set-seo adds to Yoast's Organization schema. */ 271 const BUSINESS_OPTION = 'nori_fe_business'; 272 273 /** schema.org LocalBusiness types a small-business site can be. */ 274 public static function business_types() { 275 return array( 'LocalBusiness', 'HomeAndConstructionBusiness', 'GeneralContractor', 'Electrician', 'HVACBusiness', 'HousePainter', 'Locksmith', 'MovingCompany', 'Plumber', 'RoofingContractor', 'ProfessionalService', 'AccountingService', 'LegalService', 'AutomotiveBusiness', 'AutoRepair', 'HealthAndBeautyBusiness', 'BeautySalon', 'HairSalon', 'DaySpa', 'MedicalBusiness', 'Dentist', 'ChildCare', 'DryCleaningOrLaundry','EmergencyService', 'EntertainmentBusiness', 'SportsActivityLocation', 'ExerciseGym', 'FoodEstablishment', 'Bakery', 'CafeOrCoffeeShop', 'Restaurant', 'LodgingBusiness', 'RealEstateAgent', 'Store', 'TravelAgency', 'AnimalShelter', 'EmploymentAgency', 'FinancialService', 'InternetCafe', 'Library', 'RadioStation', 'RecyclingCenter', 'SelfStorage', 'ShoppingCenter', 'TouristInformationCenter' ); 276 } 277 278 /** Front end: Yoast prints the schema, Nori only adds the business details to it. */ 279 public function register_hooks() { 280 add_filter( 'wpseo_schema_organization', array( $this, 'business_schema' ) ); 281 } 282 283 /** 284 * Yoast's Organization piece, made a LocalBusiness with the details given to nori/set-seo: 285 * description, phone, email, address, areas served, founding year, opening hours, a license 286 * or other credential and profile links. Only what was given; nothing is guessed. 287 * 288 * @param mixed $data Yoast's Organization schema piece. 289 * @return mixed 290 */ 291 public function business_schema( $data ) { 292 $b = get_option( self::BUSINESS_OPTION ); 293 if ( ! is_array( $data ) || ! is_array( $b ) || empty( $b ) ) { 294 return $data; 295 } 296 $types = array_values( array_unique( array_merge( (array) ( $data['@type'] ?? 'Organization' ), array( $b['type'] ?? 'LocalBusiness' ) ) ) ); 297 $data['@type'] = $types; 298 $map = array( 299 'description' => 'description', 300 'phone' => 'telephone', 301 'email' => 'email', 302 'founding_year' => 'foundingDate', 303 ); 304 foreach ( $map as $from => $to ) { 305 if ( isset( $b[ $from ] ) && '' !== (string) $b[ $from ] ) { 306 $data[ $to ] = (string) $b[ $from ]; 307 } 308 } 309 if ( ! empty( $b['address'] ) ) { 310 $address = array( '@type' => 'PostalAddress' ); 311 foreach ( array( 'street' => 'streetAddress', 'city' => 'addressLocality', 'region' => 'addressRegion', 'postal_code' => 'postalCode', 'country' => 'addressCountry' ) as $from => $to ) { 312 if ( ! empty( $b['address'][ $from ] ) ) { 313 $address[ $to ] = (string) $b['address'][ $from ]; 314 } 315 } 316 $data['address'] = $address; 317 } 318 if ( ! empty( $b['area_served'] ) ) { 319 $data['areaServed'] = array_map( 320 fn( $name ) => array( 321 '@type' => 'Place', 322 'name' => (string) $name, 323 ), 324 (array) $b['area_served'] 325 ); 326 } 327 if ( ! empty( $b['opening_hours'] ) ) { 328 $data['openingHours'] = array_values( (array) $b['opening_hours'] ); 329 } 330 if ( ! empty( $b['credential'] ) ) { 331 $data['hasCredential'] = array( 332 '@type' => 'EducationalOccupationalCredential', 333 'credentialCategory' => 'license', 334 'name' => (string) $b['credential'], 335 ); 336 } 337 if ( ! empty( $b['same_as'] ) ) { 338 $data['sameAs'] = array_values( array_unique( array_merge( (array) ( $data['sameAs'] ?? array() ), (array) $b['same_as'] ) ) ); 339 } 340 return $data; 341 } 342 343 /** 344 * Check and clean the business details for nori/set-seo. An empty object clears them. 345 * 346 * @return array|WP_Error The clean details. 347 */ 348 private static function clean_business( array $in ) { 349 $bad = fn( $field, $why ) => new WP_Error( 350 'nori_seo_input', 351 /* translators: 1: field name, 2: what it must be. */ 352 sprintf( __( 'site.business.%1$s %2$s', 'nori-for-elementor' ), $field, $why ) 353 ); 354 $out = array(); 355 if ( isset( $in['type'] ) ) { 356 if ( ! in_array( $in['type'], self::business_types(), true ) ) { 357 return $bad( 'type', __( 'must be one of the schema.org LocalBusiness types this tool lists.', 'nori-for-elementor' ) ); 358 } 359 $out['type'] = $in['type']; 360 } 361 foreach ( array( 'description' => 500, 'credential' => 200 ) as $k => $max ) { 362 if ( isset( $in[ $k ] ) && '' !== trim( (string) $in[ $k ] ) ) { 363 $out[ $k ] = mb_substr( sanitize_text_field( (string) $in[ $k ] ), 0, $max ); 364 } 365 } 366 if ( isset( $in['phone'] ) && '' !== trim( (string) $in['phone'] ) ) { 367 $phone = trim( (string) $in['phone'] ); 368 if ( ! preg_match( '/^\+?[0-9 ().-]{7,25}$/', $phone ) ) { 369 return $bad( 'phone', __( 'must be a phone number, like +1-407-555-0100.', 'nori-for-elementor' ) ); 370 } 371 $out['phone'] = $phone; 372 } 373 if ( isset( $in['email'] ) && '' !== trim( (string) $in['email'] ) ) { 374 if ( ! is_email( trim( (string) $in['email'] ) ) ) { 375 return $bad( 'email', __( 'must be an email address.', 'nori-for-elementor' ) ); 376 } 377 $out['email'] = sanitize_email( (string) $in['email'] ); 378 } 379 if ( isset( $in['founding_year'] ) ) { 380 $year = (int) $in['founding_year']; 381 if ( $year < 1700 || $year > (int) gmdate( 'Y' ) ) { 382 return $bad( 'founding_year', __( 'must be a year, like 2003.', 'nori-for-elementor' ) ); 383 } 384 $out['founding_year'] = (string) $year; 385 } 386 if ( isset( $in['address'] ) && is_array( $in['address'] ) ) { 387 $address = array(); 388 foreach ( array( 'street', 'city', 'region', 'postal_code' ) as $k ) { 389 if ( isset( $in['address'][ $k ] ) && '' !== trim( (string) $in['address'][ $k ] ) ) { 390 $address[ $k ] = mb_substr( sanitize_text_field( (string) $in['address'][ $k ] ), 0, 200 ); 391 } 392 } 393 if ( isset( $in['address']['country'] ) && '' !== (string) $in['address']['country'] ) { 394 if ( ! preg_match( '/^[A-Za-z]{2}$/', (string) $in['address']['country'] ) ) { 395 return $bad( 'address.country', __( 'must be a two-letter country code, like US.', 'nori-for-elementor' ) ); 396 } 397 $address['country'] = strtoupper( (string) $in['address']['country'] ); 398 } 399 if ( $address ) { 400 $out['address'] = $address; 401 } 402 } 403 if ( isset( $in['area_served'] ) ) { 404 $areas = array_values( array_filter( array_map( fn( $a ) => mb_substr( sanitize_text_field( (string) $a ), 0, 100 ), array_filter( (array) $in['area_served'], 'is_scalar' ) ) ) ); 405 if ( $areas ) { 406 $out['area_served'] = array_slice( array_unique( $areas ), 0, 50 ); 407 } 408 } 409 if ( isset( $in['opening_hours'] ) ) { 410 $day = '(Mo|Tu|We|Th|Fr|Sa|Su)'; 411 foreach ( (array) $in['opening_hours'] as $h ) { 412 if ( ! is_string( $h ) || ! preg_match( "/^$day(-$day)?(,$day(-$day)?)* ([01][0-9]|2[0-4]):[0-5][0-9]-([01][0-9]|2[0-4]):[0-5][0-9]$/", $h ) ) { 413 return $bad( 'opening_hours', __( 'must be like "Mo-Fr 08:00-17:00" or "Sa 09:00-12:00".', 'nori-for-elementor' ) ); 414 } 415 $out['opening_hours'][] = $h; 416 } 417 } 418 if ( isset( $in['same_as'] ) ) { 419 foreach ( (array) $in['same_as'] as $url ) { 420 if ( ! is_string( $url ) || 'https' !== wp_parse_url( $url, PHP_URL_SCHEME ) || ! wp_http_validate_url( $url ) ) { 421 return $bad( 'same_as', __( 'must be https addresses of the business\'s profiles (Google Business Profile, Facebook, Yelp…).', 'nori-for-elementor' ) ); 422 } 423 $out['same_as'][] = esc_url_raw( $url ); 424 } 425 } 426 if ( $out && ! isset( $out['type'] ) ) { 427 $out['type'] = 'LocalBusiness'; 428 } 429 return $out; 430 } 431 270 432 /** 271 433 * Set search and sharing details through Yoast SEO: per page the SEO title, meta description, … … 273 435 * social image. Nothing is printed by Nori: Yoast outputs the tags. 274 436 * 275 * @param array $site { organization?, logo?, default_image? }437 * @param array $site { organization?, logo?, default_image?, business?, llms_txt? } 276 438 * @param array $pages [ { id, title?, description?, image?, focus_keyphrase? } ] 277 439 * @return array|WP_Error … … 299 461 } 300 462 } 463 $business = null; 464 if ( isset( $site['business'] ) ) { 465 $business = self::clean_business( (array) $site['business'] ); 466 if ( is_wp_error( $business ) ) { 467 return $business; 468 } 469 } 470 $llms_supported = null !== \WPSEO_Options::get( 'enable_llms_txt', null ); 301 471 302 472 $out_site = array(); 473 $notes = array(); 474 if ( null !== $business ) { 475 if ( $business ) { 476 update_option( self::BUSINESS_OPTION, $business, true ); 477 // Also in Yoast's own Organization details, where the owner can see them. 478 $yoast = array( 479 'org-description' => $business['description'] ?? '', 480 'org-phone' => $business['phone'] ?? '', 481 'org-email' => $business['email'] ?? '', 482 'org-founding-date' => $business['founding_year'] ?? '', 483 ); 484 foreach ( $yoast as $k => $v ) { 485 if ( null !== \WPSEO_Options::get( $k, null ) ) { 486 \WPSEO_Options::set( $k, $v ); 487 } 488 } 489 if ( empty( $business['address'] ) && empty( $business['area_served'] ) ) { 490 $notes[] = __( 'Local search works best with an address or the areas the business serves (site.business.address or area_served).', 'nori-for-elementor' ); 491 } 492 } else { 493 delete_option( self::BUSINESS_OPTION ); 494 } 495 $out_site['business'] = (object) $business; 496 } 497 if ( isset( $site['llms_txt'] ) ) { 498 if ( $llms_supported ) { 499 \WPSEO_Options::set( 'enable_llms_txt', (bool) $site['llms_txt'] ); 500 $out_site['llms_txt'] = (bool) $site['llms_txt']; 501 } else { 502 $notes[] = __( 'This Yoast SEO version can\'t make an llms.txt file: update Yoast SEO, then try again.', 'nori-for-elementor' ); 503 } 504 } 303 505 if ( isset( $site['organization'] ) && '' !== trim( (string) $site['organization'] ) ) { 304 506 \WPSEO_Options::set( 'company_or_person', 'company' ); … … 362 564 } 363 565 364 $notes = array();365 566 if ( '0' === (string) get_option( 'blog_public' ) ) { 366 567 $notes[] = __( 'Search engines are asked not to index this site (Settings > Reading). That\'s usual on a staging site; switch it off when the site goes live.', 'nori-for-elementor' ); -
nori-for-elementor/tags/0.25.0/nori-for-elementor.php
r3819046 r3841458 4 4 * Plugin URI: https://noriforelement.com/ 5 5 * Description: Editable Atomic global classes and variables, plus lightweight animation and interaction modules, for Elementor 4. 6 * Version: 0.2 4.56 * Version: 0.25.0 7 7 * Requires at least: 6.5 8 8 * Requires PHP: 7.4 … … 21 21 } 22 22 23 define( 'NORI_FE_VERSION', '0.2 4.5' );23 define( 'NORI_FE_VERSION', '0.25.0' ); 24 24 define( 'NORI_FE_FILE', __FILE__ ); 25 25 define( 'NORI_FE_DIR', plugin_dir_path( __FILE__ ) ); -
nori-for-elementor/tags/0.25.0/readme.txt
r3819046 r3841458 6 6 Tested up to: 7.2 7 7 Requires PHP: 7.4 8 Stable tag: 0.2 4.58 Stable tag: 0.25.0 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 131 131 == Changelog == 132 132 133 = 0.25.0 = 134 * New: MCP capabilities: nori/set-seo takes business details (business type, phone, founding year, license, areas served, hours, address and profiles) and shows them to search engines as LocalBusiness structured data on Yoast SEO's Organization, and can switch on Yoast's llms.txt for AI search tools. 135 133 136 = 0.24.5 = 134 137 * Improved: Tested with Elementor 4.4 and WordPress 7.2. -
nori-for-elementor/tags/0.25.0/uninstall.php
r3748863 r3841458 24 24 delete_option( 'nori_fe_dark_colors' ); 25 25 delete_option( 'nori_fe_spam_log' ); 26 delete_option( 'nori_fe_business' ); // Business details for the search schema (Yoast's own settings stay). 26 27 delete_transient( 'nori_fe_gzip_sizes' ); 27 28 delete_site_transient( 'nori_fe_latest' ); // Left by versions before 0.23.0, which checked the website for updates. -
nori-for-elementor/trunk/includes/class-abilities.php
r3748863 r3841458 580 580 array( 581 581 'label' => __( 'Set search and sharing details (Yoast SEO)', 'nori-for-elementor' ), 582 'description' => __( 'Writes each page\'s SEO title, meta description, social sharing image and focus keyphrase into Yoast SEO, and the site\'s organization name, logo and default sharing image. Needs Yoast SEO (free) active. Titles of 60 characters or less and descriptions of 70 to 160 show best; sharing images should be 1200×630 (add them with nori/add-image).', 'nori-for-elementor' ),582 'description' => __( 'Writes each page\'s SEO title, meta description, social sharing image and focus keyphrase into Yoast SEO, and the site\'s organization name, logo and default sharing image. For local search and AI answers, also give site.business (LocalBusiness schema: type, description, phone, address or areas served, hours, license, profiles) and site.llms_txt. Needs Yoast SEO (free) active. Titles of 60 characters or less and descriptions of 70 to 160 show best; sharing images should be 1200×630 (add them with nori/add-image).', 'nori-for-elementor' ), 583 583 'category' => self::CATEGORY, 584 584 'input_schema' => array( … … 600 600 'type' => 'integer', 601 601 'description' => __( 'Media library id of the sharing image for pages without their own (1200×630).', 'nori-for-elementor' ), 602 ), 603 'business' => array( 604 'type' => 'object', 605 'description' => __( 'The business as a schema.org LocalBusiness, added to Yoast\'s Organization schema for local search and AI answers. Real details only; leave out what you don\'t know. An empty object removes them.', 'nori-for-elementor' ), 606 'properties' => array( 607 'type' => array( 608 'type' => 'string', 609 'enum' => Site_Tools::business_types(), 610 'description' => __( 'The closest schema.org type, like Plumber, HomeAndConstructionBusiness or Bakery. Default LocalBusiness.', 'nori-for-elementor' ), 611 ), 612 'description' => array( 613 'type' => 'string', 614 'maxLength' => 500, 615 'description' => __( 'Two or three plain sentences: what the business does, where, since when, and what sets it apart.', 'nori-for-elementor' ), 616 ), 617 'phone' => array( 'type' => 'string', 'maxLength' => 25, 'description' => __( 'Like +1-407-555-0100.', 'nori-for-elementor' ) ), 618 'email' => array( 'type' => 'string', 'maxLength' => 200 ), 619 'founding_year' => array( 'type' => 'integer' ), 620 'address' => array( 621 'type' => 'object', 622 'properties' => array( 623 'street' => array( 'type' => 'string' ), 624 'city' => array( 'type' => 'string' ), 625 'region' => array( 'type' => 'string', 'description' => __( 'State or region, like FL.', 'nori-for-elementor' ) ), 626 'postal_code' => array( 'type' => 'string' ), 627 'country' => array( 'type' => 'string', 'description' => __( 'Two-letter code, like US.', 'nori-for-elementor' ) ), 628 ), 629 'additionalProperties' => false, 630 ), 631 'area_served' => array( 632 'type' => 'array', 633 'items' => array( 'type' => 'string' ), 634 'maxItems' => 50, 635 'description' => __( 'Cities and neighborhoods served, for a business that goes to its customers.', 'nori-for-elementor' ), 636 ), 637 'opening_hours' => array( 638 'type' => 'array', 639 'items' => array( 'type' => 'string' ), 640 'description' => __( 'Like "Mo-Fr 08:00-17:00" and "Sa 09:00-12:00".', 'nori-for-elementor' ), 641 ), 642 'credential' => array( 643 'type' => 'string', 644 'maxLength' => 200, 645 'description' => __( 'A license or certification, like "Florida Certified Pool Contractor, License No. 1458116".', 'nori-for-elementor' ), 646 ), 647 'same_as' => array( 648 'type' => 'array', 649 'items' => array( 'type' => 'string' ), 650 'description' => __( 'https addresses of the business\'s own profiles: Google Business Profile, Facebook, Yelp, BBB.', 'nori-for-elementor' ), 651 ), 652 ), 653 'additionalProperties' => false, 654 ), 655 'llms_txt' => array( 656 'type' => 'boolean', 657 'description' => __( 'Have Yoast SEO publish /llms.txt, a plain summary of the site for AI assistants.', 'nori-for-elementor' ), 602 658 ), 603 659 ), -
nori-for-elementor/trunk/includes/class-plugin.php
r3748863 r3841458 115 115 $this->site_parts = new Site_Parts( $this->templates ); 116 116 $this->site_tools = new Site_Tools(); 117 $this->site_tools->register_hooks(); 117 118 $this->site_parts->register_hooks(); 118 119 -
nori-for-elementor/trunk/includes/class-site-tools.php
r3748863 r3841458 268 268 } 269 269 270 /** The business details nori/set-seo adds to Yoast's Organization schema. */ 271 const BUSINESS_OPTION = 'nori_fe_business'; 272 273 /** schema.org LocalBusiness types a small-business site can be. */ 274 public static function business_types() { 275 return array( 'LocalBusiness', 'HomeAndConstructionBusiness', 'GeneralContractor', 'Electrician', 'HVACBusiness', 'HousePainter', 'Locksmith', 'MovingCompany', 'Plumber', 'RoofingContractor', 'ProfessionalService', 'AccountingService', 'LegalService', 'AutomotiveBusiness', 'AutoRepair', 'HealthAndBeautyBusiness', 'BeautySalon', 'HairSalon', 'DaySpa', 'MedicalBusiness', 'Dentist', 'ChildCare', 'DryCleaningOrLaundry','EmergencyService', 'EntertainmentBusiness', 'SportsActivityLocation', 'ExerciseGym', 'FoodEstablishment', 'Bakery', 'CafeOrCoffeeShop', 'Restaurant', 'LodgingBusiness', 'RealEstateAgent', 'Store', 'TravelAgency', 'AnimalShelter', 'EmploymentAgency', 'FinancialService', 'InternetCafe', 'Library', 'RadioStation', 'RecyclingCenter', 'SelfStorage', 'ShoppingCenter', 'TouristInformationCenter' ); 276 } 277 278 /** Front end: Yoast prints the schema, Nori only adds the business details to it. */ 279 public function register_hooks() { 280 add_filter( 'wpseo_schema_organization', array( $this, 'business_schema' ) ); 281 } 282 283 /** 284 * Yoast's Organization piece, made a LocalBusiness with the details given to nori/set-seo: 285 * description, phone, email, address, areas served, founding year, opening hours, a license 286 * or other credential and profile links. Only what was given; nothing is guessed. 287 * 288 * @param mixed $data Yoast's Organization schema piece. 289 * @return mixed 290 */ 291 public function business_schema( $data ) { 292 $b = get_option( self::BUSINESS_OPTION ); 293 if ( ! is_array( $data ) || ! is_array( $b ) || empty( $b ) ) { 294 return $data; 295 } 296 $types = array_values( array_unique( array_merge( (array) ( $data['@type'] ?? 'Organization' ), array( $b['type'] ?? 'LocalBusiness' ) ) ) ); 297 $data['@type'] = $types; 298 $map = array( 299 'description' => 'description', 300 'phone' => 'telephone', 301 'email' => 'email', 302 'founding_year' => 'foundingDate', 303 ); 304 foreach ( $map as $from => $to ) { 305 if ( isset( $b[ $from ] ) && '' !== (string) $b[ $from ] ) { 306 $data[ $to ] = (string) $b[ $from ]; 307 } 308 } 309 if ( ! empty( $b['address'] ) ) { 310 $address = array( '@type' => 'PostalAddress' ); 311 foreach ( array( 'street' => 'streetAddress', 'city' => 'addressLocality', 'region' => 'addressRegion', 'postal_code' => 'postalCode', 'country' => 'addressCountry' ) as $from => $to ) { 312 if ( ! empty( $b['address'][ $from ] ) ) { 313 $address[ $to ] = (string) $b['address'][ $from ]; 314 } 315 } 316 $data['address'] = $address; 317 } 318 if ( ! empty( $b['area_served'] ) ) { 319 $data['areaServed'] = array_map( 320 fn( $name ) => array( 321 '@type' => 'Place', 322 'name' => (string) $name, 323 ), 324 (array) $b['area_served'] 325 ); 326 } 327 if ( ! empty( $b['opening_hours'] ) ) { 328 $data['openingHours'] = array_values( (array) $b['opening_hours'] ); 329 } 330 if ( ! empty( $b['credential'] ) ) { 331 $data['hasCredential'] = array( 332 '@type' => 'EducationalOccupationalCredential', 333 'credentialCategory' => 'license', 334 'name' => (string) $b['credential'], 335 ); 336 } 337 if ( ! empty( $b['same_as'] ) ) { 338 $data['sameAs'] = array_values( array_unique( array_merge( (array) ( $data['sameAs'] ?? array() ), (array) $b['same_as'] ) ) ); 339 } 340 return $data; 341 } 342 343 /** 344 * Check and clean the business details for nori/set-seo. An empty object clears them. 345 * 346 * @return array|WP_Error The clean details. 347 */ 348 private static function clean_business( array $in ) { 349 $bad = fn( $field, $why ) => new WP_Error( 350 'nori_seo_input', 351 /* translators: 1: field name, 2: what it must be. */ 352 sprintf( __( 'site.business.%1$s %2$s', 'nori-for-elementor' ), $field, $why ) 353 ); 354 $out = array(); 355 if ( isset( $in['type'] ) ) { 356 if ( ! in_array( $in['type'], self::business_types(), true ) ) { 357 return $bad( 'type', __( 'must be one of the schema.org LocalBusiness types this tool lists.', 'nori-for-elementor' ) ); 358 } 359 $out['type'] = $in['type']; 360 } 361 foreach ( array( 'description' => 500, 'credential' => 200 ) as $k => $max ) { 362 if ( isset( $in[ $k ] ) && '' !== trim( (string) $in[ $k ] ) ) { 363 $out[ $k ] = mb_substr( sanitize_text_field( (string) $in[ $k ] ), 0, $max ); 364 } 365 } 366 if ( isset( $in['phone'] ) && '' !== trim( (string) $in['phone'] ) ) { 367 $phone = trim( (string) $in['phone'] ); 368 if ( ! preg_match( '/^\+?[0-9 ().-]{7,25}$/', $phone ) ) { 369 return $bad( 'phone', __( 'must be a phone number, like +1-407-555-0100.', 'nori-for-elementor' ) ); 370 } 371 $out['phone'] = $phone; 372 } 373 if ( isset( $in['email'] ) && '' !== trim( (string) $in['email'] ) ) { 374 if ( ! is_email( trim( (string) $in['email'] ) ) ) { 375 return $bad( 'email', __( 'must be an email address.', 'nori-for-elementor' ) ); 376 } 377 $out['email'] = sanitize_email( (string) $in['email'] ); 378 } 379 if ( isset( $in['founding_year'] ) ) { 380 $year = (int) $in['founding_year']; 381 if ( $year < 1700 || $year > (int) gmdate( 'Y' ) ) { 382 return $bad( 'founding_year', __( 'must be a year, like 2003.', 'nori-for-elementor' ) ); 383 } 384 $out['founding_year'] = (string) $year; 385 } 386 if ( isset( $in['address'] ) && is_array( $in['address'] ) ) { 387 $address = array(); 388 foreach ( array( 'street', 'city', 'region', 'postal_code' ) as $k ) { 389 if ( isset( $in['address'][ $k ] ) && '' !== trim( (string) $in['address'][ $k ] ) ) { 390 $address[ $k ] = mb_substr( sanitize_text_field( (string) $in['address'][ $k ] ), 0, 200 ); 391 } 392 } 393 if ( isset( $in['address']['country'] ) && '' !== (string) $in['address']['country'] ) { 394 if ( ! preg_match( '/^[A-Za-z]{2}$/', (string) $in['address']['country'] ) ) { 395 return $bad( 'address.country', __( 'must be a two-letter country code, like US.', 'nori-for-elementor' ) ); 396 } 397 $address['country'] = strtoupper( (string) $in['address']['country'] ); 398 } 399 if ( $address ) { 400 $out['address'] = $address; 401 } 402 } 403 if ( isset( $in['area_served'] ) ) { 404 $areas = array_values( array_filter( array_map( fn( $a ) => mb_substr( sanitize_text_field( (string) $a ), 0, 100 ), array_filter( (array) $in['area_served'], 'is_scalar' ) ) ) ); 405 if ( $areas ) { 406 $out['area_served'] = array_slice( array_unique( $areas ), 0, 50 ); 407 } 408 } 409 if ( isset( $in['opening_hours'] ) ) { 410 $day = '(Mo|Tu|We|Th|Fr|Sa|Su)'; 411 foreach ( (array) $in['opening_hours'] as $h ) { 412 if ( ! is_string( $h ) || ! preg_match( "/^$day(-$day)?(,$day(-$day)?)* ([01][0-9]|2[0-4]):[0-5][0-9]-([01][0-9]|2[0-4]):[0-5][0-9]$/", $h ) ) { 413 return $bad( 'opening_hours', __( 'must be like "Mo-Fr 08:00-17:00" or "Sa 09:00-12:00".', 'nori-for-elementor' ) ); 414 } 415 $out['opening_hours'][] = $h; 416 } 417 } 418 if ( isset( $in['same_as'] ) ) { 419 foreach ( (array) $in['same_as'] as $url ) { 420 if ( ! is_string( $url ) || 'https' !== wp_parse_url( $url, PHP_URL_SCHEME ) || ! wp_http_validate_url( $url ) ) { 421 return $bad( 'same_as', __( 'must be https addresses of the business\'s profiles (Google Business Profile, Facebook, Yelp…).', 'nori-for-elementor' ) ); 422 } 423 $out['same_as'][] = esc_url_raw( $url ); 424 } 425 } 426 if ( $out && ! isset( $out['type'] ) ) { 427 $out['type'] = 'LocalBusiness'; 428 } 429 return $out; 430 } 431 270 432 /** 271 433 * Set search and sharing details through Yoast SEO: per page the SEO title, meta description, … … 273 435 * social image. Nothing is printed by Nori: Yoast outputs the tags. 274 436 * 275 * @param array $site { organization?, logo?, default_image? }437 * @param array $site { organization?, logo?, default_image?, business?, llms_txt? } 276 438 * @param array $pages [ { id, title?, description?, image?, focus_keyphrase? } ] 277 439 * @return array|WP_Error … … 299 461 } 300 462 } 463 $business = null; 464 if ( isset( $site['business'] ) ) { 465 $business = self::clean_business( (array) $site['business'] ); 466 if ( is_wp_error( $business ) ) { 467 return $business; 468 } 469 } 470 $llms_supported = null !== \WPSEO_Options::get( 'enable_llms_txt', null ); 301 471 302 472 $out_site = array(); 473 $notes = array(); 474 if ( null !== $business ) { 475 if ( $business ) { 476 update_option( self::BUSINESS_OPTION, $business, true ); 477 // Also in Yoast's own Organization details, where the owner can see them. 478 $yoast = array( 479 'org-description' => $business['description'] ?? '', 480 'org-phone' => $business['phone'] ?? '', 481 'org-email' => $business['email'] ?? '', 482 'org-founding-date' => $business['founding_year'] ?? '', 483 ); 484 foreach ( $yoast as $k => $v ) { 485 if ( null !== \WPSEO_Options::get( $k, null ) ) { 486 \WPSEO_Options::set( $k, $v ); 487 } 488 } 489 if ( empty( $business['address'] ) && empty( $business['area_served'] ) ) { 490 $notes[] = __( 'Local search works best with an address or the areas the business serves (site.business.address or area_served).', 'nori-for-elementor' ); 491 } 492 } else { 493 delete_option( self::BUSINESS_OPTION ); 494 } 495 $out_site['business'] = (object) $business; 496 } 497 if ( isset( $site['llms_txt'] ) ) { 498 if ( $llms_supported ) { 499 \WPSEO_Options::set( 'enable_llms_txt', (bool) $site['llms_txt'] ); 500 $out_site['llms_txt'] = (bool) $site['llms_txt']; 501 } else { 502 $notes[] = __( 'This Yoast SEO version can\'t make an llms.txt file: update Yoast SEO, then try again.', 'nori-for-elementor' ); 503 } 504 } 303 505 if ( isset( $site['organization'] ) && '' !== trim( (string) $site['organization'] ) ) { 304 506 \WPSEO_Options::set( 'company_or_person', 'company' ); … … 362 564 } 363 565 364 $notes = array();365 566 if ( '0' === (string) get_option( 'blog_public' ) ) { 366 567 $notes[] = __( 'Search engines are asked not to index this site (Settings > Reading). That\'s usual on a staging site; switch it off when the site goes live.', 'nori-for-elementor' ); -
nori-for-elementor/trunk/nori-for-elementor.php
r3819046 r3841458 4 4 * Plugin URI: https://noriforelement.com/ 5 5 * Description: Editable Atomic global classes and variables, plus lightweight animation and interaction modules, for Elementor 4. 6 * Version: 0.2 4.56 * Version: 0.25.0 7 7 * Requires at least: 6.5 8 8 * Requires PHP: 7.4 … … 21 21 } 22 22 23 define( 'NORI_FE_VERSION', '0.2 4.5' );23 define( 'NORI_FE_VERSION', '0.25.0' ); 24 24 define( 'NORI_FE_FILE', __FILE__ ); 25 25 define( 'NORI_FE_DIR', plugin_dir_path( __FILE__ ) ); -
nori-for-elementor/trunk/readme.txt
r3819046 r3841458 6 6 Tested up to: 7.2 7 7 Requires PHP: 7.4 8 Stable tag: 0.2 4.58 Stable tag: 0.25.0 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 131 131 == Changelog == 132 132 133 = 0.25.0 = 134 * New: MCP capabilities: nori/set-seo takes business details (business type, phone, founding year, license, areas served, hours, address and profiles) and shows them to search engines as LocalBusiness structured data on Yoast SEO's Organization, and can switch on Yoast's llms.txt for AI search tools. 135 133 136 = 0.24.5 = 134 137 * Improved: Tested with Elementor 4.4 and WordPress 7.2. -
nori-for-elementor/trunk/uninstall.php
r3748863 r3841458 24 24 delete_option( 'nori_fe_dark_colors' ); 25 25 delete_option( 'nori_fe_spam_log' ); 26 delete_option( 'nori_fe_business' ); // Business details for the search schema (Yoast's own settings stay). 26 27 delete_transient( 'nori_fe_gzip_sizes' ); 27 28 delete_site_transient( 'nori_fe_latest' ); // Left by versions before 0.23.0, which checked the website for updates.
Note:
See TracChangeset
for help on using the changeset viewer.