Giter Site home page Giter Site logo

pp-keep's Introduction

=== Private Posts Keep === 

== Description == 

Essentially the intent is to segregate private posts.
Removes private posts from the main query on the posts Page, adds a widget and creates a Page for holding private posts.
On single post views, post navigation is filtered to show only posts from the same status.

== NB ==
This is not complete.
== Acknowledgments == 

The WordPress community

pp-keep's People

Contributors

korvinm avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar  avatar

pp-keep's Issues

Refactor to avoid duplicating check on user cap

The if statement

if( current_user_can( 'read_private_posts' ) ){
  //do something
}

is used twice in the plugin. First in the class PPKeep to wrap the contents of the function rem_pp()
and secondly in the class PP_Keep_Widget to wrap the contents of the function widget() so that the widget is not output on the front end for users without that capability.
How can this be refactored so the if statement only needs using once?

Some functions depend on the user not changing a page title

The class PPKeep has a function, create() which creates a page.
The function returns a variable like so:

$insert_post = wp_insert_post( $post, true);//now you can use $post_id within add_post_meta or update_post_meta 
return $insert_post;    

There are a couple of places elsewhere in the plugin where I am interacting with this page.
in the class PP_Keep_Widget, the widget includes a link to the page.
In the deactivation hook I am deleting the page. In both cases I am getting the page using the page title. However this depends on the user neither changing the title nor deleting the page, which cannot be guaranteed. I'm not coding defensively, as the saying goes.

I would really like to access the return variable from the create() function instead as at least using the ID of the post would be a bit more like it. It wouldn't defend against the user deleting the page but it would still work if the user has changed the page title.

But I don't know how to access the variable outside the class.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.