Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
autoshortcoder
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wordpress
autoshortcoder
Commits
be0ab5a8
Commit
be0ab5a8
authored
9 years ago
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ok, that's all!
parent
8f86e7d8
Pipeline
#18
skipped
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
1 deletion
+53
-1
class-autoshortcoder-settings.php
includes/class-autoshortcoder-settings.php
+1
-1
class-autoshortcoder.php
includes/class-autoshortcoder.php
+52
-0
No files found.
includes/class-autoshortcoder-settings.php
View file @
be0ab5a8
...
...
@@ -39,7 +39,7 @@ class autoshortcoder_Settings {
public
function
__construct
(
$parent
)
{
$this
->
parent
=
$parent
;
$this
->
base
=
'
wpt
_'
;
$this
->
base
=
'
autoshortcode
_'
;
// Initialise settings
add_action
(
'init'
,
array
(
$this
,
'init_settings'
),
11
);
...
...
This diff is collapsed.
Click to expand it.
includes/class-autoshortcoder.php
View file @
be0ab5a8
...
...
@@ -76,6 +76,8 @@ class autoshortcoder {
*/
public
$script_suffix
;
private
$done
;
/**
* Constructor function.
* @access public
...
...
@@ -85,6 +87,8 @@ class autoshortcoder {
public
function
__construct
(
$file
=
''
,
$version
=
'1.0.0'
)
{
$this
->
_version
=
$version
;
$this
->
_token
=
'autoshortcoder'
;
$this
->
done
=
false
;
// Load plugin environment variables
$this
->
file
=
$file
;
...
...
@@ -106,9 +110,57 @@ class autoshortcoder {
}
//add_action( 'init', array( $this, 'load_localisation' ), 0 );
add_filter
(
'the_content'
,
array
(
$this
,
'add_shortcodes'
));
}
// End __construct ()
public
function
get_tagarray
()
{
$options
=
get_option
(
'autoshortcode_autoshortcode_settings'
);
$options
=
explode
(
"
\n
"
,
str_replace
(
"
\r
"
,
""
,
$options
));
$opt
=
array
();
foreach
(
$options
as
$optline
)
{
$optarray
=
explode
(
"|"
,
$optline
);
$tag
=
trim
(
$optarray
[
0
]);
if
(
count
(
$optarray
)
>
2
)
{
$title
=
$optarray
[
1
];
$shortcode
=
$optarray
[
2
];
}
else
{
$title
=
false
;
$shortcode
=
$optarray
[
1
];
}
if
(
!
in_array
(
$tag
,
$opt
))
$opt
[
$tag
]
=
array
();
$opt
[
$tag
][]
=
array
(
'title'
=>
$title
,
'shortcode'
=>
$shortcode
);
}
//print_r($opt);
return
$opt
;
}
public
function
add_shortcodes
(
$content
)
{
if
(
!
$this
->
done
)
{
$tags
=
wp_get_post_tags
(
$GLOBALS
[
'post'
]
->
ID
,
array
(
'fields'
=>
'names'
));
$opts
=
$this
->
get_tagarray
();
foreach
(
$opts
as
$tagname
=>
$tagcontent
)
{
if
(
in_array
(
$tagname
,
$tags
))
{
foreach
(
$tagcontent
as
$addcode
)
{
$content
.=
"<hr>"
;
if
(
$addcode
[
'title'
])
{
$content
.=
'<h4>'
.
$addcode
[
'title'
]
.
'</h4>'
;
}
$content
.=
do_shortcode
(
$addcode
[
'shortcode'
]);
$content
.=
"<hr>"
;
}
}
}
}
$this
->
done
=
true
;
return
$content
;
}
/**
* Load admin CSS.
* @access public
...
...
This diff is collapsed.
Click to expand it.
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