| @@ -647,8 +647,172 @@ | ||
| 647 | 647 | |
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | /** |
| 651 | + * Returns this settings group's programmatic name. | |
| 652 | + * | |
| 653 | + * @since 3.4.0 | |
| 654 | + * | |
| 655 | + * @return string | |
| 656 | + */ | |
| 657 | + public function get_name() { | |
| 658 | + | |
| 659 | + return 'general'; | |
| 660 | + | |
| 661 | + } | |
| 662 | + | |
| 663 | + /** | |
| 664 | + * Returns the title of this settings group. | |
| 665 | + * | |
| 666 | + * @since 3.4.0 | |
| 667 | + * | |
| 668 | + * @return string | |
| 669 | + */ | |
| 670 | + public function get_title() { | |
| 671 | + | |
| 672 | + return __( 'General Settings', 'convertkit' ); | |
| 673 | + | |
| 674 | + } | |
| 675 | + | |
| 676 | + /** | |
| 677 | + * Returns the keys in this settings group that hold credentials or other | |
| 678 | + * sensitive values. | |
| 679 | + * | |
| 680 | + * @since 3.4.0 | |
| 681 | + * | |
| 682 | + * @return string[] | |
| 683 | + */ | |
| 684 | + public function get_secret_keys() { | |
| 685 | + | |
| 686 | + return array( | |
| 687 | + 'access_token', | |
| 688 | + 'refresh_token', | |
| 689 | + 'token_expires', | |
| 690 | + 'api_key', | |
| 691 | + 'api_secret', | |
| 692 | + 'recaptcha_secret_key', | |
| 693 | + ); | |
| 694 | + | |
| 695 | + } | |
| 696 | + | |
| 697 | + /** | |
| 698 | + * Returns the JSON Schema describing this settings group, in the shape | |
| 699 | + * stored by save() / returned by get(), excluding secret keys. | |
| 700 | + * | |
| 701 | + * @since 3.4.0 | |
| 702 | + * | |
| 703 | + * @return array | |
| 704 | + */ | |
| 705 | + public function get_schema() { | |
| 706 | + | |
| 707 | + $properties = array( | |
| 708 | + 'non_inline_form' => array( | |
| 709 | + 'type' => 'array', | |
| 710 | + 'items' => array( 'type' => 'integer' ), | |
| 711 | + 'description' => __( 'IDs of non-inline Forms to display site-wide.', 'convertkit' ), | |
| 712 | + ), | |
| 713 | + 'non_inline_form_honor_none_setting' => array( | |
| 714 | + 'type' => 'string', | |
| 715 | + 'enum' => array( '', 'on' ), | |
| 716 | + 'description' => __( 'Whether the site-wide non-inline Form honors a per-Page / per-Post "None" Form setting.', 'convertkit' ), | |
| 717 | + ), | |
| 718 | + 'non_inline_form_limit_per_session' => array( | |
| 719 | + 'type' => 'string', | |
| 720 | + 'enum' => array( '', 'on' ), | |
| 721 | + 'description' => __( 'Whether to limit non-inline Form display to once per session.', 'convertkit' ), | |
| 722 | + ), | |
| 723 | + 'recaptcha_site_key' => array( | |
| 724 | + 'type' => 'string', | |
| 725 | + 'description' => __( 'Google reCAPTCHA v3 site key.', 'convertkit' ), | |
| 726 | + ), | |
| 727 | + 'recaptcha_minimum_score' => array( | |
| 728 | + 'type' => 'number', | |
| 729 | + 'minimum' => 0, | |
| 730 | + 'maximum' => 1, | |
| 731 | + 'description' => __( 'Minimum Google reCAPTCHA v3 score (0.0 - 1.0) below which a request is treated as spam.', 'convertkit' ), | |
| 732 | + ), | |
| 733 | + 'debug' => array( | |
| 734 | + 'type' => 'string', | |
| 735 | + 'enum' => array( '', 'on' ), | |
| 736 | + 'description' => __( 'Whether debug logging is enabled.', 'convertkit' ), | |
| 737 | + ), | |
| 738 | + 'no_scripts' => array( | |
| 739 | + 'type' => 'string', | |
| 740 | + 'enum' => array( '', 'on' ), | |
| 741 | + 'description' => __( 'Whether the Plugin\'s frontend JavaScript is disabled.', 'convertkit' ), | |
| 742 | + ), | |
| 743 | + 'no_css' => array( | |
| 744 | + 'type' => 'string', | |
| 745 | + 'enum' => array( '', 'on' ), | |
| 746 | + 'description' => __( 'Whether the Plugin\'s frontend CSS is disabled.', 'convertkit' ), | |
| 747 | + ), | |
| 748 | + 'no_add_new_button' => array( | |
| 749 | + 'type' => 'string', | |
| 750 | + 'enum' => array( '', 'on' ), | |
| 751 | + 'description' => __( 'Whether the "Add New" button for Landing Pages / Member Content is hidden in the WordPress Admin.', 'convertkit' ), | |
| 752 | + ), | |
| 753 | + 'usage_tracking' => array( | |
| 754 | + 'type' => 'string', | |
| 755 | + 'enum' => array( '', 'on' ), | |
| 756 | + 'description' => __( 'Whether anonymous usage tracking is enabled.', 'convertkit' ), | |
| 757 | + ), | |
| 758 | + ); | |
| 759 | + | |
| 760 | + // Per-post-type Default Form settings, mirroring get_defaults(). | |
| 761 | + foreach ( convertkit_get_supported_post_types() as $post_type ) { | |
| 762 | + $properties[ $post_type . '_form' ] = array( | |
| 763 | + 'type' => 'integer', | |
| 764 | + 'minimum' => -1, | |
| 765 | + 'description' => sprintf( | |
| 766 | + /* translators: Post type slug. */ | |
| 767 | + __( 'Default Form ID to display on %s. `-1` = Plugin Default; `0` = None; positive integer = specific Kit Form ID.', 'convertkit' ), | |
| 768 | + $post_type | |
| 769 | + ), | |
| 770 | + ); | |
| 771 | + | |
| 772 | + $properties[ $post_type . '_form_position' ] = array( | |
| 773 | + 'type' => 'string', | |
| 774 | + 'enum' => array( 'before_content', 'after_content', 'before_after_content', 'after_element' ), | |
| 775 | + 'description' => sprintf( | |
| 776 | + /* translators: Post type slug. */ | |
| 777 | + __( 'Where the Default Form displays relative to the %s content.', 'convertkit' ), | |
| 778 | + $post_type | |
| 779 | + ), | |
| 780 | + ); | |
| 781 | + | |
| 782 | + $properties[ $post_type . '_form_position_element' ] = array( | |
| 783 | + 'type' => 'string', | |
| 784 | + 'enum' => array( 'p', 'h2', 'h3', 'h4', 'h5', 'h6', 'img' ), | |
| 785 | + 'description' => sprintf( | |
| 786 | + /* translators: 1: Post type slug, 2: Post type slug. */ | |
| 787 | + __( 'HTML element after which to display the Default Form on %1$s. Only used when `%2$s_form_position` is `after_element`.', 'convertkit' ), | |
| 788 | + $post_type, | |
| 789 | + $post_type | |
| 790 | + ), | |
| 791 | + ); | |
| 792 | + | |
| 793 | + $properties[ $post_type . '_form_position_element_index' ] = array( | |
| 794 | + 'type' => 'integer', | |
| 795 | + 'minimum' => 1, | |
| 796 | + 'maximum' => 999, | |
| 797 | + 'description' => sprintf( | |
| 798 | + /* translators: 1: Post type slug, 2: Post type slug. */ | |
| 799 | + __( 'Nth occurrence of the element after which to display the Default Form on %1$s. Only used when `%2$s_form_position` is `after_element`.', 'convertkit' ), | |
| 800 | + $post_type, | |
| 801 | + $post_type | |
| 802 | + ), | |
| 803 | + ); | |
| 804 | + } | |
| 805 | + | |
| 806 | + return array( | |
| 807 | + 'type' => 'object', | |
| 808 | + 'additionalProperties' => false, | |
| 809 | + 'properties' => $properties, | |
| 810 | + ); | |
| 811 | + | |
| 812 | + } | |
| 813 | + | |
| 814 | + /** | |
| 651 | 815 | * The default settings, used when the ConvertKit Plugin Settings haven't been saved |
| 652 | 816 | * e.g. on a new installation. |
| 653 | 817 | * |
| 654 | 818 | * @since 1.9.6 |