__construct(). */ public function __construct( &$plugin ) { $this->p =& $plugin; if ( $this->p->debug->enabled ) { $this->p->debug->mark(); } } public static function show_is_hidden_content( $mb, $screen_id = '', $user_id = null ) { if ( WpssoUser::is_metabox_hidden( $mb[ 'id' ], $screen_id, $user_id ) ) { echo ''; echo '
'; echo '

' . __( 'Reload the page to show this content.', 'wpsso' ) . '

'; echo '
'; return true; } return false; } public function do_tabbed( $metabox_id = '', $tabs = array(), $table_rows = array(), $args = array() ) { echo $this->get_tabbed( $metabox_id, $tabs, $table_rows, $args ); } public function get_tabbed( $metabox_id = '', $tabs = array(), $table_rows = array(), $args = array() ) { $doing_ajax = SucomUtilWP::doing_ajax(); $tab_keys = array_keys( $tabs ); $default_tab = '_' . reset( $tab_keys ); // Must start with an underscore. $mb_tabs_class = 'sucom-metabox-tabs'; $mb_tabs_id = ''; $tablink_class = 'sucom-tablink'; $tabset_class = 'sucom-tabset'; if ( ! empty( $metabox_id ) ) { $metabox_id = '_' . trim( $metabox_id, '_' ); // Must start with an underscore. $mb_tabs_id = $mb_tabs_class . $metabox_id; $mb_tabs_class .= ' ' . $mb_tabs_id; } $tabs_layout = empty( $args[ 'layout' ] ) ? WPSSO_METABOX_TAB_LAYOUT : $args[ 'layout' ]; $mb_tabs_class = SucomUtil::sanitize_css_class( $mb_tabs_class . ' ' . $tabs_layout ); $mb_tabs_id = SucomUtil::sanitize_css_id( $mb_tabs_id ); $metabox_html = "\n"; $metabox_html .= '
' . "\n"; $metabox_html .= '' . "\n\n"; /* * Add the settings table for each tab. */ foreach ( $tabs as $tab => $title_transl ) { $href_key_class = $tabset_class . $metabox_id . '-tab_' . $tab; $metabox_html .= $this->get_table( $table_rows[ $tab ], $href_key_class, ( empty( $metabox_id ) ? '' : $tabset_class . $metabox_id ), $tabset_class, $title_transl ); } $metabox_html .= '
' . "\n"; if ( $doing_ajax ) { $metabox_html .= '' . "\n"; $metabox_html .= '' . "\n"; } else { $metabox_html .= '' . "\n"; $metabox_html .= '' . "\n"; } return $metabox_html; } public function do_table( $table_rows, $href_key_class = '', $tabset_mb_class = '', $tabset_class = 'sucom-no_tabset', $title_transl = '' ) { echo $this->get_table( $table_rows, $href_key_class, $tabset_mb_class, $tabset_class, $title_transl ); } public function get_table( $table_rows, $href_key_class = '', $tabset_mb_class = '', $tabset_class = 'sucom-no_tabset', $title_transl = '' ) { $metabox_html = ''; if ( ! is_array( $table_rows ) ) { // Just in case. return $metabox_html; } $total_rows = count( $table_rows ); $count_rows = 0; $hidden_opts = 0; $hidden_rows = 0; $user_show_opts = WpssoUser::show_opts(); foreach ( $table_rows as $key => $row ) { if ( ! empty( $key ) ) { // Just in case. $filter_name = SucomUtil::sanitize_hookname( $href_key_class . '_' . $key . '_row' ); $row = apply_filters( $filter_name, $row ); } if ( empty( $row ) ) { // Just in case. continue; } /* * Default row class and id attribute values. */ $tr = array( 'class' => 'sucom-alt' . ( $count_rows % 2 ) . ( $count_rows === 0 ? ' first-row' : '' ) . ( $count_rows === ( $total_rows - 1 ) ? ' last-row' : '' ), 'id' => ( is_int( $key ) ? '' : 'tr_' . $key ) ); /* * If we don't already have a table row tag, then add one. */ if ( strpos( $row, '' . $row; } else { foreach ( $tr as $att => $val ) { if ( empty( $tr[ $att ] ) ) { continue; } /* * If we're here, then we have a table row tag already. * * Count the number of rows and options that are hidden. */ if ( $att === 'class' && ! empty( $user_show_opts ) ) { if ( $matched = preg_match( '/]*class="[^"]*hide(_row)?_in_' . $user_show_opts . '[" ]/', $row, $m ) > 0 ) { if ( ! isset( $m[ 1 ] ) ) { $hidden_opts += preg_match_all( '/(]*>]*' . $att . '=")([^"]*)(")/', '$1$2 ' . $tr[ $att ] . '$3', $row, -1, $replace_count ); /* * If one hasn't been added, then add both the attribute and its value. */ if ( $replace_count < 1 ) { $row = preg_replace( '/(' ) === false ) { $row .= '' . "\n"; } /* * Update the table row array element with the new value. */ $table_rows[ $key ] = $row; $count_rows++; } if ( 0 === $count_rows ) { $table_rows[ 'no_options' ] = '' . '

' . __( 'No options available.', 'wpsso' ) . '

' . ''; $count_rows++; } $div_class = ( empty( $user_show_opts ) ? '' : 'sucom-show_' . $user_show_opts ) . ( empty( $tabset_class ) ? '' : ' ' . $tabset_class ) . ( empty( $tabset_mb_class ) ? '' : ' ' . $tabset_mb_class ) . ( empty( $href_key_class ) ? '' : ' ' . $href_key_class ); $table_class = 'sucom-settings ' . $this->p->id . ( empty( $href_key_class ) ? '' : ' ' . $href_key_class ) . ( $hidden_rows > 0 && $hidden_rows === $count_rows ? ' hide_in_' . $user_show_opts : '' ); $metabox_html .= '
' . "\n"; $metabox_html .= $title_transl ? '

' . $title_transl . '

' . "\n" : ''; $metabox_html .= '' . "\n"; foreach ( $table_rows as $row ) { $metabox_html .= $row; } $metabox_html .= '
' . "\n"; $metabox_html .= '
' . "\n\n"; $user_show_opts_label = $this->p->cf[ 'form' ][ 'show_options' ][ $user_show_opts ]; if ( $hidden_opts > 0 ) { $metabox_html .= '
' . sprintf( _x( '%1$d additional options not shown in "%2$s" view', 'option comment', 'wpsso' ), $hidden_opts, _x( $user_show_opts_label, 'option value', 'wpsso' ) ) . ' (' . _x( 'show these options now', 'option comment', 'wpsso' ) . ')
' . "\n"; } elseif ( $hidden_rows > 0 ) { $metabox_html .= '
' . sprintf( _x( '%1$d additional rows not shown in "%2$s" view', 'option comment', 'wpsso' ), $hidden_rows, _x( $user_show_opts_label, 'option value', 'wpsso' ) ) . ' (' . _x( 'show these rows now', 'option comment', 'wpsso' ) . ')
' . "\n"; } return $metabox_html; } } }