Skip to content

Instantly share code, notes, and snippets.

@ramiabraham
Created September 10, 2016 01:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramiabraham/95834a57bc1f5bba4bc967327fc4103f to your computer and use it in GitHub Desktop.
Save ramiabraham/95834a57bc1f5bba4bc967327fc4103f to your computer and use it in GitHub Desktop.
jyounin
jQuery( document ).ready( function( $ ) {
// Container
$( '.wp-admin.ninja-forms-app #nf-pre-builder' ).css( 'position', 'relative' );
$( '.wp-admin.ninja-forms-app #nf-pre-builder' ).css( 'top', '32px' );
$( '.wp-admin.ninja-forms-app #nf-pre-builder' ).css( 'left', '100px' );
// Restore menus
$( '.wp-admin.ninja-forms-app #nf-builder' ).css( 'z-index', '1' );
$( '.wp-admin.ninja-forms-app #nf-builder' ).css( 'top', '32px' );
$( '.wp-admin.ninja-forms-app #nf-builder' ).css( 'left', '160px' );
$( '.wp-admin.ninja-forms-app #nf-builder' ).css( 'box-shadow', 'none' );
// Restore admin menus and footer
$( '.wp-admin.ninja-forms-app #adminmenumain' ).css( 'display', 'block' );
$( '.wp-admin.ninja-forms-app #wpfooter' ).css( 'display', 'block' );
} );
<?php
/**
* Plugin Name: Jyounin for Ninja Forms Three
* Plugin URI: https://dennys.com
* Description: Restores a popular ninja_forms_get_fields_by_form_id function, and adds a touch of humility to the NF Three admin interface, by showing the WordPress admin menu, and menu bar, if they're enabled.
* Author: ramiabraham
* Author URI: https://dennys.com
* Version: 1.0
* Text Domain: nf-jyounin
* Domain Path: languages
*
* This plugin is distributed under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* any later version.
*
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( function_exists( 'ninja_forms_get_fields_by_form_id' ) ) {
function ninja_forms_get_fields_by_form_id( $form_id ) {
/**
* If no form ID is specified, let's try to get the form id by context.
*/
if ( ! $form_id || empty( $form_id ) ) {
if ( $form || ! empty( $form ) ) {
if ( $form->get_tmp_id() || ! empty( $form->get_tmp_id() ) ) {
$form_id = $form->get_tmp_id();
}
} elseif ( Ninja_Forms()->form()->get() || ! empty( Ninja_Forms()->form()->get() ) ) {
$form = Ninja_Forms()->form()->get();
$form_id = $form->get_id();
} elseif ( ! empty( $_GET[ 'form_id' ] ) ) {
$form_id = $_GET[ 'form_id' ];
} else {
// Bummer.
return false;
}
$form_id = absint( $form_id );
if ( $form_id || ! empty( $form_id ) ) {
$fields = Ninja_Forms()->form( $form_id )->get_fields();
return apply_filters( 'jyounin_get_form_fields', $fields );
} else {
return false;
}
}
}
}
function nf_jyounin_enqueue_js() {
$screen = get_current_screen();
$screen_id = $screen->id;
$src = plugins_url( 'jyounin.js', __FILE__ );
wp_register_script( 'jyounin', $src, array( 'jquery' ), null, true );
if ( $screen_id === 'toplevel_page_ninja-forms' ) {
wp_enqueue_script( 'jyounin' );
}
}
add_action('admin_enqueue_scripts', 'nf_jyounin_enqueue_js', 9999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment