GFDirectory_EditForm

The Gravity Forms Directory & Addons GFDirectory EditForm class.

Defined (1)

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

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