Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
ETH Embed Anchor.fm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WP Plugins
ETH Embed Anchor.fm
Commits
41e054f4
Commit
41e054f4
authored
2 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Introduce singleton to prepare for Block Editor class
parent
458dc748
No related branches found
No related tags found
1 merge request
!2
Add `core/embed` variation in Block Editor
Pipeline
#5148
failed
2 years ago
Stage: test
Stage: security
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
eth-embed-anchor-fm.php
+2
-0
2 additions, 0 deletions
eth-embed-anchor-fm.php
inc/class-plugin.php
+2
-28
2 additions, 28 deletions
inc/class-plugin.php
inc/trait-singleton.php
+48
-0
48 additions, 0 deletions
inc/trait-singleton.php
with
52 additions
and
28 deletions
eth-embed-anchor-fm.php
+
2
−
0
View file @
41e054f4
...
...
@@ -45,5 +45,7 @@ add_action( 'plugins_loaded', __NAMESPACE__ . '\action_plugins_loaded' );
/**
* Load plugin classes.
*/
require_once
__DIR__
.
'/inc/trait-singleton.php'
;
require_once
__DIR__
.
'/inc/class-plugin.php'
;
Plugin
::
get_instance
();
This diff is collapsed.
Click to expand it.
inc/class-plugin.php
+
2
−
28
View file @
41e054f4
...
...
@@ -11,6 +11,8 @@ namespace ETH_Embed_Anchor_FM;
* Class Plugin.
*/
class
Plugin
{
use
Singleton
;
/**
* Regex pattern to match URL to be oEmbedded.
*
...
...
@@ -39,34 +41,6 @@ class Plugin {
*/
private
const
SHORTCODE_TAG
=
'eth_anchor_fm'
;
/**
* Singleton.
*
* @var Plugin
*/
private
static
$_instance
=
null
;
/**
* Implement singleton.
*
* @return Plugin
*/
public
static
function
get_instance
():
Plugin
{
if
(
!
is_a
(
self
::
$_instance
,
__CLASS__
)
)
{
self
::
$_instance
=
new
self
();
self
::
$_instance
->
_setup
();
}
return
self
::
$_instance
;
}
/**
* Silence is golden!
*/
private
function
__construct
()
{
// Add nothing here.
}
/**
* Register hooks.
*
...
...
This diff is collapsed.
Click to expand it.
inc/trait-singleton.php
0 → 100644
+
48
−
0
View file @
41e054f4
<?php
/**
* Singleton trait.
*
* @package ETH_Embed_Anchor_FM
*/
namespace
ETH_Embed_Anchor_FM
;
/**
* Trait Singleton.
*/
trait
Singleton
{
/**
* Singleton.
*
* @var self
*/
private
static
$_instance
=
null
;
/**
* Implement singleton.
*
* @return self
*/
public
static
function
get_instance
():
self
{
if
(
!
is_a
(
self
::
$_instance
,
__CLASS__
)
)
{
self
::
$_instance
=
new
self
();
self
::
$_instance
->
_setup
();
}
return
self
::
$_instance
;
}
/**
* Silence is golden!
*/
private
function
__construct
()
{
// Add nothing here.
}
/**
* Register hooks.
*
* @return void
*/
abstract
function
_setup
():
void
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment