[WordPress] Templating and Conditional Logic with OOP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="wrap"> | |
<!-- Snipping out irrelevant code in this file --> | |
<form id="yhd-upload-new-item-settings"> | |
<?php if (!$this->hasSecondaryPlugin()) { ?> | |
<?php include_once 'partials/error-inactive-plugin.php'; ?> | |
<?php } else { ?> | |
<h2>Secondary Plugin Settings</h2> | |
<p class="description">The Secondary Plugin is installed and active.</p> | |
<form method="post" action="<?php echo esc_html(admin_url('admin-post.php')); ?>"> | |
<label for="acme-secondary-plugin"> | |
<input type="checkbox" name="acme-secondary-plugin" value="true"/> | |
Would you like to automatically use the secondary plugin? | |
</label> | |
<!-- Snipping out irrelevant code in this file --> | |
</form> | |
<?php } ?> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This is the partial displayed when the Secondary Plugin is not active. | |
*/ | |
?> | |
<div id="inactive-importer-message" class="error notice is-dismissible"> | |
<p>[The message you want to display here.]</p> | |
<button type="button" class="notice-dismiss"> | |
<span class="screen-reader-text">Dismiss this notice.</span> | |
</button> | |
</div><!-- #inactive-importer-message --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Determines if the Secondary Importer is is activated. | |
* | |
* @return bool True if the the pklugin is active; false, otherwise. | |
*/ | |
private function hasSecondaryPlugin() | |
{ | |
return in_array( | |
'secondary-plugin/secondary-plugin.php', | |
get_option('active_plugins') | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment