From 09e7bb265d7ee7e40907ad7cf8178d76a8a869eb Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 13 Oct 2022 17:18:05 +0800 Subject: [PATCH] update 1.0.1 --- inc/page_setting.php | 2 -- classes/uppgrade.php => inc/upgrade.php | 11 ++++++- languages/sig-ga4-widget-zh_TW.mo | Bin 4820 -> 4820 bytes languages/sig-ga4-widget-zh_TW.po | 36 ++++++++++----------- languages/sig-ga4-widget.pot | 40 ++++++++++++------------ readme.txt | 21 ++++++++----- sig-ga4-widget.php | 15 +++++++-- 7 files changed, 74 insertions(+), 51 deletions(-) rename classes/uppgrade.php => inc/upgrade.php (77%) diff --git a/inc/page_setting.php b/inc/page_setting.php index f7c0ed5..d4d0f39 100644 --- a/inc/page_setting.php +++ b/inc/page_setting.php @@ -3,8 +3,6 @@ exit; } -settings_errors( 'siga4w-settings-notices' ); - ?>
diff --git a/classes/uppgrade.php b/inc/upgrade.php similarity index 77% rename from classes/uppgrade.php rename to inc/upgrade.php index 7b94187..f558106 100644 --- a/classes/uppgrade.php +++ b/inc/upgrade.php @@ -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); @@ -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 ); } diff --git a/languages/sig-ga4-widget-zh_TW.mo b/languages/sig-ga4-widget-zh_TW.mo index 0e35dfd58879dc5125a0eb3c0c1b83688d73f012..ac0173aa46df1d1aebf08487781a6901ec83e3a1 100644 GIT binary patch delta 20 bcmcbjdPQ}^FK%{Y1w%tC1JlinJeS!3P;&;H delta 20 bcmcbjdPQ}^FK%`t1w%6{WAn|7JeS!3P_+i7 diff --git a/languages/sig-ga4-widget-zh_TW.po b/languages/sig-ga4-widget-zh_TW.po index 1c6d5fe..b6717ea 100644 --- a/languages/sig-ga4-widget-zh_TW.po +++ b/languages/sig-ga4-widget-zh_TW.po @@ -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" @@ -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 "造訪" @@ -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
Status: %2$s" msgstr "錯誤:%1$s
狀態:%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 "未允許執行此操作" diff --git a/languages/sig-ga4-widget.pot b/languages/sig-ga4-widget.pot index 6e47d15..f5093a6 100644 --- a/languages/sig-ga4-widget.pot +++ b/languages/sig-ga4-widget.pot @@ -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" @@ -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 "" @@ -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
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 "" diff --git a/readme.txt b/readme.txt index 361d6c0..77af35a 100644 --- a/readme.txt +++ b/readme.txt @@ -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 == @@ -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 diff --git a/sig-ga4-widget.php b/sig-ga4-widget.php index d11ac5c..735628c 100644 --- a/sig-ga4-widget.php +++ b/sig-ga4-widget.php @@ -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(); @@ -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' ] ); @@ -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' );