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 ) { ?>
' . esc_html__( 'Tag' ) . ' %s ' . esc_html__( 'as' ) . '...
', esc_html( $object ) ); $helps = __( 'Separate tags with commas.' ); $box['title'] = __( 'Tags' ); ?> '', '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' ); ?>%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; ?> | ||||
|---|---|---|---|---|
| link_rss ) > 0 ) ? __( 'Switch Feed' ) : __( 'Find Feed' ) ); ?> | link_name ); ?> | link_rss ) > 0 ) : ?>|||
():
get_error_messages() as $mesg ) :
printf( '%s', esc_html( $mesg ) );
endforeach;
?>
<setting( 'update/xml' ) ); ?>>