'post', // specify a post type here. 'type' => 'string', 'single' => true, 'show_in_rest' => true, 'auth_callback' => function () { return current_user_can( 'edit_posts' ); }, ) ); } /** * Adds the script loader to the page. */ public function add_frontend_scripts() { if ( LeadinOptions::get( 'disable_internal_tracking' ) && ( is_user_logged_in() || current_user_can( 'install_plugins' ) ) ) { return; } if ( is_single() ) { $page_type = 'post'; } elseif ( is_front_page() ) { $page_type = 'home'; } elseif ( is_archive() ) { $page_type = 'archive'; } elseif ( is_page() ) { $page_type = 'page'; } else { $page_type = 'other'; } $leadin_wordpress_info = array( 'userRole' => User::get_role(), 'pageType' => $page_type, 'leadinPluginVersion' => LEADIN_PLUGIN_VERSION, ); AssetsManager::enqueue_script_loader( $leadin_wordpress_info ); } /** * Adds the script containing the information needed by the script loader. */ public function add_page_analytics() { $portal_id = AccountOptions::get_portal_id(); if ( empty( $portal_id ) ) { echo ''; } else { $id = get_the_ID(); $post_meta = get_post_meta( $id ); $content_type = isset( $post_meta['content-type'][0] ) && '' !== $post_meta['content-type'][0] ? $post_meta['content-type'][0] : LeadinFilters::get_page_content_type(); ?> * * @param String $tag tag name. * @param String $handle handle. */ public function add_id_to_tracking_code( $tag, $handle ) { if ( AssetsManager::TRACKING_CODE === $handle ) { $tag = str_replace( "id='" . $handle . "-js'", "async defer id='hs-script-loader'", $tag ); } return $tag; } /** * Add defer to leadin forms plugin * * @param String $tag tag name. * @param String $handle handle. */ public function add_defer_to_forms_script( $tag, $handle ) { if ( AssetsManager::FORMS_SCRIPT === $handle ) { $tag = str_replace( 'src', 'defer src', $tag ); } return $tag; } /** * Parse leadin shortcodes * * @param array $attributes Shortcode attributes. */ public function leadin_add_hubspot_shortcode( $attributes ) { return ShortcodeRenderUtils::render_shortcode( $attributes ); } }