Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor so that plugins can always add their own URLs at runtime. #3

Merged
merged 1 commit into from Mar 4, 2015

Conversation

fabacab
Copy link
Contributor

@fabacab fabacab commented Mar 4, 2015

This commit refactors the get_syndication_links() function in order to
ensure that the syn_add_links filter is always processed. Prior to
this commit, the filter was only processed if the syndication_urls
post meta field was non-empty, which meant that plugins were unable to
modify the $urls array that contained POSSE syndication addresses
unless a prior syndication URL already existed. But this constraint made
the plugin mostly useless for auto-crossposting plugins that wanted to
automate the process of adding syndication links to crossposted entries.

This commit also cleans up mixed spaces and tabs. :\

This commit refactors the `get_syndication_links()` function in order to
ensure that the `syn_add_links` filter is always processed. Prior to
this commit, the filter was only processed if the `syndication_urls`
post meta field was non-empty, which meant that plugins were unable to
modify the `$urls` array that contained POSSE syndication addresses
unless a prior syndication URL already existed. But this constraint made
the plugin mostly useless for auto-crossposting plugins that wanted to
automate the process of adding syndication links to crossposted entries.

This commit also cleans up mixed spaces and tabs. :\
dshanske added a commit that referenced this pull request Mar 4, 2015
Refactor so that plugins can always add their own URLs at runtime.
@dshanske dshanske merged commit 0f2faea into dshanske:master Mar 4, 2015
@dshanske
Copy link
Owner

dshanske commented Mar 4, 2015

Happy to merge this. I went through a lot of revisions prior to deploying this to the repository. I tried specifying the types of networks initially, but changing to a list of URLs actually made things easier for everyone.

Then I was going to write code to have plugins copy their data into the right key, but realized that would mean a lot of support I didn't need to have.

As for the mixed spaces and tabs...I know, people keep telling me. I have to break that habit. I've been working on it.

@fabacab
Copy link
Contributor Author

fabacab commented Mar 4, 2015

As for the mixed spaces and tabs...I know, people keep telling me. I have to break that habit. I've been working on it.

/me preaches Vim it up, my friend! :D See also 7 Habits of Highly Effective Text Editing.

Anyways, thanks for merging this so quickly. :)

fabacab added a commit to fabacab/syndication-links that referenced this pull request Mar 4, 2015
If a user creates, but then deletes a syndication link, this refactored
code will always return an array that begins with an empty string as the
first element, because that's how WordPress saves the "Syndication
Links" meta field when it's empty. This commit guards against creating
an empty list item in the list of syndicated links. Probably should have
put this in pull request dshanske#3 but I did not test thoroughly enough, obvs.
@fabacab
Copy link
Contributor Author

fabacab commented Mar 4, 2015

Oopsies, found a small issue with this in my testing, so I have a new defensive code commit e05f420. This could probably also be addressed by modifying the meta field's save handler, but guarding against empty strings here seems both simpler and more robust. Sorry for not including this in the original commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants