wakeupqueen

Untitled

Sep 24th, 2020
1,074
4 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Get params to be used in javascript
  3.  *
  4.  * @return array
  5.  */
  6. public function tcm_get_localization_parameters() {
  7.     $post    = $this->post_for_localization();
  8.     $post_id = empty( $post['ID'] ) ? 0 : $post['ID'];
  9.  
  10.     $localization = array(
  11.         'current_user'               => tcmh()->tcm_get_current_user(),
  12.         'translations'               => include tcm()->plugin_path( 'includes/i18n.php' ),
  13.         'nonce'                      => $this->create_nonce(),
  14.         'routes'                     => array(
  15.             'comments'               => tcm()->tcm_get_route_url( 'comments' ),
  16.             'gravatar'               => tcm()->tcm_get_route_url( 'comments' ) . '/gravatar',
  17.             'live_update'            => tcm()->tcm_get_route_url( 'comments' ) . '/live_update',
  18.             'update_post_subscriber' => tcm()->tcm_get_route_url( 'comments' ) . '/update_post_subscriber',
  19.             'generate_nonce'         => admin_url( 'admin-ajax.php' ),
  20.         ),
  21.         'post'                       => $post,
  22.         'related_posts'              => tcmc()->get_related_posts( Thrive_Comments_Constants::TCM_NO_RELATED_POSTS, $args = array() ),
  23.         'const'                      => array(
  24.             'toast_timeout' => Thrive_Comments_Constants::TCM_TOAST_TIMEOUT, // Not sure if we really need this.
  25.             'wp_content'    => rtrim( WP_CONTENT_URL, '/' ) . '/',
  26.             'ajax_dash'     => array( Thrive_Comments_Constants::TCM_AJAX_DASH ),
  27.             'site_url'      => get_site_url(),
  28.             'post_url'      => apply_filters( 'tcm_post_url', get_permalink() ),
  29.             'moderation'    => array(
  30.                 'approve'              => Thrive_Comments_Constants::TCM_APPROVE,
  31.                 'unapprove'            => Thrive_Comments_Constants::TCM_UNAPPROVE,
  32.                 'spam'                 => Thrive_Comments_Constants::TCM_SPAM,
  33.                 'unspam'               => Thrive_Comments_Constants::TCM_UNSPAM,
  34.                 'trash'                => Thrive_Comments_Constants::TCM_TRASH,
  35.                 'untrash'              => Thrive_Comments_Constants::TCM_UNTRASH,
  36.                 'unreplied'            => Thrive_Comments_Constants::TCM_UNREPLIED,
  37.                 'tcm_delegate'         => Thrive_Comments_Constants::TCM_DELEGATE,
  38.                 'tcm_featured'         => Thrive_Comments_Constants::TCM_FEATURED,
  39.                 'tcm_keyboard_tooltip' => Thrive_Comments_Constants::TCM_KEYBOARD_TOOLTIP,
  40.                 'featured'             => Thrive_Comments_Constants::TCM_FEATURE_VALUE,
  41.                 'not_featured'         => Thrive_Comments_Constants::TCM_NOT_FEATURE_VALUE,
  42.             ),
  43.         ),
  44.         'settings'                   => tcms()->tcm_get_settings(),
  45.         'close_comments'             => tcms()->close_comments( $post_id ) || ! $this->tcm_show_comments(),
  46.         'sorting'                    => tcms()->get_comment_sorting(),
  47.         'tcm_customize_labels'       => tcms()->tcm_get_setting_by_name( Thrive_Comments_Constants::TCM_LABELS_KEY ),
  48.         'tcm_social_apis'            => array(
  49.             'facebook' => Thrive_Dash_List_Manager::credentials( 'facebook' ),
  50.             'google'   => Thrive_Dash_List_Manager::credentials( 'google' ),
  51.         ),
  52.         'email_services'             => tcamh()->get_email_services(),
  53.         'tcm_accent_color'           => tcms()->tcm_get_setting_by_name( Thrive_Comments_Constants::TCM_ACCENT_COLOR ),
  54.         'has_plugin_cache'           => tve_dash_detect_cache_plugin(),
  55.         'default_author_picture_url' => tcmh()->get_picture_url(),
  56.     );
  57.  
  58.     /**
  59.      * Filter for adding extra params for comments localization in fronted
  60.      *
  61.      * @param array $localization the already built localization by TC
  62.      */
  63.     return apply_filters( 'tcm_comments_localization', $localization );
  64. }
RAW Paste Data