slug ); $list[ $slug ] = 'powerkit_social_links_counter'; return $list; } /** * Adds custom user contact methods * * @param array $user_contacts array of all user contacts. */ public function contactmethods( $user_contacts ) { return array_merge( $user_contacts, powerkit_get_author_fields() ); } /** * Social Links fields in Guest Author profiles * * @param array $fields Fields to be returned. * @param array $groups Field groups. */ public function guest_author_fields( $fields, $groups ) { if ( in_array( 'all', $groups, true ) || in_array( 'contact-info', $groups, true ) ) { foreach ( powerkit_get_author_fields() as $slug => $name ) { $fields[] = array( 'key' => $slug, 'label' => $name, 'group' => 'contact-info', ); } } return $fields; } /** * Register admin page * * @since 1.0.0 */ public function register_options_page() { add_options_page( esc_html__( 'Social Links', 'powerkit' ), esc_html__( 'Social Links', 'powerkit' ), 'manage_options', powerkit_get_page_slug( $this->slug ), array( $this, 'build_options_page' ) ); } /** * Build admin page * * @since 1.0.0 */ public function build_options_page() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You do not have sufficient rights to view this page.', 'powerkit' ) ); } $this->save_options_page(); ?> $field_caption ) { if ( isset( $_POST[ $field_key ] ) ) { // Input var ok. update_option( $field_key, sanitize_text_field( wp_unslash( $_POST[ $field_key ] ) ) ); // Input var ok. } } } } // Reset cache. Powerkit_Connect::reset_cache( 'powerkit_social_links_counter' ); printf( '

%s

', esc_html__( 'Settings saved.', 'powerkit' ) ); } } /** * Register the stylesheets and JavaScript for the admin area. * * @param string $page Current page. */ public function admin_enqueue_scripts( $page ) { if ( 'settings_page_' . powerkit_get_page_slug( $this->slug ) === $page ) { wp_enqueue_script( 'jquery-ui-sortable' ); // Styles. wp_enqueue_style( 'powerkit-social-links', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/admin-powerkit-social-links.css' ), array(), powerkit_get_setting( 'version' ), 'all' ); // Scripts. wp_enqueue_script( 'powerkit-social-links', plugin_dir_url( __FILE__ ) . 'js/admin-powerkit-social-links.js', array( 'jquery' ), powerkit_get_setting( 'version' ), false ); } } }