array(
/**
* Filters the primary link URL for the 'WordPress Events and News' dashboard widget.
*
* @param string $link The widget's primary link URL.
*
* @since 2.5.0
*
*/
'link' => 'https://wp-parsi.com/',
/**
* Filters the primary feed URL for the 'WordPress Events and News' dashboard widget.
*
* @param string $url The widget's primary feed URL.
*
* @since 2.3.0
*
*/
'url' => 'https://wp-parsi.com/parsidate/feed/',
/**
* Filters the primary link title for the 'WordPress Events and News' dashboard widget.
*
* @param string $title Title attribute for the widget's primary link.
*
* @since 2.3.0
*
*/
'title' => apply_filters( 'dashboard_primary_title', __( 'Parsidate' ) ),
'items' => 5,
'show_summary' => 0,
'show_author' => 0,
'show_date' => 0,
),
//'planet' => array(
/**
* Filters the secondary link URL for the 'WordPress Events and News' dashboard widget.
*
* @param string $link The widget's secondary link URL.
*
* @since 2.3.0
*
*/
//'link' => __( 'https://wp-planet.ir/' ),
/**
* Filters the secondary feed URL for the 'WordPress Events and News' dashboard widget.
*
* @param string $url The widget's secondary feed URL.
*
* @since 2.3.0
*
*/
//'url' => __( 'https://wp-planet.ir/feed' ),
/**
* Filters the secondary link title for the 'WordPress Events and News' dashboard widget.
*
* @param string $title Title attribute for the widget's secondary link.
*
* @since 2.3.0
*
*/
//'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ),
/**
* Filters the number of secondary link items for the 'WordPress Events and News' dashboard widget.
*
* @param string $items How many items to show in the secondary feed.
*
* @since 4.4.0
*
*/
// 'items' => apply_filters( 'dashboard_secondary_items', 3 ),
// 'show_summary' => 0,
// 'show_author' => 0,
// 'show_date' => 0,
//),
);
wp_dashboard_cached_rss_widget( 'wpp_dashboard_primary', 'wpp_dashboard_primary_output', $feeds );
}
}
if ( ! function_exists( 'wpp_dashboard_primary_output' ) ) {
/**
* Displays the WordPress events and news feeds.
*
* @param string $widget_id Widget ID.
* @param array $feeds Array of RSS feeds.
*
* @since 3.8.0
* @since 4.8.0 Removed popular plugins feed.
*
*/
function wpp_dashboard_primary_output( $widget_id, $feeds ) {
foreach ( $feeds as $type => $args ) {
$args['type'] = $type;
echo '';
}
}
}
if ( ! function_exists( 'wpp_ajax_dashboard_widgets' ) ) {
/**
* Handles dashboard widgets via AJAX.
*
* @since 5.1.0
*/
function wpp_ajax_dashboard_widgets() {
require_once ABSPATH . 'wp-admin/includes/dashboard.php';
$pagenow = $_GET['pagenow'];
if ( 'dashboard-user' === $pagenow || 'dashboard-network' === $pagenow || 'dashboard' === $pagenow ) {
set_current_screen( $pagenow );
}
switch ( $_GET['widget'] ) {
case 'wpp_dashboard_primary':
wpp_dashboard_primary();
break;
}
wp_die();
}
add_action( 'wp_ajax_wpp-dashboard-widgets', 'wpp_ajax_dashboard_widgets' );
}
if ( ! function_exists( 'wpp_enqueue_admin_dashboard_assets' ) ) {
/**
* Enqueue our assets to WP admin dashboard
*
* @param $hook
*
* @return void
* @author HamidReza Yazdani
* @sicne 5.1.0
*
*/
function wpp_enqueue_admin_dashboard_assets( $hook ) {
// Check if we are on the admin dashboard page
if ( $hook !== 'index.php' ) {
return;
}
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) || wpp_is_active( 'dev_mode' ) ? '' : '.min';
wp_enqueue_style( 'keen-slider', WP_PARSI_URL . "assets/css/keen-slider$suffix.css", false, '6.8.6' );
wp_enqueue_style( 'wpp_dashboard', WP_PARSI_URL . "assets/css/dashboard$suffix.css", false, WP_PARSI_VER );
wp_enqueue_script( 'keen-slider', WP_PARSI_URL . "assets/js/keen-slider.min.js", array(), '6.8.6', true );
wp_enqueue_script( 'wpp_dashboard', WP_PARSI_URL . "assets/js/dashboard$suffix.js", array( 'jquery', 'keen-slider' ), WP_PARSI_VER, true );
}
add_action( 'admin_enqueue_scripts', 'wpp_enqueue_admin_dashboard_assets' );
}
if ( ! function_exists( 'wpp_fetch_sponsorship_slides_callback' ) ) {
/**
* Fetch the sponsors banners
*
* @sicne 5.1.0
* @return void
*/
function wpp_fetch_sponsorship_slides_callback() {
$sponsors_cache = get_transient( 'wpp_sponsors_cache' );
if ( $sponsors_cache ) {
wp_send_json_success( json_decode( $sponsors_cache, true ) );
}
$response = wp_remote_get( 'https://wp-parsi.com/wp-json/sponsorship/v1/sponsors/' );
if ( is_wp_error( $response ) ) {
wp_send_json_error( 'Error fetching slides' );
}
$slides = wp_remote_retrieve_body( $response );
set_transient( 'wpp_sponsors_cache', $slides, DAY_IN_SECONDS );
wp_send_json_success( json_decode( $slides, true ) );
}
add_action( 'wp_ajax_fetch_sponsorship_slides', 'wpp_fetch_sponsorship_slides_callback' );
}