function fbmcc_integration_settings()

in options.php [109:343]


function fbmcc_integration_settings() {
  $pages_arr = get_pages();
  ?>
  <div class="wrap">
    <h2><?=esc_html__( 'Facebook Chat Plugin Settings', 'facebook-messenger-customer-chat' )?></h2>
    <div class="fbmcc-card card">
      <div class="intro">
        <div>
          <h2><?=esc_html__( 'Getting Started?', 'facebook-messenger-customer-chat' )?></h2>
          <p class="fbmcc-instructions"><?=esc_html__( 'Let people start a conversation on '.
            'your website and continue in Messenger. It\'s easy to set up. Chats '.
            'started on your website can be continued in the customers\' '.
            'Messenger app, so you never lose connections with your customers. '.
            'Even those without a Facebook Messenger account can chat with you '.
            'in guest mode, so you can reach more customers than ever.',
            'facebook-messenger-customer-chat' )?>
          </p>
        </div>
        <div class="fbmcc-buttonContainer">
          <button
            class="fbmcc-setupButton"
            type="button"
            onclick="fbmcc_setupCustomerChat()"
          >
            <?php
            if( get_option( 'fbmcc_pageID' ) == "" ) {
              _e( 'Setup Chat Plugin', 'facebook-messenger-customer-chat' );
            } else {
              _e( 'Edit Chat Plugin', 'facebook-messenger-customer-chat' );
            }
            ?>
          </button>
        </div>
      </div>
    </div>
    <div
      id="fbmcc-page-params"
      class="fbmcc-card card
      <?php if( get_option( 'fbmcc_pageID' ) == "" ) {
        'hidden';
      } ?>">
      <div>
        <h2><?=esc_html__( 'Setup status', 'facebook-messenger-customer-chat' )?></h2>
        <p class="fbmcc-instructions"><?=esc_html__( 'The plugin code has already been added '.
          'into your website. You can always go back through the setup process '.
          'to customize the plugin.', 'facebook-messenger-customer-chat' )?>
        </p>
        <h2><?=esc_html__( 'Advanced Configuration', 'facebook-messenger-customer-chat' )?></h2>
        <?php
          $fbmcc_page_types = get_option( 'fbmcc_page_types' );
          $active_pages = Array();
          if ($fbmcc_page_types) { $active_pages = $fbmcc_page_types['pages']; }
        ?>
        <ul>
          <li>
            <table>
              <tr>
                <td><?=esc_html__( 'Deploy Chat plugin on:', 'facebook-messenger-customer-chat' )?></td>
                <td>
                  <select id="fbmcc-deploymentSelector" class="fbmcc-displaySetting">
                    <option value="1"
                    <?php if ((!$fbmcc_page_types) || ($fbmcc_page_types['all'] == "1")) { echo "selected"; } ?>>
                      <?=esc_html__( 'All pages', 'facebook-messenger-customer-chat' )?>
                    </option>
                    <option value="2"
                    <?php if (($fbmcc_page_types) && ($fbmcc_page_types['all'] == "0")) { echo "selected"; } ?>>
                      <?=esc_html__( 'Custom pages', 'facebook-messenger-customer-chat' )?>
                    </option>
                  </select>
                </td>
              </tr>
              <tr>
                <td></td>
                <td>
                  <div class="fbmcc-deploymentMenu
                  <?php if ((!$fbmcc_page_types) || ($fbmcc_page_types['all'] == "1")) { echo "hidden"; } ?>">
                    <ul>
                      <li>
                        <input type="checkbox" id="cbShowFrontPage" class="fbmcc-displaySetting"
                          <?php echo
                                (
                                  ($fbmcc_page_types) &&
                                    (isset($fbmcc_page_types['front_page'])) &&
                                    ($fbmcc_page_types['front_page'] == "0")
                                )
                            ? '' : 'checked';?>/>
                              Homepage
                      </li>
                      <li>
                        <input type="checkbox" id="cbShowPosts" class="fbmcc-displaySetting fbmcc-menuParentItem" checked />
                        <a
                          href="javascript:;"
                          id="fbmcc-postsSubmenuLink"
                          class="fbmcc-menuParentLink"
                          title="Click for granular options">
                          Posts
                          <img
                            src="<?=plugin_dir_url( __FILE__ ) . 'images/chevron-right.png';?>"
                            class="fbmcc-chevron" alt="&gt;" /></a>
                        <ul class="fbmcc-submenu hidden">
                          <li>
                            <input type="checkbox" id="cbShowSinglePostView" class="fbmcc-displaySetting fbmcc-submenuOption"
                            <?php echo
                                (
                                  ($fbmcc_page_types) &&
                                    (isset($fbmcc_page_types['posts'])) &&
                                    ($fbmcc_page_types['posts'] == "0")
                                )
                              ? '' : 'checked';?>/> Single post view
                          </li>
                          <li>
                            <input type="checkbox" id="cbShowCategoryIndex" class="fbmcc-displaySetting fbmcc-submenuOption"
                            <?php echo
                                (
                                  ($fbmcc_page_types) &&
                                    (isset($fbmcc_page_types['category_index'])) &&
                                    ($fbmcc_page_types['category_index'] == "0")
                                )
                                ? '' : 'checked';?>/> Category view
                          </li>
                          <li>
                            <input type="checkbox" id="cbShowTagsIndex" class="fbmcc-displaySetting fbmcc-submenuOption"
                              <?php echo
                                (
                                  ($fbmcc_page_types) &&
                                    (isset($fbmcc_page_types['tag_index'])) &&
                                    ($fbmcc_page_types['tag_index'] == "0")
                                )
                                ? '' : 'checked';?>/> Tags view
                          </li>
                        </ul>
                      </li>
                      <li>
                        <input type="checkbox" id="cbShowPages" class="fbmcc-displaySetting fbmcc-menuParentItem"
                          <?php echo
                            (
                              ($fbmcc_page_types) &&
                                (isset($fbmcc_page_types['pages_all'])) &&
                                ($fbmcc_page_types['pages_all'] == "0")
                            )
                            ? '' : 'checked';?> />
                            <?php
                              if (empty($pages_arr)) {
                            ?>Pages<?php
                              } else {
                            ?><a href="javascript:;" id="fbmcc-pagesSubmenuLink" class="fbmcc-menuParentLink" title="Click for granular options">Pages <img src="<?php echo plugin_dir_url( __FILE__ ) . 'images/chevron-right.png'; ?>" class="fbmcc-chevron" alt="&gt;" /></a><?php
                              }
                            ?>
                        <ul class="fbmcc-submenu hidden">
                          <?php
                            foreach($pages_arr as $page) {
                          ?>
                          <li>
                            <input type="checkbox" id="pageid_<?php echo $page->ID; ?>" class="fbmcc-displaySetting fbmcc-submenuOption fbmcc-activePageOption"<?php
                              if (
                                (!$fbmcc_page_types) ||
                                (isset($fbmcc_page_types['all']) &&
                                  ($fbmcc_page_types['all'] == "1") &&
                                    (!isset($fbmcc_page_types['pages_all'])) &&
                                    (!isset($fbmcc_page_types['pages']))
                                ) ||
                                (
                                  ($fbmcc_page_types) &&
                                    (
                                      ($fbmcc_page_types['pages_all'] == "1") ||
                                        (isset($fbmcc_page_types['pages']) &&
                                          (in_array( $page->ID, $fbmcc_page_types['pages'] )))
                                    )
                                )
                              ) {
                                echo 'checked';
                              }
                            ?>/> <?php echo $page->post_title; ?>
                          </li>
                          <?php
                            }
                          ?>
                        </ul>
                      </li>
                      <?php
                        if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
                      ?>
                      <li>
                        <input type="checkbox" id="cbShowProductPages" class="fbmcc-displaySetting"
                          <?php echo
                            (
                              ($fbmcc_page_types) &&
                                (isset($fbmcc_page_types['product_pages'])) &&
                                ($fbmcc_page_types['product_pages'] == "0")
                            )
                            ? '' : 'checked';?>/> WooCommerce
                              <?=esc_html__( 'Product pages', 'facebook-messenger-customer-chat' )?>
                      </li>
                      <?php
                        }
                      ?>
                    </ul>
                  </div>
                  <div id="fbmcc-saveStatus">
                    <div class="hidden" id="fbmcc-saveStatus-error">
                      <?=esc_html__( 'Error saving settings.', 'facebook-messenger-customer-chat' )?></div>
                    <div class="hidden" id="fbmcc-saveStatus-saved">
                      <?=esc_html__( 'Settings saved.', 'facebook-messenger-customer-chat' )?></div>
                    <div class="hidden" id="fbmcc-saveStatus-saving">
                      <?=esc_html__( 'Saving settings...', 'facebook-messenger-customer-chat' )?></div>
                  </div>
                </td>
              </tr>
            </table>
          </li>
        </ul>
      </div>
    </div>
    <div class="fbmcc-card card">
      <div class="intro">
        <p class="fbmcc-instructions">
          <a href='https://developers.facebook.com/terms/'>
            <?=esc_html__( 'Use of this plugin is subject to Facebook\'s Platform Terms',
              'facebook-messenger-customer-chat' )?></a><br><br>
            <?=esc_html__( 'Having a problem setting up or using the Chat Plugin?',
              'facebook-messenger-customer-chat' )?><br>
        <ul>
          <li><a href='https://www.facebook.com/business/help/789975831794468'>
            <?=esc_html__( 'Please consult our Troubleshooting Guide.', 'facebook-messenger-customer-chat' )?></a>
          </li>
          <li><a href='https://wordpress.org/support/plugin/facebook-messenger-customer-chat/'>
            <?=esc_html__( 'If the troubleshooting steps in the guide do not solve your problem, please post '.
            'in the plugin support forum.', 'facebook-messenger-customer-chat' )?></a>
          </li>
        </ul>
        </p>
      </div>
    </div>
  </div>
<?php }