/edit-form.php

  1. <?php 
  2.  
  3. add_action('init', array('GFDirectory_EditForm', 'initialize')); 
  4.  
  5. class GFDirectory_EditForm { 
  6.  
  7. static public function initialize() { 
  8. new self; 
  9.  
  10. function __construct() { 
  11.  
  12. add_action('admin_init', array(&$this, 'process_exterior_pages')); 
  13.  
  14. if(self::is_gravity_page() ) { 
  15.  
  16. add_filter('admin_head', array(&$this, 'directory_admin_head')); 
  17.  
  18. if( isset($_REQUEST['id'] ) || self::is_gravity_page('gf_entries') ) { 
  19. add_filter('gform_tooltips', array(&$this, 'directory_tooltips')); //Filter to add a new tooltip 
  20. add_action("gform_editor_js", array(&$this, "editor_script")); //Action to inject supporting script to the form editor page 
  21.  
  22. // No need to add via JS any more. 
  23. if( class_exists( 'GFForms' ) && version_compare( GFForms::$version, '2.0', '>=' ) ) { 
  24. add_filter( 'gform_toolbar_menu', array( $this, 'toolbar_menu_item' ), 10, 2 ); 
  25. } else { 
  26. add_action("admin_head", array(&$this, "toolbar_links")); //Action to inject supporting script to the form editor page 
  27. add_action("gform_field_advanced_settings", array(&$this, "use_as_entry_link_settings"), 10, 2); 
  28. add_filter("gform_add_field_buttons", array(&$this, "add_field_buttons")); 
  29. add_action('gform_editor_js_set_default_values', array(&$this, 'directory_add_default_values')); 
  30.  
  31. // From gravityforms.php 
  32. public static function process_exterior_pages() { 
  33. if(rgempty("gf_page", $_GET)) 
  34. {return;} 
  35.  
  36. //ensure users are logged in 
  37. if(!is_user_logged_in()) 
  38. {auth_redirect();} 
  39.  
  40. switch(rgget("gf_page")) { 
  41. case "directory_columns" : 
  42. require_once("select_directory_columns.php"); 
  43. break; 
  44. exit(); 
  45.  
  46. public function directory_add_default_values() { 
  47. ?> 
  48. case "entrylink" : 
  49. field.label = "<?php echo esc_js( __("Go to Entry", "gravity-forms-addons") ); ?>"; 
  50. field.adminOnly = true; 
  51. field.choices = null; 
  52. field.inputs = null; 
  53. field.hideInSingle = true; 
  54. field.useAsEntryLink = 'label'; 
  55. field.type = 'hidden'; 
  56. field.disableMargins = true; 
  57.  
  58. break; 
  59.  
  60. case 'usereditlink': 
  61. field.label = "<?php echo esc_js( __("Edit", "gravity-forms-addons") ); ?>"; 
  62.  
  63. field.adminOnly = true; 
  64. field.choices = null; 
  65. field.inputs = null; 
  66. field.hideInSingle = false; 
  67. field.useAsEntryLink = false; 
  68. field.type = 'hidden'; 
  69. field.disableMargins = 2; 
  70.  
  71. break; 
  72.  
  73. case 'directoryapproved': 
  74. field.label = "<?php echo esc_js( __("Approved? (Admin-only)", "gravity-forms-addons")); ?>"; 
  75.  
  76. field.adminLabel = "<?php echo esc_js( __("Approved?", "gravity-forms-addons")); ?>"; 
  77. field.adminOnly = true; 
  78.  
  79. field.choices = null; 
  80. field.inputs = null; 
  81.  
  82. if(!field.choices) 
  83. field.choices = new Array(new Choice("<?php echo esc_js( __("Approved", "gravity-forms-addons")); ?>")); 
  84.  
  85. field.inputs = new Array(); 
  86. for(var i=1; i<=field.choices.length; i++) 
  87. field.inputs.push(new Input(field.id + (i/10), field.choices[i-1].text)); 
  88.  
  89. field.hideInDirectory = true; 
  90. field.hideInSingle = true; 
  91. field.type = 'checkbox'; 
  92.  
  93. break; 
  94. <?php 
  95.  
  96. public function directory_admin_head() { 
  97. global $_gform_directory_approvedcolumn, $process_bulk_update_message; 
  98.  
  99. // Entries screen shows first form's entries by default, if not specified 
  100. if( isset( $_GET['id'] ) ) { 
  101. $formID = intval( $_GET['id'] ); 
  102. } else { 
  103. if( class_exists('RGFormsModel') ) { 
  104. $forms = RGFormsModel::get_forms(NULL, "title"); 
  105. $formID = $forms[0]->id; 
  106.  
  107. if( !( self::is_gravity_page('gf_entries') && !self::is_gravity_page('gf_edit_forms') ) ) { 
  108. return; 
  109.  
  110. if( ! isset( $formID ) ) { 
  111. return; 
  112.  
  113. // Don't display on single entry view. 
  114. if( !empty( $_GET['view'] ) && $_GET['view'] === 'entry' ) { 
  115. return; 
  116.  
  117. ?> 
  118. <style> 
  119.  
  120. .lead_approved .toggleApproved { 
  121. background: url(<?php echo plugins_url('images/tick.png', __FILE__); ?>) left top no-repeat; 
  122. .toggleApproved { 
  123. background: url(<?php echo plugins_url('images/cross.png', __FILE__); ?>) left top no-repeat; 
  124. width: 16px; 
  125. height: 16px; 
  126. display: block; 
  127. text-indent: -9999px; 
  128. overflow: hidden; 
  129. </style> 
  130. <script> 
  131.  
  132. <?php 
  133.  
  134. //$formID = RGForms::get("id"); 
  135.  
  136. if(empty($formID)) { 
  137. $forms = RGFormsModel::get_forms(NULL, "title"); 
  138. $formID = $forms[0]->id; 
  139.  
  140. $_gform_directory_approvedcolumn = empty($_gform_directory_approvedcolumn) ? GFDirectory::globals_get_approved_column($formID) : $_gform_directory_approvedcolumn; 
  141.  
  142. if(!empty($_gform_directory_approvedcolumn)) { 
  143. echo 'formID = '.$formID.';'; 
  144. ?> 
  145.  
  146. function UpdateApproved(lead_id, approved) { 
  147. var mysack = new sack("<?php echo admin_url("admin-ajax.php")?>" ); 
  148. mysack.execute = 1; 
  149. mysack.method = 'POST'; 
  150. mysack.setVar( "action", "rg_update_approved" ); 
  151. mysack.setVar( "rg_update_approved", "<?php echo wp_create_nonce("rg_update_approved") ?>" ); 
  152. mysack.setVar( "lead_id", lead_id); 
  153. mysack.setVar( "form_id", formID); 
  154. mysack.setVar( "approved", approved); 
  155. mysack.encVar( "cookie", document.cookie, false ); 
  156. mysack.onError = function() { 
  157. console.log('<?php echo esc_js(__("Ajax error while setting lead approval", "gravity-forms-addons")) ?>' ); 
  158. }; 
  159. mysack.runAJAX(); 
  160.  
  161. return true; 
  162.  
  163. <?php 
  164.  
  165. if(!function_exists('gform_get_meta')) { ?> 
  166.  
  167. function displayMessage(message, messageClass, container) { 
  168.  
  169. hideMessage(container, true); 
  170.  
  171. var messageBox = jQuery('<div class="message ' + messageClass + '" style="display:none;"><p>' + message + '</p></div>'); 
  172. jQuery(messageBox).prependTo(container).slideDown(); 
  173.  
  174. if(messageClass == 'updated') 
  175. {messageTimeout = setTimeout(function() { hideMessage(container, false); }, 10000); 
  176.  
  177.  
  178. function hideMessage(container, messageQueued) { 
  179.  
  180. var messageBox = jQuery(container).find('.message'); 
  181.  
  182. if(messageQueued) 
  183. {jQuery(messageBox).remove(); 
  184. }else 
  185. {jQuery(messageBox).slideUp(function() { jQuery(this).remove(); }); 
  186.  
  187.  
  188. <?php } // end meta check for 1.6 ?> 
  189.  
  190. jQuery(document).ready(function($) { 
  191.  
  192. <?php if(!empty($process_bulk_update_message)) { ?> 
  193. displayMessage('<?php echo esc_js($process_bulk_update_message); ?>', 'updated', '#lead_form'); 
  194. <?php } ?> 
  195.  
  196. $("#bulk_action, #bulk_action2").append('<optgroup label="Directory"><option value="approve-'+formID+'"><?php echo esc_js( __('Approve', 'gravity-forms-addons')); ?></option><option value="unapprove-'+formID+'"><?php echo esc_js( __('Disapprove', 'gravity-forms-addons')); ?></option></optgroup>'); 
  197.  
  198. var approveTitle = '<?php echo esc_js( __('Entry not approved for directory viewing. Click to approve this entry.', 'gravity-forms-addons')); ?>'; 
  199. var unapproveTitle = '<?php echo esc_js( __('Entry approved for directory viewing. Click to disapprove this entry.', 'gravity-forms-addons')); ?>'; 
  200.  
  201. $(document).on('click load', '.toggleApproved', function(e) { 
  202. e.preventDefault(); 
  203.  
  204. var $tr = $(this).parents('tr'); 
  205. var is_approved = $tr.is(".lead_approved"); 
  206.  
  207. if(e.type == 'click') { 
  208. $tr.toggleClass("lead_approved"); 
  209.  
  210. // Update the title and screen-reader text 
  211. if(!is_approved) { $(this).text('X').prop('title', unapproveTitle); } 
  212. else { $(this).text('O').prop('title', approveTitle); } 
  213.  
  214. if(e.type == 'click') { 
  215. UpdateApproved($('th input[type="checkbox"]', $tr).val(), is_approved ? 0 : 'Approved'); 
  216.  
  217. UpdateApprovedColumns($(this).parents('table'), false); 
  218.  
  219. return false; 
  220.  
  221. }); 
  222.  
  223. // We want to make sure that the checkboxes go away even if the Approved column is showing. 
  224. // They will be in sync when loaded, so only upon click will we process. 
  225. function UpdateApprovedColumns($table, onLoad) { 
  226. var colIndex = $('th:contains("Approved")', $table).index() - 1; 
  227.  
  228. $('tr', $table).each(function() { 
  229. if($(this).is('.lead_approved') || (onLoad && $("input.lead_approved", $(this)).length > 0)) { 
  230. if(onLoad && $(this).not('.lead_approved')) { $(this).addClass('lead_approved'); } 
  231. $('td:visible:eq('+colIndex+'):has(.toggleApproved)', $(this)).html("<img src='<?php echo plugins_url('images/tick.png', __FILE__); ?>/>"); 
  232. } else { 
  233. if(onLoad && $(this).is('.lead_approved')) { $(this).removeClass('lead_approved'); } 
  234. $('td:visible:eq('+colIndex+'):has(.toggleApproved)', $(this)).html(''); 
  235. }); 
  236.  
  237. // Add the header column 
  238. $('thead .column-is_starred, tfoot .column-is_starred').after('<th class="manage-column column-is_starred sortable"><a href="<?php echo esc_url( add_query_arg(array('sort' => $_gform_directory_approvedcolumn)) ); ?>"><img src="<?php echo plugins_url( '/images/form-button-1.png', __FILE__); ?>" title="<?php echo esc_js( __('Show entry in directory view?', 'gravity-forms-addons')); ?>" /></span></a></th>'); 
  239.  
  240. // Add to each row 
  241. $('tbody td:has(img[src*="star"]), tbody th:has(img[src*="star"])').after('<td><a href="#" class="toggleApproved" title="'+approveTitle+'">X</a></td>'); 
  242.  
  243. $('tr:has(input.lead_approved)').addClass('lead_approved').find('a.toggleApproved').prop('title', unapproveTitle).text('O'); 
  244.  
  245. UpdateApprovedColumns($('table'), true); 
  246.  
  247. }); 
  248. <?php } // end if(!empty($_gform_directory_approvedcolumn)) check ?> 
  249. </script><?php 
  250.  
  251. public function use_as_entry_link_settings($position, $form_id) { 
  252.  
  253. //create settings on position 50 (right after Admin Label) 
  254. if($position === -1) : ?> 
  255. </ul> 
  256. </div> 
  257. <div id="gform_tab_directory"> 
  258. <ul> 
  259. <li class="use_as_entry_link gf_directory_setting field_setting"> 
  260. <label for="field_use_as_entry_link"> 
  261. <?php esc_html_e("Use As Link to Single Entry", "gravity-forms-addons"); ?> 
  262. <?php gform_tooltip("kws_gf_directory_use_as_link_to_single_entry") ?> 
  263. </label> 
  264. <label for="field_use_as_entry_link"><input type="checkbox" value="1" id="field_use_as_entry_link" /> <?php esc_html_e("Use this field as a link to single entry view", "gravity-forms-addons"); ?></label> 
  265. </li> 
  266. <li class="use_as_entry_link_value gf_directory_setting field_setting"> 
  267. <label> 
  268. <?php esc_html_e("Single Entry Link Text", "gravity-forms-addons"); ?> 
  269. <span class="howto"><?php esc_html_e('Note: it is a good idea to use required fields for links to single entries so there are no blank links.', 'gravity-forms-addons'); ?></span> 
  270. </label> 
  271.  
  272. <label><input type="radio" name="field_use_as_entry_link_value" id="field_use_as_entry_link_value" value="on" /> <?php esc_html_e("Use field values from entry", "gravity-forms-addons"); ?></label> 
  273. <label><input type="radio" name="field_use_as_entry_link_value" id="field_use_as_entry_link_label" value="label" /> <?php printf( esc_html( "Use the Field Label %s as link text", 'gravity-forms-addons'), '<span id="entry_link_label_text"></span>'); ?></label> 
  274. <label><input type="radio" name="field_use_as_entry_link_value" id="field_use_as_entry_link_custom" value="custom" /> <?php esc_html_e("Use custom link text.", "gravity-forms-addons"); ?></label> 
  275. <span class="hide-if-js" style="display:block;clear:both; margin-left:1.5em"><input type="text" class="widefat" id="field_use_as_entry_link_value_custom_text" value="" /><span class="howto"><?php printf(esc_html('%s%%value%%%s will be replaced with each entry\'s value.', 'gravity-forms-addons'), "<code class='code'>", '</code>'); ?></span></span> 
  276. </li> 
  277. <li class="hide_in_directory_view only_visible_to_logged_in only_visible_to_logged_in_cap gf_directory_setting field_setting"> 
  278. <label for="hide_in_directory_view"> 
  279. <?php esc_html_e("Hide This Field in Directory View?", "gravity-forms-addons"); ?> 
  280. <?php gform_tooltip("kws_gf_directory_hide_in_directory_view") ?> 
  281. </label> 
  282. <label><input type="checkbox" id="hide_in_directory_view" /> <?php esc_html_e("Hide this field in the directory view.", "gravity-forms-addons"); ?></label> 
  283.  
  284. <label> 
  285. <input type="checkbox" id="only_visible_to_logged_in" /> <?php esc_html_e("Only visible to logged in users with the following role:", "gravity-forms-addons"); ?> 
  286. <select id="only_visible_to_logged_in_cap"> 
  287. <option value="read"><?php esc_html_e("Any", "gravity-forms-addons"); ?></option> 
  288. <option value="publish_posts"><?php esc_html_e("Author or higher", "gravity-forms-addons"); ?></option> 
  289. <option value="delete_others_posts"><?php esc_html_e("Editor or higher", "gravity-forms-addons"); ?></option> 
  290. <option value="manage_options"><?php esc_html_e("Administrator", "gravity-forms-addons"); ?></option> 
  291. </select> 
  292. </label> 
  293.  
  294. </li> 
  295. <li class="hide_in_single_entry_view gf_directory_setting field_setting"> 
  296. <label for="hide_in_single_entry_view"> 
  297. <?php esc_html_e("Hide This Field in Single Entry View?", "gravity-forms-addons"); ?> 
  298. <?php gform_tooltip("kws_gf_directory_hide_in_single_entry_view") ?> 
  299. </label> 
  300. <label><input type="checkbox" id="hide_in_single_entry_view" /> <?php esc_html_e("Hide this field in the single entry view.", "gravity-forms-addons"); ?></label> 
  301. </li> 
  302. <li class="use_field_as_search_filter gf_directory_setting field_setting"> 
  303. <label for="use_field_as_search_filter"> 
  304. <?php esc_html_e("Directory Search Field", "gravity-forms-addons"); ?> 
  305. <?php gform_tooltip("kws_gf_directory_use_field_as_search_filter") ?> 
  306. </label> 
  307. <label for="use_field_as_search_filter"><input type="checkbox" id="use_field_as_search_filter" /> <?php esc_html_e("Use this field as a search filter", "gravity-forms-addons"); ?></label> 
  308. </li> 
  309. <?php endif; 
  310.  
  311. /** 
  312. * Add "Directory Columns" item to GF toolbar in GF 2.0+ 
  313. * 
  314. * @param array $menu_items Menu items in GF toolbar 
  315. * @param int $form_id Form ID 
  316. * 
  317. * @return array 
  318. */ 
  319. function toolbar_menu_item( $menu_items = array(), $form_id = 0 ) { 
  320.  
  321. wp_enqueue_style( 'thickbox' ); 
  322.  
  323. $entries_capabilities = array( 
  324. 'gravityforms_view_entries',  
  325. 'gravityforms_edit_entries',  
  326. 'gravityforms_delete_entries' 
  327. ); 
  328.  
  329. $menu_items['directory_columns'] = array( 
  330. 'label' => __('Directory Columns', 'gravity-forms-addons'),  
  331. 'icon' => '<i class="dashicons dashicons-welcome-widgets-menus" style="line-height:17px"></i>',  
  332. 'title' => __('Modify Gravity Forms Directory Columns', 'gravity-forms-addons'),  
  333. 'url' => sprintf( '?gf_page=directory_columns&id=%d&add=entry&TB_iframe=true&height=600&width=700', $form_id ),  
  334. 'menu_class' => 'gf_form_toolbar_directory',  
  335. 'link_class' => 'thickbox',  
  336. 'capabilities' => $entries_capabilities,  
  337. 'priority' => 200,  
  338. ); 
  339.  
  340. return $menu_items; 
  341.  
  342. /** 
  343. * Add "Directory Columns" link to GF toolbar. No longer used after 2.0 
  344. * @see toolbar_menu_item 
  345. * @return void 
  346. */ 
  347. public function toolbar_links() { 
  348.  
  349. wp_enqueue_style( 'thickbox' ); 
  350.  
  351. ?> 
  352. <script type='text/javascript'> 
  353. jQuery(document).ready(function($) { 
  354. var url = '<?php echo esc_url_raw( add_query_arg(array('gf_page' => 'directory_columns', 'id' => intval( $_GET['id'] ), 'TB_iframe' => 'true', 'height' => 600, 'width' => 700), admin_url()) ); ?>'; 
  355. $link = $('<li class="gf_form_toolbar_preview gf_form_toolbar_directory" id="gf_form_toolbar_directory"><a href="'+url+'" class="thickbox" title="<?php echo esc_js(__('Modify Gravity Forms Directory Columns', 'gravity-forms-addons')); ?>"><i class="dashicons dashicons-welcome-widgets-menus" style="line-height:17px"></i> <?php echo esc_js( __('Directory Columns', 'gravity-forms-addons')); ?></a></li>'); 
  356. $('#gf_form_toolbar_links').append($link); 
  357. }); 
  358. </script> 
  359. <?php 
  360.  
  361. public function editor_script() { 
  362. ?> 
  363. <style> 
  364. li.gf_directory_setting, li.gf_directory_setting li { 
  365. padding-bottom: 4px!important; 
  366. </style> 
  367. <script> 
  368. jQuery(document).ready(function($) { 
  369.  
  370. // instead of simply .tabs('add')... 
  371. $('<li><a href="#gform_tab_directory"><?php echo esc_js( __('Directory', 'gravity-forms-addons')); ?></a></li>' ).appendTo('#field_settings .ui-tabs-nav'); 
  372. $('#gform_tab_directory').appendTo( "#field_settings" ); 
  373. $( '#field_settings' ).tabs( "refresh" ); 
  374.  
  375. $('a[href="#gform_tab_directory"]').parent('li').css({'width':'100px', 'padding':'0'}); 
  376.  
  377. for (var key in fieldSettings) { 
  378. fieldSettings[key] += ", .gf_directory_setting"; 
  379.  
  380. $('#field_use_as_entry_link_value_custom_text').change(function() { 
  381. if($("#field_use_as_entry_link_custom").is(':checked')) { 
  382. SetFieldProperty('useAsEntryLink', $(this).val()); 
  383. }); 
  384.  
  385. $("input:checkbox, input:radio", $('#gform_tab_directory')).click(function() { 
  386. var $li = $(this).parents('#field_settings'); 
  387. var entrylink = false; 
  388.  
  389. if($("#field_use_as_entry_link", $li).is(":checked")) { 
  390. entrylink = '1'; 
  391.  
  392. $('.use_as_entry_link_value').slideDown(); 
  393.  
  394. if($('input[name="field_use_as_entry_link_value"]:checked').length) { 
  395. entrylink = $('input[name="field_use_as_entry_link_value"]:checked').val(); 
  396. if(entrylink == 'custom') { 
  397. entrylink = $('#field_use_as_entry_link_value_custom_text').val(); 
  398. $('#field_use_as_entry_link_value_custom_text').parent('span').slideDown(); 
  399. } else { 
  400. $('#field_use_as_entry_link_value_custom_text').parent('span').slideUp(); 
  401. } else { 
  402. $('.use_as_entry_link_value', $li).slideUp(); 
  403.  
  404. var hideInSingle = false; 
  405. if($("#hide_in_single_entry_view", $li).is(':checked')) { 
  406. hideInSingle = true; 
  407.  
  408. var hideInDirectory = false; 
  409. if($("#hide_in_directory_view", $li).is(':checked')) { 
  410. hideInDirectory = true; 
  411. SetFieldProperty('hideInDirectory', hideInDirectory); 
  412. SetFieldProperty('hideInSingle', hideInSingle); 
  413. SetFieldProperty('useAsEntryLink', entrylink); 
  414.  
  415. // since 3.5 
  416. var visibleToLoggedIn = false; 
  417. if($("#only_visible_to_logged_in", $li).is(':checked')) { 
  418. visibleToLoggedIn = true; 
  419. SetFieldProperty('visibleToLoggedIn', visibleToLoggedIn); 
  420.  
  421. var isSearchFilter = false; 
  422. if($("#use_field_as_search_filter", $li).is(':checked')) { 
  423. isSearchFilter = true; 
  424. SetFieldProperty('isSearchFilter', isSearchFilter ); 
  425.  
  426. }); 
  427.  
  428.  
  429. $('#field_label').change(function() { 
  430. kwsGFupdateEntryLinkLabel($(this).val()); 
  431. }); 
  432.  
  433. function kwsGFupdateEntryLinkLabel(label) { 
  434. $('#entry_link_label_text').html(' ("'+label+'")'); 
  435.  
  436.  
  437. $('#only_visible_to_logged_in_cap').change( function() { 
  438. if( $("#only_visible_to_logged_in").is(':checked') ) { 
  439. SetFieldProperty('visibleToLoggedInCap', $(this).val() ); 
  440.  
  441. }); 
  442.  
  443.  
  444.  
  445. //binding to the load field settings event to initialize the checkbox 
  446. $(document).bind("gform_load_field_settings", function(event, field, form) { 
  447.  
  448. if(typeof(field["useAsEntryLink"]) !== "undefined" && field["useAsEntryLink"] !== false && field["useAsEntryLink"] !== 'false' && field["useAsEntryLink"] !== '') { 
  449. $("#field_use_as_entry_link").prop("checked", true); 
  450. $(".use_as_entry_link_value").show(); 
  451. $('#field_use_as_entry_link_value_custom_text').parent('span').hide(); 
  452. switch(field["useAsEntryLink"]) { 
  453. case "on": 
  454. case "": 
  455. case false: 
  456. $("#field_use_as_entry_link_value").prop('checked', true); 
  457. break; 
  458. case "label": 
  459. $("#field_use_as_entry_link_label").prop('checked', true); 
  460. break; 
  461. default: 
  462. $('#field_use_as_entry_link_value_custom_text').parent('span').show(); 
  463. $("#field_use_as_entry_link_custom").prop('checked', true); 
  464. $("#field_use_as_entry_link_value_custom_text").val(field["useAsEntryLink"]); 
  465. } else { 
  466. $(".use_as_entry_link_value").hide(); 
  467. $("#field_use_as_entry_link").prop("checked", false); 
  468.  
  469. if($('input[name="field_use_as_entry_link_value"]:checked').length === 0) { 
  470. $('#field_use_as_entry_link_value').prop('checked', true); 
  471.  
  472. kwsGFupdateEntryLinkLabel(field.label); 
  473.  
  474.  
  475. $("#field_use_as_entry_link_label").prop("checked", field["useAsEntryLink"] === 'label'); 
  476.  
  477. $("#hide_in_single_entry_view").prop("checked", (field["hideInSingle"] === true || field["hideInSingle"] === "on")); 
  478. $("#hide_in_directory_view").prop("checked", (field["hideInDirectory"] === true || field["hideInDirectory"] === "on")); 
  479.  
  480. //since 3.5 
  481. $("#only_visible_to_logged_in").prop("checked", (field["visibleToLoggedIn"] === true || field["visibleToLoggedIn"] === "on")); 
  482. $("#only_visible_to_logged_in_cap").val( field["visibleToLoggedInCap"] ); 
  483. //since 3.5 
  484. $("#use_field_as_search_filter").prop("checked", (field["isSearchFilter"] === true || field["isSearchFilter"] === "on")); 
  485.  
  486.  
  487.  
  488. }); 
  489. }); 
  490. </script> 
  491. <?php 
  492.  
  493. public function directory_tooltips($tooltips) { 
  494. $tooltips["kws_gf_directory_use_as_link_to_single_entry"] = sprintf( esc_html__("%sLink to single entry using this field%sIf you would like to link to the single entry view using this link, check the box.", 'gravity-forms-addons'), '<h6>', '</h6>'); 
  495. $tooltips['kws_gf_directory_hide_in_directory_view'] = sprintf( esc_html__('%sHide in Directory View%sIf checked, this field will not be shown in the directory view, even if it is visible in the %sDirectory Columns%s. If this field is Admin Only (set in the Advanced tab), it will be hidden in the directory view unless "Show Admin-Only columns" is enabled in the directory. Even if "Show Admin-Only columns" is enabled, checking this box will hide the column in the directory view.', 'gravity-forms-addons'), '<h6>', '</h6>', sprintf('<a class="thickbox" title="%s" href="'.add_query_arg(array('gf_page' => 'directory_columns', 'id' => @$_GET['id'], 'TB_iframe' => 'true', 'height' => 600, 'width' => 700), admin_url()).'">', esc_html__('Modify Directory Columns', 'gravity-forms-addons')), '</a>'); 
  496. $tooltips['kws_gf_directory_hide_in_single_entry_view'] = sprintf( esc_html__('%sHide in Single Entry View%sIf checked, this field will not be shown in the single entry view of the directory.', 'gravity-forms-addons'), '<h6>', '</h6>'); 
  497. $tooltips['kws_gf_directory_use_field_as_search_filter'] = sprintf( esc_html__('%sDirectory Search Field%sIf checked, add search fields to the Directory search form. If this field is a text field, a text search input will be added that will search only this field. Otherwise, the field choices will be used to populate a dropdown menu search input. Example: if the field has choices "A", "B", and "C", the search dropdown will have those items as choices in a dropdown search field.', 'gravity-forms-addons'), '<h6>', '</h6>'); 
  498. return $tooltips; 
  499.  
  500. //Returns true if the current page is one of Gravity Forms pages. Returns false if not 
  501. private static function is_gravity_page($page = array()) { 
  502. return GFDirectory::is_gravity_page($page); 
  503.  
  504. function add_field_buttons($field_groups) { 
  505. $directory_fields = array( 
  506. 'name' => 'directory_fields',  
  507. 'label' => 'Directory Fields',  
  508. 'fields' => array( 
  509. array( 
  510. 'class' => 'button',  
  511. 'value' => esc_attr__('Approved', 'gravity-forms-addons'),  
  512. 'onclick' => "StartAddField('directoryapproved');",  
  513. ),  
  514. array( 
  515. 'class' => 'button',  
  516. 'value' => esc_attr__('Entry Link', 'gravity-forms-addons'),  
  517. 'onclick' => "StartAddField('entrylink');",  
  518. ),  
  519. array( 
  520. 'class' => 'button',  
  521. 'value' => esc_attr__('User Edit Link', 'gravity-forms-addons'),  
  522. 'onclick' => "StartAddField('usereditlink');",  
  523. ),  
  524. ),  
  525. ); 
  526.  
  527. array_push($field_groups, $directory_fields); 
  528.  
  529. return $field_groups; 
.