0 ) : $s_class_name = sanitize_html_class( $class_name ); printf( '%sclass="%s"%s', esc_html( $before ), esc_attr( $s_class_name ), esc_html( $after ) ); endif; endif; } /* fwp_form_class_attr() */ /** * Prints a flag attribute for selected UI elements (selected="selected" or checked="checked", etc.) when appropriate * * In HTML form output templates, this allows conditional output of the selected="selected" * (or checked="checked", etc.) attribute on input or option controls when appropriate, and * omits the element when not appropriate, as measured by a flag that is monitored and updated * by the caller. * * @param mixed $arg Flag monitoring variable. * @param mixed $key When $arg is an array, $key provides the index within the array to check for the flag. * @param string $flag The name of the flag attribute to output when appropriate; default, "selected". */ function fwp_selected_flag( /* mixed */ $arg = null, $key = null, $flag = 'selected' ) { $is_on = false; $s_arg = $arg; if ( is_array( $arg ) && ! is_null( $key ) ) : if ( array_key_exists( $key, $arg ) ) : $s_arg = $arg[ $key ]; else : $s_arg = false; endif; endif; if ( is_string( $s_arg ) ) : $is_on = ( strlen( $s_arg ) > 0 ); else : $is_on = (bool) ( $s_arg ); endif; if ( $is_on ) : print sprintf( '%s="%s"', esc_attr( $flag ), esc_attr( $flag ) ); endif; } /* fwp_selected_flag() */ /** * Outputs a flag attribute for checked UI elements (checked="checked") when appropriate * * In HTML form output templates, this allows conditional output of the check="checked" * attribute on input controls (e.g. checkbox, radio) when appropriate, and omits when * inappropriate (unchecked), as determined by a flag monitored and updated by caller. * * @param mixed $arg Flag monitoring variable. * @param mixed $key When $arg is an array, $key provides index within the array to check for flag value. * * @uses fwp_selected_flag() */ function fwp_checked_flag( /* mixed */ $arg = null, $key = null ) { fwp_selected_flag( $arg, $key, 'checked' ); } /* fwp_checked_flag() */ if ( ! function_exists( '_s' ) ) : /** * Retrieves a plural or singular form of a string based on the supplied number. * * Used when you want to use the appropriate form of a string based on whether * a number is singular or plural. Very similar to WordPress l10n.php _n(), * but designed for a nice short form in the * default case (provide "s" when plural, "" otherwise). * * @note This function *may* have been defined elsewhere; also, consider * using WordPress's own `_n()` function and derivatives. (gwyneth 20230920) * * @param int $n The counter to determine singular or plural form. * @param string $plural The text to use if the counter is plural. * @param string $singular The text to use if the counter is singular. * * @return string The text of the singular or plural form. */ function _s( $n = 0, $plural = 's', $singular = '' ) { $is_singular = ( is_numeric( $n ) && intval( $n ) === 1 ); return ( $is_singular ? $singular : $plural ); } /* _s() */ endif; /** * Outputs a status message for the aggregate results of polling a set of feeds. * * This will always output the number of new syndicated posts added, even if this is 0. * Posts updated and alternate versions stored will be added to the message iff > 0. * * @param array $delta Counters indicating results in "new", "updated" and "stored". * @param string $joiner Default ';'. Delimiter used to separate messages about new, updated and stored posts. */ function fwp_update_set_results_message( $delta, $joiner = ';' ) { $mesg = array(); $delta = wp_parse_args( $delta, array( 'new' => 0, 'updated' => 0, 'stored' => 0, ) ); $mesg[] = sprintf( ' %d new post%s syndicated', intval( $delta['new'] ), _s( $delta['new'], 's were', ' was' ) ); if ( $delta['updated'] > 0 ) : $mesg[] = sprintf( ' %d existing post%s updated', intval( $delta['updated'] ), _s( $delta['updated'], 's were', ' was' ) ); endif; if ( $delta['stored'] > 0 ) : $mesg[] = sprintf( ' %d alternate version%s of existing post%s stored for reference', intval( $delta['stored'] ), _s( $delta['stored'] ), _s( $delta['stored'], 's were', ' was' ) ); endif; if ( ! is_null( $joiner ) ) : $mesg = implode( $joiner, $mesg ); endif; return $mesg; } /* function fwp_update_set_results_message() */ /** * Outputs the HTML template for a "Submit" button on FWP admin pages. * * @param mixed $link The syndicated link, if any, that we are viewing settings for. (Unused) */ function fwp_authors_single_submit( $link = null ) { ?> 'post_tag', 'textarea_name' => null, 'textarea_id' => null, 'input_id' => null, 'input_name' => null, 'id' => null, 'box_title' => __( 'Post Tags' ), ) ); if ( ! is_array( $tags ) ) : $tags = array(); endif; $tax_name = $params['taxonomy']; $o_tax = get_taxonomy( $params['taxonomy'] ); $o_tax_labels = get_taxonomy_labels( $o_tax ); $is_enabled = current_user_can( $o_tax->cap->assign_terms ); if ( is_null( $params['textarea_name'] ) ) : $params['textarea_name'] = "tax_input[$tax_name]"; endif; if ( is_null( $params['textarea_id'] ) ) : $params['textarea_id'] = "tax-input-{$tax_name}"; endif; if ( is_null( $params['input_id'] ) ) : $params['input_id'] = "new-tag-{$tax_name}"; endif; if ( is_null( $params['input_name'] ) ) : $params['input_name'] = "newtag[$tax_name]"; endif; if ( is_null( $params['id'] ) ) : $params['id'] = $tax_name; endif; printf( /* $desc = */ '

' . esc_html__( 'Tag' ) . ' %s ' . esc_html__( 'as' ) . '...

', esc_html( $object ) ); $helps = __( 'Separate tags with commas.' ); $box['title'] = __( 'Tags' ); ?>

add_or_remove_items ); ?>

add_new_item ); ?>

separate_items_with_commas ); ?>

choose_from_most_used ); ?>

'', 'taxonomy' => 'category', ) ); $prefix = $params['prefix']; $taxonomy = $params['taxonomy']; endif; $o_tax = get_taxonomy( $taxonomy ); $o_tax_labels = get_taxonomy_labels( $o_tax ); if ( strlen( $prefix ) === 0 ) : $prefix = 'feedwordpress'; endif; $id_prefix = $prefix . '-'; $id_suffix = '-' . $prefix; $name_prefix = $prefix . '_'; // unused? (gwyneth 20230918) $box_div_id = sanitize_html_class( $id_prefix . 'taxonomy-' . $taxonomy ); $tabs_ul_id = sanitize_html_class( $id_prefix . $taxonomy . '-tabs' ); $all_tab_id = sanitize_html_class( $id_prefix . $taxonomy . '-all' ); $chk_lst_id = sanitize_html_class( $id_prefix . $taxonomy . 'checklist' ); $add_tax_id = sanitize_html_class( $id_prefix . $taxonomy . '-adder' ); $add_tog_id = sanitize_html_class( $id_prefix . $taxonomy . '-add-toggle' ); $add_cat_id = sanitize_html_class( $id_prefix . $taxonomy . '-add' ); $new_tax_id = sanitize_html_class( $id_prefix . 'new' . $taxonomy ); $tax_id_add_submit = sanitize_html_class( $id_prefix . $taxonomy . '-add-sumbit' ); ?>

.

$taxonomy, 'hide_empty' => 0, 'id' => $new_tax_id . '-parent', 'class' => $newcat . '-parent', 'name' => $newcat . '_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __( 'Parent category' ), 'tab_index' => 3, ) ); $nonce_code = ( 'add-' . $taxonomy ); ?>

' . esc_html__( 'Updating' ) . ' %s ' . esc_html__( 'from' ) . ' <%s> ...', esc_html( $feed['link/name'] ), esc_url( $feed['link/uri'] ), esc_html( $feed['link/uri'] ) ); flush(); } /* update_feeds_mention() */ /** * Outputs a text/html status message indicating that FWP has completed polling a feed. * * @param array $feed An associative array containing meta-data about the feed being polled (unused). * @param mixed $added a WP_Error object with error codes and messages, if there was an error in polling. * @param int $dt seconds it took to complete the poll. */ function update_feeds_finish( $feed, $added, $dt ) { if ( is_wp_error( $added ) ) : $mesgs = $added->get_error_messages(); foreach ( $mesgs as $mesg ) : printf( '
%s: %s', esc_html__( 'Feed error' ), esc_html( $mesg ) ); endforeach; echo "\n"; else : printf( esc_html__(" completed in %d second%s") . "\n", esc_html( $dt ), esc_html( _s( $dt ) ) ); endif; flush(); } /* update_feeds_finish() */ /** * Retrieves a list of users via the WordPress API. * * @return array List of users, by numeric ID => display_name */ function fwp_author_list() { $ret = array(); $users = get_users(); if ( is_array( $users ) ) : foreach ( $users as $user ) : $id = (int) $user->ID; $ret[ $id ] = $user->display_name; if ( strlen( trim( $ret[ $id ] ) ) === 0 ) : $ret[ $id ] = $user->user_login; endif; endforeach; endif; return $ret; } /* fwp_author_list() */ /** * Insert a new user into the WordPress database, with some FeedWordPress-specific default behaviors. * * @param string $newuser_name The "Display Name" for the new user; user logins and the like will be determined by a formula. * @return int|WP_Error Either a numeric ID or a WP_Error object. */ function fwp_insert_new_user( $newuser_name ) { $ret = null; if ( strlen( $newuser_name ) > 0 ) : $userdata = array(); $userdata['ID'] = null; $userdata['user_login'] = apply_filters( 'pre_user_login', sanitize_user( $newuser_name ) ); $userdata['user_nicename'] = apply_filters( 'pre_user_nicename', sanitize_title( $newuser_name ) ); $userdata['display_name'] = $newuser_name; $userdata['user_pass'] = substr( md5( uniqid( microtime() ) ), 0, 6 ); // just something random to lock it up. $blah_url = get_bloginfo( 'url' ); $url = wp_parse_url( $blah_url ); $userdata['user_email'] = substr( md5( uniqid( microtime() ) ), 0, 6 ) . '@' . $url['host']; $newuser_id = wp_insert_user( $userdata ); $ret = $newuser_id; // Either a numeric ID or a WP_Error object. else : $ret = new WP_Error( 'empty_username', 'Provide a non-empty string for the Display Name to fwp_insert_new_user' ); endif; return $ret; } /* fwp_insert_new_user ( ) */ /** * Output HTML for table row in FeedWordPress Syndicated Sources list. * * @param array $links array of WordPress link objects. * @param object $page FeedWordPress admin page object. * @param string $visible 'Y' or 'N', whether to display syndicated sources marked as visible or as hidden. */ function fwp_syndication_manage_page_links_table_rows( $links, $page, $visible = 'Y' ) { $fwp_syndicated_sources_columns = array( __( 'Name' ), __( 'Feed' ), __( 'Updated' ) ); $subscribed = ( 'Y' === strtoupper( $visible ) ); if ( $subscribed || ( count( $links ) > 0 ) ) : $table_classes = array( 'widefat' ); if ( ! $subscribed ) : $table_classes[] = 'unsubscribed'; endif; $table_classes = implode( ' ', $table_classes ); ?> %s\n", esc_html( $col ) ); endforeach; ?> 0 ) : foreach ( $links as $link ) : $tr_class = array(); $o_s_link = new SyndicatedLink( $link->link_id ); if ( is_null( $o_s_link->setting( 'update/error' ) ) ) : $the_error = null; else : $tr_class[] = 'feed-error'; $the_error = unserialize( $o_s_link->setting( 'update/error' ) ); endif; $ttl = $o_s_link->setting( 'update/ttl' ); $alt_row = ! $alt_row; if ( $alt_row ) : $tr_class[] = 'alternate'; endif; ?> > link_rss ) > 0 ) ? __( 'Switch Feed' ) : __( 'Find Feed' ) ); ?> link_rss ) > 0 ) : ?>
link_name ); ?>
display_feed_settings_page_links( array( 'before' => '
' . __( 'Settings' ) . ' > ', 'after' => '
', 'subscription' => $link, ) ); endif; ?>
> | |
link_rss, 32 ) ); ?>

(): get_error_messages() as $mesg ) : printf( '
%s', esc_html( $mesg ) ); endforeach; ?>

setting( 'update/last' ) ) ) : print esc_html__( 'Last checked ') . esc_html( fwp_time_elapsed( $o_s_link->setting( 'update/last' ) ) ); else : print esc_html__( 'None yet' ); endif; $ttl = $o_s_link->setting( 'update/ttl' ); if ( is_numeric( $ttl ) ) : $next = $o_s_link->setting( 'update/last' ) + $o_s_link->setting( 'update/fudge' ) + ( (int) $ttl * 60 ); if ( 'automatically' !== $o_s_link->setting( 'update/timed' ) ) : print ' · ' . esc_html__( 'Next') . ' '; print esc_html( fwp_relative_time_string( $next ) ); endif; endif; } /** * Return a status message indicating when a feed will next be polled, based on a next-update timestamp. * * @param int $ts Timestamp for next updrate. * @param bool $ago Display "[relative time] ago", or "ASAP", if the timestamp is in the past. */ function fwp_relative_time_string( $ts, $ago = false ) { $dt = ( $ts - time() ); if ( $dt < 0 && ! $ago ) : $ret = __( 'ASAP' ); elseif ( $dt < 60 * 60 ) : $ret = fwp_time_elapsed( $ts ); elseif ( $dt < 60 * 60 * 24 ) : $ret = wp_date( 'g:ia', $ts ); else : $ret = wp_date( 'F j', $ts ); endif; return $ret; } /** * Output the File Size / Format status message in Syndicated Sites table. * * @param SyndicatedLink $o_s_link Object representing the feed displayed on this row. */ function fwp_links_table_rows_file_size( $o_s_link ) { $mesg_file_size_lines = array(); $feed_type = $o_s_link->get_feed_type(); if ( ! is_null( $o_s_link->setting( 'link/item count' ) ) ) : $n = $o_s_link->setting( 'link/item count' ); // translators: %1$d is the item count; %2$s is the plural marker (if any) for item. $mesg_file_size_lines[] = sprintf( __( '%1$d item%2$s' ), $n, _s( $n ) ) . ', ' . $feed_type; endif; if ( is_null( $o_s_link->setting( 'update/error' ) ) ) : if ( ! is_null( $o_s_link->setting( 'link/filesize' ) ) ) : // size_format() _can_ return false, so we check for that first (gwyneth 20230918) $formatted_bytes = size_format( $o_s_link->setting( 'link/filesize' ) ); if ( $formatted_bytes ) : $mesg_file_size_lines[] = $formatted_bytes . ' ' . __( 'total' ); else: $mesg_file_size_lines[] = __( '(invalid number of bytes)' ); endif; FeedWordPress::diagnostic( 'link/filesize', 'File size for this link was reported as being `' . $o_s_link->setting( 'link/filesize' ) . '\'' ); else : $mesg_file_size_lines[] = __( '(unknown bytes)' ); FeedWordPress::diagnostic( 'link/filesize', 'No error, but link/filesize reported NULL bytes.' ); endif; endif; if ( count( $mesg_file_size_lines ) > 0 ) : print '
'; $sep = ''; foreach ( $mesg_file_size_lines as $line ) : print esc_html( $sep ); print esc_html( $line ); $sep = ' / '; endforeach; print '
'; endif; } /** * Output the Scheduled For Next Update status message in Syndicated Sites table. * * @param SyndicatedLink $o_s_link Object representing the feed displayed on this row. */ function fwp_links_table_rows_next_update( $o_s_link ) { $ttl = $o_s_link->setting( 'update/ttl' ); ?>
setting( 'update/last' ) + $o_s_link->setting( 'update/fudge' ) + ( (int) $ttl * 60 ); if ( 'automatically' === $o_s_link->setting( 'update/timed' ) ) : if ( $next < time() ) : esc_html_e( 'Ready and waiting to be updated since ' ); else : esc_html_e( 'Scheduled for next update ' ); endif; print esc_html( fwp_time_elapsed( $next ) ); if ( FEEDWORDPRESS_DEBUG ) : $interval = ( ( $next - time() ) / 60 ); printf( ' [%d %s%s]', intval( $interval ), esc_html__( 'minute' ), esc_html( _s( $interval ) ) ); endif; else : printf( esc_html__( 'Scheduled to be checked for updates every ' ) . '%d %s%s.', intval( $ttl ), esc_html__( 'minute' ), esc_html( _s( $ttl ) ) ); ?>
setting( 'update/xml' ) ) : ?> <setting( 'update/xml' ) ); ?>>