%s', esc_html__( 'Select your option', 'all-in-one-content-restriction' ) );
foreach ( $items as $key => $value ) {
$items_html .= sprintf( '', $key, selected( $key === $selected_item, true, false ), $value['label'] );
}
return $items_html;
}
// Get not found HTML
public static function get_not_found_html() {
return sprintf( '
| | %s |
', esc_html( Strings::get()[101] ) );
}
// User Roles List HTML for Settings Page
public static function get_role_names_html( $selected_role_names ) {
$role_names = Query::get_role_names();
$role_names_html = '';
foreach ( $role_names as $key => $value ) {
if ( in_array( $key, $selected_role_names ) ) {
$role_names_html .= sprintf( '', $key, $value );
} else {
$role_names_html .= sprintf( '', $key, $value );
}
}
return $role_names_html;
}
// User Roles List HTML for Settings Page
public static function get_specified_user_html( $selected_role_names ) {
$users = Query::get_users();
$users_html = '';
foreach ( $users as $key => $value ) {
$display_name = $value->display_name;
$user_login = $value->user_login;
if ( in_array( $user_login, $selected_role_names ) ) {
$users_html .= sprintf( '', $user_login, $display_name, $user_login );
} else {
$users_html .= sprintf( '', $user_login, $display_name, $user_login );
}
}
return $users_html;
}
// Blur & Obfuscate Apply List HTML for Settings Page
public static function apply_to_html( $selected_items ) {
$apply_to_arr = array(
'the_title' => __( 'Title', 'all-in-one-content-restriction' ),
'the_excerpt' => __( 'Excerpt', 'all-in-one-content-restriction' ),
'the_content' => __( 'Descriptions', 'all-in-one-content-restriction' ),
);
$apply_to_html = '';
foreach ( $apply_to_arr as $key => $value ) {
if ( in_array( $key, $selected_items ) ) {
$apply_to_html .= sprintf( '', $key, $value );
} else {
$apply_to_html .= sprintf( '', $key, $value );
}
}
return $apply_to_html;
}
// Get Items HTML for Table
public static function get_items_html( $items_array, $icon, $in_type ) {
$items_list_html = '';
if ( empty( $items_array ) ) {
return self::get_not_found_html();
}
if ( 'taxonomy' === $in_type ) {
foreach ( $items_array->terms as $id => $name ) {
$items_list_html .= sprintf( ' | %s | %s |
', $id, $icon, $id, $name );
}
}
if ( 'single_post' === $in_type ) {
foreach ( $items_array as $id ) {
$items_list_html .= sprintf( ' | %s | %s |
', $id, $icon, $id, get_post( $id )->post_title );
}
}
return $items_list_html;
}
public static function display_taxonomy_single_items_html( $post_type, $restrict_in, $icon, $exclude_ids = array(), $selected_items = array(), $no_items = false ) {
$items_list_html = '';
if ( $no_items && empty( $selected_items ) ) {
return self::get_not_found_html();
}
if ( 'selected_single_items' == $restrict_in ) {
$single_items = Query::get_posts( $post_type, $exclude_ids, $selected_items );
foreach ( $single_items as $id ) {
$items_list_html .= sprintf( ' | %s | %s |
', esc_attr( $id ), esc_attr( $icon ), esc_attr( $id ), esc_html( get_post( $id )->post_title ) );
}
return $items_list_html;
}
$terms = Query::get_terms( $restrict_in, $exclude_ids, $selected_items );
if ( isset( $terms->errors ) || isset( $terms->error_data ) || ! $terms ) {
return self::get_not_found_html();
} else {
foreach ( $terms as $key => $value ) {
$items_list_html .= sprintf( ' | %s | %s |
', esc_attr( $value->term_id ), esc_attr( $icon ), esc_attr( $value->term_id ), esc_attr( $value->name ) );
}
return $items_list_html;
}
}
}