| @@ -1,0 +1,68 @@ | ||
| 1 | +<?php | |
| 2 | +/* | |
| 3 | + * License: GPLv3 | |
| 4 | + * License URI: https://www.gnu.org/licenses/gpl.txt | |
| 5 | + * Copyright 2020-2026 Jean-Sebastien Morisset (https://wpsso.com/) | |
| 6 | + */ | |
| 7 | + | |
| 8 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 9 | + | |
| 10 | + die( 'These aren\'t the droids you\'re looking for.' ); | |
| 11 | +} | |
| 12 | + | |
| 13 | +if ( ! defined( 'WPSSO_PLUGINDIR' ) ) { | |
| 14 | + | |
| 15 | + die( 'Do. Or do not. There is no try.' ); | |
| 16 | +} | |
| 17 | + | |
| 18 | +if ( ! class_exists( 'WpssoEditValidators' ) ) { | |
| 19 | + | |
| 20 | + class WpssoEditValidators { | |
| 21 | + | |
| 22 | + private $p; // Wpsso class object. | |
| 23 | + | |
| 24 | + public function __construct( &$plugin ) { | |
| 25 | + | |
| 26 | + $this->p =& $plugin; | |
| 27 | + | |
| 28 | + if ( $this->p->debug->enabled ) { | |
| 29 | + | |
| 30 | + $this->p->debug->mark(); | |
| 31 | + } | |
| 32 | + | |
| 33 | + /* | |
| 34 | + * See WpssoAbstractWpMeta->get_document_sso_tabs(). | |
| 35 | + */ | |
| 36 | + $this->p->util->add_plugin_filters( $this, array( | |
| 37 | + 'mb_sso_validators_rows' => 4, | |
| 38 | + ), PHP_INT_MIN ); // Run before any add-on filters. | |
| 39 | + } | |
| 40 | + | |
| 41 | + public function filter_mb_sso_validators_rows( $table_rows, $form, $head_info, $mod ) { | |
| 42 | + | |
| 43 | + $validators = $this->p->util->get_validators( $mod, $form ); | |
| 44 | + | |
| 45 | + foreach ( $validators as $key => $el ) { | |
| 46 | + | |
| 47 | + if ( empty( $el[ 'type' ] ) ) { | |
| 48 | + | |
| 49 | + continue; | |
| 50 | + } | |
| 51 | + | |
| 52 | + $extra_msg = isset( $el[ 'extra_msg' ] ) ? $el[ 'extra_msg' ] : ''; | |
| 53 | + $button_label = sprintf( _x( 'Validate %s', 'submit button', 'wpsso' ), $el[ 'type' ] ); | |
| 54 | + $is_disabled = empty( $el[ 'url' ] ) ? true : false; | |
| 55 | + | |
| 56 | + $table_rows[ 'validate_' . $key ] = '' . | |
| 57 | + $form->get_th_html( $el[ 'title' ], $css_class = 'medium' ) . | |
| 58 | + '<td class="validate">' . $this->p->msgs->get( 'info-meta-validate-' . $key ) . $extra_msg . '</td>' . | |
| 59 | + '<td class="validate">' . $form->get_button( $button_label, $css_class = 'button-secondary', $css_id = '', | |
| 60 | + $el[ 'url' ], $newtab = true, $is_disabled ) . '</td>'; | |
| 61 | + } | |
| 62 | + | |
| 63 | + $table_rows[ 'validate_info' ] = '<td class="validate" colspan="3">' . $this->p->msgs->get( 'info-meta-validate-footer' ) . '</td>'; | |
| 64 | + | |
| 65 | + return $table_rows; | |
| 66 | + } | |
| 67 | + } | |
| 68 | +} | |