Skip to content

Commit

Permalink
update 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mark2me committed Oct 13, 2022
1 parent 25fcb9e commit 09e7bb2
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 51 deletions.
2 changes: 0 additions & 2 deletions inc/page_setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
exit;
}

settings_errors( 'siga4w-settings-notices' );

?>

<div class="wrap">
Expand Down
11 changes: 10 additions & 1 deletion classes/uppgrade.php → inc/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public function __construct($options){
*/
public function run() {

/**
* Replace label %d -> %s
* @since 1.0.1
*/
if( version_compare( $this->opt_version, '1.0', '==' ) ) {

$new_widgets = $widgets = get_option('widget_'.SIGA4W_WIDGET_ID);
Expand All @@ -31,13 +35,18 @@ public function run() {
if(is_int($id)){
foreach( $widget as $key => $val ){
if( strpos($key,'_label') !== false && strpos($val,'%d') !== false ){
$new_widgets[$id][$key] = str_replace('%d', '%s', $val);
$new_widgets[$id][$key] = str_replace( '%d', '%s', $val );
}
}
}
}
}

if( isset($this->options['post_pv_label']) && !empty($this->options['post_pv_label']) ){
$this->options['post_pv_label'] = str_replace( '%d', '%s', $this->options['post_pv_label'] );
update_option( SIGA4W_OPTION, $this->options );
}

if( $widgets != $new_widgets ) {
update_option( 'widget_'.SIGA4W_WIDGET_ID, $new_widgets );
}
Expand Down
Binary file modified languages/sig-ga4-widget-zh_TW.mo
Binary file not shown.
36 changes: 18 additions & 18 deletions languages/sig-ga4-widget-zh_TW.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Project-Id-Version: Sig GA4 widget 1.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/sig-ga4-"
"widget\n"
"POT-Creation-Date: 2022-10-12T16:36:51+08:00\n"
"PO-Revision-Date: 2022-10-12 16:37+0800\n"
"POT-Creation-Date: 2022-10-13T11:04:51+08:00\n"
"PO-Revision-Date: 2022-10-13 11:05+0800\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: zh_TW\n"
Expand Down Expand Up @@ -211,44 +211,44 @@ msgstr ""
msgid "How to setup:"
msgstr "如何設定:"

#: inc/page_setting.php:132 sig-ga4-widget.php:89
#: inc/page_setting.php:132 sig-ga4-widget.php:91
msgid "GA4 widget config"
msgstr "GA4 小工具設定"

#: inc/page_setting.php:147
#: inc/page_setting.php:146
msgid "Are you sure you want to delete this file?"
msgstr "您確定要刪除這個檔案嗎?"

#: inc/page_show.php:21
#: inc/page_show.php:17
msgid "Current month"
msgstr "本月"

#. translators: %1$s is start date, %2$s is end date.
#: inc/page_show.php:27 inc/page_show.php:46
#: inc/page_show.php:23 inc/page_show.php:42
msgid "Date range: %1$s ~ %2$s"
msgstr "日期時間範圍:%1$s ~ %2$s"

#: inc/page_show.php:40
#: inc/page_show.php:36
msgid "Current year"
msgstr "今年"

#: inc/page_show.php:61
#: inc/page_show.php:57
msgid "Popular Posts (last 7 days)"
msgstr "熱門文章(過去7天)"

#: inc/page_show.php:71
#: inc/page_show.php:67
msgid "Page title"
msgstr "頁面標題"

#: inc/page_show.php:72
#: inc/page_show.php:68
msgid "Pageviews"
msgstr "瀏覽次數"

#: inc/page_show.php:116 inc/page_show.php:147
#: inc/page_show.php:115 inc/page_show.php:146
msgid "pageviews"
msgstr "瀏覽"

#: inc/page_show.php:116 inc/page_show.php:147
#: inc/page_show.php:115 inc/page_show.php:146
msgid "visits"
msgstr "造訪"

Expand All @@ -257,28 +257,28 @@ msgstr "造訪"
msgid "Pageviews: %s"
msgstr "瀏覽次數:%s"

#: sig-ga4-widget.php:75
#: sig-ga4-widget.php:77
msgid "Settings"
msgstr "設定"

#: sig-ga4-widget.php:88
#: sig-ga4-widget.php:90
msgid "GA4 charts"
msgstr "GA4 統計圖表"

#: sig-ga4-widget.php:102
#: sig-ga4-widget.php:104
msgid "Please upload the json file and fill in the web property id."
msgstr "請上傳 json 檔案並填入網站資源ID。"

#. translators: %1$s is error message, %2$s is status.
#: sig-ga4-widget.php:113
#: sig-ga4-widget.php:115
msgid "Error: %1$s<br>Status: %2$s"
msgstr "錯誤:%1$s<br>狀態:%2$s"

#: sig-ga4-widget.php:167
#: sig-ga4-widget.php:176
msgid "Only json files are allowed"
msgstr "只允許 json 檔案"

#: sig-ga4-widget.php:299
#: sig-ga4-widget.php:308
msgid "Not allow do this action"
msgstr "未允許執行此操作"

Expand Down
40 changes: 20 additions & 20 deletions languages/sig-ga4-widget.pot
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2022-10-12T16:36:51+08:00\n"
"POT-Creation-Date: 2022-10-13T11:04:51+08:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.6.0\n"
"X-Domain: sig-ga4-widget\n"
Expand Down Expand Up @@ -197,47 +197,47 @@ msgid "How to setup:"
msgstr ""

#: inc/page_setting.php:132
#: sig-ga4-widget.php:89
#: sig-ga4-widget.php:91
msgid "GA4 widget config"
msgstr ""

#: inc/page_setting.php:147
#: inc/page_setting.php:146
msgid "Are you sure you want to delete this file?"
msgstr ""

#: inc/page_show.php:21
#: inc/page_show.php:17
msgid "Current month"
msgstr ""

#. translators: %1$s is start date, %2$s is end date.
#: inc/page_show.php:27
#: inc/page_show.php:46
#: inc/page_show.php:23
#: inc/page_show.php:42
msgid "Date range: %1$s ~ %2$s"
msgstr ""

#: inc/page_show.php:40
#: inc/page_show.php:36
msgid "Current year"
msgstr ""

#: inc/page_show.php:61
#: inc/page_show.php:57
msgid "Popular Posts (last 7 days)"
msgstr ""

#: inc/page_show.php:71
#: inc/page_show.php:67
msgid "Page title"
msgstr ""

#: inc/page_show.php:72
#: inc/page_show.php:68
msgid "Pageviews"
msgstr ""

#: inc/page_show.php:116
#: inc/page_show.php:147
#: inc/page_show.php:115
#: inc/page_show.php:146
msgid "pageviews"
msgstr ""

#: inc/page_show.php:116
#: inc/page_show.php:147
#: inc/page_show.php:115
#: inc/page_show.php:146
msgid "visits"
msgstr ""

Expand All @@ -246,27 +246,27 @@ msgstr ""
msgid "Pageviews: %s"
msgstr ""

#: sig-ga4-widget.php:75
#: sig-ga4-widget.php:77
msgid "Settings"
msgstr ""

#: sig-ga4-widget.php:88
#: sig-ga4-widget.php:90
msgid "GA4 charts"
msgstr ""

#: sig-ga4-widget.php:102
#: sig-ga4-widget.php:104
msgid "Please upload the json file and fill in the web property id."
msgstr ""

#. translators: %1$s is error message, %2$s is status.
#: sig-ga4-widget.php:113
#: sig-ga4-widget.php:115
msgid "Error: %1$s<br>Status: %2$s"
msgstr ""

#: sig-ga4-widget.php:167
#: sig-ga4-widget.php:176
msgid "Only json files are allowed"
msgstr ""

#: sig-ga4-widget.php:299
#: sig-ga4-widget.php:308
msgid "Not allow do this action"
msgstr ""
21 changes: 14 additions & 7 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,21 @@ Show your google analytics 4 visit data on your template widget.

== Installation ==

This section describes how to install the plugin and get it working.
= Automatic installation =

e.g.
1. Login your WordPress admin
2. Click __Plugins__
3. Click __Add New__
4. Search for __Sig GA4 Widget__
5. Click __Install Now__ under "Sig GA4 Widget"
6. Activate the plugin

1. Upload the plugin files to the `/wp-content/plugins/plugin-name` directory, or install the plugin through the WordPress plugins screen directly.
1. Activate the plugin through the `Plugins` screen in WordPress.
1. Go to `Settings` -> `GA4 widget config` to configure the plugin.
1. Go to `Widget` setup your sidebar widget.
= Manual installation =

1. Download the plugin
2. Extract the contents of the zip file
3. Upload the contents of the zip file to the `wp-content/plugins/` folder of your WordPress installation
4. Activate the Sig GA4 Widget plugin from 'Plugins' page.

== Screenshots ==

Expand All @@ -31,7 +38,7 @@ e.g.
== Changelog ==

= 1.0.1 =
* Fixed something and add something.
* Add choose post pageview position.

= 1.0 =
* Initial Public Release
Expand Down
15 changes: 12 additions & 3 deletions sig-ga4-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

require_once( SIGA4W_DIR . '/vendor/autoload.php' );
require_once( SIGA4W_DIR . '/inc/helper.php' );
require_once( SIGA4W_DIR . '/classes/uppgrade.php' );
require_once( SIGA4W_DIR . '/inc/upgrade.php' );

new SIGA4W_init();

Expand All @@ -47,9 +47,11 @@ public function __construct() {

add_filter( 'plugin_action_links_'.plugin_basename(__FILE__), [ $this , 'add_settings_link' ] );

add_action( 'wp_enqueue_scripts', [ $this, 'add_wp_enqueues' ] );

add_action( 'admin_menu', [ $this, 'add_admin_menu' ] );

add_action( 'admin_enqueue_scripts', [ $this, 'add_enqueues' ] );
add_action( 'admin_enqueue_scripts', [ $this, 'add_admin_enqueues' ] );

add_action( 'admin_init', [ $this, 'register_settings_fields' ] );

Expand Down Expand Up @@ -130,10 +132,17 @@ public function register_settings_fields() {
register_setting( SIGA4W_OPTION_GROUP, SIGA4W_OPTION, [ $this, 'cb_file_upload' ] );
}

/**
* Load jquery
*/
public function add_wp_enqueues() {
wp_enqueue_script( 'jquery' );
}

/**
* Add style & script files
*/
public function add_enqueues($hook){
public function add_admin_enqueues($hook){

if( in_array( $hook, array( 'settings_page_siga4w_setting', 'toplevel_page_siga4w_page' ) ) ) {
wp_enqueue_style( 'bootstrap4', SIGA4W_PLUGIN_URL . 'assets/css/bootstrap-grid.min.css' );
Expand Down

0 comments on commit 09e7bb2

Please sign in to comment.