GFDirectory_Admin

The Gravity Forms Directory & Addons GFDirectory Admin class.

Defined (1)

The class is defined in the following location(s).

/admin.php  
  1. class GFDirectory_Admin { 
  2.  
  3. static function initialize() { 
  4. new GFDirectory_Admin; 
  5.  
  6. function __construct() { 
  7.  
  8. if ( ! is_admin() ) { 
  9. return; 
  10.  
  11. $settings = GFDirectory::get_settings(); 
  12.  
  13. add_action( 'admin_notices', array( &$this, 'gf_warning' ) ); 
  14. add_filter( 'gform_pre_render', array( 'GFDirectory_Admin', 'show_field_ids' ) ); 
  15.  
  16. //creates a new Settings page on Gravity Forms' settings screen 
  17. if ( GFDirectory::has_access( "gravityforms_directory" ) ) { 
  18. RGForms::add_settings_page( "Directory & Addons", array( &$this, "settings_page" ), "" ); 
  19. add_filter( "gform_addon_navigation", array( &$this, 'create_menu' ) ); //creates the subnav left menu 
  20.  
  21. //Adding "embed form" button 
  22. add_action( 'media_buttons', array( &$this, 'add_form_button' ), 30 ); 
  23.  
  24. if ( in_array( RG_CURRENT_PAGE, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) { 
  25. add_action( 'admin_footer', array( &$this, 'add_mce_popup' ) ); 
  26. wp_enqueue_script( "jquery-ui-datepicker" ); 
  27.  
  28.  
  29. if ( ! empty( $settings['modify_admin'] ) ) { 
  30. add_action( 'admin_head', array( &$this, 'admin_head' ), 1 ); 
  31.  
  32. self::process_bulk_update(); 
  33.  
  34. public static function process_bulk_update() { 
  35. global $process_bulk_update_message; 
  36.  
  37. if ( RGForms::post( "action" ) === 'bulk' ) { 
  38. check_admin_referer( 'gforms_entry_list', 'gforms_entry_list' ); 
  39.  
  40. $bulk_action = ! empty( $_POST["bulk_action"] ) ? $_POST["bulk_action"] : $_POST["bulk_action2"]; 
  41. $leads = $_POST["lead"]; 
  42.  
  43. $entry_count = count( $leads ) > 1 ? sprintf( __( "%d entries", "gravityforms" ), count( $leads ) ) : __( "1 entry", "gravityforms" ); 
  44.  
  45. $bulk_action = explode( '-', $bulk_action ); 
  46. if ( ! isset( $bulk_action[1] ) || empty( $leads ) ) { 
  47. return false; 
  48.  
  49. switch ( $bulk_action[0] ) { 
  50. case "approve": 
  51. self::directory_update_bulk( $leads, 1, $bulk_action[1] ); 
  52. $process_bulk_update_message = sprintf( __( "%s approved.", "gravity-forms-addons" ), $entry_count ); 
  53. break; 
  54.  
  55. case "unapprove": 
  56. self::directory_update_bulk( $leads, 0, $bulk_action[1] ); 
  57. $process_bulk_update_message = sprintf( __( "%s disapproved.", "gravity-forms-addons" ), $entry_count ); 
  58. break; 
  59.  
  60. static private function directory_update_bulk( $leads, $approved, $form_id ) { 
  61. global $_gform_directory_approvedcolumn; 
  62.  
  63. if ( empty( $leads ) || ! is_array( $leads ) ) { 
  64. return false; 
  65.  
  66. $_gform_directory_approvedcolumn = empty( $_gform_directory_approvedcolumn ) ? self::globals_get_approved_column( $_POST['form_id'] ) : $_gform_directory_approvedcolumn; 
  67.  
  68. $approved = empty( $approved ) ? 0 : 'Approved'; 
  69. foreach ( $leads as $lead_id ) { 
  70. GFDirectory::directory_update_approved( $lead_id, $approved, $form_id ); 
  71.  
  72. // If the classes don't exist, the plugin won't do anything useful. 
  73. function gf_warning() { 
  74. global $pagenow; 
  75. $message = ''; 
  76.  
  77. if ( $pagenow != 'plugins.php' ) { 
  78. return; 
  79.  
  80. if ( ! GFDirectory::is_gravityforms_installed() ) { 
  81. if ( file_exists( WP_PLUGIN_DIR . '/gravityforms/gravityforms.php' ) ) { 
  82. $message .= sprintf( esc_html__( '%sGravity Forms is installed but not active. %sActivate Gravity Forms%s to use the Gravity Forms Directory & Addons plugin.%s', 'gravity-forms-addons' ), '<p>', '<a href="' . wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=gravityforms/gravityforms.php' ), 'activate-plugin_gravityforms/gravityforms.php' ) . '" style="font-weight:strong;">', '</a>', '</p>' ); 
  83. } else { 
  84. $message = sprintf( esc_html__( '%sGravity Forms cannot be found%s 
  85.  
  86. The %sGravity Forms plugin%s must be installed and activated for the Gravity Forms Addons plugin to work. 
  87.  
  88. If you haven\'t installed the plugin, you can %3$spurchase the plugin here%4$s. If you have, and you believe this notice is in error, %5$sstart a topic on the plugin support forum%4$s. 
  89.  
  90. %6$s%7$sBuy Gravity Forms%4$s%8$s 
  91. ', 'gravity-forms-addons' ), '<strong>', '</strong>', "<a href='http://katz.si/gravityforms'>", '</a>', '<a href="http://wordpress.org/tags/gravity-forms-addons?forum_id=10#postform">', '<p class="submit">', "<a href='http://katz.si/gravityforms' style='color:white!important' class='button button-primary'>", '</p>' ); 
  92. if ( ! empty( $message ) ) { 
  93. echo '<div id="message" class="error">' . wpautop( $message ) . '</div>'; 
  94. } else if ( $message = get_transient( 'kws_gf_activation_notice' ) ) { 
  95. echo '<div id="message" class="updated">' . wpautop( $message ) . '</div>'; 
  96. delete_transient( 'kws_gf_activation_notice' ); 
  97.  
  98. public function activation() { 
  99. self::add_activation_notice(); 
  100.  
  101. public function add_activation_notice() { 
  102. # if(!get_option("gf_addons_settings")) { 
  103. $message = sprintf( esc_html__( 'Congratulations - the Gravity Forms Directory & Addons plugin has been installed. %sGo to the settings page%s to read usage instructions and configure the plugin default settings. %sGo to settings page%s', 'gravity-forms-addons' ), '<a href="' . admin_url( 'admin.php?page=gf_settings&addon=Directory+%26+Addons&viewinstructions=true' ) . '">', '</a>', '<p class="submit"><a href="' . admin_url( 'admin.php?page=gf_settings&addon=Directory+%26+Addons&viewinstructions=true' ) . '" class="button button-secondary">', '</a></p>' ); 
  104. set_transient( 'kws_gf_activation_notice', $message, 60 * 60 ); 
  105. # } 
  106.  
  107. public function admin_head( $settings = array() ) { 
  108. if ( empty( $settings ) ) { 
  109. $settings = GFDirectory::get_settings(); 
  110.  
  111. if ( ! empty( $settings['modify_admin']['expand'] ) ) { 
  112. if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'gf_edit_forms' && isset( $_REQUEST['id'] ) && is_numeric( $_REQUEST['id'] ) ) { 
  113. $style = '<style> 
  114. .gforms_edit_form_expanded ul.menu li.add_field_button_container ul,  
  115. .gforms_edit_form_expanded ul.menu li.add_field_button_container ul ol { 
  116. display:block!important; 
  117. #floatMenu {padding-top:1.4em!important;} 
  118. </style>'; 
  119. $style = apply_filters( 'kws_gf_display_all_fields', $style ); 
  120. echo $style; 
  121.  
  122. if ( isset( $_REQUEST['page'] ) && ( $_REQUEST['page'] == 'gf_edit_forms' || $_REQUEST['page'] == 'gf_entries' ) ) { 
  123. echo self::add_edit_js( isset( $_REQUEST['id'] ), $settings ); 
  124.  
  125. static private function add_edit_js( $edit_forms = false, $settings = array() ) { 
  126. ?> 
  127. <script> 
  128. // Edit link for Gravity Forms entries 
  129. jQuery( document ).ready( function ( $ ) { 
  130. <?php if(! empty( $settings['modify_admin']['expand'] ) && $edit_forms) { ?> 
  131. var onScrollScript = window.onscroll; 
  132. $( 'div.gforms_edit_form #add_fields #floatMenu' ).prepend( '<div class="gforms_expend_all_menus_form"><label for="expandAllMenus"><input type="checkbox" id="expandAllMenus" value="1" /> Expand All Menus</label></div>' ); 
  133.  
  134. $( 'input#expandAllMenus' ).live( 'click', function ( e ) { 
  135. if ( $( this ).is( ':checked' ) ) { 
  136. window.onscroll = ''; 
  137. $( 'div.gforms_edit_form' ).addClass( 'gforms_edit_form_expanded' ); 
  138. //$('ul.menu li .button-title-link').unbind().die(); // .unbind() is for the initial .click()... .die() is for the live() below 
  139. } else { 
  140. window.onscroll = onScrollScript; 
  141. $( 'div.gforms_edit_form' ).removeClass( 'gforms_edit_form_expanded' ); 
  142. } ); 
  143.  
  144. <?php 
  145. if(! empty( $settings['modify_admin']['toggle'] ) && $edit_forms) { ?> 
  146.  
  147. $( 'ul.menu' ).addClass( 'noaccordion' ); 
  148. <?php 
  149.  
  150. if(isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'gf_entries' && ! empty( $settings['modify_admin']['edit'] )) { 
  151. ?> 
  152. // Changed from :contains('Delete') to :last-child to work with 1.6 
  153. $( ".row-actions span:last-child" ).each( function () { 
  154. var editLink = $( this ).parents( 'tr' ).find( '.column-title a' ).attr( 'href' ); 
  155. editLink = editLink + '&screen_mode=edit'; 
  156. //alert(); 
  157. $( this ).after( '<span class="edit">| <a title="<?php echo esc_js( __( "Edit this entry", "gravity-forms-addons" ) ); ?>" href="' + editLink + '"><?php echo esc_js( __( "Edit", "gravity-forms-addons" ) ); ?></a></span>' ); 
  158. } ); 
  159. <?php 
  160.  
  161. else if(isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'gf_edit_forms' && ! empty( $settings['modify_admin']['ids'] )) { 
  162. ?> 
  163. // Changed from :contains('Delete') to :last-child for future-proofing 
  164. $( ".row-actions .trash" ).each( function () { 
  165. var formID = $( this ).parents( 'tr' ).find( '.column-id' ).text(); 
  166.  
  167. var title = '<?php echo esc_js( __( "Fields for Form ID %s", "gravity-forms-addons" ) ); ?>'; 
  168. title = title.replace( '%s', formID ); 
  169.  
  170. $( this ).after( '<span class="edit"> | <a title="' + title + '" href="<?php echo plugins_url( "field-ids.php", __FILE__ ); ?>?id=' + formID + '&show_field_ids=true&TB_iframe=true&height=295&width=370" class="thickbox form_ids"><?php echo esc_js( __( "IDs", "gravity-forms-addons" ) ); ?></a></span>' ); 
  171. } ); 
  172. <?php } ?> 
  173. } ); 
  174. </script> 
  175. <?php 
  176.  
  177. static function show_field_ids( $form = array() ) { 
  178. if ( isset( $_REQUEST['show_field_ids'] ) ) { 
  179. $form = RGFormsModel::get_form_meta( $_GET["id"] ); 
  180. $form = RGFormsModel::add_default_properties( $form ); 
  181.  
  182. echo <<<EOD 
  183. <style> 
  184.  
  185. #input_ids th, #input_ids td { border-bottom:1px solid #999; padding:.25em 15px; } 
  186. #input_ids th { border-bottom-color: #333; font-size:.9em; background-color: #464646; color:white; padding:.5em 15px; font-weight:bold; } 
  187. #input_ids { background:#ccc; margin:0 auto; font-size:1.2em; line-height:1.4; width:100%; border-collapse:collapse; } 
  188. #input_ids strong { font-weight:bold; } 
  189. #input_ids caption,  
  190. #preview_hdr { display:none;} 
  191. #input_ids caption { color:white!important;} 
  192. </style> 
  193. EOD; 
  194.  
  195. if ( ! empty( $form ) ) { 
  196. echo '<table id="input_ids"><caption id="input_id_caption">Fields for <strong>Form ID ' . $form['id'] . '</strong></caption><thead><tr><th>Field Name</th><th>Field ID</th></thead><tbody>'; 
  197. foreach ( $form['fields'] as $field ) { 
  198. // If there are multiple inputs for a field; ie: address has street, city, zip, country, etc. 
  199. if ( is_array( $field['inputs'] ) ) { 
  200. foreach ( $field['inputs'] as $input ) { 
  201. echo "<tr><td width='50%'><strong>{$input['label']}</strong></td><td>{$input['id']}</td></tr>"; 
  202. } // Otherwise, it's just the one input. 
  203. else { 
  204. echo "<tr><td width='50%'><strong>{$field['label']}</strong></td><td>{$field['id']}</td></tr>"; 
  205. if ( ! empty( $form ) ) { 
  206. echo '</tbody></table><div style="clear:both;"></div></body></html>'; 
  207. exit(); 
  208. } else { 
  209. return $form; 
  210.  
  211. function add_mce_popup() { 
  212.  
  213. //Action target that displays the popup to insert a form to a post/page 
  214. ?> 
  215. <script> 
  216. function addslashes( str ) { 
  217. // Escapes single quote, double quotes and backslash characters in a string with backslashes 
  218. // discuss at: http://phpjs.org/functions/addslashes 
  219. return (str + '').replace( /[\\"']/g, '\\$&' ).replace( /\u0000/g, '\\0' ); 
  220.  
  221. jQuery( 'document' ).ready( function ( $ ) { 
  222.  
  223.  
  224. $( '#select_gf_directory_form .datepicker' ).each( function () { 
  225. if ( $.fn.datepicker ) { 
  226. var element = jQuery( this ); 
  227. var format = "yy-mm-dd"; 
  228.  
  229. var image = ""; 
  230. var showOn = "focus"; 
  231. if ( element.hasClass( "datepicker_with_icon" ) ) { 
  232. showOn = "both"; 
  233. image = jQuery( '#gforms_calendar_icon_' + this.id ).val(); 
  234.  
  235. element.datepicker( { 
  236. yearRange: '-100:+10',  
  237. showOn: showOn,  
  238. buttonImage: image,  
  239. buttonImageOnly: true,  
  240. dateFormat: format 
  241. } ); 
  242. } ); 
  243.  
  244.  
  245. $( '#select_gf_directory_form' ).bind( 'submit', function ( e ) { 
  246. e.preventDefault(); 
  247. var shortcode = InsertGFDirectory(); 
  248. //send_to_editor(shortcode); 
  249. return false; 
  250. } ); 
  251.  
  252.  
  253. $( document ).on( 'click', '#insert_gf_directory', function ( e ) { 
  254. e.preventDefault(); 
  255. $( '#select_gf_directory_form' ).trigger( 'submit' ); 
  256. return; 
  257. } ); 
  258.  
  259. $( 'a.select_gf_directory' ).click( function ( e ) { 
  260. // This auto-sizes the box 
  261. if ( typeof tb_position == 'function' ) { 
  262. tb_position(); 
  263. return; 
  264. } ); 
  265.  
  266. // Toggle advanced settings 
  267. $( 'a.kws_gf_advanced_settings' ).click( function ( e ) { 
  268. e.preventDefault(); 
  269. $( '#kws_gf_advanced_settings' ).toggle(); 
  270. return false; 
  271. } ); 
  272.  
  273. function InsertGFDirectory() { 
  274. var directory_id = jQuery( "#add_directory_id" ).val(); 
  275. if ( directory_id == "" ) { 
  276. alert( "<?php echo esc_js( __( "Please select a form", "gravity-forms-addons" ) ); ?>" ); 
  277. jQuery( '#add_directory_id' ).focus(); 
  278. return false; 
  279.  
  280. <?php 
  281. $js = self::make_popup_options( true ); 
  282.  
  283. $ids = $idOutputList = $setvalues = $vars = ''; 
  284.  
  285. foreach ( $js as $j ) { 
  286. $vars .= $j['js'] . " 
  287. "; 
  288. $ids .= $j['idcode'] . " "; 
  289. $setvalues .= $j['setvalue'] . " 
  290. "; 
  291. $idOutputList .= $j['id'] . 'Output' . ' + '; 
  292. echo $vars; 
  293. echo $setvalues; 
  294. ?> 
  295.  
  296. //var win = window.dialogArguments || opener || parent || top; 
  297. var shortcode = "[directory form=\"" + directory_id + "\"" + <?php echo addslashes( $idOutputList ); ?>"]"; 
  298. window.send_to_editor( shortcode ); 
  299. return false; 
  300. } ); 
  301.  
  302. </script> 
  303. <div id="select_gf_directory" style="overflow-x:hidden; overflow-y:auto;display:none;"> 
  304. <form action="#" method="get" id="select_gf_directory_form"> 
  305. <div class="wrap"> 
  306. <div> 
  307. <div style="padding:15px 15px 0 15px;"> 
  308. <h2><?php esc_html_e( "Insert A Directory", "gravity-forms-addons" ); ?></h2> 
  309. <span> 
  310. <?php esc_html_e( "Select a form below to add it to your post or page.", "gravity-forms-addons" ); ?> 
  311. </span> 
  312. </div> 
  313. <div style="padding:15px 15px 0 15px;"> 
  314. <select id="add_directory_id"> 
  315. <option 
  316. value=""> <?php esc_html_e( "Select a Form", "gravity-forms-addons" ); ?> </option> 
  317. <?php 
  318. $forms = RGFormsModel::get_forms( 1, "title" ); 
  319. foreach ( $forms as $form ) { 
  320. ?> 
  321. <option 
  322. value="<?php echo absint( $form->id ) ?>"><?php echo esc_html( $form->title ) ?></option> 
  323. <?php 
  324. ?> 
  325. </select> <br/> 
  326. <div 
  327. style="padding:8px 0 0 0; font-size:11px; font-style:italic; color:#5A5A5A"><?php esc_html_e( "This form will be the basis of your directory.", "gravity-forms-addons" ); ?></div> 
  328. </div> 
  329. <?php 
  330.  
  331. self::make_popup_options(); 
  332.  
  333. ?> 
  334. <div class="submit"> 
  335. <input type="submit" class="button-primary" style="margin-right:15px;" 
  336. value="Insert Directory" id="insert_gf_directory"/> 
  337. <a class="button button-secondary" style="color:#bbb;" href="#" 
  338. onclick="tb_remove(); return false;"><?php esc_html_e( "Cancel", "gravity-forms-addons" ); ?></a> 
  339. </div> 
  340. </div> 
  341. </div> 
  342. </form> 
  343. </div> 
  344. <?php 
  345.  
  346. static function make_popup_options( $js = false ) { 
  347. $i = 0; 
  348.  
  349. $defaults = GFDirectory::directory_defaults(); 
  350.  
  351. $standard = array( 
  352. array( 
  353. 'text',  
  354. 'page_size',  
  355. 20,  
  356. sprintf( esc_html__( "Number of entries to show at once. Use %s0%s to show all entries.", 'gravity-forms-addons' ), '<code>', '</code>' ),  
  357. ),  
  358. array( 
  359. 'select',  
  360. 'directoryview',  
  361. array( 
  362. array( 'value' => 'table', 'label' => esc_html__( "Table", 'gravity-forms-addons' ) ),  
  363. array( 'value' => 'ul', 'label' => esc_html__( "Unordered List", 'gravity-forms-addons' ) ),  
  364. array( 'value' => 'dl', 'label' => esc_html__( "Definition List", 'gravity-forms-addons' ) ),  
  365. ),  
  366. esc_html__( "Format for directory listings (directory view)", 'gravity-forms-addons' ),  
  367. ),  
  368. array( 
  369. 'select',  
  370. 'entryview',  
  371. array( 
  372. array( 'value' => 'table', 'label' => esc_html__( "Table", 'gravity-forms-addons' ) ),  
  373. array( 'value' => 'ul', 'label' => esc_html__( "Unordered List", 'gravity-forms-addons' ) ),  
  374. array( 'value' => 'dl', 'label' => esc_html__( "Definition List", 'gravity-forms-addons' ) ),  
  375. ),  
  376. esc_html__( "Format for single entries (single entry view)", 'gravity-forms-addons' ),  
  377. ),  
  378. array( 'checkbox', 'search', true, esc_html__( "Show the search field", 'gravity-forms-addons' ) ),  
  379. array( 
  380. 'checkbox',  
  381. 'smartapproval',  
  382. true,  
  383. esc_html__( "Automatically convert directory into Approved-only when an Approved field is detected.", 'gravity-forms-addons' ),  
  384. ),  
  385. array( 
  386. 'checkbox',  
  387. 'approved',  
  388. false,  
  389. sprintf( esc_html__( "(If Smart Approval above is not enabled) Show only entries that have been Approved (have a field in the form that is an Admin-only checkbox with a value of 'Approved'). %sNote:%s This will hide entries that have not been explicitly approved.%s", 'gravity-forms-addons' ), "<span class='description'><strong>", "</strong>", "</span>" ),  
  390. ),  
  391. ); 
  392. if ( ! $js ) { 
  393. echo '<ul>'; 
  394. foreach ( $standard as $o ) { 
  395. self::make_field( $o[0], $o[1], maybe_serialize( $o[2] ), $o[3], $defaults ); 
  396. echo '</ul>'; 
  397. } else { 
  398. foreach ( $standard as $o ) { 
  399. $out[ $i ] = self::make_popup_js( $o[0], $o[1], $defaults ); 
  400. $i ++; 
  401.  
  402. $content = array( 
  403. array( 
  404. 'checkbox',  
  405. 'entry',  
  406. true,  
  407. esc_html__( "If there's a displayed Entry ID column, add link to each full entry", 'gravity-forms-addons' ),  
  408. ),  
  409. #array('checkbox', 'wpautop' , true, sprintf( esc_html__( "Convert bulk paragraph text to paragraphs (using the WordPress function %s)", 'gravity-forms-addons'), "<code><a href='http://codex.wordpress.org/Function_Reference/wpautop'>wpautop()</a></code>" )),  
  410. array( 
  411. 'checkbox',  
  412. 'getimagesize',  
  413. false,  
  414. esc_html__( "Calculate image sizes (Warning: this may slow down the directory loading speed!)", 'gravity-forms-addons' ),  
  415. ),  
  416. array( 
  417. 'radio',  
  418. 'postimage',  
  419. array( 
  420. array( 
  421. 'label' => '<img src="' . GFCommon::get_base_url() . '/images/doctypes/icon_image.gif" /> ' . esc_html__( 'Show image icon', 'gravity-forms-addons' ),  
  422. 'value' => 'icon',  
  423. 'default' => '1',  
  424. ),  
  425. array( 'label' => esc_html__( 'Show full image', 'gravity-forms-addons' ), 'value' => 'image' ),  
  426. ),  
  427. esc_html__( "How do you want images to appear in the directory?", 'gravity-forms-addons' ),  
  428. ),  
  429. #array('checkbox', 'fulltext' , true, esc_html__("Show full content of a textarea or post content field, rather than an excerpt", 'gravity-forms-addons')),  
  430.  
  431. array( 
  432. 'date',  
  433. 'start_date',  
  434. false,  
  435. sprintf( esc_html__( 'Start date (in %sYYYY-MM-DD%s format)', 'gravity-forms-addons' ), '<code>', '</code>' ),  
  436. ),  
  437. array( 
  438. 'date',  
  439. 'end_date',  
  440. false,  
  441. sprintf( esc_html__( 'End date (in %sYYYY-MM-DD%s format)', 'gravity-forms-addons' ), '<code>', '</code>' ),  
  442. ),  
  443. ); 
  444.  
  445. $administration = array( 
  446. array( 
  447. 'checkbox',  
  448. 'showadminonly',  
  449. false,  
  450. sprintf( esc_html__( "Show Admin-Only columns %s(in Gravity Forms, Admin-Only fields are defined by clicking the Advanced tab on a field in the Edit Form view, then editing Visibility > Admin Only)%s", 'gravity-forms-addons' ), "<span class='description'>", "</span>" ),  
  451. ),  
  452. array( 
  453. 'checkbox',  
  454. 'useredit',  
  455. false,  
  456. esc_html__( "Allow logged-in users to edit entries they created. Will add an 'Edit Your Entry' field to the Single Entry View.", 'gravity-forms-addons' ),  
  457. ),  
  458. array( 
  459. 'checkbox',  
  460. 'limituser',  
  461. false,  
  462. esc_html__( "Display entries only the the creator of the entry (users will not see other people's entries).", 'gravity-forms-addons' ),  
  463. ),  
  464. array( 
  465. 'checkbox',  
  466. 'adminedit',  
  467. false,  
  468. sprintf( esc_html__( 'Allow %sadministrators%s to edit all entries. Will add an \'Edit Your Entry\' field to the Single Entry View.', 'gravity-forms-addons' ), '<strong>', '</strong>' ),  
  469. ),  
  470. ); 
  471.  
  472. $style_label = esc_html_x( 'Style %d', 'Lightbox style', 'gravity-forms-addons' ); 
  473.  
  474. $lightbox = array( 
  475.  
  476. array( 
  477. 'radio',  
  478. 'lightboxstyle',  
  479. array( 
  480. array( 
  481. 'label' => sprintf( $style_label, 1 ) . ' <a href="http://www.jacklmoore.com/colorbox/example1/" target="_blank">See example</a>',  
  482. 'value' => '1',  
  483. ),  
  484. array( 
  485. 'label' => sprintf( $style_label, 2 ) . ' <a href="http://www.jacklmoore.com/colorbox/example2/" target="_blank">See example</a>',  
  486. 'value' => '2',  
  487. ),  
  488. array( 
  489. 'label' => sprintf( $style_label, 3 ) . ' <a href="http://www.jacklmoore.com/colorbox/example3/" target="_blank">See example</a>',  
  490. 'value' => '3',  
  491. 'default' => '1',  
  492. ),  
  493. array( 
  494. 'label' => sprintf( $style_label, 4 ) . ' <a href="http://www.jacklmoore.com/colorbox/example4/" target="_blank">See example</a>',  
  495. 'value' => '4',  
  496. ),  
  497. array( 
  498. 'label' => sprintf( $style_label, 5 ) . ' <a href="http://www.jacklmoore.com/colorbox/example5/" target="_blank">See example</a>',  
  499. 'value' => '5',  
  500. ),  
  501. ),  
  502. "What style should the lightbox use?",  
  503. ),  
  504. array( 
  505. 'checkboxes',  
  506. 'lightboxsettings',  
  507. array( 
  508. array( 
  509. 'label' => esc_html__( 'Images', 'gravity-forms-addons' ),  
  510. 'value' => 'images',  
  511. 'default' => '1',  
  512. ),  
  513. array( 
  514. 'label' => esc_html__( "Entry Links (Open entry details in lightbox)" ),  
  515. 'value' => 'entry',  
  516. ),  
  517. array( 
  518. 'label' => esc_html__( 'Website Links (non-entry)', 'gravity-forms-addons' ),  
  519. 'value' => 'urls',  
  520. ),  
  521. ),  
  522. esc_html__( "Set what type of links should be loaded in the lightbox", 'gravity-forms-addons' ),  
  523. ),  
  524. ); 
  525.  
  526. $formatting = array( 
  527. array( 
  528. 'checkbox',  
  529. 'jstable',  
  530. false,  
  531. esc_html__( 'Use the TableSorter jQuery plugin to sort the table?', 'gravity-forms-addons' ),  
  532. ),  
  533. array( 
  534. 'checkbox',  
  535. 'titleshow',  
  536. true,  
  537. '<strong>' . esc_html__( 'Show a form title?', 'gravity-forms-addons' ) . '</strong> ' . esc_html__( "By default, the title will be the form title.", 'gravity-forms-addons' ),  
  538. ),  
  539. array( 
  540. 'checkbox',  
  541. 'showcount',  
  542. true,  
  543. esc_html__( "Do you want to show 'Displaying 1-19 of 19'?", 'gravity-forms-addons' ),  
  544. ),  
  545. array( 
  546. 'checkbox',  
  547. 'thead',  
  548. true,  
  549. sprintf( esc_html__( "Show the top heading row (%s<thead>%s)", 'gravity-forms-addons' ), '<code>', '</code>' ),  
  550. ),  
  551. array( 
  552. 'checkbox',  
  553. 'tfoot',  
  554. true,  
  555. sprintf( esc_html__( "Show the bottom heading row (%s<tfoot>%s)", 'gravity-forms-addons' ), '<code>', '</code>' ),  
  556. ),  
  557. array( 
  558. 'checkbox',  
  559. 'pagelinksshowall',  
  560. true,  
  561. esc_html__( "Show each page number (eg: 1 2 3 4 5 6 7 8) instead of summary (eg: 1 2 3 ... 8 »)", 'gravity-forms-addons' ),  
  562. ),  
  563. array( 
  564. 'checkbox',  
  565. 'jssearch',  
  566. true,  
  567. sprintf( esc_html__( "Use JavaScript for sorting (otherwise, %slinks%s will be used for sorting by column)", 'gravity-forms-addons' ), '<em>', '</em>' ),  
  568. ),  
  569. array( 
  570. 'checkbox',  
  571. 'dateformat',  
  572. false,  
  573. esc_html__( "Override the options from Gravity Forms, and use standard PHP date formats", 'gravity-forms-addons' ),  
  574. ),  
  575. ); 
  576.  
  577. $links = array( 
  578. array( 
  579. 'checkbox',  
  580. 'linkemail',  
  581. true,  
  582. esc_html__( "Convert email fields to email links", 'gravity-forms-addons' ),  
  583. ),  
  584. array( 'checkbox', 'linkwebsite', true, esc_html__( "Convert URLs to links", 'gravity-forms-addons' ) ),  
  585. array( 
  586. 'checkbox',  
  587. 'truncatelink',  
  588. false,  
  589. sprintf( esc_html__( "Show more simple links for URLs (strip %shttp://%s, %swww.%s, etc.)", 'gravity-forms-addons' ), '<code>', '</code>', '<code>', '</code>' ),  
  590. ), #'truncatelink' => false,  
  591. array( 
  592. 'checkbox',  
  593. 'linknewwindow',  
  594. false,  
  595. sprintf( esc_html__( "%sOpen links in new window?%s (uses %s)", 'gravity-forms-addons' ), '<strong>', '</strong>', "<code>target='_blank'</code>" ),  
  596. ),  
  597. array( 
  598. 'checkbox',  
  599. 'nofollowlinks',  
  600. false,  
  601. sprintf( esc_html__( "%sAdd %snofollow%s to all links%s, including emails", 'gravity-forms-addons' ), '<strong>', '<code>', '</code>', '</strong>' ),  
  602. ),  
  603. ); 
  604.  
  605. $address = array( 
  606. array( 
  607. 'checkbox',  
  608. 'appendaddress',  
  609. false,  
  610. esc_html__( "Add the formatted address as a column at the end of the table", 'gravity-forms-addons' ),  
  611. ),  
  612. array( 
  613. 'checkbox',  
  614. 'hideaddresspieces',  
  615. false,  
  616. esc_html__( "Hide the pieces that make up an address (Street, City, State, ZIP, Country, etc.)", 'gravity-forms-addons' ),  
  617. ),  
  618. ); 
  619.  
  620. $entry = array( 
  621. array( 
  622. 'text',  
  623. 'entrytitle',  
  624. esc_html__( 'Entry Detail', 'gravity-forms-addons' ),  
  625. esc_html__( "Title of entry lightbox window", 'gravity-forms-addons' ),  
  626. ),  
  627. array( 
  628. 'text',  
  629. 'entrydetailtitle',  
  630. sprintf( esc_html__( 'Entry Detail Table Caption', 'gravity-forms-addons' ), esc_html__( "The text displayed at the top of the entry details. Use %s%%%%formtitle%%%%%s and %s%%%%leadid%%%%%s as variables that will be replaced.", 'gravity-forms-addons' ), '<code>', '</code>', '<code>', '</code>' ),  
  631. ),  
  632. array( 
  633. 'text',  
  634. 'entrylink',  
  635. esc_html__( 'View entry details', 'gravity-forms-addons' ),  
  636. esc_html__( "Link text to show full entry", 'gravity-forms-addons' ),  
  637. ),  
  638. array( 
  639. 'text',  
  640. 'entryth',  
  641. esc_html__( 'More Info', 'gravity-forms-addons' ),  
  642. esc_html__( "Entry ID column title", 'gravity-forms-addons' ),  
  643. ),  
  644. array( 
  645. 'text',  
  646. 'entryback',  
  647. esc_html__( '← Back to directory', 'gravity-forms-addons' ),  
  648. esc_html__( "The text of the link to return to the directory view from the single entry view.", 'gravity-forms-addons' ),  
  649. ),  
  650. array( 
  651. 'checkbox',  
  652. 'entryonly',  
  653. true,  
  654. esc_html__( "When viewing full entry, show entry only? Otherwise, show entry with directory below", 'gravity-forms-addons' ),  
  655. ),  
  656. array( 
  657. 'checkbox',  
  658. 'entryanchor',  
  659. true,  
  660. esc_html__( "When returning to directory view from single entry view, link to specific anchor row?", 'gravity-forms-addons' ),  
  661. ),  
  662. ); 
  663.  
  664. $fieldsets = array( 
  665. esc_html__( 'Content Settings', 'gravity-forms-addons' ) => $content,  
  666. esc_html__( 'Administration of Entries', 'gravity-forms-addons' ) => $administration,  
  667. esc_html__( 'Lightbox Options', 'gravity-forms-addons' ) => $lightbox,  
  668. esc_html__( 'Formatting Options', 'gravity-forms-addons' ) => $formatting,  
  669. esc_html__( 'Link Settings', 'gravity-forms-addons' ) => $links,  
  670. esc_html__( 'Address Options', 'gravity-forms-addons' ) => $address,  
  671. ); 
  672.  
  673. if ( ! $js ) { 
  674. echo '<a href="#kws_gf_advanced_settings" class="kws_gf_advanced_settings">' . esc_html__( 'Show advanced settings', 'gravity-forms-addons' ) . '</a>'; 
  675. echo '<div style="display:none;" id="kws_gf_advanced_settings">'; 
  676. echo "<h2 style='margin:0; padding:0; font-weight:bold; font-size:1.5em; margin-top:1em;'>Single-Entry View</h2>"; 
  677. echo '<span class="howto">These settings control whether users can view each entry as a separate page or lightbox. Single entries will show all data associated with that entry.</span>'; 
  678. echo '<ul style="padding:0 15px 0 15px; width:100%;">'; 
  679. foreach ( $entry as $o ) { 
  680. if ( isset( $o[3] ) ) { 
  681. $o3 = esc_html( $o[3] ); 
  682. } else { 
  683. $o3 = ''; 
  684. self::make_field( $o[0], $o[1], maybe_serialize( $o[2] ), $o3, $defaults ); 
  685. echo '</ul>'; 
  686.  
  687. echo '<div class="hr-divider label-divider"></div>'; 
  688.  
  689. echo "<h2 style='margin:0; padding:0; font-weight:bold; font-size:1.5em; margin-top:1em;'>" . esc_html__( 'Directory View', 'gravity-forms-addons' ) . "</h2>"; 
  690. echo '<span class="howto">' . esc_html__( 'These settings affect how multiple entries are shown at once.', 'gravity-forms-addons' ) . '</span>'; 
  691.  
  692. foreach ( $fieldsets as $title => $fieldset ) { 
  693. echo "<fieldset><legend><h3 style='padding-top:1em; padding-bottom:.5em; margin:0;'>{$title}</h3></legend>"; 
  694. echo '<ul style="padding: 0 15px 0 15px; width:100%;">'; 
  695. foreach ( $fieldset as $o ) { 
  696. self::make_field( $o[0], $o[1], maybe_serialize( $o[2] ), $o[3], $defaults ); 
  697. echo '</ul></fieldset>'; 
  698. echo '<div class="hr-divider label-divider"></div>'; 
  699. echo "<h2 style='margin:0; padding:0; font-weight:bold; font-size:1.5em; margin-top:1em;'>" . esc_html__( 'Additional Settings', 'gravity-forms-addons' ) . "</h2>"; 
  700. echo '<span class="howto">' . esc_html__( 'These settings affect both the directory view and single entry view.', 'gravity-forms-addons' ) . '</span>'; 
  701. echo '<ul style="padding: 0 15px 0 15px; width:100%;">'; 
  702. } else { 
  703. foreach ( $entry as $o ) { 
  704. $out[ $i ] = self::make_popup_js( $o[0], $o[1], $defaults ); 
  705. $i ++; 
  706. foreach ( $fieldsets as $title => $fieldset ) { 
  707. foreach ( $fieldset as $o ) { 
  708. $out[ $i ] = self::make_popup_js( $o[0], $o[1], $defaults ); 
  709. $i ++; 
  710. $advanced = array( 
  711. array( 
  712. 'text',  
  713. 'tableclass',  
  714. 'gf_directory widefat',  
  715. esc_html__( "Class for the <table>, <ul>, or <dl>", 'gravity-forms-addons' ),  
  716. ),  
  717. array( 
  718. 'text',  
  719. 'tablestyle',  
  720. '',  
  721. esc_html__( "inline CSS for the <table>, <ul>, or <dl>", 'gravity-forms-addons' ),  
  722. ),  
  723. array( 
  724. 'text',  
  725. 'rowclass',  
  726. '',  
  727. esc_html__( "Class for the <table>, <ul>, or <dl>", 'gravity-forms-addons' ),  
  728. ),  
  729. array( 
  730. 'text',  
  731. 'rowstyle',  
  732. '',  
  733. esc_html__( "Inline CSS for all <tbody><tr>'s, <ul><li>'s, or <dl><dt>'s", 'gravity-forms-addons' ),  
  734. ),  
  735. array( 
  736. 'text',  
  737. 'valign',  
  738. 'baseline',  
  739. esc_html__( "Vertical align for table cells", 'gravity-forms-addons' ),  
  740. ),  
  741. array( 
  742. 'text',  
  743. 'sort',  
  744. 'date_created',  
  745. esc_html__( "Use the input ID ( example: 1.3 or 7 or ip)", 'gravity-forms-addons' ),  
  746. ),  
  747. array( 
  748. 'text',  
  749. 'dir',  
  750. 'DESC',  
  751. sprintf( esc_html__( "Sort in ascending order (%sASC%s or descending (%sDESC%s)", 'gravity-forms-addons' ), '<code>', '</code>', '<code>', '</code>' ),  
  752. ),  
  753. array( 
  754. 'text',  
  755. 'startpage',  
  756. 1,  
  757. esc_html__( "If you want to show page 8 instead of 1", 'gravity-forms-addons' ),  
  758. ),  
  759. array( 
  760. 'text',  
  761. 'pagelinkstype',  
  762. 'plain',  
  763. sprintf( esc_html__( "Type of pagination links. %splain%s is just a string with the links separated by a newline character. The other possible values are either %sarray%s or %slist%s.", 'gravity-forms-addons' ), '<code>', '</code>', '<code>', '</code>', '<code>', '</code>' ),  
  764. ),  
  765. array( 
  766. 'text',  
  767. 'titleprefix',  
  768. 'Entries for ',  
  769. esc_html__( "Default GF behavior is 'Entries : '", 'gravity-forms-addons' ),  
  770. ),  
  771. array( 
  772. 'text',  
  773. 'tablewidth',  
  774. '100%',  
  775. esc_html__( "Set the 'width' attribute for the <table>, <ul>, or <dl>", 'gravity-forms-addons' ),  
  776. ),  
  777. array( 
  778. 'text',  
  779. 'datecreatedformat',  
  780. get_option( 'date_format' ) . ' \a\t ' . get_option( 'time_format' ),  
  781. sprintf( esc_html__( "Use %sstandard PHP date formats%s", 'gravity-forms-addons' ), "<a href='http://php.net/manual/en/function.date.php' target='_blank'>", '</a>' ),  
  782. ),  
  783. array( 
  784. 'checkbox',  
  785. 'credit',  
  786. true,  
  787. esc_html__( "Give credit to the plugin creator (who has spent over 300 hours on this free plugin!) with a link at the bottom of the directory", 'gravity-forms-addons' ),  
  788. ),  
  789. ); 
  790. if ( ! $js ) { 
  791. foreach ( $advanced as $o ) { 
  792. self::make_field( $o[0], $o[1], maybe_serialize( $o[2] ), $o[3], $defaults ); 
  793. echo '</ul></fieldset></div>'; 
  794. } else { 
  795. foreach ( $advanced as $o ) { 
  796. $out[ $i ] = self::make_popup_js( $o[0], $o[1], $defaults ); 
  797. $i ++; 
  798.  
  799. return $out; 
  800.  
  801. static function make_field( $type, $id, $default, $label, $defaults = array() ) { 
  802. $rawid = $id; 
  803. $idLabel = ''; 
  804. if ( GFDirectory::is_gravity_page( 'gf_settings' ) ) { 
  805. $id = 'gf_addons_directory_defaults[' . $id . ']'; 
  806. $idLabel = " <span style='color:#868686'>(<pre style='display:inline'>{$rawid}</pre>)</span>"; 
  807. $checked = ''; 
  808. $label = str_replace( '<code>', '<code>', str_replace( '</code>', '</code>', $label ) ); 
  809. $output = '<li class="setting-container" style="width:90%; clear:left; border-bottom: 1px solid #cfcfcf; padding:.25em .25em .4em; margin-bottom:.25em;">'; 
  810. $default = maybe_unserialize( $default ); 
  811.  
  812. $class = ''; 
  813. if ( $type == 'date' ) { 
  814. $type = 'text'; 
  815. $class = ' class="gf_addons_datepicker datepicker"'; 
  816.  
  817. if ( $type == "checkbox" ) { 
  818. if ( ! empty( $defaults["{$rawid}"] ) || ( $defaults["{$rawid}"] === '1' || $defaults["{$rawid}"] === 1 ) ) { 
  819. $checked = ' checked="checked"'; 
  820. $output .= '<label for="gf_settings_' . $rawid . '"><input type="hidden" value="" name="' . $id . '" /><input type="checkbox" id="gf_settings_' . $rawid . '"' . $checked . ' name="' . $id . '" /> ' . $label . $idLabel . '</label>' . "\n"; 
  821. } elseif ( $type == "text" ) { 
  822. $default = $defaults["{$rawid}"]; 
  823. $output .= '<label for="gf_settings_' . $rawid . '"><input type="text" id="gf_settings_' . $rawid . '" value="' . htmlspecialchars( stripslashes( $default ) ) . '" style="width:40%;" name="' . $id . '"' . $class . ' /> <span class="howto">' . $label . $idLabel . '</span></label>' . "\n"; 
  824. } elseif ( $type == 'radio' || $type == 'checkboxes' ) { 
  825. if ( is_array( $default ) ) { 
  826. $output .= $label . $idLabel . '<ul class="ul-disc">'; 
  827. foreach ( $default as $opt ) { 
  828. if ( $type == 'radio' ) { 
  829. $id_opt = $id . '_' . sanitize_title( $opt['value'] ); 
  830. if ( ! empty( $defaults["{$rawid}"] ) && $defaults["{$rawid}"] == $opt['value'] ) { 
  831. $checked = ' checked="checked"'; 
  832. } else { 
  833. $checked = ''; 
  834. $inputtype = 'radio'; 
  835. $name = $id; 
  836. $value = $opt['value']; 
  837. $output .= ' 
  838. <li><label for="gf_settings_' . $id_opt . '">'; 
  839. } else { 
  840. $id_opt = $rawid . '_' . sanitize_title( $opt['value'] ); 
  841. if ( ! empty( $defaults["{$rawid}"][ sanitize_title( $opt['value'] ) ] ) ) { 
  842. $checked = ' checked="checked"'; 
  843. } else { 
  844. $checked = ''; 
  845. $inputtype = 'checkbox'; 
  846. $name = $id . '[' . sanitize_title( $opt['value'] ) . ']'; 
  847. $value = 1; 
  848. $output .= ' 
  849. <li><label for="gf_settings_' . $id_opt . '"> 
  850. <input type="hidden" value="0" name="' . $name . '" />'; 
  851. $output .= ' 
  852. <input type="' . $inputtype . '"' . $checked . ' value="' . $value . '" id="gf_settings_' . $id_opt . '" name="' . $name . '" /> ' . $opt['label'] . " <span style='color:#868686'>(<pre style='display:inline'>" . sanitize_title( $opt['value'] ) . "</pre>)</span>" . ' 
  853. </label> 
  854. </li>' . "\n"; 
  855. $output .= "</ul>"; 
  856. } elseif ( $type == 'select' ) { 
  857. if ( is_array( $default ) ) { 
  858. $output .= ' 
  859. <label for="gf_settings_' . $rawid . '">' . $label . ' 
  860. <select name="' . $id . '" id="gf_settings_' . $rawid . '">'; 
  861. foreach ( $default as $opt ) { 
  862.  
  863. if ( ! empty( $defaults["{$rawid}"] ) && $defaults["{$rawid}"] == $opt['value'] ) { 
  864. $checked = ' selected="selected"'; 
  865. } else { 
  866. $checked = ''; 
  867. $id_opt = $id . '_' . sanitize_title( $opt['value'] ); 
  868. $output .= '<option' . $checked . ' value="' . $opt['value'] . '"> ' . $opt['label'] . '</option>' . "\n"; 
  869. $output .= '</select>' . $idLabel . ' 
  870. </label> 
  871. '; 
  872. } else { 
  873. $output = ''; 
  874. if ( ! empty( $output ) ) { 
  875. $output .= '</li>' . "\n"; 
  876. echo $output; 
  877.  
  878. static function make_popup_js( $type, $id, $defaults ) { 
  879.  
  880. foreach ( $defaults as $key => $default ) { 
  881. if ( $default === true || $default === 'on' ) { 
  882. $defaults[ $key ] = 'true'; 
  883. } elseif ( $default === false || ( $type == 'checkbox' && empty( $default ) ) ) { 
  884. $defaults[ $key ] = 'false'; 
  885. $defaultsArray = array(); 
  886. if ( $type == "checkbox" ) { 
  887. $js = 'var ' . $id . ' = jQuery("#gf_settings_' . $id . '").is(":checked") ? "true" : "false";'; 
  888. } elseif ( $type == "checkboxes" && is_array( $defaults["{$id}"] ) ) { 
  889. $js = ''; 
  890. $i = 0; 
  891. $js .= "\n\t\t\tvar " . $id . ' = new Array();'; 
  892. foreach ( $defaults["{$id}"] as $key => $value ) { 
  893. $defaultsArray[] = $key; 
  894. $js .= "\n\t\t\t" . $id . '[' . $i . '] = jQuery("input#gf_settings_' . $id . '_' . $key . '").is(":checked") ? "' . $key . '" : null;'; 
  895. $i ++; 
  896. } elseif ( $type == "text" || $type == "date" ) { 
  897. $js = 'var ' . $id . ' = jQuery("#gf_settings_' . $id . '").val();'; 
  898. } elseif ( $type == 'radio' ) { 
  899. $js = ' 
  900. if(jQuery("input[name=\'' . $id . '\']:checked").length > 0) { 
  901. var ' . $id . ' = jQuery("input[name=\'' . $id . '\']:checked").val(); 
  902. } else { 
  903. var ' . $id . ' = jQuery("input[name=\'' . $id . '\']").eq(0).val(); 
  904. }'; 
  905. } elseif ( $type == 'select' ) { 
  906. $js = ' 
  907. if(jQuery("select[name=\'' . $id . '\']:selected").length > 0) { 
  908. var ' . $id . ' = jQuery("select[name=\'' . $id . '\']:selected").val(); 
  909. } else { 
  910. var ' . $id . ' = jQuery("select[name=\'' . $id . '\']").eq(0).val(); 
  911. }'; 
  912. $set = ''; 
  913. if ( ! is_array( $defaults["{$id}"] ) ) { 
  914. $idCode = $id . '=\""+' . $id . '+"\"'; 
  915. $set = 'var ' . $id . 'Output = (jQuery.trim(' . $id . ') == "' . trim( addslashes( stripslashes( $defaults["{$id}"] ) ) ) . '") ? "" : " ' . $idCode . '";'; 
  916. } else { 
  917.  
  918. $idCode2 = $id . '.join()'; 
  919. $idCode = '"' . $idCode2 . '"'; 
  920. $set = ' 
  921. ' . $id . ' = jQuery.grep(' . $id . ', function(n) { return(n); }); 
  922. var ' . $id . 'Output = (jQuery.trim(' . $idCode2 . ') === "' . implode( ', ', $defaultsArray ) . '") ? "" : " ' . $id . '=\""+ ' . $idCode2 . '+"\"";'; 
  923. // Debug 
  924.  
  925. $return = array( 'js' => $js, 'id' => $id, 'idcode' => $idCode, 'setvalue' => $set ); 
  926.  
  927. return $return; 
  928.  
  929. public function add_form_button() { 
  930.  
  931. $output = '<a href="#TB_inline?width=640&inlineId=select_gf_directory" class="thickbox button select_gf_directory gform_media_link" id="add_gform" title="' . esc_attr__( "Add a Gravity Forms Directory", 'gravity-forms-addons' ) . '"><span class="dashicons dashicons-welcome-widgets-menus" style="line-height: 26px;"></span> ' . esc_html__( "Add Directory", "gravityforms" ) . '</a>'; 
  932.  
  933. echo $output; 
  934.  
  935. //Creates directory left nav menu under Forms 
  936. public function create_menu( $menus ) { 
  937. // Adding submenu if user has access 
  938. $permission = GFDirectory::has_access( "gravityforms_directory" ); 
  939. if ( ! empty( $permission ) ) { 
  940. $menus[] = array( 
  941. "name" => "gf_settings&addon=Directory+%26+Addons",  
  942. "label" => esc_html__( "Directory & Addons", "gravity-forms-addons" ),  
  943. "callback" => array( &$this, "settings_page" ),  
  944. "permission" => $permission,  
  945. ); 
  946.  
  947. return $menus; 
  948.  
  949. public function settings_page() { 
  950. $message = $validimage = false; 
  951. global $plugin_page; 
  952.  
  953. if ( isset( $_POST["gf_addons_submit"] ) ) { 
  954. check_admin_referer( "update", "gf_directory_update" ); 
  955.  
  956. $settings = array( 
  957. "directory" => isset( $_POST["gf_addons_directory"] ),  
  958. "referrer" => isset( $_POST["gf_addons_referrer"] ),  
  959. "directory_defaults" => GFDirectory::directory_defaults( $_POST['gf_addons_directory_defaults'], true ),  
  960. "modify_admin" => isset( $_POST["gf_addons_modify_admin"] ) ? $_POST["gf_addons_modify_admin"] : array(),  
  961. "version" => GFDirectory::get_version(),  
  962. "saved" => true,  
  963. ); 
  964. $message = esc_html__( 'Settings saved.', 'gravity-forms-addons' ); 
  965. update_option( "gf_addons_settings", $settings ); 
  966. } else { 
  967. $settings = GFDirectory::get_settings(); 
  968.  
  969. ?> 
  970. <style> 
  971. .ul-square li { 
  972. list-style: square !important; 
  973.  
  974. .ol-decimal li { 
  975. list-style: decimal !important; 
  976.  
  977. .form-table label { 
  978. font-size: 1em !important; 
  979. margin: .4em 0; 
  980. display: block; 
  981.  
  982. li.setting-container { 
  983. border: none !important; 
  984. </style> 
  985. <script> 
  986. jQuery( 'document' ).ready( function ( $ ) { 
  987. $( '#kws_gf_advanced_settings' ).show(); 
  988. $( 'a:contains(Directory)', $( 'ul.subsubsub' ) ).css( 'font-weight', 'bold' ); 
  989. $( '.wp-submenu li.current, .wp-submenu li.current a' ).removeClass( 'current' ); 
  990. $( 'a:contains(Directory)', $( '.wp-submenu' ) ).addClass( 'current' ).parent( 'li' ).addClass( 'current' ); 
  991.  
  992. $( 'a.kws_gf_advanced_settings' ).hide(); //click(function(e) { e.preventDefault(); jQuery('#kws_gf_advanced_settings').slideToggle(); return false; }); 
  993.  
  994. $( '#kws_gf_advanced_settings' ).change( function () { 
  995. if ( $( "#gf_settings_thead:checked" ).length || $( "#gf_settings_tfoot:checked" ).length ) { 
  996. $( '#gf_settings_jssearch' ).parents( 'li' ).show(); 
  997. } else { 
  998. $( '#gf_settings_jssearch' ).parents( 'li' ).hide(); 
  999. } ).trigger( 'change' ); 
  1000.  
  1001. $( document ).on( 'load click', 'label[for=gf_addons_directory]', function () { 
  1002. if ( $( '#gf_addons_directory' ).is( ":checked" ) ) { 
  1003. $( "tr#directory_settings_row" ).show(); 
  1004. } else { 
  1005. $( "tr#directory_settings_row" ).hide(); 
  1006. } ); 
  1007.  
  1008. $( '#kws_gf_instructions_button' ).click( function ( e ) { 
  1009. e.preventDefault(); 
  1010.  
  1011. $( '#kws_gf_instructions' ).slideToggle( function () { 
  1012. var $that = $( '#kws_gf_instructions_button' ); 
  1013. $that.text( function () { 
  1014. if ( $( '#kws_gf_instructions' ).is( ":visible" ) ) { 
  1015. return '<?php echo esc_js( __( 'Hide Directory Instructions', 'gravity-forms-addons' ) ); ?>'; 
  1016. } else { 
  1017. return '<?php echo esc_js( __( 'View Directory Instructions', 'gravity-forms-addons' ) ); ?>'; 
  1018. } ); 
  1019. } ); 
  1020.  
  1021. return false; 
  1022. } ); 
  1023.  
  1024. $( '#message.fade' ).delay( 1000 ).fadeOut( 'slow' ); 
  1025.  
  1026. } ); 
  1027. </script> 
  1028. <div class="wrap"> 
  1029. <?php 
  1030. if ( $plugin_page !== 'gf_settings' ) { 
  1031.  
  1032. echo '<h2>' . esc_html__( 'Gravity Forms Directory Add-on', "gravity-forms-addons" ) . '</h2>'; 
  1033. if ( $message ) { 
  1034. echo "<div class='fade below-h2 updated' id='message'>" . wpautop( $message ) . "</div>"; 
  1035.  
  1036. // if you must, you can filter this out... 
  1037. if ( apply_filters( 'kws_gf_show_donate_box', true ) ) { 
  1038. include( plugin_dir_path( __FILE__ ) . '/gravityview-info.php' ); 
  1039. } // End donate box 
  1040.  
  1041. ?> 
  1042.  
  1043. <p class="submit"><span style="padding-right:.5em;" 
  1044. class="description"><?php esc_html_e( 'Need help getting started?', 'gravity-forms-addons' ); ?></span> 
  1045. <a href="#" class="button button-secondary" id="kws_gf_instructions_button"><?php 
  1046. if ( ! empty( $settings['saved'] ) && ! isset( $_REQUEST['viewinstructions'] ) ) { 
  1047. esc_html_e( 'View Directory Instructions', 'gravity-forms-addons' ); 
  1048. } else { 
  1049. esc_html_e( 'Hide Directory Instructions', 'gravity-forms-addons' ); 
  1050. ?></a></p> 
  1051.  
  1052. <div 
  1053. id="kws_gf_instructions"<?php if ( ! empty( $settings['saved'] ) && ! isset( $_REQUEST['viewinstructions'] ) ) { ?> class="hide-if-js clear" <?php } ?>> 
  1054. <div class="delete-alert alert_gray"> 
  1055. <div class="alignright" style="margin:1em 1.2em;"> 
  1056. <iframe width="400" height="255" 
  1057. src="http<?php echo is_ssl() ? 's' : ''; ?>://www.youtube.com/embed/PMI7Jb-RP2I?hd=1" 
  1058. frameborder="0" allowfullscreen></iframe> 
  1059. </div> 
  1060. <h3 style="padding-top:1em;"><?php esc_html_e( 'To integrate a form with Directory:', 'gravity-forms-addons' ); ?></h3> 
  1061. <ol class="ol-decimal"> 
  1062. <li><?php esc_html_e( 'Go to the post or page where you would like to add the directory.', 'gravity-forms-addons' ); ?></li> 
  1063. <li><?php esc_html_e( 'Click the "Add Directory" button above the content area.', 'gravity-forms-addons' ); ?></li> 
  1064. <li><?php esc_html_e( 'Choose a form from the drop-down menu and configure settings as you would like them.', 'gravity-forms-addons' ); ?></li> 
  1065. <li><?php printf( esc_html__( 'Click "Insert Directory". A "shortcode" should appear in the content editor that looks similar to %s[directory form="#"]%s', 'gravity-forms-addons' ), '<code style="font-size:1em;">', '</code>' ); ?></li> 
  1066. <li><?php esc_html_e( 'Save the post or page', 'gravity-forms-addons' ); ?></li> 
  1067. </ol> 
  1068.  
  1069. <h4><?php esc_html_e( 'Configuring Fields & Columns', "gravity-forms-addons" ); ?></h4> 
  1070.  
  1071. <?php echo wpautop( esc_html__( 'When editing a form, click on a field to expand the field. Next, click the "Directory" tab. There, you will find options to:', "gravity-forms-addons" ) ); ?> 
  1072.  
  1073. <ul class="ul-square"> 
  1074. <li><?php esc_html_e( "Choose whether you would like the field to be a link to the Single Entry View;", "gravity-forms-addons" ); ?></li> 
  1075. <li><?php esc_html_e( "Hide the field in Directory View; and", "gravity-forms-addons" ); ?></li> 
  1076. <li><?php esc_html_e( "Hide the field in Single Entry View", "gravity-forms-addons" ); ?></li> 
  1077. </ul> 
  1078.  
  1079. <h4><?php esc_html_e( 'Configuring Column Visibility & Order', "gravity-forms-addons" ); ?></h4> 
  1080.  
  1081. <?php echo wpautop( esc_html__( 'When editing a form in Gravity Forms, click the link near the top-center of the page named "Directory Columns"', "gravity-forms-addons" ) ); ?> 
  1082.  
  1083. <ol class="ol-decimal"> 
  1084. <li><?php esc_html_e( 'When editing a form in Gravity Forms, click the link near the top-center of the page named "Directory Columns"', "gravity-forms-addons" ); ?></li> 
  1085. <li><?php esc_html_e( 'Drag and drop columns from the right ("Hidden Columns") side to the left ("Visible Columns") side.', "gravity-forms-addons" ); ?></li> 
  1086. <li><?php esc_html_e( 'Click the "Save" button', "gravity-forms-addons" ); ?></li> 
  1087. </ol> 
  1088.  
  1089. </div> 
  1090.  
  1091. <div class="hr-divider"></div> 
  1092. </div> 
  1093. <form method="post" action="" class="clear"> 
  1094. <?php wp_nonce_field( "update", "gf_directory_update" ) ?> 
  1095. <table class="form-table"> 
  1096. <tr> 
  1097. <th scope="row"><label 
  1098. for="gf_addons_directory"><?php esc_html_e( "Gravity Forms Directory", "gravity-forms-addons" ); ?></label> 
  1099. </th> 
  1100. <td> 
  1101. <label for="gf_addons_directory" class="howto"><input type="checkbox" 
  1102. id="gf_addons_directory" 
  1103. name="gf_addons_directory" <?php checked( $settings["directory"] ); ?> /> <?php esc_html_e( 'Enable Gravity Forms Directory capabilities', 'gravity-forms-addons' ); ?> 
  1104. </label> 
  1105. </td> 
  1106. </tr> 
  1107. <tr id="directory_settings_row"> 
  1108. <th scope="row"></th> 
  1109. <td> 
  1110. <h2 style="margin-bottom:0; padding-bottom:0;"><?php esc_html_e( "Directory Default Settings", "gravity-forms-addons" ); ?></h2> 
  1111. <h3><?php esc_html_e( "These defaults can be over-written when inserting a directory.", "gravity-forms-addons" ); ?></h3> 
  1112.  
  1113. <?php 
  1114. self::make_popup_options( false ); 
  1115. ?> 
  1116. <div class="hr-divider"></div> 
  1117. </td> 
  1118. </tr> 
  1119. <tr> 
  1120. <th scope="row"><label 
  1121. for="gf_addons_referrer"><?php esc_html_e( "Add Referrer Data to Emails", "gravity-forms-addons" ); ?></label> 
  1122. </th> 
  1123. <td> 
  1124. <label for="gf_addons_referrer"><input type="checkbox" id="gf_addons_referrer" 
  1125. name="gf_addons_referrer" <?php checked( $settings["referrer"] ); ?> /> <?php esc_html_e( "Adds referrer data to entries, including the path the user took to get to the form before submitting.", 'gravity-forms-addons' ); ?> 
  1126. </label> 
  1127. </td> 
  1128. </tr> 
  1129. <tr> 
  1130. <th scope="row"><label 
  1131. for="gf_addons_modify_admin"><?php esc_html_e( "Modify Gravity Forms Admin", "gravity-forms-addons" ); ?></label> 
  1132. </th> 
  1133. <td> 
  1134. <ul> 
  1135. <li><label for="gf_addons_modify_admin_expand"><input type="checkbox" 
  1136. id="gf_addons_modify_admin_expand" 
  1137. name="gf_addons_modify_admin[expand]" <?php checked( isset( $settings["modify_admin"]['expand'] ) ); ?> /> <?php esc_html_e( "Show option to expand Form Editor Field boxes", "gravity-forms-addons" ); ?> 
  1138. </label></li> 
  1139.  
  1140. <li><label for="gf_addons_modify_admin_toggle"><input type="checkbox" 
  1141. id="gf_addons_modify_admin_toggle" 
  1142. name="gf_addons_modify_admin[toggle]" <?php checked( isset( $settings["modify_admin"]['toggle'] ) ); ?> /> <?php esc_html_e( 'When clicking Form Editor Field boxes, toggle open and closed instead of "accordion mode" (closing all except the clicked box).', "gravity-forms-addons" ); ?> 
  1143. </label></li> 
  1144.  
  1145. <li><label for="gf_addons_modify_admin_edit"><input type="checkbox" 
  1146. id="gf_addons_modify_admin_edit" 
  1147. name="gf_addons_modify_admin[edit]" <?php checked( isset( $settings["modify_admin"]['edit'] ) ); ?> /> <?php printf( esc_html__( "Makes possible direct editing of entries from %sEntries list view%s", "gravity-forms-addons" ), '<a href="' . admin_url( 'admin.php?page=gf_entries' ) . '">', '</a>' ); ?> 
  1148. </label></li> 
  1149.  
  1150. <li><label for="gf_addons_modify_admin_ids"><input type="checkbox" 
  1151. id="gf_addons_modify_admin_ids" 
  1152. name="gf_addons_modify_admin[ids]" <?php checked( isset( $settings["modify_admin"]['ids'] ) ); ?> /> <?php printf( esc_html__( "Adds a link in the Forms list view to view form IDs", "gravity-forms-addons" ), '<a href="' . admin_url( 'admin.php?page=gf_edit_forms' ) . '">', '</a>' ); ?> 
  1153. </label></li> 
  1154. </ul> 
  1155. </td> 
  1156. </tr> 
  1157. <tr> 
  1158. <td colspan="2"><input type="submit" name="gf_addons_submit" 
  1159. class="button-primary button-large button-mega" 
  1160. value="<?php esc_attr_e( "Save Settings", "gravity-forms-addons" ) ?>"/> 
  1161. </td> 
  1162. </tr> 
  1163. </table> 
  1164. </form> 
  1165. </div> 
  1166. <?php