emails;
$this->items = apply_filters(
"learn-press/settings/emails-group/$this->group_id/key-ids",
$this->items
);
$ids = [];
foreach ( $emails as $email ) {
if ( ! is_object( $email ) ) {
continue;
}
//Todo: need review code here
if ( ! in_array( $email->id, $this->items ) ) {
continue;
}
$email->group = $this;
$ids[ $email->id ] = $email;
}
$this->items = $ids;
add_action( 'learn-press/admin/setting-payments/admin-options-' . $this->group_id, array( $this, 'output_settings' ) );
add_filter( 'learn-press/admin/get-settings/admin-options-' . $this->group_id, array( $this, 'filter_get_settings' ) );
}
public function output_settings() {
$current = $this->get_current_section();
echo '
';
foreach ( $this->items as $email ) {
if ( ! is_object( $email ) ) {
continue;
}
if ( $current == $email->id ) {
echo '- ' . wp_kses_post( $email->title ) . '
';
} else {
echo '- ' . wp_kses_post( $email->title ) . '
';
}
}
echo '
';
if ( ! empty( $this->items[ $current ] ) ) {
$this->items[ $current ]->admin_option_settings(); // Email content show in here LP_Abstract_Settings.
}
}
/**
* Filter save setting.
*
* @return array list setting Email.
* @version 4.0.0
* @author Nhamdv
*/
public function filter_get_settings() {
$current = $this->get_current_section();
if ( ! empty( $this->items[ $current ] ) ) {
return $this->items[ $current ]->get_settings();
}
}
public function get_current_section() {
$ids = array_keys( $this->items );
return ! empty( $_REQUEST['sub-section'] ) ? sanitize_text_field( $_REQUEST['sub-section'] ) : reset( $ids );
}
public function __toString() {
$name = str_replace( array( 'LP_Settings_', '_' ), array( '', ' ' ), get_class( $this ) );
return (string) $name;
}
}