HEX
Server: LiteSpeed
System: Linux starfruit.7ho.st 3.10.0-962.3.2.lve1.5.88.el7.x86_64 #1 SMP Fri Sep 26 14:06:42 UTC 2025 x86_64
User: edtir (1699)
PHP: 7.4.33
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open
Upload Files
File: /home/edtir/public_html/nabilico.ir/wp-content/plugins/persian-woocommerce/include/class-widget.php
<?php

defined( 'ABSPATH' ) || exit;

class Persian_Woocommerce_Widget extends Persian_Woocommerce_Core {

	public function __construct() {
		add_action( 'wp_dashboard_setup', [ $this, 'widget_setup' ] );
	}

	public function widget_setup() {
		wp_add_dashboard_widget( 'persian_woocommerce_feed',
			'آخرین اخبار و اطلاعیه های ووکامرس پارسی',
			[ $this, 'widget_render' ],
			[ $this, 'widget_settings' ] );
	}

	public function widget_render() { ?>

		<div class="rss-widget">

			<?php $widget_options = $this->widget_options();

			wp_widget_rss_output( [
				'url'          => 'https://woocommerce.ir/feed/',
				'title'        => 'آخرین اخبار و اطلاعیه های ووکامرس پارسی',
				'meta'         => [ 'target' => '_new' ],
				'items'        => intval( $widget_options['posts_number'] ),
				'show_summary' => 1,
				'show_author'  => 0,
				'show_date'    => 1,
			] );
			?>

			<div style="border-top: 1px solid #e7e7e7; padding-top: 12px !important; font-size: 12px;">
				<img src="<?php echo esc_url( PW()->plugin_url( 'assets/images/feed.png' ) ); ?>" width="16"
					 height="16">
				<a href="http://woosupport.ir" target="_new" title="خانه">وب سایت پشتیبان ووکامرس پارسی</a>
			</div>
		</div>
		<?php
	}

	public function widget_settings() {

		$options = $this->widget_options();

		if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['widget_id'] ) && 'persian_woocommerce_feed' == $_POST['widget_id'] ) {
			$options['posts_number'] = intval( $_POST['posts_number'] );
			update_option( 'persian_woocommerce_feed', $options );
		}
		?>
		<p>
			<label for="posts_number">تعداد نوشته های قابل نمایش در ابزارک ووکامرس پارسی:
				<select id="posts_number" name="posts_number">
					<?php for ( $i = 3; $i <= 20; $i ++ ) {
						printf( '<option value="%d" %s>%d</option>', $i, selected( $options['posts_number'], $i, false ), $i );
					}
					?>
				</select>
			</label>
		</p>
		<?php
	}

	public function widget_options() {
		$defaults = [ 'posts_number' => 5 ];
		if ( ( ! $options = get_option( 'persian_woocommerce_feed' ) ) || ! is_array( $options ) ) {
			$options = [];
		}

		return array_merge( $defaults, $options );
	}
}

new Persian_Woocommerce_Widget();