Skip to content

Commit

Permalink
Added default settings to prevent fatal error
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Kobzarev committed Dec 6, 2019
1 parent 55701fd commit d89e1db
Show file tree
Hide file tree
Showing 106 changed files with 67 additions and 3,371 deletions.
28 changes: 27 additions & 1 deletion includes/class-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ class Main {
*/
private $wposa_obj;

/**
* @var array $defaults Default settings.
*/
private $defaults = [
'charset' => 'UTF-8',
'orderby' => 'date',
'order' => 'DESC',
'post_types' => [
'post' => 'post',
],
'taxonomies' => [
'category' => 'category',
],
'total_posts' => 1000,
];

public function __construct() {
$this->setup();
$this->hooks();
Expand Down Expand Up @@ -136,11 +152,21 @@ public function hide_wpseo_rss_footer( $include_footer = true ) {
public function send_headers_for_aio_seo_pack() {
// Добавим заголовок `X-Robots-Tag`
// для решения проблемы с сеошными плагинами.
header( 'X-Robots-Tag: index, follow', true );
if ( is_feed( $this->feedname ) ) {
header( 'X-Robots-Tag: index, follow', true );
}
}

public function on_activate() {

// Смотрим, есть ли настройки в базе данных,
// если нет - создадим дефолтные.
$settings = $this->wposa_obj->get_option( 'charset', 'feed' );

if ( ! $settings ) {
update_option( 'feed', $this->defaults );
}

// Добавим флаг, свидетельствующий о том,
// что нужно сбросить реврайты.
update_option( $this->slug . '_flush_rewrite_rules', 1, true );
Expand Down
34 changes: 32 additions & 2 deletions includes/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,43 @@ private function fields() {
)
);

$this->wposa_obj->add_field(
'contacts',
array(
'id' => 'help',
'type' => 'html',
'name' => __( 'Помощь', 'mihdan-mailru-pulse-feed' ),
'desc' => __( 'Нужна помощь?<br />По всем вопросам пишите в телеграм <a href="https://t.me/mihdan" target="_blank">@mihdan</a>.', 'mihdan-mailru-pulse-feed' ),
)
);

$this->wposa_obj->add_field(
'contacts',
array(
'id' => 'donate',
'type' => 'html',
'name' => __( 'Нужна помощь?', 'mihdan-mailru-pulse-feed' ),
'desc' => 'По всем вопросам пишите в телеграм @mihdan',
'name' => __( 'Благодарность', 'mihdan-mailru-pulse-feed' ),
'desc' => __( 'Хотите отблагодарить автора?<br />Сделать это можно на <a href="https://www.kobzarev.com/donate/" target="_blank">официальном сайте</a>.', 'mihdan-mailru-pulse-feed' ),
)
);

$this->wposa_obj->add_field(
'contacts',
array(
'id' => 'mark',
'type' => 'html',
'name' => __( 'Оценка', 'mihdan-mailru-pulse-feed' ),
'desc' => __( 'Хотите оценить плагин ★★★★★?<br />Сделать это можно на <a href="https://wordpress.org/support/plugin/mihdan-mailru-pulse-feed/reviews/?rate=5#new-post" target="_blank">официальном странице</a> плагина.', 'mihdan-mailru-pulse-feed' ),
)
);

$this->wposa_obj->add_field(
'contacts',
array(
'id' => 'plugins',
'type' => 'html',
'name' => __( 'Плагины автора', 'mihdan-mailru-pulse-feed' ),
'desc' => __( 'Понравился плагин?<br />Остальные полезные плагины автора вы можете посмотреть в <a href="https://profiles.wordpress.org/mihdan/#content-plugins" target="_blank">официальном репозитории</a> wp.org.', 'mihdan-mailru-pulse-feed' ),
)
);
}
Expand Down
6 changes: 3 additions & 3 deletions mihdan-mailru-pulse-feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
* Author URI: https://www.kobzarev.com/
* Requires at least: 4.6
* Tested up to: 5.3
* Version: 0.1.1
* Stable tag: 0.1.1
* Version: 0.1.2
* Stable tag: 0.1.2
*
* Text Domain: mihdan-mailru-pulse-feed
* Domain Path: /languages/
Expand All @@ -26,7 +26,7 @@
exit; // Exit if accessed directly.
}

define( 'MIHDAN_MAILRU_PULSE_FEED_VERSION', '0.1.1' );
define( 'MIHDAN_MAILRU_PULSE_FEED_VERSION', '0.1.2' );
define( 'MIHDAN_MAILRU_PULSE_FEED_PATH', __DIR__ );
define( 'MIHDAN_MAILRU_PULSE_FEED_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
define( 'MIHDAN_MAILRU_PULSE_FEED_FILE', __FILE__ );
Expand Down
7 changes: 5 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
=== Mihdan: Mail.ru Pulse Feed ===
Contributors: mihdan
Tags: mailru, pulse, feed
Tags: mailru, pulse, feed, seo, seo-friendly
Requires at least: 4.6
Tested up to: 5.3
Stable tag: 0.1.1
Stable tag: 0.1.2
Requires PHP: 5.2.60

WordPress плагин, формирующий ленту для новой рекомендательной системы Пульс от компании Mail.ru.
Expand Down Expand Up @@ -58,6 +58,9 @@ add_filter(

== Changelog ==

= 0.1.2 (06.12.2019) =
* Added default settings to prevent fatal error

= 0.1.1 (28.11.2019) =
* Updated readme.txt
* Fixed error with localization
Expand Down
7 changes: 0 additions & 7 deletions vendor/autoload.php

This file was deleted.

Loading

0 comments on commit d89e1db

Please sign in to comment.