Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hosting_reviews
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Ali Arshad
hosting_reviews
Commits
b57601c3
Commit
b57601c3
authored
Dec 27, 2019
by
Muhammad Usman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
csv export
parent
b243c5f9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
+27
-2
theme-settings.php
...wp-content/themes/hostingreviews/admin/theme-settings.php
+25
-0
footer.php
WWW_DATA/wp-content/themes/hostingreviews/footer.php
+2
-2
No files found.
WWW_DATA/wp-content/themes/hostingreviews/admin/theme-settings.php
View file @
b57601c3
...
...
@@ -6,14 +6,39 @@ function vq_theme_settings_page()
<div
class=
"wrap"
>
<h1>
Theme Settings
</h1>
<form
method=
"post"
action=
"options.php"
>
<button
class=
"my-5"
type=
"button"
onclick=
"exportCSV()"
>
Export Subscribers
</button>
<?php
settings_fields
(
"section"
);
do_settings_sections
(
"hosting-review-theme-options"
);
do_settings_sections
(
"hosting-server-locations"
);
global
$wpdb
;
$subTableName
=
$wpdb
->
prefix
.
"review_subscribers"
;
$oldResutls
=
$wpdb
->
get_results
(
"SELECT * FROM
$subTableName
"
);
submit_button
();
?>
<script>
var
subscribers
=
<?php
echo
json_encode
(
$oldResutls
)
?
json_encode
(
$oldResutls
)
:
'[]'
?>
;
function
exportCSV
()
{
const
list
=
subscribers
.
map
(
s
=>
[
s
.
id
,
s
.
name
,
s
.
email
]);
let
csvContent
=
"data:text/csv;charset=utf-8,"
;
list
.
forEach
(
function
(
rowArray
)
{
let
row
=
rowArray
.
join
(
","
);
csvContent
+=
row
+
"
\
r
\
n"
;
});
var
encodedUri
=
encodeURI
(
csvContent
);
window
.
open
(
encodedUri
);
}
</script>
</form>
</div>
<?php
...
...
WWW_DATA/wp-content/themes/hostingreviews/footer.php
View file @
b57601c3
...
...
@@ -35,8 +35,8 @@
if
(
subscriberNameEl
.
value
.
trim
()
&&
validateEmail
(
subscriberEmailEl
.
value
))
{
var
actData
=
{
'action'
:
'add_review_subscribers'
,
'email'
:
subscriber
Name
El
.
value
,
'name'
:
subscriber
Email
El
.
value
'email'
:
subscriber
Email
El
.
value
,
'name'
:
subscriber
Name
El
.
value
};
$
.
post
(
ajax_url
,
actData
,
function
(
response
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment