From dc6feeb97fa7b47afc89314568d253e84330c2f2 Mon Sep 17 00:00:00 2001 From: Marco Antonio Vivas Date: Fri, 8 Aug 2025 22:07:56 -0300 Subject: [PATCH] Initial commit --- .gitattributes | 2 + README.md | 2 + hide-page-and-post-title.php | 120 +++++++++++++++++++++++++++++++++++ uninstall.php | 8 +++ 4 files changed, 132 insertions(+) create mode 100644 .gitattributes create mode 100644 README.md create mode 100644 hide-page-and-post-title.php create mode 100644 uninstall.php diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/README.md b/README.md new file mode 100644 index 0000000..a76ab2d --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# hide-page-and-post-title + diff --git a/hide-page-and-post-title.php b/hide-page-and-post-title.php new file mode 100644 index 0000000..91d0245 --- /dev/null +++ b/hide-page-and-post-title.php @@ -0,0 +1,120 @@ +ID, $this->hpt_slug, true ); + if( (bool) $toggle ){return true;} else {return false;}} + else {return false;} + } +/*Function hptheadinseart for Hiding page title*/ + public function hpt_hptheadinsert() + { if( $this->hpt_ishidden() ){ ?> + + + hpt_afthead = true; + } +/*Function hptaddbox*/ + public function hpt_hptaddbox(){ + $posttypes = array( 'post', 'page' ); + $args = array( + 'public' => true, + '_builtin' => false, + ); + + $output = 'names'; + $operator = 'and'; + + $post_types = get_post_types( $args, $output, $operator ); + + foreach ( $post_types as $post_type ) { + $posttypes[] = $post_type; + } + foreach ( $posttypes as $posttype ){ + add_meta_box( $this->hpt_slug, __( 'Ocultar Título da Página e do Post', 'hpt' ), array( $this, 'build_hptbox' ), $posttype, 'side' ); + } + } +/*Adding box in admindashboard*/ + public function build_hptbox( $post ){ + $value = get_post_meta( $post->ID, $this->hpt_slug, true ); + $checked = ''; + if( (bool) $value ){ $checked = ' checked="checked"'; } + wp_nonce_field( $this->hpt_slug . '_dononce', $this->hpt_slug . '_noncename' ); ?> + hpt_ishidden() && $hptcontent == $this->title && $this->hpt_afthead ){ + // Retorna uma linha em branco no lugar do título + $hptcontent = '
'; + } + return $hptcontent; + } +/*Script*/ + public function hpt_hptloadscripts(){ + global $post; + $this->title = $post->post_title; + if( $this->hpt_ishidden() ){wp_enqueue_script( 'jquery' );} + } + +/*Autosave metabox*/ + public function hpt_hptsave( $postID ){ + if ( ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) + || !isset( $_POST[ $this->hpt_slug . '_noncename' ] ) + || !wp_verify_nonce( $_POST[ $this->hpt_slug . '_noncename' ], $this->hpt_slug . '_dononce' ) ) { + return $postID; + } + $old = get_post_meta( $postID, $this->hpt_slug, true ); + $new = $_POST[ $this->hpt_slug ] ; + if( $old ){if ( is_null( $new ) ){delete_post_meta( $postID, $this->hpt_slug );} else { update_post_meta( $postID, $this->hpt_slug, $new, $old );} + } elseif ( !is_null( $new ) ){add_post_meta( $postID, $this->hpt_slug, $new, true );} + return $postID; + } +/*Delete metabox */ + public function hpt_hptdelete( $postID ){delete_post_meta( $postID, $this->hpt_slug );return $postID;} + public function set_hpt_selector( $hpt_selector ){if( isset( $hpt_selector ) && is_string( $hpt_selector ) ){$this->hpt_selector = $hpt_selector;} + } + +/*ENDclass Hide page title*/ + }$hpt_hidepagetitle = new hpt_hidepagetitle; +} \ No newline at end of file diff --git a/uninstall.php b/uninstall.php new file mode 100644 index 0000000..290dddb --- /dev/null +++ b/uninstall.php @@ -0,0 +1,8 @@ + \ No newline at end of file