__( 'Freelancer', 'acknowledgify' ), 'section_team' => __( 'Team', 'acknowledgify' ), 'section_project_credits' => __( 'Project Credits', 'acknowledgify' ), // Freelancer field labels. 'freelancer_name' => __( 'Freelancer', 'acknowledgify' ), 'freelancer_website' => __( 'Website', 'acknowledgify' ), 'freelancer_email' => __( 'Email', 'acknowledgify' ), 'freelancer_location' => __( 'Location', 'acknowledgify' ), 'freelancer_project' => __( 'Project', 'acknowledgify' ), 'freelancer_role' => __( 'Role', 'acknowledgify' ), 'freelancer_thanks_to' => __( 'Thanks To', 'acknowledgify' ), // Agency field labels. 'agency_name' => __( 'Agency', 'acknowledgify' ), 'agency_website' => __( 'Website', 'acknowledgify' ), 'agency_contact' => __( 'Contact', 'acknowledgify' ), 'agency_location' => __( 'Location', 'acknowledgify' ), 'agency_project' => __( 'Project', 'acknowledgify' ), 'agency_design' => __( 'Design', 'acknowledgify' ), 'agency_development' => __( 'Development', 'acknowledgify' ), 'agency_seo' => __( 'SEO & Performance', 'acknowledgify' ), 'agency_hosting' => __( 'Hosting & Maintenance', 'acknowledgify' ), 'agency_thanks' => __( 'Special Thanks', 'acknowledgify' ), ); /** * Filters the labels used in humans.txt output and the admin preview. * * Lets a site customise wording without supplying a translation file. * * @param array $labels Associative array of label keys to strings. */ return apply_filters( 'acknowledgify_humans_txt_labels', $labels ); } /** * Make our custom query var available. */ public static function query_vars( $vars ) { $vars[] = 'acknowledgify_humans_txt'; return $vars; } /** * Outputs the humans.txt content based on the selected template. */ public static function output_humans_txt() { if ( 1 !== intval( get_query_var( 'acknowledgify_humans_txt' ) ) ) { return; } if ( ! Helper::get_setting( 'enable_humans_txt', 0 ) ) { global $wp_query; if ( $wp_query instanceof \WP_Query ) { $wp_query->set_404(); } status_header( 404 ); nocache_headers(); return; } $labels = self::get_labels(); $template = sanitize_text_field( Helper::get_setting( 'humans_template', 'freelancer' ) ); $output = ACKNOWLEDGIFY_HUMANS_TXT_HEADER; if ( 'freelancer' === $template ) { $freelancerContent = ''; $freelancerContent .= Helper::format_setting( ACKNOWLEDGIFY_FREELANCER_NAME, $labels['freelancer_name'] ); $freelancerContent .= Helper::format_setting( ACKNOWLEDGIFY_FREELANCER_WEBSITE, $labels['freelancer_website'] ); $freelancerContent .= Helper::format_setting( ACKNOWLEDGIFY_FREELANCER_EMAIL, $labels['freelancer_email'] ); $freelancerContent .= Helper::format_setting( ACKNOWLEDGIFY_FREELANCER_LOCATION, $labels['freelancer_location'] ); if($freelancerContent != '') { $output .= $labels['section_freelancer'] . "\n"; $output .= $freelancerContent; } $projectCreditsContent = ''; $projectCreditsContent .= Helper::format_setting( ACKNOWLEDGIFY_FREELANCER_PROJECT, $labels['freelancer_project'] ); $projectCreditsContent .= Helper::format_setting( ACKNOWLEDGIFY_FREELANCER_ROLE, $labels['freelancer_role'] ); $projectCreditsContent .= Helper::format_setting( ACKNOWLEDGIFY_FREELANCER_THANKS_TO, $labels['freelancer_thanks_to'] ); if($projectCreditsContent != '') { $output .= "\n\n" . $labels['section_project_credits'] . "\n"; $output .= $projectCreditsContent; } } elseif ( 'agency' === $template ) { $agencyContent = ''; $agencyContent .= Helper::format_setting( ACKNOWLEDGIFY_AGENCY_NAME, $labels['agency_name'] ); $agencyContent .= Helper::format_setting( ACKNOWLEDGIFY_AGENCY_WEBSITE, $labels['agency_website'] ); $agencyContent .= Helper::format_setting( ACKNOWLEDGIFY_AGENCY_CONTACT, $labels['agency_contact'] ); $agencyContent .= Helper::format_setting( ACKNOWLEDGIFY_AGENCY_LOCATION, $labels['agency_location'] ); if($agencyContent != '') { $output .= $labels['section_team'] . "\n"; $output .= $agencyContent; } $projectCreditsContent = ''; $projectCreditsContent .= Helper::format_setting( ACKNOWLEDGIFY_AGENCY_PROJECT, $labels['agency_project'] ); $projectCreditsContent .= Helper::format_setting( ACKNOWLEDGIFY_AGENCY_DESIGN, $labels['agency_design'] ); $projectCreditsContent .= Helper::format_setting( ACKNOWLEDGIFY_AGENCY_DEVELOPMENT, $labels['agency_development'] ); $projectCreditsContent .= Helper::format_setting( ACKNOWLEDGIFY_AGENCY_SEO, $labels['agency_seo'] ); $projectCreditsContent .= Helper::format_setting( ACKNOWLEDGIFY_AGENCY_HOSTING, $labels['agency_hosting'] ); $projectCreditsContent .= Helper::format_setting( ACKNOWLEDGIFY_AGENCY_THANKS, $labels['agency_thanks'] ); if($projectCreditsContent != '') { $output .= "\n\n" . $labels['section_project_credits'] . "\n"; $output .= $projectCreditsContent; } } elseif ( 'custom' === $template ) { // Plain-text response: preserve the author's line breaks verbatim // rather than HTML-escaping them. Content is sanitised on input. $output .= Helper::plain_text( Helper::get_setting( 'humans_custom_content', '' ), true ); } status_header( 200 ); nocache_headers(); send_nosniff_header(); header( 'Content-Type: text/plain; charset=utf-8' ); // This response is text/plain, not HTML. Escaping here would send // entities to the reader verbatim -- "Smith & Jones" instead of // "Smith & Jones". The safeguards for this context are the // Content-Type header above, nosniff, and the control-character and // line-ending normalisation applied by Helper::plain_text() on the way // in. Values are sanitised when saved. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $output; exit; } /** * Outputs a reference to the humans.txt file in the if the feature is enabled. */ public static function add_humans_txt_link() { if ( Helper::get_setting( 'enable_humans_txt', 0 ) ) { // Output the link tag, ensuring you use the correct URL. echo '' . "\n"; } } }