-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from visual-framework/removes-plugins
re-adds header footer injections plugin
- Loading branch information
Showing
20 changed files
with
1,992 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
|
||
.form-table, .form-table td, .form-table th, .form-table td p, .form-wrap label { | ||
font-size: 12px; | ||
} | ||
|
||
.form-table th { | ||
font-weight: bold; | ||
font-size: 12px; | ||
text-align: right; | ||
border-right: 1px solid #ddd; | ||
} | ||
.form-table td { | ||
font-size: 12px; | ||
} | ||
|
||
h3 { | ||
font-weight: bold; | ||
margin-bottom: 0; | ||
padding: 0; | ||
text-transform: uppercase; | ||
} | ||
|
||
.form-table textarea, .ui-widget textarea { | ||
font-family: Consolas,Monaco,monospace; | ||
} | ||
|
||
.notice { | ||
position: relative; | ||
} | ||
.hefo-dismiss { | ||
position: absolute; | ||
top: 0px; | ||
right: 10px; | ||
text-decoration: none; | ||
font-size: 20px; | ||
} | ||
|
||
.CodeMirror { | ||
border: 1px solid #eee; | ||
height: 200px; | ||
} | ||
|
||
.row { | ||
margin-left: -10px; margin-right: -10px; | ||
box-sizing: border-box; | ||
} | ||
|
||
.col-1 { | ||
width: 100%; | ||
min-width: 350px; | ||
float: left; | ||
padding: 10px; | ||
box-sizing: border-box; | ||
} | ||
|
||
.col-2 { | ||
width: 50%; | ||
min-width: 350px; | ||
float: left; | ||
padding: 10px; | ||
box-sizing: border-box; | ||
} | ||
|
||
.clearfix { | ||
float: none; | ||
clear: both; | ||
display: table; | ||
content: ""; | ||
} | ||
|
||
.hefo-cm { | ||
width: 100%; | ||
height: 100px; | ||
box-sizing: border-box; | ||
} | ||
|
||
@media all and (max-width: 1200px) { | ||
.col-2 { | ||
width: 100%; | ||
box-sizing: border-box; | ||
} | ||
} | ||
|
||
.rules { | ||
margin-top: 15px; | ||
} | ||
.rules select { | ||
height: 27px; | ||
display: block; | ||
margin-right: 10px; | ||
} | ||
|
||
.rules input { | ||
height: 27px; | ||
display: block; | ||
margin-right: 10px; | ||
} | ||
|
||
.rules div { | ||
margin-right: 10px; | ||
padding-top: 5px; | ||
} | ||
|
||
.hf-index-entry { | ||
display: block; | ||
background-color: #aaa; | ||
color: white; | ||
text-decoration: none; | ||
width: 150px; | ||
box-sizing: border-box; | ||
border: 2px solid #aaa; | ||
} | ||
|
||
.hf-index-entry:hover { | ||
border-color: #ddd; | ||
} | ||
|
||
.col-2 label { | ||
font-size: 12px; | ||
text-transform: uppercase; | ||
display: block; | ||
} | ||
|
||
a.readmore { | ||
display: inline-block; | ||
background-color: #007cba; | ||
padding: 3px 10px; | ||
color: #fff; | ||
text-decoration: none; | ||
border-radius: 5px; | ||
line-height: normal; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
defined('ABSPATH') || exit; | ||
|
||
add_action('admin_init', function () { | ||
global $hefo_options; | ||
|
||
if (isset($hefo_options['page_add_tags'])) { | ||
register_taxonomy_for_object_type('post_tag', 'page'); | ||
} | ||
|
||
if (isset($hefo_options['page_add_categories'])) { | ||
register_taxonomy_for_object_type('category', 'page'); | ||
} | ||
}); | ||
|
||
|
||
|
||
add_action('admin_menu', function() { | ||
add_options_page('Header and Footer', 'Header and Footer', 'manage_options', 'header-footer/admin/options.php'); | ||
}); | ||
|
||
|
||
if (isset($_GET['page']) && strpos($_GET['page'], 'header-footer/') === 0) { | ||
header('X-XSS-Protection: 0'); | ||
add_action('admin_enqueue_scripts', function () { | ||
wp_enqueue_script('jquery-ui-tabs'); | ||
wp_enqueue_style('hefo', plugins_url('header-footer') . '/admin/admin.css', [], time()); | ||
wp_enqueue_style('hefo-jquery-ui', plugins_url('header-footer') . '/vendor/jquery-ui/jquery-ui.min.css', [], time()); | ||
wp_enqueue_code_editor(['type' => 'php']); | ||
wp_enqueue_script('jquery-ui-tabs'); | ||
}); | ||
} | ||
|
||
add_action('add_meta_boxes', function () { | ||
add_meta_box('hefo', __('Head and Footer', 'header-footer'), 'hefo_meta_boxes_callback', ['post', 'page']); | ||
}); | ||
|
||
add_action('save_post', 'hefo_save_post'); | ||
|
||
|
||
function hefo_meta_boxes_callback($post) { | ||
|
||
// Use nonce for verification | ||
wp_nonce_field(plugin_basename(__FILE__), 'hefo'); | ||
|
||
// The actual fields for data entry | ||
// Use get_post_meta to retrieve an existing value from the database and use the value for the form | ||
$before = get_post_meta($post->ID, 'hefo_before', true); | ||
$after = get_post_meta($post->ID, 'hefo_after', true); | ||
echo '<label>'; | ||
echo '<input type="checkbox" id="hefo_before" name="hefo_before" ' . (empty($before) ? "" : "checked") . '> '; | ||
esc_html_e("Disable top injection", 'header-footer'); | ||
echo '</label> '; | ||
echo '<br>'; | ||
echo '<label>'; | ||
echo '<input type="checkbox" id="hefo_after" name="hefo_after]" ' . (empty($after) ? "" : "checked") . '> '; | ||
esc_html_e("Disable bottom injection", 'header-footer'); | ||
echo '</label> '; | ||
} | ||
|
||
|
||
function hefo_save_post($post_id) { | ||
|
||
if (!isset($_POST['hefo'])) return; | ||
|
||
// First we need to check if the current user is authorised to do this action. | ||
if (isset($_POST['post_type']) && 'page' == $_POST['post_type']) { | ||
if (!current_user_can('edit_page', $post_id)) | ||
return; | ||
} else { | ||
if (!current_user_can('edit_post', $post_id)) | ||
return; | ||
} | ||
|
||
// Secondly we need to check if the user intended to change this value. | ||
if (!wp_verify_nonce($_POST['hefo'], plugin_basename(__FILE__))) | ||
return; | ||
|
||
update_post_meta($post_id, 'hefo_before', isset($_REQUEST['hefo_before']) ? 1 : 0); | ||
update_post_meta($post_id, 'hefo_after', isset($_REQUEST['hefo_after']) ? 1 : 0); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<?php | ||
defined('ABSPATH') || exit; | ||
|
||
function hefo_request($name, $default = null) { | ||
if (!isset($_REQUEST[$name])) { | ||
return $default; | ||
} | ||
return stripslashes_deep($_REQUEST[$name]); | ||
} | ||
|
||
function hefo_base_checkbox($name, $label = '') { | ||
global $options; | ||
echo '<label>'; | ||
echo '<input type="checkbox" name="options[' . esc_attr($name) . ']" value="1" ' . | ||
(isset($options[$name]) ? 'checked' : '') . '>'; | ||
echo esc_html($label); | ||
echo '</label>'; | ||
} | ||
|
||
function hefo_field_checkbox_only($name, $tips = '', $attrs = '', $link = null) { | ||
global $options; | ||
echo '<td><input type="checkbox" name="options[' . esc_attr($name) . ']" value="1" ' . | ||
(isset($options[$name]) ? 'checked' : '') . '/>'; | ||
echo ' ' . $tips; | ||
if ($link) { | ||
echo '<br><a href="' . esc_attr($link) . '" target="_blank">Read more</a>.'; | ||
} | ||
echo '</td>'; | ||
} | ||
|
||
function hefo_field_text($name, $label = '', $tips = '') { | ||
global $options; | ||
|
||
if (!isset($options[$name])) { | ||
$options[$name] = ''; | ||
} | ||
|
||
echo '<th scope="row">'; | ||
echo '<label>' . esc_html($label) . '</label></th>'; | ||
echo '<td><input type="text" name="options[' . esc_attr($name) . ']" value="' . | ||
esc_attr($options[$name]) . '" size="50"/>'; | ||
echo '<br /> ' . $tips; | ||
echo '</td>'; | ||
} | ||
|
||
function hefo_base_text($name) { | ||
global $options; | ||
|
||
if (!isset($options[$name])) { | ||
$options[$name] = ''; | ||
} | ||
|
||
echo '<input type="text" name="options[' . esc_attr($name) . ']" value="' . | ||
esc_attr($options[$name]) . '" size="30">'; | ||
} | ||
|
||
function hefo_field_textarea($name, $label = '', $tips = '') { | ||
global $options; | ||
|
||
if (!isset($options[$name])) { | ||
$options[$name] = ''; | ||
} | ||
|
||
if (is_array($options[$name])) { | ||
$options[$name] = implode("\n", $options[$name]); | ||
} | ||
|
||
echo '<th scope="row">'; | ||
echo '<label>' . esc_html($label) . '</label></th>'; | ||
echo '<td><textarea style="width: 100%; height: 100px" wrap="off" name="options[' . esc_attr($name) . ']">' . | ||
esc_html($options[$name]) . '</textarea>'; | ||
echo '<p class="description">' . esc_html($tips) . '</p>'; | ||
echo '</td>'; | ||
} | ||
|
||
function hefo_base_textarea_cm($name, $type = '', $tips = '') { | ||
global $options; | ||
|
||
if (!empty($type)) { | ||
$type = '-' . $type; | ||
} | ||
|
||
if (!isset($options[$name])) { | ||
$options[$name] = ''; | ||
} | ||
|
||
if (is_array($options[$name])) { | ||
$options[$name] = implode("\n", $options[$name]); | ||
} | ||
|
||
echo '<textarea class="hefo-cm' . esc_attr($type) . '" name="options[' . esc_attr($name) . ']" onfocus="hefo_cm_on(this)">'; | ||
echo esc_html($options[$name]); | ||
echo '</textarea>'; | ||
echo '<p class="description">' . $tips . '</p>'; | ||
} | ||
|
||
function hefo_rule($number) { | ||
global $options; | ||
|
||
if (!isset($options['inner_pos_' . $number])) { | ||
$options['inner_pos_' . $number] = 'after'; | ||
} | ||
|
||
if (!isset($options['inner_skip_' . $number])) { | ||
$options['inner_skip_' . $number] = 0; | ||
} | ||
|
||
if (!isset($options['inner_tag_' . $number])) { | ||
$options['inner_tag_' . $number] = ''; | ||
} | ||
|
||
echo '<div class="rules">'; | ||
echo '<div style="float: left">Inject</div>'; | ||
echo '<select style="float: left" name="options[inner_pos_' . esc_attr($number) . ']">'; | ||
echo '<option value="after"'; | ||
echo $options['inner_pos_' . $number] == 'after' ? ' selected' : ''; | ||
echo '>after</option>'; | ||
echo '<option value="before"'; | ||
echo $options['inner_pos_' . $number] == 'before' ? ' selected' : ''; | ||
echo '>before</option>'; | ||
echo '</select>'; | ||
echo '<input style="float: left" type="text" placeholder="marker" name="options[inner_tag_' . esc_attr($number) . ']" value="'; | ||
echo esc_attr($options['inner_tag_' . $number]); | ||
echo '">'; | ||
echo '<div style="float: left">skipping</div>'; | ||
echo '<input style="float: left" type="text" size="5" name="options[inner_skip_' . esc_attr($number) . ']" value="'; | ||
echo esc_attr($options['inner_skip_' . $number]); | ||
echo '">'; | ||
echo '<div style="float: left">chars, on failure inject</div>'; | ||
echo '<select style="float: left" name="options[inner_alt_' . esc_attr($number) . ']">'; | ||
echo '<option value=""'; | ||
echo $options['inner_alt_' . $number] == 'after' ? ' selected' : ''; | ||
echo '>nowhere</option>'; | ||
echo '<option value="after"'; | ||
echo $options['inner_alt_' . $number] == 'after' ? ' selected' : ''; | ||
echo '>after the content</option>'; | ||
echo '<option value="before"'; | ||
echo $options['inner_alt_' . $number] == 'before' ? ' selected' : ''; | ||
echo '>before the content</option>'; | ||
echo '</select>'; | ||
echo '<div class="clearfix"></div></div>'; | ||
} | ||
|
||
|
Oops, something went wrong.