function az_shortcode_init() { if (is_admin()) { if (is_edit_page()) { require_once plugin_dir_path(__FILE__) . 'tinymce/tinymce-class.php'; } } }
function yada_wiki_admin() { // Only add buttons if editing a Yada Wiki post if (current_user_can('edit_posts')) { // Snippet adapted from Ross McKay - http://snippets.webaware.com.au/snippets/wordpress-admin_init-hook-and-the-elusive-typenow/ global $typenow; if (empty($typenow)) { // try to pick it up from the query string if (!empty($_GET['post'])) { $post = get_post($_GET['post']); $typenow = $post->post_type; $typenow = sanitize_text_field($typenow); } elseif (!empty($_POST['post_ID'])) { $post = get_post($_POST['post_ID']); $typenow = $post->post_type; $typenow = sanitize_text_field($typenow); } elseif (is_edit_page('new')) { if (empty($_GET['post_type'])) { $typenow = "post"; } else { $type_test = sanitize_text_field($_GET['post_type']); $typenow = $type_test; } } } $options = get_option('yada_wiki_settings'); $yadaWikiEditorButtons = false; if (isset($options['yada_wiki_checkbox_editor_buttons_setting'])) { $yadaWikiEditorButtons = true; } if (is_edit_page() && ("yada_wiki" == $typenow || $yadaWikiEditorButtons == true)) { foreach (array('post.php', 'post-new.php') as $hook) { add_action("admin_footer-{$hook}", 'yw_admin_footer'); } wp_enqueue_style("wp-jquery-ui-dialog"); wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui-core'); wp_enqueue_script('jquery-ui-dialog'); wp_enqueue_script('jquery-ui-button'); wp_enqueue_script('jquery-ui-widget'); wp_enqueue_script('jquery-ui-position'); wp_enqueue_script('jquery-ui-autocomplete'); wp_enqueue_script('yadawiki-dialog', plugin_dir_url(__FILE__) . '../js/yadawiki-dialog.js', array('wpdialogs'), '20150815'); add_filter('mce_external_plugins', 'yada_wiki_link_add_plugin'); add_filter('mce_external_plugins', 'yada_wiki_toc_add_plugin'); add_filter('mce_buttons', 'yada_wiki_link_register_button'); add_filter('mce_buttons', 'yada_wiki_toc_register_button'); add_filter('wp_terms_checklist_args', 'yada_wiki_fix_cat_order'); } } }
function nectar_shortcode_init() { if (is_admin()) { if (is_edit_page()) { //load nectar shortcode button require_once 'nectar/tinymce/tinymce-class.php'; } } }
} elseif ($new_edit == "new") { //check for new post page return in_array($pagenow, array('post-new.php')); } else { //check for either new or edit return in_array($pagenow, array('post.php', 'post-new.php')); } } /*------------------------------------------*/ /* Theme Widgets /*------------------------------------------*/ $old_sidebars = get_option('sbg_sidebars'); if (is_array($old_sidebars)) { require_once MOM_FW . '/inc/sidebar_generator.php'; } if (!is_edit_page()) { foreach (glob(MOM_WIDGETS . '/*.php') as $file) { require_once $file; } if (file_exists(MOM_FW . '/sidebars/sidebars.php')) { include MOM_FW . '/sidebars/sidebars.php'; } } /*------------------------------------------*/ /* Theme Plugins /*------------------------------------------*/ require_once MOM_FW . '/plugins.php'; if (mom_option('breadcrumb') == 1) { require_once MOM_FW . '/inc/breadcrumbs-plus/breadcrumbs-plus.php'; } if (class_exists('WPBakeryVisualComposerAbstract') && file_exists(MOM_FW . '/organized/organized.php')) {
/** * Enque Plugin Assets */ public function enque_plugin_assets() { if (is_admin()) { function is_edit_page($new_edit = null) { global $pagenow; //make sure we are on the backend if (!is_admin()) { return false; } if ($new_edit == "edit") { return in_array($pagenow, array('post.php')); } elseif ($new_edit == "new") { //check for new post page return in_array($pagenow, array('post-new.php')); } else { //check for either new or edit return in_array($pagenow, array('post.php', 'post-new.php')); } } if (is_plugin_page() || is_edit_page()) { $path = plugin_dir_url(); wp_enqueue_style('hbs-css', $path . 'hanbootstrap/css/hbs.css'); if ($_GET["page"] == "hanbs-namespace-admin") { wp_enqueue_script('jquery-hbs', $path . 'hanbootstrap/js/jquery.1.11.0.js', null, null, true); wp_enqueue_script('hbs-validation', $path . 'hanbootstrap/js/hbs_validation.js', 'jquery-hbs', '9880649384aea9f1ee166331c0a30daa', true); } } } }
function page_save_postdata($post_id) { global $page_postmetas; if (!is_edit_page('new')) { //Add gallery cats select $gallery_cat_select = retrieve_my_gallerycat(); $page_postmetas[] = array("section" => "Content Type", "id" => "page_gallery_cat", "type" => "select", "title" => "Gallery Category", "description" => "You can select gallery category to display on this page. <strong>(If you select Gallery Archive as page template)</strong>", "items" => $gallery_cat_select); } // verify this came from the our screen and with proper authorization, // because save_post can be triggered at other times if (isset($_POST['pp_meta_form']) && !wp_verify_nonce($_POST['pp_meta_form'], plugin_basename(__FILE__))) { return $post_id; } // verify if this is an auto save routine. If it is our form has not been submitted, so we dont want to do anything if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } // Check permissions if (isset($_POST['post_type']) && 'page' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } else { if (!current_user_can('edit_post', $post_id)) { return $post_id; } } // OK, we're authenticated if ($parent_id = wp_is_post_revision($post_id)) { $post_id = $parent_id; } if (isset($_POST['pp_meta_form'])) { foreach ($page_postmetas as $postmeta) { if (isset($_POST[$postmeta['id']]) && $_POST[$postmeta['id']]) { page_update_custom_meta($post_id, $_POST[$postmeta['id']], $postmeta['id']); } if (isset($_POST[$postmeta['id']]) && $_POST[$postmeta['id']] == "") { delete_post_meta($post_id, $postmeta['id']); } if (!isset($_POST[$postmeta['id']])) { delete_post_meta($post_id, $postmeta['id']); } } // Saving Page Builder Data if (isset($_POST['ppb_enable']) && !empty($_POST['ppb_enable'])) { page_update_custom_meta($post_id, $_POST['ppb_enable'], 'ppb_enable'); } else { delete_post_meta($post_id, 'ppb_enable'); } if (isset($_POST['ppb_form_data_order']) && !empty($_POST['ppb_form_data_order'])) { page_update_custom_meta($post_id, $_POST['ppb_form_data_order'], 'ppb_form_data_order'); $ppb_item_arr = explode(',', $_POST['ppb_form_data_order']); if (is_array($ppb_item_arr) && !empty($ppb_item_arr)) { foreach ($ppb_item_arr as $key => $ppb_item_arr) { if (isset($_POST[$ppb_item_arr . '_data']) && !empty($_POST[$ppb_item_arr . '_data'])) { page_update_custom_meta($post_id, $_POST[$ppb_item_arr . '_data'], $ppb_item_arr . '_data'); } if (isset($_POST[$ppb_item_arr . '_size']) && !empty($_POST[$ppb_item_arr . '_size'])) { page_update_custom_meta($post_id, $_POST[$ppb_item_arr . '_size'], $ppb_item_arr . '_size'); } } } } else { page_update_custom_meta($post_id, '', 'ppb_form_data_order'); } } //If enable Content Builder then also copy its content to standard page content if (isset($_POST['ppb_enable']) && !empty($_POST['ppb_enable']) && !wp_is_post_revision($post_id)) { //unhook this function so it doesn't loop infinitely remove_action('save_post', 'page_save_postdata'); //update the post, which calls save_post again $ppb_page_content = tg_apply_builder($post_id, 'page', FALSE); $current_post = array('ID' => $post_id, 'post_content' => $ppb_page_content); wp_update_post($current_post); if (is_wp_error($post_id)) { $errors = $post_id->get_error_messages(); foreach ($errors as $error) { echo $error; } } //re-hook this function add_action('save_post', 'page_save_postdata'); } }
public function displayMetabox($post) { wp_enqueue_script('authorship-admin', plugins_url() . '/' . $this->pluginDir . '/js/admin.js', array('jquery')); $authors = $this->getAuthors($post->ID); $isDisplayed = $this->isDisplayed($post->ID); // new posts will by default enable author display checkbox $isPostNew = is_edit_page('new'); $html = '<!-- begin admin panel for authorship metabox -->'; ob_start(); include 'templates/admin_authorship.php'; $html .= ob_get_clean(); echo $html; }