Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jeremy Groot
/
stellervista-Intranet
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
921d7660
authored
2024-08-19 15:37:56 -0400
by
Jeff Balicki
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added filters
Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent
9d48efc0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
34 deletions
wp-content/plugins/stellervista-export-media-urls/classes/class-export-media-urls-admin.php
wp-content/plugins/stellervista-export-media-urls/classes/class-export-media-urls-admin.php
View file @
921d766
...
...
@@ -66,7 +66,7 @@ class ExportMediaURLsAdmin
public
function
enqueue_scripts
(
$hook_suffix
)
{
if
(
$hook_suffix
!==
Constants
::
PLUGIN_HOOK_SUFFIX
)
{
if
(
$hook_suffix
!==
Constants
::
PLUGIN_HOOK_SUFFIX
)
{
return
;
}
...
...
@@ -81,7 +81,7 @@ class ExportMediaURLsAdmin
wp_enqueue_script
(
'select2'
);
wp_enqueue_style
(
'select2css'
);
}
wp_enqueue_script
(
'emu_script'
,
plugin_dir_url
(
__FILE__
)
.
'../assets/js/script.js'
,
array
(
'jquery'
,
'select2'
),
'2.1'
,
true
);
}
...
...
@@ -101,7 +101,7 @@ class ExportMediaURLsAdmin
$user_names
[]
=
$user
->
data
->
user_login
;
}
?>
?>
<div
class=
"wrap"
>
...
...
@@ -121,11 +121,11 @@ class ExportMediaURLsAdmin
<td>
<label><input
type=
"checkbox"
name=
"additional-data[]"
value=
"id"
checked
/>
<label><input
type=
"checkbox"
name=
"additional-data[]"
value=
"id"
checked
/>
ID
</label><br
/>
<label><input
type=
"checkbox"
name=
"additional-data[]"
value=
"title"
checked
/>
<label><input
type=
"checkbox"
name=
"additional-data[]"
value=
"title"
checked
/>
Title
</label><br
/>
<label><input
type=
"checkbox"
name=
"additional-data[]"
value=
"file_name"
checked
/>
<label><input
type=
"checkbox"
name=
"additional-data[]"
value=
"file_name"
checked
/>
File Name
</label><br
/>
<label><input
type=
"checkbox"
name=
"additional-data[]"
value=
"caption"
/>
Caption
</label><br
/>
...
...
@@ -135,10 +135,14 @@ class ExportMediaURLsAdmin
Description
</label><br
/>
<label><input
type=
"checkbox"
name=
"additional-data[]"
value=
"url"
checked
/>
URL
</label><br
/>
<label><input
type=
"checkbox"
name=
"additional-data[]"
value=
"date"
checked
/>
Date Uploaded
</label><br
/>
<label><input
type=
"checkbox"
name=
"additional-data[]"
value=
"date"
checked
/>
Date
Uploaded
</label><br
/>
<label><input
type=
"checkbox"
name=
"additional-data[]"
value=
"type"
checked
/>
Type
</label><br
/>
<label><input
type=
"checkbox"
name=
"additional-data[]"
value=
"category"
checked
/>
Category
&
filters
</label><br
/>
<label><input
type=
"checkbox"
name=
"additional-data[]"
value=
"type"
checked
/>
Type
</label><br
/>
<label><input
type=
"checkbox"
name=
"additional-data[]"
value=
"category"
checked
/>
Category
</label><br
/>
</td>
...
...
@@ -147,7 +151,8 @@ class ExportMediaURLsAdmin
<tr>
<th><label
for=
"post-author"
>
By Author:
</label></th>
<td>
<select
id=
"post-author"
class=
"select2"
name=
"post-author"
required=
"required"
style=
"width: 40%;"
>
<select
id=
"post-author"
class=
"select2"
name=
"post-author"
required=
"required"
style=
"width: 40%;"
>
<option
value=
"all"
selected
>
All
</option>
<?php
if
(
!
empty
(
$user_ids
)
&&
!
empty
(
$user_names
))
{
...
...
@@ -167,7 +172,8 @@ class ExportMediaURLsAdmin
<td>
<label><input
type=
"radio"
name=
"export-type"
value=
"csv"
required=
"required"
checked
/>
CSV File
</label><br
/>
<label><input
type=
"radio"
name=
"export-type"
value=
"csv"
required=
"required"
checked
/>
CSV File
</label><br
/>
<label><input
type=
"radio"
name=
"export-type"
value=
"dashboard"
required=
"required"
/>
Output here
</label><br
/>
...
...
@@ -195,13 +201,13 @@ class ExportMediaURLsAdmin
</div>
</div>
<div
class=
"EMU-Side-Container"
>
</div>
</div>
</div>
<?php
<?php
if
(
isset
(
$_POST
[
'export'
]))
{
...
...
@@ -274,10 +280,10 @@ class ExportMediaURLsAdmin
$line_break
=
$export_type
==
'dashboard'
?
"<br/>"
:
""
;
$query_media_urls
=
array
(
'post_type'
=>
'attachment'
,
'author'
=>
$post_author
!=
'all'
?
$post_author
:
""
,
'post_status'
=>
'inherit'
,
'posts_per_page'
=>
-
1
,
'post_type'
=>
'attachment'
,
'author'
=>
$post_author
!=
'all'
?
$post_author
:
""
,
'post_status'
=>
'inherit'
,
'posts_per_page'
=>
-
1
,
);
$query_urls
=
new
\WP_Query
(
$query_media_urls
);
...
...
@@ -292,12 +298,12 @@ class ExportMediaURLsAdmin
$counter
=
0
;
while
(
$query_urls
->
have_posts
())
{
$query_urls
->
the_post
();
$used_categories
=
array
();
if
(
!
isset
(
$data
[
$data_type
][
$counter
]))
{
$data
[
$data_type
][
$counter
]
=
null
;
}
switch
(
$data_type
)
{
case
'id'
:
$data
[
$data_type
][
$counter
]
.=
get_the_ID
()
.
$line_break
;
...
...
@@ -337,15 +343,54 @@ class ExportMediaURLsAdmin
$data
[
$data_type
][
$counter
]
.=
get_post_mime_type
()
.
$line_break
;
break
;
case
'category'
:
$categories
=
wp_get_post_terms
(
get_the_ID
(),
'mlo-category'
,
array
(
'fields'
=>
'names'
));
$data
[
'category'
][
$counter
]
.=
implode
(
', '
,
$categories
)
.
$line_break
;
$categories
=
wp_get_post_terms
(
get_the_ID
(),
'mlo-category'
,
array
(
'fields'
=>
'all'
));
$used_categories
=
array
();
$category_terms
=
array
();
$sub_category_terms
=
array
();
foreach
(
$categories
as
$category
)
{
if
(
$category
->
parent
==
0
)
{
// Add to category array and mark as used
$category_terms
[]
=
$category
->
name
;
$used_categories
[]
=
$category
->
term_id
;
}
}
foreach
(
$categories
as
$category
)
{
if
(
$category
->
parent
!=
0
&&
!
in_array
(
$category
->
term_id
,
$used_categories
))
{
// Add to sub-category array if not already used
$sub_category_terms
[]
=
$category
->
name
;
}
}
if
(
empty
(
$category_terms
)
&&
!
empty
(
$sub_category_terms
))
{
// Get the parent term of one of the sub-category terms
$first_sub_category
=
reset
(
$sub_category_terms
);
foreach
(
$categories
as
$category
)
{
if
(
$category
->
name
==
$first_sub_category
)
{
$parent_term
=
get_term
(
$category
->
parent
,
'mlo-category'
);
if
(
!
is_wp_error
(
$parent_term
)
&&
$parent_term
)
{
$category_terms
[]
=
$parent_term
->
name
;
}
break
;
}
}
}
if
(
!
empty
(
$category_terms
))
{
$data
[
'category'
][
$counter
]
.=
implode
(
', '
,
$category_terms
)
.
$line_break
;
}
if
(
!
empty
(
$sub_category_terms
))
{
$data
[
'sub-category'
][
$counter
]
.=
implode
(
', '
,
$sub_category_terms
)
.
$line_break
;
}
break
;
default
:
default
:
break
;
}
$counter
++
;
}
...
...
@@ -362,16 +407,17 @@ class ExportMediaURLsAdmin
$filtered_headers
=
[];
$headers
=
[
'id'
=>
'ID'
,
'title'
=>
'Title'
,
'file_name'
=>
'File Name'
,
'caption'
=>
'Caption'
,
'alt'
=>
'Alt Text'
,
'id'
=>
'ID'
,
'title'
=>
'Title'
,
'file_name'
=>
'File Name'
,
'caption'
=>
'Caption'
,
'alt'
=>
'Alt Text'
,
'description'
=>
'Description'
,
'url'
=>
'URLs'
,
'date'
=>
'Date Uploaded'
,
'type'
=>
'Type'
,
'category'
=>
'Categories'
,
'url'
=>
'URLs'
,
'date'
=>
'Date Uploaded'
,
'type'
=>
'Type'
,
'category'
=>
'Categories'
,
'sub-category'
=>
'Filters'
,
];
foreach
(
$headers
as
$key
=>
$name
)
{
...
...
Please
register
or
sign in
to post a comment