MS_Rule_Url_View

The Membership 2 MS Rule Url View class.

Defined (1)

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

/app/rule/url/class-ms-rule-url-view.php  
  1. class MS_Rule_Url_View extends MS_View { 
  2.  
  3. public function to_html() { 
  4. $membership = MS_Model_Membership::get_base(); 
  5. $rule = $membership->get_rule( MS_Rule_Url::RULE_ID ); 
  6.  
  7. $listtable = new MS_Rule_Url_ListTable( $rule ); 
  8. $listtable->prepare_items(); 
  9.  
  10. if ( $listtable->list_shows_base_items() ) { 
  11. $add_fields = array( 
  12. 'url' => array( 
  13. 'id' => 'url_value',  
  14. 'title' => __( 'Add new URL Address', 'membership2' ),  
  15. 'type' => MS_Helper_Html::INPUT_TYPE_TEXT,  
  16. 'class' => 'ms-text-medium',  
  17. ),  
  18. 'url_add' => array( 
  19. 'id' => 'url_add',  
  20. 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT,  
  21. 'value' => __( 'Protect this URL', 'membership2' ),  
  22. 'button_type' => 'button',  
  23. ),  
  24. 'url_action' => array( 
  25. 'name' => 'rule_action',  
  26. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  27. 'value' => MS_Rule_Url::ACTION_ADD,  
  28. ),  
  29. 'url_nonce' => array( 
  30. 'name' => '_wpnonce',  
  31. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  32. 'value' => wp_create_nonce( MS_Rule_Url::ACTION_ADD ),  
  33. ),  
  34. ); 
  35.  
  36. $header_data = apply_filters( 
  37. 'ms_view_membership_protectedcontent_header',  
  38. array( 
  39. 'title' => __( 'URL Restriction', 'membership2' ),  
  40. 'desc' => array( 
  41. __( 'Specify URLs that you want to protect.', 'membership2' ),  
  42. __( 'e.g. <b>example.com/protectme/</b> will protect all URLs that contain <b>example.com/protectme/</b>, including any child page.', 'membership2' ),  
  43. ),  
  44. 'class' => '',  
  45. ),  
  46. MS_Rule_Url::RULE_ID,  
  47. $this 
  48. ); 
  49.  
  50. ob_start(); 
  51. ?> 
  52. <div class="ms-settings"> 
  53. <?php MS_Helper_Html::settings_tab_header( $header_data ); ?> 
  54.  
  55. <form action="" method="post"> 
  56. <?php 
  57. if ( $listtable->list_shows_base_items() ) { 
  58. foreach ( $add_fields as $field ) { 
  59. MS_Helper_Html::html_element( $field ); 
  60. ?> 
  61. </form> 
  62.  
  63. <?php 
  64. $listtable->views(); 
  65. $listtable->search_box(); 
  66. ?> 
  67. <form action="" method="post"> 
  68. <?php 
  69. $listtable->display(); 
  70.  
  71. do_action( 
  72. 'ms_view_membership_protectedcontent_footer',  
  73. MS_Rule_Url::RULE_ID,  
  74. $this 
  75. ); 
  76. ?> 
  77. </form> 
  78. </div> 
  79. <?php 
  80.  
  81. MS_Helper_Html::settings_footer(); 
  82.  
  83. return ob_get_clean(); 
  84.