/admin.php

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